Bug 1304302 part 11 - Remove StyleSheetHandle as well as other places reference it. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Thu, 22 Sep 2016 22:09:08 +1000
changeset 417494 a7b9ad86731e317cc95fac927a07646c80488006
parent 417493 b6405cb281e1bc150479969f993996b6247f2ccb
child 532093 6c740e520668fec5bc10c2c81e47b39d5b1cfe72
push id30405
push userxquan@mozilla.com
push dateSun, 25 Sep 2016 23:29:22 +0000
reviewersheycam
bugs1304302
milestone51.0a1
Bug 1304302 part 11 - Remove StyleSheetHandle as well as other places reference it. r?heycam MozReview-Commit-ID: FfYZiShjJNX
layout/style/HandleRefPtr.h
layout/style/StyleSheet.h
layout/style/StyleSheetHandle.h
layout/style/StyleSheetHandleInlines.h
layout/style/StyleSheetInlines.h
layout/style/moz.build
python/gdbpp/gdbpp/smartptr.py
--- a/layout/style/HandleRefPtr.h
+++ b/layout/style/HandleRefPtr.h
@@ -14,19 +14,19 @@
 #ifndef mozilla_HandleRefPtr_h
 #define mozilla_HandleRefPtr_h
 
 namespace mozilla {
 
 /**
  * A class for holding strong references to handle-managed objects.
  *
- * This is intended for use with objects like StyleSheet*, where
- * the handle type is not a pointer but which can still have ->AddRef()
- * and ->Release() called on it.
+ * This is intended for use with objects like RestyleManagerHandle,
+ * where the handle type is not a pointer but which can still have
+ * ->AddRef() and ->Release() called on it.
  */
 template<typename T>
 class HandleRefPtr
 {
 public:
   HandleRefPtr() {}
 
   HandleRefPtr(HandleRefPtr<T>& aRhs)
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -6,17 +6,16 @@
 
 #ifndef mozilla_StyleSheet_h
 #define mozilla_StyleSheet_h
 
 #include "mozilla/css/SheetParsingMode.h"
 #include "mozilla/dom/CSSStyleSheetBinding.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "mozilla/StyleBackendType.h"
-#include "mozilla/StyleSheetHandle.h"
 #include "mozilla/CORSMode.h"
 
 class nsIDocument;
 class nsINode;
 
 namespace mozilla {
 
 class CSSStyleSheet;
@@ -65,17 +64,16 @@ public:
     return false;
 #endif
   }
 
   // Only safe to call if the caller has verified that that |this| is of the
   // correct type.
   inline CSSStyleSheet* AsGecko();
   inline ServoStyleSheet* AsServo();
-  inline StyleSheetHandle AsHandle();
   inline const CSSStyleSheet* AsGecko() const;
   inline const ServoStyleSheet* AsServo() const;
 
   inline MozExternalRefCountType AddRef();
   inline MozExternalRefCountType Release();
 
   // Whether the sheet is for an inline <style> element.
   inline bool IsInline() const;
deleted file mode 100644
--- a/layout/style/StyleSheetHandle.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_StyleSheetHandle_h
-#define mozilla_StyleSheetHandle_h
-
-#include "mozilla/css/SheetParsingMode.h"
-#include "mozilla/net/ReferrerPolicy.h"
-#include "mozilla/CORSMode.h"
-#include "mozilla/HandleRefPtr.h"
-#include "mozilla/RefCountType.h"
-
-namespace mozilla {
-namespace dom {
-class SRIMetadata;
-} // namespace dom
-class CSSStyleSheet;
-class ServoStyleSheet;
-class StyleSheet;
-} // namespace mozilla
-class nsIDocument;
-class nsIPrincipal;
-class nsIURI;
-
-namespace mozilla {
-
-#define SERVO_BIT 0x1
-
-/**
- * Smart pointer class that can hold a pointer to either a CSSStyleSheet
- * or a ServoStyleSheet.
- */
-class StyleSheetHandle
-{
-public:
-  typedef HandleRefPtr<StyleSheetHandle> RefPtr;
-
-  // We define this Ptr class with a StyleSheet API that forwards on to the
-  // wrapped pointer, rather than putting these methods on StyleSheetHandle
-  // itself, so that we can have StyleSheetHandle behave like a smart pointer
-  // and be dereferenced with operator->.
-  class Ptr
-  {
-  public:
-    friend class ::mozilla::StyleSheetHandle;
-
-    bool IsGecko() const { return !IsServo(); }
-    bool IsServo() const
-    {
-      MOZ_ASSERT(mValue);
-#ifdef MOZ_STYLO
-      return mValue & SERVO_BIT;
-#else
-      return false;
-#endif
-    }
-
-    inline StyleSheet* AsStyleSheet();
-    inline const StyleSheet* AsStyleSheet() const;
-
-    CSSStyleSheet* AsGecko()
-    {
-      MOZ_ASSERT(IsGecko());
-      return reinterpret_cast<CSSStyleSheet*>(mValue);
-    }
-
-    ServoStyleSheet* AsServo()
-    {
-      MOZ_ASSERT(IsServo());
-      return reinterpret_cast<ServoStyleSheet*>(mValue & ~SERVO_BIT);
-    }
-
-    CSSStyleSheet* GetAsGecko() { return IsGecko() ? AsGecko() : nullptr; }
-    ServoStyleSheet* GetAsServo() { return IsServo() ? AsServo() : nullptr; }
-
-    const CSSStyleSheet* AsGecko() const
-    {
-      return const_cast<Ptr*>(this)->AsGecko();
-    }
-
-    const ServoStyleSheet* AsServo() const
-    {
-      MOZ_ASSERT(IsServo());
-      return const_cast<Ptr*>(this)->AsServo();
-    }
-
-    void* AsVoidPtr() const
-    {
-      return reinterpret_cast<void*>(mValue & ~SERVO_BIT);
-    }
-
-    const CSSStyleSheet* GetAsGecko() const { return IsGecko() ? AsGecko() : nullptr; }
-    const ServoStyleSheet* GetAsServo() const { return IsServo() ? AsServo() : nullptr; }
-
-    // These inline methods are defined in StyleSheetHandleInlines.h.
-    inline MozExternalRefCountType AddRef();
-    inline MozExternalRefCountType Release();
-
-    // Style sheet interface.  These inline methods are defined in
-    // StyleSheetHandleInlines.h and just forward to the underlying
-    // CSSStyleSheet or ServoStyleSheet.  See corresponding comments in
-    // CSSStyleSheet.h for descriptions of these methods.
-
-    inline bool IsInline() const;
-    inline nsIURI* GetSheetURI() const;
-    inline nsIURI* GetOriginalURI() const;
-    inline nsIURI* GetBaseURI() const;
-    inline void SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, nsIURI* aBaseURI);
-    inline bool IsApplicable() const;
-    inline bool HasRules() const;
-    inline nsIDocument* GetOwningDocument() const;
-    inline void SetOwningDocument(nsIDocument* aDocument);
-    inline nsINode* GetOwnerNode() const;
-    inline void SetOwningNode(nsINode* aNode);
-    inline StyleSheetHandle GetParentSheet() const;
-    inline void AppendStyleSheet(StyleSheetHandle aSheet);
-    inline nsIPrincipal* Principal() const;
-    inline void SetPrincipal(nsIPrincipal* aPrincipal);
-    inline CORSMode GetCORSMode() const;
-    inline net::ReferrerPolicy GetReferrerPolicy() const;
-    inline void GetIntegrity(dom::SRIMetadata& aResult) const;
-    inline size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
-#ifdef DEBUG
-    inline void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
-#endif
-
-  private:
-    // Stores a pointer to an CSSStyleSheet or a ServoStyleSheet.  The least
-    // significant bit is 0 for the former, 1 for the latter.
-    uintptr_t mValue;
-  };
-
-  MOZ_IMPLICIT StyleSheetHandle(decltype(nullptr) = nullptr)
-  {
-    mPtr.mValue = 0;
-  }
-  StyleSheetHandle(const StyleSheetHandle& aOth) {
-    mPtr.mValue = aOth.mPtr.mValue;
-  }
-  MOZ_IMPLICIT StyleSheetHandle(CSSStyleSheet* aSet) { *this = aSet; }
-  MOZ_IMPLICIT StyleSheetHandle(ServoStyleSheet* aSet) { *this = aSet; }
-  MOZ_IMPLICIT StyleSheetHandle(const ::RefPtr<CSSStyleSheet>& aSet)
-  {
-    *this = aSet.get();
-  }
-  MOZ_IMPLICIT StyleSheetHandle(const ::RefPtr<ServoStyleSheet>& aSet)
-  {
-    *this = aSet.get();
-  }
-
-  StyleSheetHandle& operator=(decltype(nullptr)) { mPtr.mValue = 0; return *this; }
-
-  StyleSheetHandle& operator=(CSSStyleSheet* aSheet)
-  {
-    MOZ_ASSERT(!(reinterpret_cast<uintptr_t>(aSheet) & SERVO_BIT),
-               "least significant bit shouldn't be set; we use it for state");
-    mPtr.mValue = reinterpret_cast<uintptr_t>(aSheet);
-    return *this;
-  }
-
-  StyleSheetHandle& operator=(ServoStyleSheet* aSheet)
-  {
-#ifdef MOZ_STYLO
-    MOZ_ASSERT(!(reinterpret_cast<uintptr_t>(aSheet) & SERVO_BIT),
-               "least significant bit shouldn't be set; we use it for state");
-    mPtr.mValue =
-      aSheet ? (reinterpret_cast<uintptr_t>(aSheet) | SERVO_BIT) : 0;
-    return *this;
-#else
-    MOZ_CRASH("should not have a ServoStyleSheet object when MOZ_STYLO is "
-              "disabled");
-#endif
-  }
-
-  // Make StyleSheetHandle usable in boolean contexts.
-  explicit operator bool() const { return !!mPtr.mValue; }
-  bool operator!() const { return !mPtr.mValue; }
-
-  // Make StyleSheetHandle behave like a smart pointer.
-  Ptr* operator->() { return &mPtr; }
-  const Ptr* operator->() const { return &mPtr; }
-
-  bool operator==(const StyleSheetHandle& aOther) const
-  {
-    return mPtr.mValue == aOther.mPtr.mValue;
-  }
-
-private:
-  Ptr mPtr;
-};
-
-#undef SERVO_BIT
-
-} // namespace mozilla
-
-#endif // mozilla_StyleSheetHandle_h
deleted file mode 100644
--- a/layout/style/StyleSheetHandleInlines.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_StyleSheetHandleInlines_h
-#define mozilla_StyleSheetHandleInlines_h
-
-#include "mozilla/CSSStyleSheet.h"
-#include "mozilla/ServoStyleSheet.h"
-
-#define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \
-  if (IsGecko()) { \
-    return AsGecko()->method_ geckoargs_; \
-  } else { \
-    return AsServo()->method_ servoargs_; \
-  }
-
-#define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_)
-
-namespace mozilla {
-
-StyleSheet*
-StyleSheetHandle::Ptr::AsStyleSheet()
-{
-  if (IsServo()) {
-    return AsServo();
-  }
-  return AsGecko();
-}
-
-const StyleSheet*
-StyleSheetHandle::Ptr::AsStyleSheet() const
-{
-  return const_cast<Ptr*>(this)->AsStyleSheet();
-}
-
-MozExternalRefCountType
-StyleSheetHandle::Ptr::AddRef()
-{
-  FORWARD(AddRef, ());
-}
-
-MozExternalRefCountType
-StyleSheetHandle::Ptr::Release()
-{
-  FORWARD(Release, ());
-}
-
-bool
-StyleSheetHandle::Ptr::IsInline() const
-{
-  FORWARD(IsInline, ());
-}
-
-nsIURI*
-StyleSheetHandle::Ptr::GetSheetURI() const
-{
-  FORWARD(GetSheetURI, ());
-}
-
-nsIURI*
-StyleSheetHandle::Ptr::GetOriginalURI() const
-{
-  FORWARD(GetOriginalURI, ());
-}
-
-nsIURI*
-StyleSheetHandle::Ptr::GetBaseURI() const
-{
-  FORWARD(GetBaseURI, ());
-}
-
-void
-StyleSheetHandle::Ptr::SetURIs(nsIURI* aSheetURI, nsIURI* aOriginalSheetURI, nsIURI* aBaseURI)
-{
-  FORWARD(SetURIs, (aSheetURI, aOriginalSheetURI, aBaseURI));
-}
-
-bool
-StyleSheetHandle::Ptr::IsApplicable() const
-{
-  FORWARD(IsApplicable, ());
-}
-
-bool
-StyleSheetHandle::Ptr::HasRules() const
-{
-  FORWARD(HasRules, ());
-}
-
-nsIDocument*
-StyleSheetHandle::Ptr::GetOwningDocument() const
-{
-  FORWARD(GetOwningDocument, ());
-}
-
-void
-StyleSheetHandle::Ptr::SetOwningDocument(nsIDocument* aDocument)
-{
-  FORWARD(SetOwningDocument, (aDocument));
-}
-
-nsINode*
-StyleSheetHandle::Ptr::GetOwnerNode() const
-{
-  FORWARD(GetOwnerNode, ());
-}
-
-void
-StyleSheetHandle::Ptr::SetOwningNode(nsINode* aNode)
-{
-  FORWARD(SetOwningNode, (aNode));
-}
-
-StyleSheetHandle
-StyleSheetHandle::Ptr::GetParentSheet() const
-{
-  FORWARD(GetParentSheet, ());
-}
-
-void
-StyleSheetHandle::Ptr::AppendStyleSheet(StyleSheetHandle aSheet)
-{
-  FORWARD_CONCRETE(AppendStyleSheet, (aSheet->AsGecko()), (aSheet->AsServo()));
-}
-
-nsIPrincipal*
-StyleSheetHandle::Ptr::Principal() const
-{
-  FORWARD(Principal, ());
-}
-
-void
-StyleSheetHandle::Ptr::SetPrincipal(nsIPrincipal* aPrincipal)
-{
-  FORWARD(SetPrincipal, (aPrincipal));
-}
-
-mozilla::CORSMode
-StyleSheetHandle::Ptr::GetCORSMode() const
-{
-  FORWARD(GetCORSMode, ());
-}
-
-mozilla::net::ReferrerPolicy
-StyleSheetHandle::Ptr::GetReferrerPolicy() const
-{
-  FORWARD(GetReferrerPolicy, ());
-}
-
-void
-StyleSheetHandle::Ptr::GetIntegrity(dom::SRIMetadata& aResult) const
-{
-  FORWARD(GetIntegrity, (aResult));
-}
-
-size_t
-StyleSheetHandle::Ptr::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
-{
-  FORWARD(SizeOfIncludingThis, (aMallocSizeOf));
-}
-
-#ifdef DEBUG
-void
-StyleSheetHandle::Ptr::List(FILE* aOut, int32_t aIndex) const
-{
-  FORWARD(List, (aOut, aIndex));
-}
-#endif
-
-#undef FORWARD
-#undef FORWARD_CONCRETE
-
-inline void
-ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                            StyleSheetHandle& aField,
-                            const char* aName,
-                            uint32_t aFlags = 0)
-{
-  if (aField && aField->IsGecko()) {
-    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, aName);
-    aCallback.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, aField->AsGecko()));
-  }
-}
-
-inline void
-ImplCycleCollectionUnlink(StyleSheetHandle& aField)
-{
-  aField = nullptr;
-}
-
-inline void
-ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
-                            StyleSheetHandle::RefPtr& aField,
-                            const char* aName,
-                            uint32_t aFlags = 0)
-{
-  if (aField && aField->IsGecko()) {
-    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, aName);
-    aCallback.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIDOMCSSStyleSheet*, aField->AsGecko()));
-  }
-}
-
-inline void
-ImplCycleCollectionUnlink(StyleSheetHandle::RefPtr& aField)
-{
-  aField = nullptr;
-}
-
-} // namespace mozilla
-
-#endif // mozilla_StyleSheetHandleInlines_h
--- a/layout/style/StyleSheetInlines.h
+++ b/layout/style/StyleSheetInlines.h
@@ -23,25 +23,16 @@ StyleSheet::AsGecko()
 
 ServoStyleSheet*
 StyleSheet::AsServo()
 {
   MOZ_ASSERT(IsServo());
   return static_cast<ServoStyleSheet*>(this);
 }
 
