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

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: Fix jchaffraix' issues. Created 6 years, 7 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
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/style/AppliedTextDecoration.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
}
}
« no previous file with comments | « Source/core/rendering/RenderObject.h ('k') | Source/core/rendering/style/AppliedTextDecoration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698