Bug 1420026 - Part 1: Add aWasCurrentColor outparam to ServoCSSParser::ComputeColor. r=TYLin draft
authorCameron McCormack <cam@mcc.id.au>
Thu, 30 Nov 2017 17:27:18 +0800
changeset 707332 0fe2aed5d789096411fc1509b4d17b8ef11afdf2
parent 707331 321e5cbdf5368f5c1fdf4cfbdd8c7d5b4056531d
child 707333 17388783ac4f08b7a1ba34b0f36ed4fd4ea3e1dd
push id92088
push userbmo:cam@mcc.id.au
push dateTue, 05 Dec 2017 05:26:04 +0000
reviewersTYLin
bugs1420026
milestone59.0a1
Bug 1420026 - Part 1: Add aWasCurrentColor outparam to ServoCSSParser::ComputeColor. r=TYLin MozReview-Commit-ID: CMv0LedpEfv
layout/style/ServoBindingList.h
layout/style/ServoCSSParser.cpp
layout/style/ServoCSSParser.h
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -739,17 +739,18 @@ SERVO_BINDING_FUNC(Servo_CloneArcStringD
                    const mozilla::ServoRawOffsetArc<RustString>* string);
 
 // CSS parsing utility functions.
 SERVO_BINDING_FUNC(Servo_IsValidCSSColor, bool, const nsAString* value);
 SERVO_BINDING_FUNC(Servo_ComputeColor, bool,
                    RawServoStyleSetBorrowedOrNull set,
                    nscolor current_color,
                    const nsAString* value,
-                   nscolor* result_color);
+                   nscolor* result_color,
+                   bool* was_current_color);
 SERVO_BINDING_FUNC(Servo_ParseIntersectionObserverRootMargin, bool,
                    const nsAString* value,
                    nsCSSRect* result);
 // Returning false means the parsed transform contains relative lengths or
 // percentage value, so we cannot compute the matrix. In this case, we keep
 // |result| and |contains_3d_transform| as-is.
 SERVO_BINDING_FUNC(Servo_ParseTransformIntoMatrix, bool,
                    const nsAString* value,
--- a/layout/style/ServoCSSParser.cpp
+++ b/layout/style/ServoCSSParser.cpp
@@ -15,20 +15,22 @@ ServoCSSParser::IsValidCSSColor(const ns
 {
   return Servo_IsValidCSSColor(&aValue);
 }
 
 /* static */ bool
 ServoCSSParser::ComputeColor(ServoStyleSet* aStyleSet,
                              nscolor aCurrentColor,
                              const nsAString& aValue,
-                             nscolor* aResultColor)
+                             nscolor* aResultColor,
+                             bool* aWasCurrentColor)
 {
   return Servo_ComputeColor(aStyleSet ? aStyleSet->RawSet() : nullptr,
-                            aCurrentColor, &aValue, aResultColor);
+                            aCurrentColor, &aValue, aResultColor,
+                            aWasCurrentColor);
 }
 
 /* static */ bool
 ServoCSSParser::ParseIntersectionObserverRootMargin(const nsAString& aValue,
                                                     nsCSSRect* aResult)
 {
   return Servo_ParseIntersectionObserverRootMargin(&aValue, aResult);
 }
--- a/layout/style/ServoCSSParser.h
+++ b/layout/style/ServoCSSParser.h
@@ -27,22 +27,25 @@ public:
   /**
    * Computes an nscolor from the given CSS <color> value.
    *
    * @param aStyleSet The style set whose nsPresContext will be used to
    *   compute system colors and other special color values.
    * @param aCurrentColor The color value that currentcolor should compute to.
    * @param aValue The CSS <color> value.
    * @param aResultColor The resulting computed color value.
+   * @param aWasCurrentColor Whether aValue was currentcolor. Can be nullptr
+   *   if the caller doesn't care.
    * @return Whether aValue was successfully parsed and aResultColor was set.
    */
   static bool ComputeColor(ServoStyleSet* aStyleSet,
                            nscolor aCurrentColor,
                            const nsAString& aValue,
-                           nscolor* aResultColor);
+                           nscolor* aResultColor,
+                           bool* aWasCurrentColor = nullptr);
 
   /**
    * Parses a IntersectionObserver's initialization dictionary's rootMargin
    * property.
    *
    * @param aValue The rootMargin value.
    * @param aResult The nsCSSRect object to write the result into.
    * @return Whether the value was successfully parsed.