Bug 1324618 part 10. Fix style resolution for pseudo-elements to actually pass through the right parent style. r?emilio draft
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 26 Jun 2017 23:35:09 -0700
changeset 600507 2a9d98c0de2905a6fb2c21badfcc256b00f58634
parent 600506 8c38971cfbdcb6d0c0fea8b56da16e62ad4cbfbb
child 635015 58e7d50e0a077acf244fac2ef4302f92dde636c9
push id65783
push userbzbarsky@mozilla.com
push dateTue, 27 Jun 2017 06:35:27 +0000
reviewersemilio
bugs1324618
milestone56.0a1
Bug 1324618 part 10. Fix style resolution for pseudo-elements to actually pass through the right parent style. r?emilio MozReview-Commit-ID: 1UVJj9l0tKi
layout/reftests/bugs/reftest.list
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -31,17 +31,17 @@ asserts(2) skip-if(!cocoaWidget) HTTP(..
 == 18217-width-2a.html 18217-width-2-ref.html
 == 18217-width-2b.html 18217-width-2-ref.html
 == 18217-zorder-1.html 18217-zorder-ref.html
 == 18217-zorder-2.html 18217-zorder-ref.html
 == 18217-zorder-3.html 18217-zorder-ref-inline.html
 == 18217-zorder-4.html 18217-zorder-ref-inline-table.html
 == 18217-zorder-5.html 18217-zorder-ref-inline-table.html
 fails-if(styloVsGecko) == 23604-1.html 23604-1-ref.html
-fails-if(styloVsGecko) == 23604-2.html 23604-2-ref.html
+== 23604-2.html 23604-2-ref.html
 != 24998-1.html 24998-1-ref.html
 == 25888-1l.html 25888-1l-ref.html
 != 25888-1l.html 25888-1l-notref.html
 == 25888-1r.html 25888-1r-ref.html
 != 25888-1r.html 25888-1r-notref.html
 == 25888-2l.html 25888-2l-ref.html
 == 25888-2r.html 25888-2r-ref.html
 == 25888-3l.html 25888-3l-ref.html
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -489,17 +489,19 @@ SERVO_BINDING_FUNC(Servo_NoteExplicitHin
 SERVO_BINDING_FUNC(Servo_TakeChangeHint, nsChangeHint, RawGeckoElementBorrowed element)
 SERVO_BINDING_FUNC(Servo_ResolveStyle, ServoComputedValuesStrong,
                    RawGeckoElementBorrowed element,
                    RawServoStyleSetBorrowed set,
                    bool allow_stale)
 SERVO_BINDING_FUNC(Servo_ResolvePseudoStyle, ServoComputedValuesStrong,
                    RawGeckoElementBorrowed element,
                    mozilla::CSSPseudoElementType pseudo_type,
-                   bool is_probe, RawServoStyleSetBorrowed set)
+                   bool is_probe,
+                   ServoComputedValuesBorrowedOrNull inherited_style,
+                   RawServoStyleSetBorrowed set)
 SERVO_BINDING_FUNC(Servo_HasAuthorSpecifiedRules, bool,
                    RawGeckoElementBorrowed element,
                    uint32_t rule_type_mask,
                    bool author_colors_allowed)
 
 // Resolves style for an element or pseudo-element without processing pending
 // restyles first. The Element and its ancestors may be unstyled, have pending
 // restyles, or be in a display:none subtree. Styles are cached when possible,
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -563,31 +563,31 @@ ServoStyleSet::ResolveStyleForPlaceholde
 already_AddRefed<nsStyleContext>
 ServoStyleSet::ResolvePseudoElementStyle(Element* aOriginatingElement,
                                          CSSPseudoElementType aType,
                                          nsStyleContext* aParentContext,
                                          Element* aPseudoElement)
 {
   UpdateStylistIfNeeded();
 
-  // NB: We ignore aParentContext, on the assumption that pseudo element styles
-  // should just inherit from aOriginatingElement's primary style, which Servo
-  // already knows.
   MOZ_ASSERT(aType < CSSPseudoElementType::Count);
 
   RefPtr<ServoComputedValues> computedValues;
   if (aPseudoElement) {
     MOZ_ASSERT(aType == aPseudoElement->GetPseudoElementType());
     computedValues = Servo_ResolveStyle(aPseudoElement, mRawSet.get(),
                                         mAllowResolveStaleStyles).Consume();
   } else {
+    const ServoComputedValues* parentStyle =
+      aParentContext ? aParentContext->ComputedValues() : nullptr;
     computedValues =
       Servo_ResolvePseudoStyle(aOriginatingElement,
                                aType,
                                /* is_probe = */ false,
+                               parentStyle,
                                mRawSet.get()).Consume();
   }
 
   MOZ_ASSERT(computedValues);
 
   bool isBeforeOrAfter = aType == CSSPseudoElementType::before ||
                          aType == CSSPseudoElementType::after;
 
@@ -913,24 +913,27 @@ ServoStyleSet::AddDocStyleSheet(ServoSty
 
 already_AddRefed<nsStyleContext>
 ServoStyleSet::ProbePseudoElementStyle(Element* aOriginatingElement,
                                        CSSPseudoElementType aType,
                                        nsStyleContext* aParentContext)
 {
   UpdateStylistIfNeeded();
 
-  // NB: We ignore aParentContext, on the assumption that pseudo element styles
-  // should just inherit from aOriginatingElement's primary style, which Servo
-  // already knows.
+  // NB: We ignore aParentContext, because in some cases
+  // (first-line/first-letter on anonymous box blocks) Gecko passes something
+  // nonsensical there.  In all other cases we want to inherit directly from
+  // aOriginatingElement's styles anyway.
   MOZ_ASSERT(aType < CSSPseudoElementType::Count);
 
   RefPtr<ServoComputedValues> computedValues =
     Servo_ResolvePseudoStyle(aOriginatingElement, aType,
-                             /* is_probe = */ true, mRawSet.get()).Consume();
+                             /* is_probe = */ true,
+                             nullptr,
+                             mRawSet.get()).Consume();
   if (!computedValues) {
     return nullptr;
   }
 
   // For :before and :after pseudo-elements, having display: none or no
   // 'content' property is equivalent to not having the pseudo-element
   // at all.
   bool isBeforeOrAfter = aType == CSSPseudoElementType::before ||