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

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

Issue 219633002: Proper support for multiple text decorations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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/RenderObject.cpp
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp
index d55645e614dfe44aece0455d296605469d0c60a7..72f06006d92e78a6ccea892a57676319685818db 100644
--- a/Source/core/rendering/RenderObject.cpp
+++ b/Source/core/rendering/RenderObject.cpp
@@ -2977,61 +2977,38 @@ static Color decorationColor(const RenderObject* object, RenderStyle* style)
return object->resolveColor(style, CSSPropertyWebkitTextFillColor);
}
-void RenderObject::getTextDecorations(unsigned decorations, AppliedTextDecoration& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethrough, bool quirksMode, bool firstlineStyle)
+static bool hasSimpleUnderline(RenderStyle* style)
+{
+ return style->textDecoration() & TextDecorationUnderline
+ && style->textDecorationStyle() == TextDecorationStyleSolid;
esprehn 2014/03/31 17:41:24 This should be a method on RenderStyle.
+}
+
+Color RenderObject::getUnderlineColor(bool quirksMode, bool firstlineStyle)
{
RenderObject* curr = this;
- RenderStyle* styleToUse = 0;
- unsigned currDecs = TextDecorationNone;
- Color resultColor;
- TextDecorationStyle resultStyle;
do {
- styleToUse = curr->style(firstlineStyle);
- currDecs = styleToUse->textDecoration();
- currDecs &= decorations;
- resultColor = decorationColor(this, styleToUse);
- resultStyle = styleToUse->textDecorationStyle();
- // Parameter 'decorations' is cast as an int to enable the bitwise operations below.
- if (currDecs) {
- if (currDecs & TextDecorationUnderline) {
- decorations &= ~TextDecorationUnderline;
- underline.color = resultColor;
- underline.style = resultStyle;
- }
- if (currDecs & TextDecorationOverline) {
- decorations &= ~TextDecorationOverline;
- overline.color = resultColor;
- overline.style = resultStyle;
- }
- if (currDecs & TextDecorationLineThrough) {
- decorations &= ~TextDecorationLineThrough;
- linethrough.color = resultColor;
- linethrough.style = resultStyle;
- }
- }
- if (curr->isRubyText())
- return;
+ RenderStyle* styleToUse = curr->style(firstlineStyle);
+ if (hasSimpleUnderline(styleToUse))
+ return styleToUse->visitedDependentDecorationColor();
curr = curr->parent();
if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuation())
curr = toRenderBlock(curr)->continuation();
- } while (curr && decorations && (!quirksMode || !curr->node() || (!isHTMLAnchorElement(*curr->node()) && !isHTMLFontElement(*curr->node()))));
+ } while (curr && (!quirksMode || !curr->node() || (!isHTMLAnchorElement(*curr->node()) && !isHTMLFontElement(*curr->node()))));
// If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
- if (decorations && curr) {
- styleToUse = curr->style(firstlineStyle);
- resultColor = decorationColor(this, styleToUse);
- if (decorations & TextDecorationUnderline) {
- underline.color = resultColor;
- underline.style = resultStyle;
- }
- if (decorations & TextDecorationOverline) {
- overline.color = resultColor;
- overline.style = resultStyle;
- }
- if (decorations & TextDecorationLineThrough) {
- linethrough.color = resultColor;
- linethrough.style = resultStyle;
- }
- }
+ if (curr)
+ return curr->style(firstlineStyle)->visitedDependentDecorationColor();
+
+ // If we can't find the originating element in the first-line styles, try again
+ // with the regular styles.
+ if (firstlineStyle)
+ return getUnderlineColor(quirksMode, false);
+
+ // If we reach this, it means we can't find the originating element for
+ // the applied underline. It's probably incorrect that the underline is
+ // applied.
+ ASSERT_NOT_REACHED();
+ return Color();
}
void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions)

Powered by Google App Engine
This is Rietveld 408576698