Bug 1418899 - Part 3: Use a single image layer array filling function. r=CJKu draft
authorCameron McCormack <cam@mcc.id.au>
Mon, 20 Nov 2017 13:44:22 +0800
changeset 701033 2b7d7ff48c4d8cc06e82f8b5d76c65376d26d767
parent 701032 26031748b63044676a2e8620053bfb7dc6c52b18
child 701034 5c439fa42300c67fabea70131e59ef07f70a8177
push id90037
push userbmo:cam@mcc.id.au
push dateTue, 21 Nov 2017 04:39:57 +0000
reviewersCJKu
bugs1418899
milestone59.0a1
Bug 1418899 - Part 3: Use a single image layer array filling function. r=CJKu We were accidentally using the background one for the mask layers list anyway, and I don't think the overhead of filling the arrays for the two properties mask layers don't use is a problem. MozReview-Commit-ID: 7LDiYGrnUd5
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
layout/style/nsRuleNode.cpp
layout/style/nsRuleNode.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -845,25 +845,19 @@ Gecko_StyleTransition_SetUnsupportedProp
   if (id == eCSSProperty_UNKNOWN || id == eCSSPropertyExtra_variable) {
     aTransition->SetUnknownProperty(id, aAtom);
   } else {
     aTransition->SetProperty(id);
   }
 }
 
 void
-Gecko_FillAllBackgroundLists(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
+Gecko_FillAllImageLayers(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
 {
-  nsRuleNode::FillAllBackgroundLists(*aLayers, aMaxLen);
-}
-
-void
-Gecko_FillAllMaskLists(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
-{
-  nsRuleNode::FillAllMaskLists(*aLayers, aMaxLen);
+  nsRuleNode::FillAllImageLayers(*aLayers, aMaxLen);
 }
 
 bool
 Gecko_IsDocumentBody(RawGeckoElementBorrowed aElement)
 {
   nsIDocument* doc = aElement->GetUncomposedDoc();
   return doc && doc->GetBodyElement() == aElement;
 }
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -533,18 +533,17 @@ void Gecko_nsStyleSVG_SetDashArrayLength
 void Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* dst, const nsStyleSVG* src);
 void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
 void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst, const nsStyleSVG* src);
 
 mozilla::css::URLValue* Gecko_NewURLValue(ServoBundledURI uri);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::URLValue, CSSURLValue);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(RawGeckoURLExtraData, URLExtraData);
 
-void Gecko_FillAllBackgroundLists(nsStyleImageLayers* layers, uint32_t max_len);
-void Gecko_FillAllMaskLists(nsStyleImageLayers* layers, uint32_t max_len);
+void Gecko_FillAllImageLayers(nsStyleImageLayers* layers, uint32_t max_len);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
 
 nsCSSShadowArray* Gecko_NewCSSShadowArray(uint32_t len);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray);
 
 nsStyleQuoteValues* Gecko_NewStyleQuoteValues(uint32_t len);
 NS_DECL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues);
 
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -7154,20 +7154,19 @@ FillImageLayerPositionCoordList(
   for (uint32_t sourceLayer = 0, destLayer = aItemCount;
        destLayer < aFillCount;
        ++sourceLayer, ++destLayer) {
     aLayers[destLayer].mPosition.*aResultLocation =
       aLayers[sourceLayer].mPosition.*aResultLocation;
   }
 }
 
