<!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  &lt;antti@apple.com&gt;
+
+        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  &lt;hyatt@apple.com&gt;
</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 &amp; (TextDecorationUnderline | TextDecorationLineThrough)) != 0) {
-        Color underlineColor, overlineColor, linethroughColor;
-        TextDecorationStyle underlineStyle, overlineStyle, linethroughStyle;
-        renderer-&gt;getTextDecorationColorsAndStyles(decor, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle);
-        
-        if (decor &amp; TextDecorationUnderline)
-            AXAttributeStringSetNumber(attrString, UIAccessibilityTokenUnderline, [NSNumber numberWithBool:YES], range);
-    }
</del><ins>+    if (decor &amp; 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 &quot;ScrollView.h&quot;
</span><span class="cx"> #import &quot;TextCheckerClient.h&quot;
</span><span class="cx"> #import &quot;TextCheckingHelper.h&quot;
</span><ins>+#import &quot;TextDecorationPainter.h&quot;
</ins><span class="cx"> #import &quot;TextIterator.h&quot;
</span><span class="cx"> #import &quot;VisibleUnits.h&quot;
</span><span class="cx"> #import &quot;WebCoreFrameView.h&quot;
</span><span class="lines">@@ -1119,18 +1120,16 @@
</span><span class="cx">     
</span><span class="cx">     if ((decor &amp; (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-&gt;getTextDecorationColorsAndStyles(decor, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle);
-        
</del><ins>+        auto decorationStyles = TextDecorationPainter::stylesForRenderer(*renderer, decor);
+
</ins><span class="cx">         if ((decor &amp; 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 &amp; 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 &quot;FrameView.h&quot;
</span><span class="cx"> #include &quot;GeometryUtilities.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><del>-#include &quot;HTMLAnchorElement.h&quot;
</del><span class="cx"> #include &quot;HTMLElement.h&quot;
</span><span class="cx"> #include &quot;HTMLImageElement.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</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-&gt;visitedDependentColor(CSSPropertyWebkitTextDecorationColor);
-    if (result.isValid())
-        return result;
-    if (style-&gt;textStrokeWidth() &gt; 0) {
-        // Prefer stroke color if possible but not if it's fully transparent.
-        result = style-&gt;visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
-        if (result.alpha())
-            return result;
-    }
-    
-    result = style-&gt;visitedDependentColor(CSSPropertyWebkitTextFillColor);
-    return result;
-}
-
-void RenderObject::getTextDecorationColorsAndStyles(int decorations, Color&amp; underlineColor, Color&amp; overlineColor, Color&amp; linethroughColor,
-    TextDecorationStyle&amp; underlineStyle, TextDecorationStyle&amp; overlineStyle, TextDecorationStyle&amp; linethroughStyle, bool firstlineStyle) const
-{
-    const RenderObject* current = this;
-    const RenderStyle* styleToUse = nullptr;
-    TextDecoration currDecs = TextDecorationNone;
-    Color resultColor;
-    do {
-        styleToUse = firstlineStyle ? &amp;current-&gt;firstLineStyle() : &amp;current-&gt;style();
-        currDecs = styleToUse-&gt;textDecoration();
-        resultColor = decorationColor(styleToUse);
-        // Parameter 'decorations' is cast as an int to enable the bitwise operations below.
-        if (currDecs) {
-            if (currDecs &amp; TextDecorationUnderline) {
-                decorations &amp;= ~TextDecorationUnderline;
-                underlineColor = resultColor;
-                underlineStyle = styleToUse-&gt;textDecorationStyle();
-            }
-            if (currDecs &amp; TextDecorationOverline) {
-                decorations &amp;= ~TextDecorationOverline;
-                overlineColor = resultColor;
-                overlineStyle = styleToUse-&gt;textDecorationStyle();
-            }
-            if (currDecs &amp; TextDecorationLineThrough) {
-                decorations &amp;= ~TextDecorationLineThrough;
-                linethroughColor = resultColor;
-                linethroughStyle = styleToUse-&gt;textDecorationStyle();
-            }
-        }
-        if (current-&gt;isRubyText())
-            return;
-        current = current-&gt;parent();
-        if (current &amp;&amp; current-&gt;isAnonymousBlock() &amp;&amp; downcast&lt;RenderBlock&gt;(*current).continuation())
-            current = downcast&lt;RenderBlock&gt;(*current).continuation();
-    } while (current &amp;&amp; decorations &amp;&amp; (!current-&gt;node() || (!is&lt;HTMLAnchorElement&gt;(*current-&gt;node()) &amp;&amp; !current-&gt;node()-&gt;hasTagName(fontTag))));
-
-    // If we bailed out, use the element we bailed out at (typically a &lt;font&gt; or &lt;a&gt; element).
-    if (decorations &amp;&amp; current) {
-        styleToUse = firstlineStyle ? &amp;current-&gt;firstLineStyle() : &amp;current-&gt;style();
-        resultColor = decorationColor(styleToUse);
-        if (decorations &amp; TextDecorationUnderline) {
-            underlineColor = resultColor;
-            underlineStyle = styleToUse-&gt;textDecorationStyle();
-        }
-        if (decorations &amp; TextDecorationOverline) {
-            overlineColor = resultColor;
-            overlineStyle = styleToUse-&gt;textDecorationStyle();
-        }
-        if (decorations &amp; TextDecorationLineThrough) {
-            linethroughColor = resultColor;
-            linethroughStyle = styleToUse-&gt;textDecorationStyle();
-        }
-    }
-}
-
</del><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span><span class="cx"> void RenderObject::addAnnotatedRegions(Vector&lt;AnnotatedRegionValue&gt;&amp; 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&amp;, Cursor&amp;) const;
</span><span class="cx"> 
</span><del>-    void getTextDecorationColorsAndStyles(int decorations, Color&amp; underlineColor, Color&amp; overlineColor, Color&amp; linethroughColor,
-        TextDecorationStyle&amp; underlineStyle, TextDecorationStyle&amp; overlineStyle, TextDecorationStyle&amp; 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 &quot;FontCascade.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><ins>+#include &quot;HTMLAnchorElement.h&quot;
+#include &quot;HTMLFontElement.h&quot;
</ins><span class="cx"> #include &quot;InlineTextBoxStyle.h&quot;
</span><ins>+#include &quot;RenderBlock.h&quot;
</ins><span class="cx"> #include &quot;RenderStyle.h&quot;
</span><span class="cx"> #include &quot;RenderText.h&quot;
</span><span class="cx"> #include &quot;ShadowData.h&quot;
</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&amp; textRun, const FloatPoint&amp; textOrigin, const FloatPoint&amp; 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 = [&amp;](TextDecoration decoration, TextDecorationStyle style, Color color, StrokeStyle strokeStyle,
-        const FloatPoint&amp; start, const FloatPoint&amp; end, int offset) {
</del><ins>+    auto paintDecoration = [&amp;](TextDecoration decoration, TextDecorationStyle style, Color color, const FloatPoint&amp; start, const FloatPoint&amp; 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>-        &amp;&amp; (!(m_decoration &amp; TextDecorationUnderline) || m_underlineColor.alpha() == 255)
-        &amp;&amp; (!(m_decoration &amp; TextDecorationOverline) || m_overlineColor.alpha() == 255)
-        &amp;&amp; (!(m_decoration &amp; TextDecorationLineThrough) || m_linethroughColor.alpha() == 255);
</del><ins>+        &amp;&amp; (!(m_decoration &amp; TextDecorationUnderline) || m_styles.underlineColor.alpha() == 255)
+        &amp;&amp; (!(m_decoration &amp; TextDecorationOverline) || m_styles.overlineColor.alpha() == 255)
+        &amp;&amp; (!(m_decoration &amp; TextDecorationLineThrough) || m_styles.linethroughColor.alpha() == 255);
</ins><span class="cx"> 
</span><span class="cx">     int extraOffset = 0;
</span><span class="cx">     bool clipping = !linesAreOpaque &amp;&amp; m_shadow &amp;&amp; m_shadow-&gt;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 &amp; 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 &amp; 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 &amp; 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&amp; style)
+{
+    // Check for text decoration color first.
+    Color result = style.visitedDependentColor(CSSPropertyWebkitTextDecorationColor);
+    if (result.isValid())
+        return result;
+    if (style.textStrokeWidth() &gt; 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&amp; result, const RenderObject&amp; renderer, unsigned requestedDecorations, bool firstLineStyle)
+{
+    unsigned remainingDecoration = requestedDecorations;
+    auto extractDecorations = [&amp;] (const RenderStyle&amp; style, unsigned decorations) {
+        auto color = decorationColor(style);
+        auto decorationStyle = style.textDecorationStyle();
+
+        if (decorations &amp; TextDecorationUnderline) {
+            remainingDecoration &amp;= ~TextDecorationUnderline;
+            result.underlineColor = color;
+            result.underlineStyle = decorationStyle;
+        }
+        if (decorations &amp; TextDecorationOverline) {
+            remainingDecoration &amp;= ~TextDecorationOverline;
+            result.overlineColor = color;
+            result.overlineStyle = decorationStyle;
+        }
+        if (decorations &amp; TextDecorationLineThrough) {
+            remainingDecoration &amp;= ~TextDecorationLineThrough;
+            result.linethroughColor = color;
+            result.linethroughStyle = decorationStyle;
+        }
+
+    };
+
+    auto* current = &amp;renderer;
+    do {
+        auto&amp; style = firstLineStyle ? current-&gt;firstLineStyle() : current-&gt;style();
+        extractDecorations(style, style.textDecoration());
+
+        if (current-&gt;isRubyText())
+            return;
+
+        current = current-&gt;parent();
+        if (current &amp;&amp; current-&gt;isAnonymousBlock() &amp;&amp; downcast&lt;RenderBlock&gt;(*current).continuation())
+            current = downcast&lt;RenderBlock&gt;(*current).continuation();
+
+        if (!remainingDecoration)
+            break;
+
+    } while (current &amp;&amp; !is&lt;HTMLAnchorElement&gt;(current-&gt;node()) &amp;&amp; !is&lt;HTMLFontElement&gt;(current-&gt;node()));
+
+    // If we bailed out, use the element we bailed out at (typically a &lt;font&gt; or &lt;a&gt; element).
+    if (remainingDecoration     &amp;&amp; current) {
+        auto&amp; style = firstLineStyle ? current-&gt;firstLineStyle() : current-&gt;style();
+        extractDecorations(style, remainingDecoration);
+    }
+}
+
+auto TextDecorationPainter::stylesForRenderer(const RenderObject&amp; renderer, unsigned requestedDecorations, bool firstLineStyle) -&gt; 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&amp;, const FloatPoint&amp; textOrigin, const FloatPoint&amp; boxOrigin);
</span><ins>+
+    struct Styles {
+        Color underlineColor;
+        Color overlineColor;
+        Color linethroughColor;
+        TextDecorationStyle underlineStyle;
+        TextDecorationStyle overlineStyle;
+        TextDecorationStyle linethroughStyle;
+    };
+    static Styles stylesForRenderer(const RenderObject&amp;, unsigned requestedDecorations, bool firstLineStyle = false);
</ins><span class="cx">         
</span><span class="cx"> private:
</span><span class="cx">     GraphicsContext&amp; 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&amp; m_lineStyle;
</span><span class="cx"> };
</span><span class="cx">     
</span></span></pre>
</div>
</div>

</body>
</html>