Bug 1304302 part 9 - Make StyleSheet::SheetInfo inline. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Mon, 26 Sep 2016 09:26:37 +1000
changeset 417492 2d11a0b1e4cb193c8b74a75e2b5bee8c32edf7fb
parent 417491 b75abaaaa138722f438d6ab5ab94b99e8ca460b7
child 417493 b6405cb281e1bc150479969f993996b6247f2ccb
push id30405
push userxquan@mozilla.com
push dateSun, 25 Sep 2016 23:29:22 +0000
reviewersheycam
bugs1304302
milestone51.0a1
Bug 1304302 part 9 - Make StyleSheet::SheetInfo inline. r?heycam MozReview-Commit-ID: 9ZvnIBw6emI
layout/style/StyleSheet.cpp
layout/style/StyleSheet.h
layout/style/StyleSheetInlines.h
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -71,18 +71,9 @@ StyleSheet::SetComplete()
   if (mOwningNode && !mDisabled &&
       mOwningNode->HasFlag(NODE_IS_IN_SHADOW_TREE) &&
       mOwningNode->IsContent()) {
     dom::ShadowRoot* shadowRoot = mOwningNode->AsContent()->GetContainingShadow();
     shadowRoot->StyleSheetChanged();
   }
 }
 
-StyleSheetInfo&
-StyleSheet::SheetInfo()
-{
-  if (IsServo()) {
-    return *AsServo();
-  }
-  return *AsGecko()->mInner;
-}
-
 } // namespace mozilla
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -4,27 +4,33 @@
  * 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_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/StyleSheetInfo.h"
+#include "mozilla/CORSMode.h"
 
 class nsIDocument;
 class nsINode;
 
 namespace mozilla {
 
 class CSSStyleSheet;
 class ServoStyleSheet;
+class StyleSheetInfo;
+
+namespace dom {
+class SRIMetadata;
+} // namespace dom
 
 /**
  * Superclass for data common to CSSStyleSheet and ServoStyleSheet.
  */
 class StyleSheet
 {
 protected:
   StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMode);
@@ -45,21 +51,16 @@ public:
   nsIDocument* GetDocument() const { return mDocument; }
 
   /**
    * Whether the sheet is complete.
    */
   bool IsComplete() const;
   void SetComplete();
 
-  // Get a handle to the various stylesheet bits which live on the 'inner' for
-  // gecko stylesheets and live on the StyleSheet for Servo stylesheets.
-  StyleSheetInfo& SheetInfo();
-  const StyleSheetInfo& SheetInfo() const { return const_cast<StyleSheet*>(this)->SheetInfo(); };
-
   bool IsGecko() const { return !IsServo(); }
   bool IsServo() const
   {
 #ifdef MOZ_STYLO
     return mType == StyleBackendType::Servo;
 #else
     return false;
 #endif
@@ -125,16 +126,22 @@ public:
   // Get this style sheet's integrity metadata
   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:
+  // Get a handle to the various stylesheet bits which live on the 'inner' for
+  // gecko stylesheets and live on the StyleSheet for Servo stylesheets.
+  inline StyleSheetInfo& SheetInfo();
+  inline const StyleSheetInfo& SheetInfo() const;
+
 protected:
   nsIDocument*          mDocument; // weak ref; parents maintain this for their children
   nsINode*              mOwningNode; // weak ref
 
   // mParsingMode controls access to nonstandard style constructs that
   // are not safe for use on the public Web but necessary in UA sheets
   // and/or useful in user sheets.
   css::SheetParsingMode mParsingMode;
--- a/layout/style/StyleSheetInlines.h
+++ b/layout/style/StyleSheetInlines.h
@@ -3,16 +3,17 @@
 /* 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_StyleSheetInlines_h
 #define mozilla_StyleSheetInlines_h
 
 #include "mozilla/TypeTraits.h"
+#include "mozilla/StyleSheetInfo.h"
 #include "mozilla/ServoStyleSheet.h"
 #include "mozilla/CSSStyleSheet.h"
 
 namespace mozilla {
 
 CSSStyleSheet*
 StyleSheet::AsGecko()
 {
@@ -45,16 +46,34 @@ StyleSheet::AsGecko() const
 
 const ServoStyleSheet*
 StyleSheet::AsServo() const
 {
   MOZ_ASSERT(IsServo());
   return static_cast<const ServoStyleSheet*>(this);
 }
 
+StyleSheetInfo&
+StyleSheet::SheetInfo()
+{
+  if (IsServo()) {
+    return *AsServo();
+  }
+  return *AsGecko()->mInner;
+}
+
+const StyleSheetInfo&
+StyleSheet::SheetInfo() const
+{
+  if (IsServo()) {
+    return *AsServo();
+  }
+  return *AsGecko()->mInner;
+}
+
 #define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \
   static_assert(!IsSame<decltype(&StyleSheet::method_), \
                         decltype(&CSSStyleSheet::method_)>::value, \
                 "CSSStyleSheet should define its own " #method_); \
   static_assert(!IsSame<decltype(&StyleSheet::method_), \
                         decltype(&ServoStyleSheet::method_)>::value, \
                 "ServoStyleSheet should define its own " #method_); \
   if (IsServo()) { \