Bug 1366735 part 2 - Use the new struct in stylo. r=heycam
authorXidorn Quan <me@upsuper.org>
Tue, 23 May 2017 00:32:05 +1000
changeset 408657 3da40efe9851348f5a92be871b25d4312c81f4d4
parent 408656 787d3a0c5dd103199466107efce043c715f8a613
child 408658 ed34125549dba9293246c411d55d9d55837a7b52
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1366735
milestone55.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 1366735 part 2 - Use the new struct in stylo. r=heycam MozReview-Commit-ID: trgd0lKLP1
js/src/devtools/rootAnalysis/analyzeHeapWrites.js
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
layout/style/ServoBindings.toml
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
--- a/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
+++ b/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
@@ -180,16 +180,17 @@ function treatAsSafeArgument(entry, varN
         ["Gecko_ClearPODTArray", "aArray", null],
         ["Gecko_SetStyleGridTemplateArrayLengths", "aValue", null],
         ["Gecko_ResizeTArrayForStrings", "aArray", null],
         ["Gecko_ClearAndResizeStyleContents", "aContent", null],
         [/Gecko_ClearAndResizeCounter/, "aContent", null],
         [/Gecko_CopyCounter.*?From/, "aContent", null],
         [/Gecko_SetContentDataImageValue/, "aList", null],
         [/Gecko_SetContentData/, "aContent", null],
+        ["Gecko_SetCounterFunction", "aContent", null],
         [/Gecko_EnsureStyle.*?ArrayLength/, "aArray", null],
         ["Gecko_GetOrCreateKeyframeAtStart", "aKeyframes", null],
         ["Gecko_GetOrCreateInitialKeyframe", "aKeyframes", null],
         ["Gecko_GetOrCreateFinalKeyframe", "aKeyframes", null],
         ["Gecko_SetStyleCoordCalcValue", null, null],
         ["Gecko_StyleClipPath_SetURLValue", "aClip", null],
         ["Gecko_nsStyleFilter_SetURLValue", "aEffects", null],
         ["Gecko_nsStyleSVGPaint_CopyFrom", "aDest", null],
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1257,22 +1257,24 @@ Gecko_SetContentDataImageValue(nsStyleCo
 {
   MOZ_ASSERT(aContent && aImageValue);
 
   RefPtr<nsStyleImageRequest> req =
     CreateStyleImageRequest(nsStyleImageRequest::Mode::Track, aImageValue);
   aContent->SetImageRequest(req.forget());
 }
 
-void
-Gecko_SetContentDataArray(nsStyleContentData* aContent,
-                          nsStyleContentType aType, uint32_t aLen)
+nsStyleContentData::CounterFunction*
+Gecko_SetCounterFunction(nsStyleContentData* aContent, nsStyleContentType aType)
 {
-  nsCSSValue::Array* arr = nsCSSValue::Array::Create(aLen);
-  aContent->SetCounters(aType, arr);
+  RefPtr<nsStyleContentData::CounterFunction>
+    counterFunc = new nsStyleContentData::CounterFunction();
+  nsStyleContentData::CounterFunction* ptr = counterFunc;
+  aContent->SetCounters(aType, counterFunc.forget());
+  return ptr;
 }
 
 nsStyleGradient*
 Gecko_CreateGradient(uint8_t aShape,
                      uint8_t aSize,
                      bool aRepeating,
                      bool aLegacySyntax,
                      uint32_t aStopCount)
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -305,17 +305,18 @@ void Gecko_CopyListStyleImageFrom(nsStyl
 void Gecko_SetCursorArrayLength(nsStyleUserInterface* ui, size_t len);
 void Gecko_SetCursorImageValue(nsCursorImage* aCursor,
                                mozilla::css::ImageValue* aImageValue);
 void Gecko_CopyCursorArrayFrom(nsStyleUserInterface* dest,
                                const nsStyleUserInterface* src);
 
 void Gecko_SetContentDataImageValue(nsStyleContentData* aList,
                                     mozilla::css::ImageValue* aImageValue);
-void Gecko_SetContentDataArray(nsStyleContentData* content_data, nsStyleContentType type, uint32_t len);
+nsStyleContentData::CounterFunction* Gecko_SetCounterFunction(
+    nsStyleContentData* content_data, nsStyleContentType type);
 
 // Dirtiness tracking.
 uint32_t Gecko_GetNodeFlags(RawGeckoNodeBorrowed node);
 void Gecko_SetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
 void Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
 void Gecko_SetOwnerDocumentNeedsStyleFlush(RawGeckoElementBorrowed element);
 
 // Incremental restyle.
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -372,16 +372,17 @@ structs-types = [
     "nsMediaFeature",
     "nsRestyleHint",
     "nsStyleBackground",
     "nsStyleBorder",
     "nsStyleColor",
     "nsStyleColumn",
     "nsStyleContent",
     "nsStyleContentData",
+    "nsStyleContentData_CounterFunction",
     "nsStyleContentType",
     "nsStyleContext",
     "nsStyleCoord",
     "nsStyleCoord_Calc",
     "nsStyleCoord_CalcValue",
     "nsStyleDisplay",
     "nsStyleEffects",
     "nsStyleFilter",
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3809,17 +3809,18 @@ nsStyleContentData::nsStyleContentData(c
 }
 
 bool
 nsStyleContentData::
 CounterFunction::operator==(const CounterFunction& aOther) const
 {
   return mIdent == aOther.mIdent &&
     mSeparator == aOther.mSeparator &&
-    mCounterStyle == aOther.mCounterStyle;
+    mCounterStyle == aOther.mCounterStyle &&
+    mCounterStyleName == aOther.mCounterStyleName;
 }
 
 nsStyleContentData&
 nsStyleContentData::operator=(const nsStyleContentData& aOther)
 {
   if (this == &aOther) {
     return *this;
   }
@@ -3840,16 +3841,41 @@ nsStyleContentData::operator==(const nsS
   }
   if (mType == eStyleContentType_Counter ||
       mType == eStyleContentType_Counters) {
     return *mContent.mCounters == *aOther.mContent.mCounters;
   }
   return safe_strcmp(mContent.mString, aOther.mContent.mString) == 0;
 }
 
+void
+nsStyleContentData::Resolve(nsPresContext* aPresContext)
+{
+  switch (mType) {
+    case eStyleContentType_Image:
+      if (!mContent.mImage->IsResolved()) {
+        mContent.mImage->Resolve(aPresContext);
+      }
+      break;
+    case eStyleContentType_Counter:
+    case eStyleContentType_Counters: {
+      CounterFunction* counters = mContent.mCounters;
+      if (counters->mCounterStyleName) {
+        MOZ_ASSERT(!counters->mCounterStyle);
+        counters->mCounterStyle = aPresContext->CounterStyleManager()->
+          BuildCounterStyle(counters->mCounterStyleName);
+        counters->mCounterStyleName = nullptr;
+      }
+      break;
+    }
+    default:
+      break;
+  }
+}
+
 
 //-----------------------
 // nsStyleContent
 //
 
 nsStyleContent::nsStyleContent(const nsPresContext* aContext)
 {
   MOZ_COUNT_CTOR(nsStyleContent);
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3043,32 +3043,37 @@ public:
     return mContent.mString;
   }
 
   struct CounterFunction
   {
     nsString mIdent;
     // This is only used when it is a counters() function.
     nsString mSeparator;
+    // One and only one of mCounterStyle and mCounterStyleName must be
+    // non-null at any time.
     mozilla::CounterStylePtr mCounterStyle;
+    nsCOMPtr<nsIAtom> mCounterStyleName;
 
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CounterFunction)
 
     bool operator==(const CounterFunction& aOther) const;
     bool operator!=(const CounterFunction& aOther) const {
       return !(*this == aOther);
     }
   private:
     ~CounterFunction() {}
   };
 
   CounterFunction* GetCounters() const
   {
     MOZ_ASSERT(mType == eStyleContentType_Counter ||
                mType == eStyleContentType_Counters);
+    MOZ_ASSERT(mContent.mCounters->mCounterStyle,
+               "Counter style should have been resolved");
     return mContent.mCounters;
   }
 
   nsStyleImageRequest* GetImageRequest() const
   {
     MOZ_ASSERT(mType == eStyleContentType_Image);
     return mContent.mImage;
   }
@@ -3117,21 +3122,17 @@ public:
   {
     MOZ_ASSERT(mType == eStyleContentType_Uninitialized,
                "should only initialize nsStyleContentData once");
     mType = eStyleContentType_Image;
     mContent.mImage = aRequest.take();
     MOZ_ASSERT(mContent.mImage);
   }
 
-  void Resolve(nsPresContext* aPresContext) {
-    if (mType == eStyleContentType_Image && !mContent.mImage->IsResolved()) {
-      mContent.mImage->Resolve(aPresContext);
-    }
-  }
+  void Resolve(nsPresContext* aPresContext);
 
 private:
   nsStyleContentType mType;
   union {
     char16_t *mString;
     nsStyleImageRequest* mImage;
     CounterFunction* mCounters;
   } mContent;