Bug 1261578 - Part 2. Correct text decoration color; r=jfkthame
authorCJKu <cku@mozilla.com>
Tue, 19 Apr 2016 17:09:54 +0800
changeset 331736 92a26bb2d41cafd184d40acfe795091656cbf2bb
parent 331735 e94186bab3849582d547bef0b5290754b49f911a
child 331737 2fc5f3fc9d70bb000a83bcf7c5b33900f08bd7c7
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1261578
milestone48.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 1261578 - Part 2. Correct text decoration color; r=jfkthame MozReview-Commit-ID: LfZnmTnL5KY
accessible/base/TextAttrs.cpp
layout/generic/nsTextFrame.cpp
layout/style/StyleAnimationValue.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsRuleNode.cpp
layout/xul/nsTextBoxFrame.cpp
--- a/accessible/base/TextAttrs.cpp
+++ b/accessible/base/TextAttrs.cpp
@@ -697,17 +697,17 @@ TextAttrsMgr::TextDecorValue::
   TextDecorValue(nsIFrame* aFrame)
 {
   const nsStyleTextReset* textReset = aFrame->StyleTextReset();
   mStyle = textReset->GetDecorationStyle();
 
   bool isForegroundColor = false;
   textReset->GetDecorationColor(mColor, isForegroundColor);
   if (isForegroundColor)
-    mColor = aFrame->StyleColor()->mColor;
+    mColor = aFrame->StyleContext()->GetTextFillColor();
 
   mLine = textReset->mTextDecorationLine &
     (NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE |
      NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH);
 }
 
 TextAttrsMgr::TextDecorTextAttr::
   TextDecorTextAttr(nsIFrame* aRootFrame, nsIFrame* aFrame) :
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -409,16 +409,28 @@ static void
 DestroyUserData(void* aUserData)
 {
   TextRunUserData* userData = static_cast<TextRunUserData*>(aUserData);
   if (userData) {
     free(userData);
   }
 }
 
+static nsCSSProperty
+GetTextDecorationColorProp(nsStyleContext* aCtx)
+{
+  nscolor textColor;
+  bool foreground;
+  aCtx->StyleTextReset()->GetDecorationColor(textColor, foreground);
+
+  return (foreground && !aCtx->StyleText()->mWebkitTextFillColorForeground)
+         ? eCSSProperty__webkit_text_fill_color
+         : eCSSProperty_text_decoration_color;
+}
+
 /**
  * Remove |aTextRun| from the frame continuation chain starting at
  * |aStartContinuation| if non-null, otherwise starting at |aFrame|.
  * Unmark |aFrame| as a text run owner if it's the frame we start at.
  * Return true if |aStartContinuation| is non-null and was found
  * in the next-continuation chain of |aFrame|.
  */
 static bool
@@ -5012,17 +5024,17 @@ nsTextFrame::GetTextDecorations(
     const uint8_t textDecorations = styleText->mTextDecorationLine;
 
     if (!useOverride &&
         (NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL & textDecorations)) {
       // This handles the <a href="blah.html"><font color="green">La 
       // la la</font></a> case. The link underline should be green.
       useOverride = true;
       overrideColor =
-        nsLayoutUtils::GetColor(f, eCSSProperty_text_decoration_color);
+        nsLayoutUtils::GetColor(f, GetTextDecorationColorProp(context));
     }
 
     nsBlockFrame* fBlock = nsLayoutUtils::GetAsBlock(f);
     const bool firstBlock = !nearestBlockFound && fBlock;
 
     // Not updating positions once we hit a parent block is equivalent to
     // the CSS 2.1 spec that blocks should propagate decorations down to their
     // children (albeit the style should be preserved)
@@ -5069,17 +5081,17 @@ nsTextFrame::GetTextDecorations(
         //     text-decoration-color has its initial value currentColor.
         //     We could choose to interpret currentColor as "currentFill"
         //     for SVG text, and have e.g. text-decoration-color:red to
         //     override the fill paint of the decoration.
         color = aColorResolution == eResolvedColors ?
                   nsLayoutUtils::GetColor(f, eCSSProperty_fill) :
                   NS_SAME_AS_FOREGROUND_COLOR;
       } else {
-        color = nsLayoutUtils::GetColor(f, eCSSProperty_text_decoration_color);
+        color = nsLayoutUtils::GetColor(f, GetTextDecorationColorProp(context));
       }
 
       bool swapUnderlineAndOverline = vertical && IsUnderlineRight(f);
       const uint8_t kUnderline =
         swapUnderlineAndOverline ? NS_STYLE_TEXT_DECORATION_LINE_OVERLINE :
                                    NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE;
       const uint8_t kOverline =
         swapUnderlineAndOverline ? NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE :
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -3302,17 +3302,17 @@ StyleAnimationValue::ExtractComputedValu
 
         case eCSSProperty_text_decoration_color: {
           const nsStyleTextReset *styleTextReset =
             static_cast<const nsStyleTextReset*>(styleStruct);
           nscolor color;
           bool isForeground;
           styleTextReset->GetDecorationColor(color, isForeground);
           if (isForeground) {
-            color = aStyleContext->StyleColor()->mColor;
+            color = aStyleContext->GetTextFillColor();
           }
           aComputedValue.SetColorValue(color);
           break;
         }
 
         case eCSSProperty_text_decoration_style: {
           uint8_t decorationStyle =
             static_cast<const nsStyleTextReset*>(styleStruct)->
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -3627,17 +3627,17 @@ already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetTextDecorationColor()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
 
   nscolor color;
   bool isForeground;
   StyleTextReset()->GetDecorationColor(color, isForeground);
   if (isForeground) {
-    color = StyleColor()->mColor;
+    color = mStyleContext->GetTextFillColor();
   }
 
   SetToRGBAColor(val, color);
 
   return val.forget();
 }
 
 already_AddRefed<CSSValue>
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -4767,17 +4767,17 @@ nsRuleNode::ComputeTextResetData(void* a
     aRuleData->ValueForTextDecorationColor();
   nscolor decorationColor;
   if (eCSSUnit_Inherit == decorationColorValue->GetUnit()) {
     conditions.SetUncacheable();
     if (parentContext) {
       bool isForeground;
       parentText->GetDecorationColor(decorationColor, isForeground);
       if (isForeground) {
-        text->SetDecorationColor(parentContext->StyleColor()->mColor);
+        text->SetDecorationColor(parentContext->GetTextFillColor());
       } else {
         text->SetDecorationColor(decorationColor);
       }
     } else {
       text->SetDecorationColorToForeground();
     }
   }
   else if (eCSSUnit_EnumColor == decorationColorValue->GetUnit() &&
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -414,26 +414,26 @@ nsTextBoxFrame::DrawText(nsRenderingCont
 
     nsIFrame* f = this;
     do {  // find decoration colors
       nsStyleContext* context = f->StyleContext();
       if (!context->HasTextDecorationLines()) {
         break;
       }
       const nsStyleTextReset* styleText = context->StyleTextReset();
-      
+
       if (decorMask & styleText->mTextDecorationLine) {  // a decoration defined here
         nscolor color;
         if (aOverrideColor) {
           color = *aOverrideColor;
         } else {
           bool isForeground;
           styleText->GetDecorationColor(color, isForeground);
           if (isForeground) {
-            color = nsLayoutUtils::GetColor(f, eCSSProperty_color);
+            color = nsLayoutUtils::GetColor(f, context->GetTextFillColorProp());
           }
         }
         uint8_t style = styleText->GetDecorationStyle();
 
         if (NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE & decorMask &
               styleText->mTextDecorationLine) {
           underColor = color;
           underStyle = style;