Bug 1261568 - part1: take -webkit-text-fill-color into consideration while
authorJeremy Chen <jeremychen@mozilla.com>
Tue, 05 Apr 2016 12:35:44 +0800
changeset 315485 066926557b7762909dbf037850941588051f2713
parent 315484 5cdaa1592a3645ff55236f51c00cc33de4f715d5
child 315486 8a00403cb58f842bf6dd577c91cc2166f40294d8
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1261568
milestone48.0a1
Bug 1261568 - part1: take -webkit-text-fill-color into consideration while building displaylist for text frame. r=jfkthame
layout/generic/nsTextFrame.cpp
layout/style/StyleAnimationValue.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsStyleContext.h
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -4818,19 +4818,21 @@ nsTextFrame::BuildDisplayList(nsDisplayL
                               const nsRect&           aDirtyRect,
                               const nsDisplayListSet& aLists)
 {
   if (!IsVisibleForPainting(aBuilder))
     return;
   
   DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame");
 
+  bool isTextTransparent =
+    NS_GET_A(StyleContext()->GetTextFillColor()) == 0;
   Maybe<bool> isSelected;
   if (((GetStateBits() & TEXT_NO_RENDERED_GLYPHS) ||
-       (NS_GET_A(StyleColor()->mColor) == 0 && !StyleText()->HasTextShadow())) &&
+       (isTextTransparent && !StyleText()->HasTextShadow())) &&
       aBuilder->IsForPainting() && !IsSVGText()) {
     isSelected.emplace(IsSelected());
     if (!isSelected.value()) {
       TextDecorations textDecs;
       GetTextDecorations(PresContext(), eResolvedColors, textDecs);
       if (!textDecs.HasDecorationLines()) {
         return;
       }
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -3280,20 +3280,17 @@ StyleAnimationValue::ExtractComputedValu
           auto styleText = static_cast<const nsStyleText*>(styleStruct);
           nscolor color = styleText->mTextEmphasisColorForeground ?
             aStyleContext->StyleColor()->mColor : styleText->mTextEmphasisColor;
           aComputedValue.SetColorValue(color);
           break;
         }
 
         case eCSSProperty__webkit_text_fill_color: {
-          auto styleText = static_cast<const nsStyleText*>(styleStruct);
-          nscolor color = styleText->mWebkitTextFillColorForeground ?
-            aStyleContext->StyleColor()->mColor : styleText->mWebkitTextFillColor;
-          aComputedValue.SetColorValue(color);
+          aComputedValue.SetColorValue(aStyleContext->GetTextFillColor());
           break;
         }
 
         case eCSSProperty_border_spacing: {
           const nsStyleTableBorder *styleTableBorder =
             static_cast<const nsStyleTableBorder*>(styleStruct);
           nsAutoPtr<nsCSSValuePair> pair(new nsCSSValuePair);
           nscoordToCSSValue(styleTableBorder->mBorderSpacingCol, pair->mXValue);
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -3923,20 +3923,17 @@ nsComputedDOMStyle::DoGetTextSizeAdjust(
   }
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetWebkitTextFillColor()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
-  const nsStyleText* text = StyleText();
-  nscolor color = text->mWebkitTextFillColorForeground ?
-    StyleColor()->mColor : text->mWebkitTextFillColor;
-  SetToRGBAColor(val, color);
+  SetToRGBAColor(val, mStyleContext->GetTextFillColor());
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetPointerEvents()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
   val->SetIdent(
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -167,16 +167,26 @@ public:
   //    non-null, GetStyleIfVisited()->mSource == aSourceIfVisited
   //  * RelevantLinkVisited() == aRelevantLinkVisited
   already_AddRefed<nsStyleContext>
   FindChildWithRules(const nsIAtom* aPseudoTag,
                      mozilla::NonOwningStyleContextSource aSource,
                      mozilla::NonOwningStyleContextSource aSourceIfVisited,
                      bool aRelevantLinkVisited);
 
+  /**
+   * Get the color that should be used to fill text: either
+   * the current foreground color, or a separately-specified text fill color.
+   */
+  nscolor GetTextFillColor() {
+    const nsStyleText* textStyle = StyleText();
+    return textStyle->mWebkitTextFillColorForeground
+           ? StyleColor()->mColor : textStyle->mWebkitTextFillColor;
+  }
+
   // Does this style context or any of its ancestors have text
   // decoration lines?
   // Differs from nsStyleTextReset::HasTextDecorationLines, which tests
   // only the data for a single context.
   bool HasTextDecorationLines() const
     { return !!(mBits & NS_STYLE_HAS_TEXT_DECORATION_LINES); }
 
   // Whether any line break inside should be suppressed? If this returns