Index: Source/core/rendering/RenderObject.cpp |
diff --git a/Source/core/rendering/RenderObject.cpp b/Source/core/rendering/RenderObject.cpp |
index f96b3e8e279e98f33374b337fd121df94b189e8f..75f38392cf2c5c629f9e6f83a4248a6eee172dfd 100644 |
--- a/Source/core/rendering/RenderObject.cpp |
+++ b/Source/core/rendering/RenderObject.cpp |
@@ -74,6 +74,7 @@ |
#include "core/rendering/RenderView.h" |
#include "core/rendering/compositing/CompositedLayerMapping.h" |
#include "core/rendering/compositing/RenderLayerCompositor.h" |
+#include "core/rendering/style/AppliedTextDecoration.h" |
#include "core/rendering/style/ContentData.h" |
#include "core/rendering/style/CursorList.h" |
#include "core/rendering/style/ShadowList.h" |
@@ -3068,60 +3069,59 @@ 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) |
+RenderObject::ResolvedDecoration::ResolvedDecoration() |
+ : line(TextDecorationUnderline) |
+ , style(TextDecorationStyleSolid) |
{ |
+} |
+ |
+RenderObject::ResolvedDecoration::ResolvedDecoration(const AppliedTextDecoration& decoration, const Color& color) |
+ : line(decoration.line()) |
+ , style(decoration.style()) |
+ , color(color) |
+{ |
+} |
+ |
+static RenderStyle* decorationStyle(RenderObject* renderObject, bool firstlineStyle, TextDecoration decoration) |
+{ |
+ RenderStyle* styleToUse = renderObject->style(firstlineStyle); |
+ |
+ if (styleToUse->textDecoration() == decoration) |
+ return styleToUse; |
+ if (!firstlineStyle) |
+ return nullptr; |
+ |
+ styleToUse = renderObject->style(false); |
+ return styleToUse->textDecoration() == decoration ? styleToUse : nullptr; |
+} |
+ |
+void RenderObject::resolvedDecorations(bool firstlineStyle, const Vector<AppliedTextDecoration>& decorations, ResolvedDecorationVector& resolved) |
+{ |
+ ASSERT(decorations.size()); |
+ |
+ bool quirksMode = document().inQuirksMode(); |
+ |
RenderObject* curr = this; |
- RenderStyle* styleToUse = 0; |
- unsigned currDecs = TextDecorationNone; |
- Color resultColor; |
- TextDecorationStyle resultStyle; |
+ Vector<AppliedTextDecoration>::const_reverse_iterator decoration = decorations.rbegin(); |
+ |
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->isText()) { |
+ RenderStyle* styleToUse = decorationStyle(curr, firstlineStyle, decoration->line()); |
+ if (styleToUse) { |
+ resolved.append(RenderObject::ResolvedDecoration(*decoration, styleToUse->visitedDependentDecorationColor())); |
+ ++decoration; |
} |
} |
- if (curr->isRubyText()) |
- return; |
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 && (decoration != decorations.rend()) && (!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 && (decoration != decorations.rend())) { |
+ RenderStyle* styleToUse = decorationStyle(curr, firstlineStyle, decoration->line()); |
+ if (styleToUse) |
+ resolved.append(RenderObject::ResolvedDecoration(*decoration, styleToUse->visitedDependentDecorationColor())); |
} |
} |