Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Unified Diff: Source/core/rendering/RenderTreeAsText.cpp

Issue 19697011: Change rendering code to use RenderObject::resolveColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderTreeAsText.cpp
diff --git a/Source/core/rendering/RenderTreeAsText.cpp b/Source/core/rendering/RenderTreeAsText.cpp
index 1b18a15852c0933d7a5eada6f3fc353da4943015..83f5e5ed4971c87c552835add61fd7a77eb12063 100644
--- a/Source/core/rendering/RenderTreeAsText.cpp
+++ b/Source/core/rendering/RenderTreeAsText.cpp
@@ -199,6 +199,11 @@ String quoteAndEscapeNonPrintables(const String& s)
return result.toString();
}
+static inline Color colorWithFallback(const RenderObject& o, const Color& color)
+{
+ return color.isValid() ? color : o.resolveColor(CSSPropertyColor);
+}
+
void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o, RenderAsTextBehavior behavior)
{
ts << o.renderName();
@@ -262,23 +267,23 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
ts << " " << quoteAndEscapeNonPrintables(toRenderFileUploadControl(&o)->fileTextValue());
if (o.parent()) {
- Color color = o.style()->visitedDependentColor(CSSPropertyColor);
- if (o.parent()->style()->visitedDependentColor(CSSPropertyColor) != color)
+ Color color = o.resolveColor(CSSPropertyColor);
+ if (o.parent()->resolveColor(CSSPropertyColor) != color)
ts << " [color=" << color.nameForRenderTreeAsText() << "]";
// Do not dump invalid or transparent backgrounds, since that is the default.
- Color backgroundColor = o.style()->visitedDependentColor(CSSPropertyBackgroundColor);
- if (o.parent()->style()->visitedDependentColor(CSSPropertyBackgroundColor) != backgroundColor
+ Color backgroundColor = o.resolveColor(CSSPropertyBackgroundColor);
+ if (o.parent()->resolveColor(CSSPropertyBackgroundColor) != backgroundColor
&& backgroundColor.isValid() && backgroundColor.rgb())
ts << " [bgcolor=" << backgroundColor.nameForRenderTreeAsText() << "]";
- Color textFillColor = o.style()->visitedDependentColor(CSSPropertyWebkitTextFillColor);
- if (o.parent()->style()->visitedDependentColor(CSSPropertyWebkitTextFillColor) != textFillColor
+ Color textFillColor = o.resolveColor(CSSPropertyWebkitTextFillColor);
+ if (o.parent()->resolveColor(CSSPropertyWebkitTextFillColor) != textFillColor
&& textFillColor.isValid() && textFillColor != color && textFillColor.rgb())
ts << " [textFillColor=" << textFillColor.nameForRenderTreeAsText() << "]";
- Color textStrokeColor = o.style()->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
- if (o.parent()->style()->visitedDependentColor(CSSPropertyWebkitTextStrokeColor) != textStrokeColor
+ Color textStrokeColor = o.resolveColor(CSSPropertyWebkitTextStrokeColor);
+ if (o.parent()->resolveColor(CSSPropertyWebkitTextStrokeColor) != textStrokeColor
&& textStrokeColor.isValid() && textStrokeColor != color && textStrokeColor.rgb())
ts << " [textStrokeColor=" << textStrokeColor.nameForRenderTreeAsText() << "]";
@@ -299,9 +304,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
else {
ts << " (" << box.borderTop() << "px ";
printBorderStyle(ts, o.style()->borderTopStyle());
- Color col = o.style()->borderTopColor();
- if (!col.isValid())
- col = o.style()->color();
+ Color col = colorWithFallback(o, o.style()->borderTopColor());
ts << col.nameForRenderTreeAsText() << ")";
}
@@ -312,9 +315,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
else {
ts << " (" << box.borderRight() << "px ";
printBorderStyle(ts, o.style()->borderRightStyle());
- Color col = o.style()->borderRightColor();
- if (!col.isValid())
- col = o.style()->color();
+ Color col = colorWithFallback(o, o.style()->borderRightColor());
ts << col.nameForRenderTreeAsText() << ")";
}
}
@@ -326,9 +327,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
else {
ts << " (" << box.borderBottom() << "px ";
printBorderStyle(ts, o.style()->borderBottomStyle());
- Color col = o.style()->borderBottomColor();
- if (!col.isValid())
- col = o.style()->color();
+ Color col = colorWithFallback(o, o.style()->borderBottomColor());
ts << col.nameForRenderTreeAsText() << ")";
}
}
@@ -340,9 +339,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
else {
ts << " (" << box.borderLeft() << "px ";
printBorderStyle(ts, o.style()->borderLeftStyle());
- Color col = o.style()->borderLeftColor();
- if (!col.isValid())
- col = o.style()->color();
+ Color col = colorWithFallback(o, o.style()->borderLeftColor());
ts << col.nameForRenderTreeAsText() << ")";
}
}
« no previous file with comments | « Source/core/rendering/RenderThemeChromiumDefault.cpp ('k') | Source/core/rendering/svg/SVGRenderTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698