Bug 1304302 part 9 - Make StyleSheet::SheetInfo inline. r=heycam
authorXidorn Quan <me@upsuper.org>
Mon, 26 Sep 2016 22:03:25 +1000
changeset 315283 cfbef1f0933b8792fd091e3457bcca56028096f0
parent 315282 59bdda2c019e81a77e8b8713038a01c45e9e1848
child 315284 0938bc1e608f09461f4f18c13d6ae925c0e29b72
push id30747
push usercbook@mozilla.com
push dateTue, 27 Sep 2016 09:22:00 +0000
treeherdermozilla-central@66a77b9bfe5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1304302
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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()) { \