<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205985] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205985">205985</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-09-15 11:11:48 -0700 (Thu, 15 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move text decoration style computation from RenderObject to TextDecorationPainter
https://bugs.webkit.org/show_bug.cgi?id=162004
Reviewed by Zalan Bujtas.
It is mostly an implementation detail of TextDecorationPainter.
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(AXAttributeStringSetStyle):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetStyle):
* rendering/RenderObject.cpp:
(WebCore::decorationColor): Deleted.
(WebCore::RenderObject::getTextDecorationColorsAndStyles): Deleted.
* rendering/RenderObject.h:
* rendering/TextDecorationPainter.cpp:
(WebCore::TextDecorationPainter::TextDecorationPainter):
(WebCore::TextDecorationPainter::paintTextDecoration):
(WebCore::decorationColor):
* rendering/TextDecorationPainter.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityiosWebAccessibilityObjectWrapperIOSmm">trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm">trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
<li><a href="#trunkSourceWebCorerenderingTextDecorationPaintercpp">trunk/Source/WebCore/rendering/TextDecorationPainter.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingTextDecorationPainterh">trunk/Source/WebCore/rendering/TextDecorationPainter.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205984 => 205985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-15 18:04:45 UTC (rev 205984)
+++ trunk/Source/WebCore/ChangeLog        2016-09-15 18:11:48 UTC (rev 205985)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-09-14 Antti Koivisto <antti@apple.com>
+
+ Move text decoration style computation from RenderObject to TextDecorationPainter
+ https://bugs.webkit.org/show_bug.cgi?id=162004
+
+ Reviewed by Zalan Bujtas.
+
+ It is mostly an implementation detail of TextDecorationPainter.
+
+ * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+ (AXAttributeStringSetStyle):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (AXAttributeStringSetStyle):
+ * rendering/RenderObject.cpp:
+ (WebCore::decorationColor): Deleted.
+ (WebCore::RenderObject::getTextDecorationColorsAndStyles): Deleted.
+ * rendering/RenderObject.h:
+ * rendering/TextDecorationPainter.cpp:
+ (WebCore::TextDecorationPainter::TextDecorationPainter):
+ (WebCore::TextDecorationPainter::paintTextDecoration):
+ (WebCore::decorationColor):
+ * rendering/TextDecorationPainter.h:
+
</ins><span class="cx"> 2016-09-15 Dave Hyatt <hyatt@apple.com>
</span><span class="cx">
</span><span class="cx"> [CSS Parser] Make stylesheets parse using the new parser if the setting is enabled
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityiosWebAccessibilityObjectWrapperIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (205984 => 205985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm        2016-09-15 18:04:45 UTC (rev 205984)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm        2016-09-15 18:11:48 UTC (rev 205985)
</span><span class="lines">@@ -2040,14 +2040,8 @@
</span><span class="cx"> AXAttributeStringSetFont(attrString, style.fontCascade().primaryFont().getCTFont(), range);
</span><span class="cx">
</span><span class="cx"> int decor = style.textDecorationsInEffect();
</span><del>- if ((decor & (TextDecorationUnderline | TextDecorationLineThrough)) != 0) {
- Color underlineColor, overlineColor, linethroughColor;
- TextDecorationStyle underlineStyle, overlineStyle, linethroughStyle;
- renderer->getTextDecorationColorsAndStyles(decor, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle);
-
- if (decor & TextDecorationUnderline)
- AXAttributeStringSetNumber(attrString, UIAccessibilityTokenUnderline, [NSNumber numberWithBool:YES], range);
- }
</del><ins>+ if (decor & TextDecorationUnderline)
+ AXAttributeStringSetNumber(attrString, UIAccessibilityTokenUnderline, [NSNumber numberWithBool:YES], range);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, NSString *text)
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilitymacWebAccessibilityObjectWrapperMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (205984 => 205985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm        2016-09-15 18:04:45 UTC (rev 205984)
+++ trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm        2016-09-15 18:11:48 UTC (rev 205985)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx"> #import "ScrollView.h"
</span><span class="cx"> #import "TextCheckerClient.h"
</span><span class="cx"> #import "TextCheckingHelper.h"
</span><ins>+#import "TextDecorationPainter.h"
</ins><span class="cx"> #import "TextIterator.h"
</span><span class="cx"> #import "VisibleUnits.h"
</span><span class="cx"> #import "WebCoreFrameView.h"
</span><span class="lines">@@ -1119,18 +1120,16 @@
</span><span class="cx">
</span><span class="cx"> if ((decor & (TextDecorationUnderline | TextDecorationLineThrough)) != 0) {
</span><span class="cx"> // FIXME: Should the underline style be reported here?
</span><del>- Color underlineColor, overlineColor, linethroughColor;
- TextDecorationStyle underlineStyle, overlineStyle, linethroughStyle;
- renderer->getTextDecorationColorsAndStyles(decor, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle);
-
</del><ins>+ auto decorationStyles = TextDecorationPainter::stylesForRenderer(*renderer, decor);
+
</ins><span class="cx"> if ((decor & TextDecorationUnderline) != 0) {
</span><span class="cx"> AXAttributeStringSetNumber(attrString, NSAccessibilityUnderlineTextAttribute, [NSNumber numberWithBool:YES], range);
</span><del>- AXAttributeStringSetColor(attrString, NSAccessibilityUnderlineColorTextAttribute, nsColor(underlineColor), range);
</del><ins>+ AXAttributeStringSetColor(attrString, NSAccessibilityUnderlineColorTextAttribute, nsColor(decorationStyles.underlineColor), range);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ((decor & TextDecorationLineThrough) != 0) {
</span><span class="cx"> AXAttributeStringSetNumber(attrString, NSAccessibilityStrikethroughTextAttribute, [NSNumber numberWithBool:YES], range);
</span><del>- AXAttributeStringSetColor(attrString, NSAccessibilityStrikethroughColorTextAttribute, nsColor(linethroughColor), range);
</del><ins>+ AXAttributeStringSetColor(attrString, NSAccessibilityStrikethroughColorTextAttribute, nsColor(decorationStyles.linethroughColor), range);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (205984 => 205985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2016-09-15 18:04:45 UTC (rev 205984)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2016-09-15 18:11:48 UTC (rev 205985)
</span><span class="lines">@@ -36,7 +36,6 @@
</span><span class="cx"> #include "FrameView.h"
</span><span class="cx"> #include "GeometryUtilities.h"
</span><span class="cx"> #include "GraphicsContext.h"
</span><del>-#include "HTMLAnchorElement.h"
</del><span class="cx"> #include "HTMLElement.h"
</span><span class="cx"> #include "HTMLImageElement.h"
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="lines">@@ -1643,79 +1642,6 @@
</span><span class="cx"> return style().computedLineHeight();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static Color decorationColor(const RenderStyle* style)
-{
- Color result;
- // Check for text decoration color first.
- result = style->visitedDependentColor(CSSPropertyWebkitTextDecorationColor);
- if (result.isValid())
- return result;
- if (style->textStrokeWidth() > 0) {
- // Prefer stroke color if possible but not if it's fully transparent.
- result = style->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
- if (result.alpha())
- return result;
- }
-
- result = style->visitedDependentColor(CSSPropertyWebkitTextFillColor);
- return result;
-}
-
-void RenderObject::getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
- TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle) const
-{
- const RenderObject* current = this;
- const RenderStyle* styleToUse = nullptr;
- TextDecoration currDecs = TextDecorationNone;
- Color resultColor;
- do {
- styleToUse = firstlineStyle ? &current->firstLineStyle() : &current->style();
- currDecs = styleToUse->textDecoration();
- resultColor = decorationColor(styleToUse);
- // Parameter 'decorations' is cast as an int to enable the bitwise operations below.
- if (currDecs) {
- if (currDecs & TextDecorationUnderline) {
- decorations &= ~TextDecorationUnderline;
- underlineColor = resultColor;
- underlineStyle = styleToUse->textDecorationStyle();
- }
- if (currDecs & TextDecorationOverline) {
- decorations &= ~TextDecorationOverline;
- overlineColor = resultColor;
- overlineStyle = styleToUse->textDecorationStyle();
- }
- if (currDecs & TextDecorationLineThrough) {
- decorations &= ~TextDecorationLineThrough;
- linethroughColor = resultColor;
- linethroughStyle = styleToUse->textDecorationStyle();
- }
- }
- if (current->isRubyText())
- return;
- current = current->parent();
- if (current && current->isAnonymousBlock() && downcast<RenderBlock>(*current).continuation())
- current = downcast<RenderBlock>(*current).continuation();
- } while (current && decorations && (!current->node() || (!is<HTMLAnchorElement>(*current->node()) && !current->node()->hasTagName(fontTag))));
-
- // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
- if (decorations && current) {
- styleToUse = firstlineStyle ? &current->firstLineStyle() : &current->style();
- resultColor = decorationColor(styleToUse);
- if (decorations & TextDecorationUnderline) {
- underlineColor = resultColor;
- underlineStyle = styleToUse->textDecorationStyle();
- }
- if (decorations & TextDecorationOverline) {
- overlineColor = resultColor;
- overlineStyle = styleToUse->textDecorationStyle();
- }
- if (decorations & TextDecorationLineThrough) {
- linethroughColor = resultColor;
- linethroughStyle = styleToUse->textDecorationStyle();
- }
- }
-}
-
</del><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span><span class="cx"> void RenderObject::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (205984 => 205985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2016-09-15 18:04:45 UTC (rev 205984)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2016-09-15 18:11:48 UTC (rev 205985)
</span><span class="lines">@@ -651,9 +651,6 @@
</span><span class="cx">
</span><span class="cx"> virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
</span><span class="cx">
</span><del>- void getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
- TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle = false) const;
-
</del><span class="cx"> // Return the RenderLayerModelObject in the container chain which is responsible for painting this object, or nullptr
</span><span class="cx"> // if painting is root-relative. This is the container that should be passed to the 'forRepaint'
</span><span class="cx"> // methods.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextDecorationPaintercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/TextDecorationPainter.cpp (205984 => 205985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextDecorationPainter.cpp        2016-09-15 18:04:45 UTC (rev 205984)
+++ trunk/Source/WebCore/rendering/TextDecorationPainter.cpp        2016-09-15 18:11:48 UTC (rev 205985)
</span><span class="lines">@@ -25,7 +25,10 @@
</span><span class="cx">
</span><span class="cx"> #include "FontCascade.h"
</span><span class="cx"> #include "GraphicsContext.h"
</span><ins>+#include "HTMLAnchorElement.h"
+#include "HTMLFontElement.h"
</ins><span class="cx"> #include "InlineTextBoxStyle.h"
</span><ins>+#include "RenderBlock.h"
</ins><span class="cx"> #include "RenderStyle.h"
</span><span class="cx"> #include "RenderText.h"
</span><span class="cx"> #include "ShadowData.h"
</span><span class="lines">@@ -243,14 +246,9 @@
</span><span class="cx"> , m_decoration(decoration)
</span><span class="cx"> , m_wavyOffset(wavyOffsetFromDecoration())
</span><span class="cx"> , m_isPrinting(renderer.document().printing())
</span><ins>+ , m_styles(stylesForRenderer(renderer, m_decoration, isFirstLine))
</ins><span class="cx"> , m_lineStyle(isFirstLine ? renderer.firstLineStyle() : renderer.style())
</span><span class="cx"> {
</span><del>- renderer.getTextDecorationColorsAndStyles(m_decoration, m_underlineColor, m_overlineColor, m_linethroughColor, m_underlineStyle, m_overlineStyle,
- m_linethroughStyle);
- if (isFirstLine) {
- renderer.getTextDecorationColorsAndStyles(m_decoration, m_underlineColor, m_overlineColor, m_linethroughColor,
- m_underlineStyle, m_overlineStyle, m_linethroughStyle, true);
- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin)
</span><span class="lines">@@ -264,10 +262,11 @@
</span><span class="cx"> m_context.setStrokeThickness(textDecorationThickness);
</span><span class="cx"> FloatPoint localOrigin = boxOrigin;
</span><span class="cx">
</span><del>- auto paintDecoration = [&](TextDecoration decoration, TextDecorationStyle style, Color color, StrokeStyle strokeStyle,
- const FloatPoint& start, const FloatPoint& end, int offset) {
</del><ins>+ auto paintDecoration = [&](TextDecoration decoration, TextDecorationStyle style, Color color, const FloatPoint& start, const FloatPoint& end, int offset) {
</ins><span class="cx"> m_context.setStrokeColor(color);
</span><span class="cx">
</span><ins>+ auto strokeStyle = textDecorationStyleToStrokeStyle(style);
+
</ins><span class="cx"> if (style == TextDecorationStyleWavy)
</span><span class="cx"> strokeWavyTextDecoration(m_context, start, end, textDecorationThickness);
</span><span class="cx"> else if (decoration == TextDecorationUnderline || decoration == TextDecorationOverline) {
</span><span class="lines">@@ -287,9 +286,9 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> bool linesAreOpaque = !m_isPrinting
</span><del>- && (!(m_decoration & TextDecorationUnderline) || m_underlineColor.alpha() == 255)
- && (!(m_decoration & TextDecorationOverline) || m_overlineColor.alpha() == 255)
- && (!(m_decoration & TextDecorationLineThrough) || m_linethroughColor.alpha() == 255);
</del><ins>+ && (!(m_decoration & TextDecorationUnderline) || m_styles.underlineColor.alpha() == 255)
+ && (!(m_decoration & TextDecorationOverline) || m_styles.overlineColor.alpha() == 255)
+ && (!(m_decoration & TextDecorationLineThrough) || m_styles.linethroughColor.alpha() == 255);
</ins><span class="cx">
</span><span class="cx"> int extraOffset = 0;
</span><span class="cx"> bool clipping = !linesAreOpaque && m_shadow && m_shadow->next();
</span><span class="lines">@@ -328,21 +327,21 @@
</span><span class="cx"> // These decorations should match the visual overflows computed in visualOverflowForDecorations()
</span><span class="cx"> if (m_decoration & TextDecorationUnderline) {
</span><span class="cx"> const int offset = computeUnderlineOffset(m_lineStyle.textUnderlinePosition(), m_lineStyle.fontMetrics(), m_inlineTextBox, textDecorationThickness);
</span><del>- int wavyOffset = m_underlineStyle == TextDecorationStyleWavy ? m_wavyOffset : 0;
</del><ins>+ int wavyOffset = m_styles.underlineStyle == TextDecorationStyleWavy ? m_wavyOffset : 0;
</ins><span class="cx"> FloatPoint start = localOrigin + FloatSize(0, offset + wavyOffset);
</span><span class="cx"> FloatPoint end = localOrigin + FloatSize(m_width, offset + wavyOffset);
</span><del>- paintDecoration(TextDecorationUnderline, m_underlineStyle, m_underlineColor, textDecorationStyleToStrokeStyle(m_underlineStyle), start, end, offset);
</del><ins>+ paintDecoration(TextDecorationUnderline, m_styles.underlineStyle, m_styles.underlineColor, start, end, offset);
</ins><span class="cx"> }
</span><span class="cx"> if (m_decoration & TextDecorationOverline) {
</span><del>- int wavyOffset = m_overlineStyle == TextDecorationStyleWavy ? m_wavyOffset : 0;
</del><ins>+ int wavyOffset = m_styles.overlineStyle == TextDecorationStyleWavy ? m_wavyOffset : 0;
</ins><span class="cx"> FloatPoint start = localOrigin - FloatSize(0, wavyOffset);
</span><span class="cx"> FloatPoint end = localOrigin + FloatSize(m_width, -wavyOffset);
</span><del>- paintDecoration(TextDecorationOverline, m_overlineStyle, m_overlineColor, textDecorationStyleToStrokeStyle(m_overlineStyle), start, end, 0);
</del><ins>+ paintDecoration(TextDecorationOverline, m_styles.overlineStyle, m_styles.overlineColor, start, end, 0);
</ins><span class="cx"> }
</span><span class="cx"> if (m_decoration & TextDecorationLineThrough) {
</span><span class="cx"> FloatPoint start = localOrigin + FloatSize(0, 2 * m_baseline / 3);
</span><span class="cx"> FloatPoint end = localOrigin + FloatSize(m_width, 2 * m_baseline / 3);
</span><del>- paintDecoration(TextDecorationLineThrough, m_linethroughStyle, m_linethroughColor, textDecorationStyleToStrokeStyle(m_linethroughStyle), start, end, 0);
</del><ins>+ paintDecoration(TextDecorationLineThrough, m_styles.linethroughStyle, m_styles.linethroughColor, start, end, 0);
</ins><span class="cx"> }
</span><span class="cx"> } while (shadow);
</span><span class="cx">
</span><span class="lines">@@ -352,4 +351,78 @@
</span><span class="cx"> m_context.clearShadow();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static Color decorationColor(const RenderStyle& style)
+{
+ // Check for text decoration color first.
+ Color result = style.visitedDependentColor(CSSPropertyWebkitTextDecorationColor);
+ if (result.isValid())
+ return result;
+ if (style.textStrokeWidth() > 0) {
+ // Prefer stroke color if possible but not if it's fully transparent.
+ result = style.visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
+ if (result.alpha())
+ return result;
+ }
+
+ return style.visitedDependentColor(CSSPropertyWebkitTextFillColor);
+}
+
+static void collectStylesForRenderer(TextDecorationPainter::Styles& result, const RenderObject& renderer, unsigned requestedDecorations, bool firstLineStyle)
+{
+ unsigned remainingDecoration = requestedDecorations;
+ auto extractDecorations = [&] (const RenderStyle& style, unsigned decorations) {
+ auto color = decorationColor(style);
+ auto decorationStyle = style.textDecorationStyle();
+
+ if (decorations & TextDecorationUnderline) {
+ remainingDecoration &= ~TextDecorationUnderline;
+ result.underlineColor = color;
+ result.underlineStyle = decorationStyle;
+ }
+ if (decorations & TextDecorationOverline) {
+ remainingDecoration &= ~TextDecorationOverline;
+ result.overlineColor = color;
+ result.overlineStyle = decorationStyle;
+ }
+ if (decorations & TextDecorationLineThrough) {
+ remainingDecoration &= ~TextDecorationLineThrough;
+ result.linethroughColor = color;
+ result.linethroughStyle = decorationStyle;
+ }
+
+ };
+
+ auto* current = &renderer;
+ do {
+ auto& style = firstLineStyle ? current->firstLineStyle() : current->style();
+ extractDecorations(style, style.textDecoration());
+
+ if (current->isRubyText())
+ return;
+
+ current = current->parent();
+ if (current && current->isAnonymousBlock() && downcast<RenderBlock>(*current).continuation())
+ current = downcast<RenderBlock>(*current).continuation();
+
+ if (!remainingDecoration)
+ break;
+
+ } while (current && !is<HTMLAnchorElement>(current->node()) && !is<HTMLFontElement>(current->node()));
+
+ // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
+ if (remainingDecoration && current) {
+ auto& style = firstLineStyle ? current->firstLineStyle() : current->style();
+ extractDecorations(style, remainingDecoration);
+ }
+}
+
+auto TextDecorationPainter::stylesForRenderer(const RenderObject& renderer, unsigned requestedDecorations, bool firstLineStyle) -> Styles
+{
+ Styles result;
+ collectStylesForRenderer(result, renderer, requestedDecorations, false);
+ if (firstLineStyle)
+ collectStylesForRenderer(result, renderer, requestedDecorations, true);
+ return result;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextDecorationPainterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/TextDecorationPainter.h (205984 => 205985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextDecorationPainter.h        2016-09-15 18:04:45 UTC (rev 205984)
+++ trunk/Source/WebCore/rendering/TextDecorationPainter.h        2016-09-15 18:11:48 UTC (rev 205985)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> class FontCascade;
</span><span class="cx"> class GraphicsContext;
</span><span class="cx"> class InlineTextBox;
</span><ins>+class RenderObject;
</ins><span class="cx"> class RenderStyle;
</span><span class="cx"> class RenderText;
</span><span class="cx"> class ShadowData;
</span><span class="lines">@@ -49,6 +50,16 @@
</span><span class="cx"> void addTextShadow(const ShadowData* textShadow) { m_shadow = textShadow; }
</span><span class="cx">
</span><span class="cx"> void paintTextDecoration(const TextRun&, const FloatPoint& textOrigin, const FloatPoint& boxOrigin);
</span><ins>+
+ struct Styles {
+ Color underlineColor;
+ Color overlineColor;
+ Color linethroughColor;
+ TextDecorationStyle underlineStyle;
+ TextDecorationStyle overlineStyle;
+ TextDecorationStyle linethroughStyle;
+ };
+ static Styles stylesForRenderer(const RenderObject&, unsigned requestedDecorations, bool firstLineStyle = false);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> GraphicsContext& m_context;
</span><span class="lines">@@ -63,12 +74,7 @@
</span><span class="cx"> const InlineTextBox* m_inlineTextBox { nullptr };
</span><span class="cx"> const FontCascade* m_font { nullptr };
</span><span class="cx">
</span><del>- Color m_underlineColor;
- Color m_overlineColor;
- Color m_linethroughColor;
- TextDecorationStyle m_underlineStyle;
- TextDecorationStyle m_overlineStyle;
- TextDecorationStyle m_linethroughStyle;
</del><ins>+ Styles m_styles;
</ins><span class="cx"> const RenderStyle& m_lineStyle;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>