-StyleSheetHandle
-StyleSheet::AsHandle()
-{
-  if (IsServo()) {
-    return AsServo();
-  }
-  return AsGecko();
-}
-
 const CSSStyleSheet*
 StyleSheet::AsGecko() const
 {
   MOZ_ASSERT(IsGecko());
   return static_cast<const CSSStyleSheet*>(this);
 }
 
 const ServoStyleSheet*
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -99,18 +99,16 @@ EXPORTS.mozilla += [
     'ServoStyleSheet.h',
     'SheetType.h',
     'StyleAnimationValue.h',
     'StyleBackendType.h',
     'StyleContextSource.h',
     'StyleSetHandle.h',
     'StyleSetHandleInlines.h',
     'StyleSheet.h',
-    'StyleSheetHandle.h',
-    'StyleSheetHandleInlines.h',
     'StyleSheetInfo.h',
     'StyleSheetInlines.h',
     'StyleStructContext.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'CSS.h',
     'CSSLexer.h',
--- a/python/gdbpp/gdbpp/smartptr.py
+++ b/python/gdbpp/gdbpp/smartptr.py
@@ -35,31 +35,8 @@ class smartptr_printer(object):
 
     def to_string(self):
         if not self.value:
             type_name = str(self.value.type)
         else:
             type_name = str(self.value.dereference().dynamic_type.pointer())
 
         return '[(%s) %s]' % (type_name, str(self.value))
-
-@GeckoPrettyPrinter('mozilla::StyleSheetHandle::RefPtr', '^mozilla::HandleRefPtr<mozilla::StyleSheetHandle>$')
-class sheetptr_printer(object):
-    def __init__(self, value):
-        self.value = 0
-        if (value['mHandle'] and
-            value['mHandle']['mPtr'] and
-            value['mHandle']['mPtr']['mValue']):
-            self.value = int(value['mHandle']['mPtr']['mValue'])
-
-    def to_string(self):
-        if self.value == 0:
-            type_name = 'mozilla::StyleSheet *'
-            value = 0
-        else:
-            value = int(self.value)
-            if value & 0x1:
-                value = value & ~0x1
-                type_name = 'mozilla::ServoStyleSheet *'
-            else:
-                type_name = 'mozilla::CSSStyleSheet *'
-
-        return '[(%s) %s]' % (type_name, hex(value))