Bug 1261578 - Part 2. Correct text decoration color;
MozReview-Commit-ID: LfZnmTnL5KY
--- 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;