<!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>[168750] trunk</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/168750">168750</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2014-05-13 16:25:34 -0700 (Tue, 13 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Text decorations do not contribute to visual overflow https://bugs.webkit.org/show_bug.cgi?id=132773

Patch by Myles C. Maxfield &lt;litherum@gmail.com&gt; on 2014-05-13
Reviewed by Darin Adler.

Source/WebCore:
Tests: fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html

* rendering/InlineTextBox.cpp:
(WebCore::textDecorationStrokeThickness): Refactor into a common function
(WebCore::wavyOffsetFromDecoration): Ditto
(WebCore::InlineTextBox::extendVerticalVisualOverflowForDecorations): Given
vertical overflow bounds, possibly extend those to include location of
decorations.
(WebCore::InlineTextBox::paintDecoration): Use refactored functions.
* rendering/InlineTextBox.h: Function signature
* rendering/RenderBlockLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun): Call extendVerticalVisualOverflowForDecorations()
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeAffectsVisualOverflow): Inspects shadows and text decorations
(WebCore::RenderStyle::changeRequiresLayout): Calls changeAffectsVisualOverflow()
(WebCore::RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline): Moved code from here
to changeAffectsVisualOverflow().
* rendering/style/RenderStyle.h: Function signature

LayoutTests:
This test makes sure that repaint rects are extended to include text decorations that may
lie outside of the text layout rects. It compares text with an underline to text that has
had underline applied to it in a timer.

* fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg: Added. This font has a
descent of 0 (so it will not intersect underlines)
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html: Added.
Apply the underline without any timeout
* fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html: Added.
Apply the underline with a timeout.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxcpp">trunk/Source/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxh">trunk/Source/WebCore/rendering/InlineTextBox.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockLineLayoutcpp">trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStylecpp">trunk/Source/WebCore/rendering/style/RenderStyle.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStyleh">trunk/Source/WebCore/rendering/style/RenderStyle.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/resources/</li>
<li><a href="#trunkLayoutTestsfastcss3textcss3textdecorationrepaintresourcesLitherumsvg">trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg</a></li>
<li><a href="#trunkLayoutTestsfastcss3textcss3textdecorationrepaintunderlineoutsideoflayoutrectexpectedhtml">trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcss3textcss3textdecorationrepaintunderlineoutsideoflayoutrecthtml">trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (168749 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-05-13 23:06:14 UTC (rev 168749)
+++ trunk/LayoutTests/ChangeLog        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-05-13  Myles C. Maxfield  &lt;litherum@gmail.com&gt;
+
+        Text decorations do not contribute to visual overflow
+        https://bugs.webkit.org/show_bug.cgi?id=132773
+
+        Reviewed by Darin Adler.
+
+        This test makes sure that repaint rects are extended to include text decorations that may
+        lie outside of the text layout rects. It compares text with an underline to text that has
+        had underline applied to it in a timer.
+
+        * fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg: Added. This font has a
+        descent of 0 (so it will not intersect underlines)
+        * fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html: Added.
+        Apply the underline without any timeout
+        * fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html: Added.
+        Apply the underline with a timeout.
+
</ins><span class="cx"> 2014-05-13  Jon Honeycutt  &lt;jhoneycutt@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         platform/mac/plugins/testplugin-onnew-onpaint.html failing after r168668
</span></span></pre></div>
<a id="trunkLayoutTestsfastcss3textcss3textdecorationrepaintresourcesLitherumsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg (0 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg                                (rev 0)
+++ trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/resources/Litherum.svg        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot; standalone=&quot;no&quot;?&gt;
+&lt;!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot; &gt;
+&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
+&lt;metadata&gt;&lt;/metadata&gt;
+&lt;defs&gt;
+&lt;font id=&quot;Litherum&quot; horiz-adv-x=&quot;1024&quot;&gt;
+&lt;font-face units-per-em=&quot;14&quot; ascent=&quot;14&quot; descent=&quot;0&quot;/&gt;
+&lt;glyph unicode=&quot;|&quot; horiz-adv-x=&quot;14&quot; d=&quot;M0 0v14h14v-14z&quot;/&gt;
+&lt;glyph unicode=&quot;-&quot; horiz-adv-x=&quot;266&quot; d=&quot;M0 0v14h266v-14z&quot;/&gt;
+&lt;/font&gt;
+&lt;/defs&gt;
+&lt;/svg&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcss3textcss3textdecorationrepaintunderlineoutsideoflayoutrectexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html (0 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect-expected.html        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+@font-face {
+    font-family: 'Litherum';
+    src: url(&quot;./resources/Litherum.svg&quot;) format(svg)
+}
+div {
+    font-family: 'Litherum';
+    -webkit-text-decoration-skip: none;
+    -webkit-text-decoration-color: green;
+    width: 1px;
+    height: 1px;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that underlines contribute to visual overflow.
+The SVG font has a descent of 0, which means that underlines will
+lie outside of the glyph boundaries. The test makes sure that
+drawing underlined text ends up the same as drawing text that has
+had the underline retroactively applied to it with javascript.
+&lt;div style=&quot;position: relative&quot;&gt;
+&lt;div id=&quot;underline&quot; style=&quot;position: absolute; left: 0px; top: 0px; text-decoration: underline;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;underlineunder&quot; style=&quot;position: absolute; left: 20px; top: 0px; -webkit-text-underline-position: under; text-decoration: underline&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;linethrough&quot; style=&quot;position: absolute; left: 40px; top: 0px; text-decoration: line-through;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;overline&quot; style=&quot;position: absolute; left: 60px; top: 0px; text-decoration: overline;&quot;&gt;|&lt;/div&gt;
+
+&lt;div id=&quot;wavyunderline&quot; style=&quot;position: absolute; left: 0px; top: 20px; -webkit-text-decoration-style: wavy; text-decoration: underline;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;wavyunderlineunder&quot; style=&quot;position: absolute; left: 20px; top: 20px; -webkit-text-underline-position: under; -webkit-text-decoration-style: wavy; text-decoration: underline;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;wavylinethrough&quot; style=&quot;font-size: 1px; position: absolute; left: 40px; top: 20px; -webkit-text-decoration-style: wavy; text-decoration: line-through;&quot;&gt;-&lt;/div&gt;
+&lt;div id=&quot;wavyoverline&quot; style=&quot;position: absolute; left: 60px; top: 20px; -webkit-text-decoration-style: wavy; text-decoration: overline;&quot;&gt;|&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcss3textcss3textdecorationrepaintunderlineoutsideoflayoutrecthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html (0 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html                                (rev 0)
+++ trunk/LayoutTests/fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+@font-face {
+    font-family: 'Litherum';
+    src: url(&quot;./resources/Litherum.svg&quot;) format(svg)
+}
+div {
+    font-family: 'Litherum';
+    -webkit-text-decoration-skip: none;
+    -webkit-text-decoration-color: green;
+    width: 1px;
+    height: 1px;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that underlines contribute to visual overflow.
+The SVG font has a descent of 0, which means that underlines will
+lie outside of the glyph boundaries. The test makes sure that
+drawing underlined text ends up the same as drawing text that has
+had the underline retroactively applied to it with javascript.
+&lt;div style=&quot;position: relative&quot;&gt;
+&lt;div id=&quot;underline&quot; style=&quot;position: absolute; left: 0px; top: 0px;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;underlineunder&quot; style=&quot;position: absolute; left: 20px; top: 0px; -webkit-text-underline-position: under;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;linethrough&quot; style=&quot;position: absolute; left: 40px; top: 0px;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;overline&quot; style=&quot;position: absolute; left: 60px; top: 0px;&quot;&gt;|&lt;/div&gt;
+
+&lt;div id=&quot;wavyunderline&quot; style=&quot;position: absolute; left: 0px; top: 20px; -webkit-text-decoration-style: wavy;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;wavyunderlineunder&quot; style=&quot;position: absolute; left: 20px; top: 20px; -webkit-text-underline-position: under; -webkit-text-decoration-style: wavy;&quot;&gt;|&lt;/div&gt;
+&lt;div id=&quot;wavylinethrough&quot; style=&quot;font-size: 1px; position: absolute; left: 40px; top: 20px; -webkit-text-decoration-style: wavy;&quot;&gt;-&lt;/div&gt;
+&lt;div id=&quot;wavyoverline&quot; style=&quot;position: absolute; left: 60px; top: 20px; -webkit-text-decoration-style: wavy;&quot;&gt;|&lt;/div&gt;
+&lt;/div&gt;
+&lt;script&gt;
+function applyUnderline() {
+    document.getElementById('underline').style.textDecoration = &quot;underline&quot;;
+    document.getElementById('underlineunder').style.textDecoration = &quot;underline&quot;;
+    document.getElementById('linethrough').style.textDecoration = &quot;line-through&quot;;
+    document.getElementById('overline').style.textDecoration = &quot;overline&quot;;
+    document.getElementById('wavyunderline').style.textDecoration = &quot;underline&quot;;
+    document.getElementById('wavyunderlineunder').style.textDecoration = &quot;underline&quot;;
+    document.getElementById('wavylinethrough').style.textDecoration = &quot;line-through&quot;;
+    document.getElementById('wavyoverline').style.textDecoration = &quot;overline&quot;;
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+if (window.testRunner)
+    testRunner.waitUntilDone();
+window.addEventListener('load', applyUnderline, false);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168749 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-13 23:06:14 UTC (rev 168749)
+++ trunk/Source/WebCore/ChangeLog        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2014-05-13  Myles C. Maxfield  &lt;litherum@gmail.com&gt;
+
+        Text decorations do not contribute to visual overflow
+        https://bugs.webkit.org/show_bug.cgi?id=132773
+
+        Reviewed by Darin Adler.
+
+        Tests: fast/css3-text/css3-text-decoration/repaint/underline-outside-of-layout-rect.html
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::textDecorationStrokeThickness): Refactor into a common function
+        (WebCore::wavyOffsetFromDecoration): Ditto
+        (WebCore::InlineTextBox::extendVerticalVisualOverflowForDecorations): Given
+        vertical overflow bounds, possibly extend those to include location of
+        decorations.
+        (WebCore::InlineTextBox::paintDecoration): Use refactored functions.
+        * rendering/InlineTextBox.h: Function signature
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::setLogicalWidthForTextRun): Call extendVerticalVisualOverflowForDecorations()
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::changeAffectsVisualOverflow): Inspects shadows and text decorations
+        (WebCore::RenderStyle::changeRequiresLayout): Calls changeAffectsVisualOverflow()
+        (WebCore::RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline): Moved code from here
+        to changeAffectsVisualOverflow().
+        * rendering/style/RenderStyle.h: Function signature
+
</ins><span class="cx"> 2014-05-13  Enrica Casucci  &lt;enrica@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (WebKit2): Zooming to text field leaves it partially hidden by the form assistant.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (168749 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.cpp        2014-05-13 23:06:14 UTC (rev 168749)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -973,6 +973,71 @@
</span><span class="cx">     context.strokePath(path);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline float textDecorationStrokeThickness(float fontSize)
+{
+    const float textDecorationBaseFontSize = 16;
+    return fontSize / textDecorationBaseFontSize;
+}
+
+static inline float wavyOffsetFromDecoration()
+{
+    return 2;
+}
+
+void InlineTextBox::extendVerticalVisualOverflowForDecorations(float&amp; top, float&amp; bottom) const
+{
+    const RenderStyle&amp; lineStyle = this-&gt;lineStyle();
+    TextDecoration decoration = lineStyle.textDecorationsInEffect();
+    
+    if (decoration == TextDecorationNone)
+        return;
+    
+    TextDecorationStyle decorationStyle = lineStyle.textDecorationStyle();
+    float strokeThickness = textDecorationStrokeThickness(renderer().style().fontSize());
+    
+    float controlPointDistance;
+    float step;
+    float wavyOffset;
+    
+    if (decorationStyle == TextDecorationStyleWavy) {
+        getWavyStrokeParameters(strokeThickness, controlPointDistance, step);
+        wavyOffset = wavyOffsetFromDecoration();
+    }
+    
+    float height = logicalHeight();
+
+    // These metrics must match where underlines get drawn.
+    if (decoration &amp; TextDecorationUnderline) {
+        float underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), this, strokeThickness);
+        if (decorationStyle == TextDecorationStyleWavy) {
+            bottom = std::max(bottom, underlineOffset + wavyOffset + controlPointDistance + strokeThickness - height);
+            top = std::max(top, -(underlineOffset + wavyOffset - controlPointDistance - strokeThickness));
+        } else {
+            bottom = std::max(bottom, underlineOffset + strokeThickness - height);
+            top = std::max(top, -underlineOffset);
+        }
+    }
+    if (decoration &amp; TextDecorationOverline) {
+        if (decorationStyle == TextDecorationStyleWavy) {
+            bottom = std::max(bottom, -wavyOffset + controlPointDistance + strokeThickness - height);
+            top = std::max(top, wavyOffset + controlPointDistance + strokeThickness);
+        } else {
+            bottom = std::max(bottom, strokeThickness - height);
+            // top is untouched
+        }
+    }
+    if (decoration &amp; TextDecorationLineThrough) {
+        float baseline = lineStyle.fontMetrics().floatAscent();
+        if (decorationStyle == TextDecorationStyleWavy) {
+            bottom = std::max(bottom, 2 * baseline / 3 + controlPointDistance + strokeThickness - height);
+            top = std::max(top, -(2 * baseline / 3 - controlPointDistance - strokeThickness));
+        } else {
+            bottom = std::max(bottom, 2 * baseline / 3 + strokeThickness - height);
+            top = std::max(top, -(2 * baseline / 3));
+        }
+    }
+}
+
</ins><span class="cx"> void InlineTextBox::paintDecoration(GraphicsContext&amp; context, const FloatPoint&amp; boxOrigin, TextDecoration decoration, TextDecorationStyle decorationStyle, const ShadowData* shadow, TextPainter&amp; textPainter)
</span><span class="cx"> {
</span><span class="cx"> #if !ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
</span><span class="lines">@@ -1000,8 +1065,7 @@
</span><span class="cx">     // Use a special function for underlines to get the positioning exactly right.
</span><span class="cx">     bool isPrinting = renderer().document().printing();
</span><span class="cx"> 
</span><del>-    const float textDecorationBaseFontSize = 16;
-    float textDecorationThickness = renderer().style().fontSize() / textDecorationBaseFontSize;
</del><ins>+    float textDecorationThickness = textDecorationStrokeThickness(renderer().style().fontSize());
</ins><span class="cx">     context.setStrokeThickness(textDecorationThickness);
</span><span class="cx"> 
</span><span class="cx">     bool linesAreOpaque = !isPrinting &amp;&amp; (!(decoration &amp; TextDecorationUnderline) || underline.alpha() == 255) &amp;&amp; (!(decoration &amp; TextDecorationOverline) || overline.alpha() == 255) &amp;&amp; (!(decoration &amp; TextDecorationLineThrough) || linethrough.alpha() == 255);
</span><span class="lines">@@ -1047,13 +1111,13 @@
</span><span class="cx">             shadow = shadow-&gt;next();
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        float wavyOffset = 2.f;
</del><ins>+        float wavyOffset = wavyOffsetFromDecoration();
</ins><span class="cx"> 
</span><span class="cx">         context.setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle));
</span><ins>+        // These decorations should match the visual overflows computed in extendVerticalVisualOverflowForDecorations()
</ins><span class="cx">         if (decoration &amp; TextDecorationUnderline) {
</span><span class="cx">             context.setStrokeColor(underline, colorSpace);
</span><del>-            TextUnderlinePosition underlinePosition = lineStyle.textUnderlinePosition();
-            const int underlineOffset = computeUnderlineOffset(underlinePosition, lineStyle.fontMetrics(), this, textDecorationThickness);
</del><ins>+            const int underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), this, textDecorationThickness);
</ins><span class="cx"> 
</span><span class="cx">             switch (decorationStyle) {
</span><span class="cx">             case TextDecorationStyleWavy: {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (168749 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.h        2014-05-13 23:06:14 UTC (rev 168749)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -159,6 +159,7 @@
</span><span class="cx"> public:
</span><span class="cx">     virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const;
</span><span class="cx">     virtual float positionForOffset(int offset) const;
</span><ins>+    void extendVerticalVisualOverflowForDecorations(float&amp; top, float&amp; bottom) const;
</ins><span class="cx"> 
</span><span class="cx">     // Needs to be public, so the static paintTextWithShadows() function can use it.
</span><span class="cx">     static FloatSize applyShadowToGraphicsContext(GraphicsContext*, const ShadowData*, const FloatRect&amp; textRect, bool stroked, bool opaque, bool horizontal);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (168749 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2014-05-13 23:06:14 UTC (rev 168749)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -524,7 +524,17 @@
</span><span class="cx">         copyToVector(fallbackFonts, it-&gt;value.first);
</span><span class="cx">         run-&gt;box()-&gt;parent()-&gt;clearDescendantsHaveSameLineHeightAndBaseline();
</span><span class="cx">     }
</span><del>-    if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right)) {
</del><ins>+
+    // Include text decoration visual overflow as part of the glyph overflow.
+    if (renderer-&gt;style().textDecorationsInEffect() != TextDecorationNone) {
+        float top = glyphOverflow.top;
+        float bottom = glyphOverflow.bottom;
+        toInlineTextBox(run-&gt;box())-&gt;extendVerticalVisualOverflowForDecorations(top, bottom);
+        glyphOverflow.top = static_cast&lt;int&gt;(ceilf(top));
+        glyphOverflow.bottom = static_cast&lt;int&gt;(ceilf(bottom));
+    }
+
+    if (glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right) {
</ins><span class="cx">         ASSERT(run-&gt;box()-&gt;behavesLikeText());
</span><span class="cx">         GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run-&gt;box()), std::make_pair(Vector&lt;const SimpleFontData*&gt;(), GlyphOverflow())).iterator;
</span><span class="cx">         it-&gt;value.second = glyphOverflow;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (168749 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2014-05-13 23:06:14 UTC (rev 168749)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -382,6 +382,22 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline bool RenderStyle::changeAffectsVisualOverflow(const RenderStyle&amp; other) const
+{
+    if (rareNonInheritedData.get() != other.rareNonInheritedData.get()
+        &amp;&amp; !rareNonInheritedData-&gt;shadowDataEquivalent(*other.rareNonInheritedData.get()))
+        return true;
+
+    if (inherited_flags._text_decorations != other.inherited_flags._text_decorations
+        || visual-&gt;textDecoration != other.visual-&gt;textDecoration
+        || rareNonInheritedData-&gt;m_textDecorationStyle != other.rareNonInheritedData-&gt;m_textDecorationStyle
+        || rareNonInheritedData-&gt;m_textDecorationColor != other.rareNonInheritedData-&gt;m_textDecorationColor
+        || rareInheritedData-&gt;m_textDecorationSkip != other.rareInheritedData-&gt;m_textDecorationSkip)
+        return true;
+
+    return false;
+}
+
</ins><span class="cx"> bool RenderStyle::changeRequiresLayout(const RenderStyle* other, unsigned&amp; changedContextSensitiveProperties) const
</span><span class="cx"> {
</span><span class="cx">     if (m_box-&gt;width() != other-&gt;m_box-&gt;width()
</span><span class="lines">@@ -404,6 +420,10 @@
</span><span class="cx">     if (surround-&gt;padding != other-&gt;surround-&gt;padding)
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    // FIXME: We should add an optimized form of layout that just recomputes visual overflow.
+    if (changeAffectsVisualOverflow(*other))
+        return true;
+
</ins><span class="cx">     if (rareNonInheritedData.get() != other-&gt;rareNonInheritedData.get()) {
</span><span class="cx">         if (rareNonInheritedData-&gt;m_appearance != other-&gt;rareNonInheritedData-&gt;m_appearance 
</span><span class="cx">             || rareNonInheritedData-&gt;marginBeforeCollapse != other-&gt;rareNonInheritedData-&gt;marginBeforeCollapse
</span><span class="lines">@@ -434,10 +454,6 @@
</span><span class="cx">             || rareNonInheritedData-&gt;m_justifyContent != other-&gt;rareNonInheritedData-&gt;m_justifyContent)
</span><span class="cx">             return true;
</span><span class="cx"> 
</span><del>-        // FIXME: We should add an optimized form of layout that just recomputes visual overflow.
-        if (!rareNonInheritedData-&gt;shadowDataEquivalent(*other-&gt;rareNonInheritedData.get()))
-            return true;
-
</del><span class="cx">         if (!rareNonInheritedData-&gt;reflectionDataEquivalent(*other-&gt;rareNonInheritedData.get()))
</span><span class="cx">             return true;
</span><span class="cx"> 
</span><span class="lines">@@ -714,11 +730,6 @@
</span><span class="cx"> bool RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle* other, unsigned&amp;) const
</span><span class="cx"> {
</span><span class="cx">     if (inherited-&gt;color != other-&gt;inherited-&gt;color
</span><del>-        || inherited_flags._text_decorations != other-&gt;inherited_flags._text_decorations
-        || visual-&gt;textDecoration != other-&gt;visual-&gt;textDecoration
-        || rareNonInheritedData-&gt;m_textDecorationStyle != other-&gt;rareNonInheritedData-&gt;m_textDecorationStyle
-        || rareNonInheritedData-&gt;m_textDecorationColor != other-&gt;rareNonInheritedData-&gt;m_textDecorationColor
-        || rareInheritedData-&gt;m_textDecorationSkip != other-&gt;rareInheritedData-&gt;m_textDecorationSkip
</del><span class="cx">         || rareInheritedData-&gt;textFillColor != other-&gt;rareInheritedData-&gt;textFillColor
</span><span class="cx">         || rareInheritedData-&gt;textStrokeColor != other-&gt;rareInheritedData-&gt;textStrokeColor
</span><span class="cx">         || rareInheritedData-&gt;textEmphasisColor != other-&gt;rareInheritedData-&gt;textEmphasisColor
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStyleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (168749 => 168750)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.h        2014-05-13 23:06:14 UTC (rev 168749)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h        2014-05-13 23:25:34 UTC (rev 168750)
</span><span class="lines">@@ -1936,6 +1936,7 @@
</span><span class="cx">     static ptrdiff_t noninheritedFlagsMemoryOffset() { return OBJECT_OFFSETOF(RenderStyle, noninherited_flags); }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    bool changeAffectsVisualOverflow(const RenderStyle&amp;) const;
</ins><span class="cx">     bool changeRequiresLayout(const RenderStyle*, unsigned&amp; changedContextSensitiveProperties) const;
</span><span class="cx">     bool changeRequiresPositionedLayoutOnly(const RenderStyle*, unsigned&amp; changedContextSensitiveProperties) const;
</span><span class="cx">     bool changeRequiresLayerRepaint(const RenderStyle*, unsigned&amp; changedContextSensitiveProperties) const;
</span></span></pre>
</div>
</div>

</body>
</html>