-/* static */
-void
-nsRuleNode::FillAllBackgroundLists(nsStyleImageLayers& aImage,
-                                   uint32_t aMaxItemCount)
+/* static */ void
+nsRuleNode::FillAllImageLayers(nsStyleImageLayers& aImage,
+                               uint32_t aMaxItemCount)
 {
   // Delete any extra items.  We need to keep layers in which any
   // property was specified.
   aImage.mLayers.TruncateLengthNonZero(aMaxItemCount);
 
   uint32_t fillCount = aImage.mImageCount;
   FillImageLayerList(aImage.mLayers,
                      &nsStyleImageLayers::Layer::mImage,
@@ -7314,17 +7313,17 @@ nsRuleNode::ComputeBackgroundData(void* 
                         bg->mImage.mLayers,
                         parentBG->mImage.mLayers,
                         &nsStyleImageLayers::Layer::mSize,
                         initialSize, parentBG->mImage.mSizeCount,
                         bg->mImage.mSizeCount, maxItemCount, rebuild,
                         conditions);
 
   if (rebuild) {
-    FillAllBackgroundLists(bg->mImage, maxItemCount);
+    FillAllImageLayers(bg->mImage, maxItemCount);
   }
 
   COMPUTE_END_RESET(Background, bg)
 }
 
 const void*
 nsRuleNode::ComputeMarginData(void* aStartStruct,
                               const nsRuleData* aRuleData,
@@ -9213,57 +9212,16 @@ SetSVGOpacity(const nsCSSValue& aValue,
     aOpacityTypeField = aParentOpacityType;
   } else if (eCSSUnit_Null != aValue.GetUnit()) {
     SetFactor(aValue, aOpacityField, aConditions,
               aParentOpacity, 1.0f, SETFCT_OPACITY);
     aOpacityTypeField = eStyleSVGOpacitySource_Normal;
   }
 }
 
-/* static */
-void
-nsRuleNode::FillAllMaskLists(nsStyleImageLayers& aMask,
-                             uint32_t aMaxItemCount)
-{
-
-  // Delete any extra items.  We need to keep layers in which any
-  // property was specified.
-  aMask.mLayers.TruncateLengthNonZero(aMaxItemCount);
-
-  uint32_t fillCount = aMask.mImageCount;
-
-  FillImageLayerList(aMask.mLayers,
-                     &nsStyleImageLayers::Layer::mImage,
-                     aMask.mImageCount, fillCount);
-  FillImageLayerList(aMask.mLayers,
-                     &nsStyleImageLayers::Layer::mRepeat,
-                     aMask.mRepeatCount, fillCount);
-  FillImageLayerList(aMask.mLayers,
-                     &nsStyleImageLayers::Layer::mClip,
-                     aMask.mClipCount, fillCount);
-  FillImageLayerList(aMask.mLayers,
-                     &nsStyleImageLayers::Layer::mOrigin,
-                     aMask.mOriginCount, fillCount);
-  FillImageLayerPositionCoordList(aMask.mLayers,
-                                  &Position::mXPosition,
-                                  aMask.mPositionXCount, fillCount);
-  FillImageLayerPositionCoordList(aMask.mLayers,
-                                  &Position::mYPosition,
-                                  aMask.mPositionYCount, fillCount);
-  FillImageLayerList(aMask.mLayers,
-                     &nsStyleImageLayers::Layer::mSize,
-                     aMask.mSizeCount, fillCount);
-  FillImageLayerList(aMask.mLayers,
-                     &nsStyleImageLayers::Layer::mMaskMode,
-                     aMask.mMaskModeCount, fillCount);
-  FillImageLayerList(aMask.mLayers,
-                     &nsStyleImageLayers::Layer::mComposite,
-                     aMask.mCompositeCount, fillCount);
-}
-
 const void*
 nsRuleNode::ComputeSVGData(void* aStartStruct,
                            const nsRuleData* aRuleData,
                            GeckoStyleContext* aContext,
                            nsRuleNode* aHighestNode,
                            const RuleDetail aRuleDetail,
                            const RuleNodeCacheConditions aConditions)
 {
@@ -10012,17 +9970,17 @@ nsRuleNode::ComputeSVGResetData(void* aS
                     svgReset->mMask.mLayers,
                     parentSVGReset->mMask.mLayers,
                     &nsStyleImageLayers::Layer::mComposite,
                     uint8_t(NS_STYLE_MASK_COMPOSITE_ADD),
                     parentSVGReset->mMask.mCompositeCount,
                     svgReset->mMask.mCompositeCount, maxItemCount, rebuild, conditions);
 
   if (rebuild) {
-    FillAllBackgroundLists(svgReset->mMask, maxItemCount);
+    FillAllImageLayers(svgReset->mMask, maxItemCount);
   }
 
   COMPUTE_END_RESET(SVGReset, svgReset)
 }
 
 const void*
 nsRuleNode::ComputeVariablesData(void* aStartStruct,
                                  const nsRuleData* aRuleData,
--- a/layout/style/nsRuleNode.h
+++ b/layout/style/nsRuleNode.h
@@ -1071,21 +1071,18 @@ public:
 
   static bool ParentHasPseudoElementData(mozilla::GeckoStyleContext* aContext);
 
   static void ComputeTimingFunction(const nsCSSValue& aValue,
                                     nsTimingFunction& aResult);
 
   // Fill unspecified layers by cycling through their values
   // till they all are of length aMaxItemCount
-  static void FillAllBackgroundLists(nsStyleImageLayers& aLayers,
-                                     uint32_t aMaxItemCount);
-
-  static void FillAllMaskLists(nsStyleImageLayers& aLayers,
-                               uint32_t aMaxItemCount);
+  static void FillAllImageLayers(nsStyleImageLayers& aLayers,
+                                 uint32_t aMaxItemCount);
 
 private:
 #ifdef DEBUG
   // non-inline helper function to allow assertions without incomplete
   // type errors
   bool ContextHasCachedData(mozilla::GeckoStyleContext* aContext, nsStyleStructID aSID);
 #endif