<!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>[174434] releases/WebKitGTK/webkit-2.6</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/174434">174434</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-10-08 04:34:54 -0700 (Wed, 08 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/173941">r173941</a> - REGRESSION: Text with a zero offset, zero blur shadow vanishes
https://bugs.webkit.org/show_bug.cgi?id=136801

Reviewed by Darin Adler.

Source/WebCore:

This patch performs some cleanup regarding TextPainter's shadow logic and handles an
additional case of empty shadows. Previously, there was tight coupling between
applyShadowToGraphicalContext() and paintTextWithShadows(), as they both used a
collection of variables to determine how shadows are to be drawn. This complexity has
been moved into a helper class, ShadowApplier, which performs what
applyShadowToGraphicsContext() used to do, and cleans up correctly in its destructor.
This removes the tight coupling mentioned earlier.

Test: fast/text/empty-shadow.html

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::applyShadowToGraphicsContext): Moved to ShadowApplier.
* rendering/InlineTextBox.h: Deleted applyShadowToGraphicsContext signature.
* rendering/TextPainter.cpp:
(WebCore::ShadowApplier::ShadowApplier): Perform the contents of applyShadowToGraphicsContext()
(WebCore::ShadowApplier::~ShadowApplier): Undo the work done previously
(WebCore::paintTextWithShadows): Create a ShadowApplier to do the relevant shadow work. In addition,
refactor some boolean flags to more meaningful ones with relation to the computation at hand.
(WebCore::isEmptyShadow): Moved to TextPainter.h, named shadowIsCompletelyCoveredByText()
* rendering/TextPainter.h:
(WebCore::ShadowApplier::ShadowApplier): Moved from InlineTextBox::applyShadowToGraphicsContext().
(WebCore::ShadowApplier::extraOffset): Getter.
(WebCore::ShadowApplier::~ShadowApplier): Moved from TextPainter::paintTextWithShadows().
(WebCore::isLastShadowIteration): Helper function.
(WebCore::shadowIsCompletelyCoveredByText): Determines whether or not we should not draw the shadow.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paintTextWithShadows): Update to use ShadowApplier.

LayoutTests:

This test should be a comprehensive test of empty shadows. It tests every
combination of one and two shadows being empty, as well as transparent and
opaque text.

After updating fast/text/empty-shadow.html, fast/text/empty-shadow-with-color.html
is no longer necessary.

* fast/text/empty-shadow-expected.html:
* fast/text/empty-shadow-with-color-expected.html: Removed.
* fast/text/empty-shadow-with-color.html: Removed.
* fast/text/empty-shadow.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit26LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.6/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowexpectedhtml">releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-expected.html</a></li>
<li><a href="#releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowhtml">releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow.html</a></li>
<li><a href="#releasesWebKitGTKwebkit26SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit26SourceWebCorerenderingInlineTextBoxcpp">releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit26SourceWebCorerenderingInlineTextBoxh">releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.h</a></li>
<li><a href="#releasesWebKitGTKwebkit26SourceWebCorerenderingTextPaintercpp">releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit26SourceWebCorerenderingTextPainterh">releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.h</a></li>
<li><a href="#releasesWebKitGTKwebkit26SourceWebCorerenderingsvgSVGInlineTextBoxcpp">releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowwithcolorexpectedhtml">releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color-expected.html</a></li>
<li><a href="#releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowwithcolorhtml">releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit26LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/LayoutTests/ChangeLog (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/LayoutTests/ChangeLog        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/ChangeLog        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-09-22  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        REGRESSION: Text with a zero offset, zero blur shadow vanishes
+        https://bugs.webkit.org/show_bug.cgi?id=136801
+
+        Reviewed by Darin Adler.
+
+        This test should be a comprehensive test of empty shadows. It tests every
+        combination of one and two shadows being empty, as well as transparent and
+        opaque text.
+
+        After updating fast/text/empty-shadow.html, fast/text/empty-shadow-with-color.html
+        is no longer necessary.
+
+        * fast/text/empty-shadow-expected.html:
+        * fast/text/empty-shadow-with-color-expected.html: Removed.
+        * fast/text/empty-shadow-with-color.html: Removed.
+        * fast/text/empty-shadow.html:
+
</ins><span class="cx"> 2014-09-23  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         The style resolution cache applies properties incorrectly whenever direction != ltr
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowexpectedhtml"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-expected.html (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-expected.html        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-expected.html        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><del>-This tests that text drawn with text-shadows of radius 0 and (0, 0) offset are not drawn.
-This is a better outcome than them being drawn in an ugly way.
-This test is successful if the text below is completely invisible.
</del><ins>+&lt;p&gt;This tests that text drawn with text-shadows of radius 0 and (0, 0) offset are not drawn.&lt;/p&gt;
+&lt;p&gt;In the following tests, the actual text is green while the shadows are blue.&lt;/p&gt;
+
+&lt;div style=&quot;color: green;&quot;&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue;&quot;&gt;Text with a single shadow.&lt;/div&gt;
+&lt;div&gt;Text with one empty (undrawn) shadow.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue, 10px 10px blue;&quot;&gt;Text with two shadows&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue;&quot;&gt;Text with two shadows: first drawn and second empty (undrawn).&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 10px 10px blue;&quot;&gt;Text with two shadows: first empty (undrawn) and second drawn.&lt;/div&gt;
+&lt;div&gt;Text with two empty (undrawn) shadows.&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=&quot;color: transparent;&quot;&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue;&quot;&gt;Transparent text with a single shadow.&lt;/div&gt;
+&lt;div style=&quot;color: blue;&quot;&gt;Transparent text with one empty shadow.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue, 10px 10px blue;&quot;&gt;Transparent text with two shadows&lt;/div&gt;
+&lt;div style=&quot;color: blue; text-shadow: 7px 7px blue;&quot;&gt;Transparent text with two shadows: first drawn and second empty.&lt;/div&gt;
+&lt;div style=&quot;color: blue; text-shadow: 10px 10px blue;&quot;&gt;Transparent text with two shadows: first drawn and second empty.&lt;/div&gt;
+&lt;div style=&quot;color: blue; position: relative;&quot;&gt;&lt;div style=&quot;position: absolute; left: 0px; top: 0px;&quot;&gt;Transparent text with two empty shadows.&lt;/div&gt;&lt;div style=&quot;position: absolute; left: 0px; top: 0px;&quot;&gt;Transparent text with two empty shadows.&lt;/div&gt;&lt;/div&gt;
+&lt;/div&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowwithcolorexpectedhtml"></a>
<div class="delfile"><h4>Deleted: releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color-expected.html (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color-expected.html        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color-expected.html        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -1,15 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;style&gt;
-#test {
-    color: green;
-    font-size: 16px;
-}
-&lt;/style&gt;
-&lt;/head&gt;
-&lt;body&gt;
-This test makes sure that text drawn with an empty shadow is colored correctly. It passes if the following text is green.
-&lt;div id=&quot;test&quot;&gt;This should be green.&lt;/div&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowwithcolorhtml"></a>
<div class="delfile"><h4>Deleted: releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color.html (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color.html        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow-with-color.html        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -1,17 +0,0 @@
</span><del>-&lt;!DOCTYPE html&gt;
-&lt;html&gt;
-&lt;head&gt;
-&lt;style&gt;
-#test {
-    color: green;
-    font-size: 16px;
-    text-shadow: red 20px 20px, red 0px 0px;
-    overflow: hidden;
-}
-&lt;/style&gt;
-&lt;/head&gt;
-&lt;body&gt;
-This test makes sure that text drawn with an empty shadow is colored correctly. It passes if the following text is green.
-&lt;div id=&quot;test&quot;&gt;This should be green.&lt;/div&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del></span></pre></div>
<a id="releasesWebKitGTKwebkit26LayoutTestsfasttextemptyshadowhtml"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow.html (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow.html        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/fast/text/empty-shadow.html        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -1,4 +1,20 @@
</span><del>-This tests that text drawn with text-shadows of radius 0 and (0, 0) offset are not drawn.
-This is a better outcome than them being drawn in an ugly way.
-This test is successful if the text below is completely invisible.
-&lt;div style=&quot;color:#fff;text-shadow:0 0 #000&quot;&gt;This is some text&lt;/div&gt;
</del><ins>+&lt;p&gt;This tests that text drawn with text-shadows of radius 0 and (0, 0) offset are not drawn.&lt;/p&gt;
+&lt;p&gt;In the following tests, the actual text is green while the shadows are blue.&lt;/p&gt;
+
+&lt;div style=&quot;color: green;&quot;&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue;&quot;&gt;Text with a single shadow.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 0px 0px blue;&quot;&gt;Text with one empty (undrawn) shadow.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue, 10px 10px blue;&quot;&gt;Text with two shadows&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue, 0px 0px blue;&quot;&gt;Text with two shadows: first drawn and second empty (undrawn).&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 0px 0px blue, 10px 10px blue;&quot;&gt;Text with two shadows: first empty (undrawn) and second drawn.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 0px 0px blue, 0px 0px blue;&quot;&gt;Text with two empty (undrawn) shadows.&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div style=&quot;color: transparent;&quot;&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue;&quot;&gt;Transparent text with a single shadow.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 0px 0px blue;&quot;&gt;Transparent text with one empty shadow.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 5px 5px blue, 10px 10px blue;&quot;&gt;Transparent text with two shadows&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 7px 7px blue, 0px 0px blue;&quot;&gt;Transparent text with two shadows: first drawn and second empty.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 0px 0px blue, 10px 10px blue;&quot;&gt;Transparent text with two shadows: first drawn and second empty.&lt;/div&gt;
+&lt;div style=&quot;text-shadow: 0px 0px blue, 0px 0px blue;&quot;&gt;Transparent text with two empty shadows.&lt;/div&gt;
+&lt;/div&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit26SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2014-09-24  Christophe Dumez  &lt;cdumez@apple.com&gt;
+
+        Unreviewed build fix after r173941.
+
+        Rename shadow to m_shadow.
+
+        * rendering/TextPainter.h:
+        (WebCore::ShadowApplier::shadowIsCompletelyCoveredByText):
+
+2014-09-22  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        REGRESSION: Text with a zero offset, zero blur shadow vanishes
+        https://bugs.webkit.org/show_bug.cgi?id=136801
+
+        Reviewed by Darin Adler.
+
+        This patch performs some cleanup regarding TextPainter's shadow logic and handles an
+        additional case of empty shadows. Previously, there was tight coupling between
+        applyShadowToGraphicalContext() and paintTextWithShadows(), as they both used a
+        collection of variables to determine how shadows are to be drawn. This complexity has
+        been moved into a helper class, ShadowApplier, which performs what
+        applyShadowToGraphicsContext() used to do, and cleans up correctly in its destructor.
+        This removes the tight coupling mentioned earlier.
+
+        Test: fast/text/empty-shadow.html
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::applyShadowToGraphicsContext): Moved to ShadowApplier.
+        * rendering/InlineTextBox.h: Deleted applyShadowToGraphicsContext signature.
+        * rendering/TextPainter.cpp:
+        (WebCore::ShadowApplier::ShadowApplier): Perform the contents of applyShadowToGraphicsContext()
+        (WebCore::ShadowApplier::~ShadowApplier): Undo the work done previously
+        (WebCore::paintTextWithShadows): Create a ShadowApplier to do the relevant shadow work. In addition,
+        refactor some boolean flags to more meaningful ones with relation to the computation at hand.
+        (WebCore::isEmptyShadow): Moved to TextPainter.h, named shadowIsCompletelyCoveredByText()
+        * rendering/TextPainter.h:
+        (WebCore::ShadowApplier::ShadowApplier): Moved from InlineTextBox::applyShadowToGraphicsContext().
+        (WebCore::ShadowApplier::extraOffset): Getter.
+        (WebCore::ShadowApplier::~ShadowApplier): Moved from TextPainter::paintTextWithShadows().
+        (WebCore::isLastShadowIteration): Helper function.
+        (WebCore::shadowIsCompletelyCoveredByText): Determines whether or not we should not draw the shadow.
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintTextWithShadows): Update to use ShadowApplier.
+
</ins><span class="cx"> 2014-09-23  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         The style resolution cache applies properties incorrectly whenever direction != ltr
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit26SourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.cpp (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.cpp        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.cpp        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -424,34 +424,6 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext&amp; context, const ShadowData* shadow, const FloatRect&amp; textRect, bool stroked, bool opaque, bool horizontal, bool&amp; didSaveContext)
-{
-    if (!shadow)
-        return FloatSize();
-
-    FloatSize extraOffset;
-    int shadowX = horizontal ? shadow-&gt;x() : shadow-&gt;y();
-    int shadowY = horizontal ? shadow-&gt;y() : -shadow-&gt;x();
-    FloatSize shadowOffset(shadowX, shadowY);
-    int shadowRadius = shadow-&gt;radius();
-    const Color&amp; shadowColor = shadow-&gt;color();
-
-    if (shadow-&gt;next() || stroked || !opaque) {
-        FloatRect shadowRect(textRect);
-        shadowRect.inflate(shadow-&gt;paintingExtent());
-        shadowRect.move(shadowOffset);
-        context.save();
-        context.clip(shadowRect);
-
-        extraOffset = FloatSize(0, 2 * textRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius);
-        shadowOffset -= extraOffset;
-        didSaveContext = true;
-    }
-
-    context.setShadow(shadowOffset, shadowRadius, shadowColor, context.fillColorSpace());
-    return extraOffset;
-}
-
</del><span class="cx"> static inline bool emphasisPositionHasNeitherLeftNorRight(TextEmphasisPosition emphasisPosition)
</span><span class="cx"> {
</span><span class="cx">     return !(emphasisPosition &amp; TextEmphasisPositionLeft) &amp;&amp; !(emphasisPosition &amp; TextEmphasisPositionRight);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit26SourceWebCorerenderingInlineTextBoxh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.h (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.h        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/InlineTextBox.h        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -154,9 +154,6 @@
</span><span class="cx">     virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const;
</span><span class="cx">     virtual float positionForOffset(int offset) const;
</span><span class="cx"> 
</span><del>-    // Needs to be public, so the static paintTextWithShadows() function can use it.
-    static FloatSize applyShadowToGraphicsContext(GraphicsContext&amp;, const ShadowData*, const FloatRect&amp; textRect, bool stroked, bool opaque, bool horizontal, bool&amp; didSaveContext);
-
</del><span class="cx"> protected:
</span><span class="cx">     void paintCompositionBackground(GraphicsContext*, const FloatPoint&amp; boxOrigin, const RenderStyle&amp;, const Font&amp;, int startPos, int endPos);
</span><span class="cx">     void paintDocumentMarkers(GraphicsContext*, const FloatPoint&amp; boxOrigin, const RenderStyle&amp;, const Font&amp;, bool background);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit26SourceWebCorerenderingTextPaintercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.cpp (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.cpp        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.cpp        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -65,13 +65,54 @@
</span><span class="cx">         context.drawEmphasisMarks(font, textRun, emphasisMark, point + IntSize(0, emphasisMarkOffset), from, to);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool isEmptyShadow(const ShadowData* shadow)
</del><ins>+ShadowApplier::ShadowApplier(GraphicsContext&amp; context, const ShadowData* shadow, const FloatRect&amp; textRect, bool lastShadowIterationShouldDrawText, bool opaque, FontOrientation orientation)
+    : m_context(context)
+    , m_shadow(shadow)
+    , m_onlyDrawsShadow(!isLastShadowIteration() || !lastShadowIterationShouldDrawText)
+    , m_avoidDrawingShadow(shadowIsCompletelyCoveredByText(opaque))
+    , m_nothingToDraw(shadow &amp;&amp; m_avoidDrawingShadow &amp;&amp; m_onlyDrawsShadow)
+    , m_didSaveContext(false)
</ins><span class="cx"> {
</span><del>-    if (!shadow)
-        return false;
-    return shadow-&gt;location() == IntPoint() &amp;&amp; !shadow-&gt;radius();
</del><ins>+    if (!shadow || m_nothingToDraw) {
+        m_shadow = nullptr;
+        return;
+    }
+
+    int shadowX = orientation == Horizontal ? shadow-&gt;x() : shadow-&gt;y();
+    int shadowY = orientation == Horizontal ? shadow-&gt;y() : -shadow-&gt;x();
+    FloatSize shadowOffset(shadowX, shadowY);
+    int shadowRadius = shadow-&gt;radius();
+    const Color&amp; shadowColor = shadow-&gt;color();
+
+    // When drawing shadows, we usually clip the context to the area the shadow will reside, and then
+    // draw the text itself outside the clipped area (so only the shadow shows up). However, we can
+    // often draw the *last* shadow and the text itself in a single call.
+    if (m_onlyDrawsShadow) {
+        FloatRect shadowRect(textRect);
+        shadowRect.inflate(shadow-&gt;paintingExtent());
+        shadowRect.move(shadowOffset);
+        context.save();
+        context.clip(shadowRect);
+
+        m_didSaveContext = true;
+        m_extraOffset = FloatSize(0, 2 * textRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius);
+        shadowOffset -= m_extraOffset;
+    }
+
+    if (!m_avoidDrawingShadow)
+        context.setShadow(shadowOffset, shadowRadius, shadowColor, context.fillColorSpace());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ShadowApplier::~ShadowApplier()
+{
+    if (!m_shadow)
+        return;
+    if (m_onlyDrawsShadow)
+        m_context.restore();
+    else if (!m_avoidDrawingShadow)
+        m_context.clearShadow();
+}
+
</ins><span class="cx"> static void paintTextWithShadows(GraphicsContext&amp; context, const Font&amp; font, const TextRun&amp; textRun, const AtomicString&amp; emphasisMark,
</span><span class="cx">     int emphasisMarkOffset, int startOffset, int endOffset, int truncationPoint, const FloatPoint&amp; textOrigin, const FloatRect&amp; boxRect,
</span><span class="cx">     const ShadowData* shadow, bool stroked, bool horizontal)
</span><span class="lines">@@ -79,20 +120,19 @@
</span><span class="cx">     Color fillColor = context.fillColor();
</span><span class="cx">     ColorSpace fillColorSpace = context.fillColorSpace();
</span><span class="cx">     bool opaque = !fillColor.hasAlpha();
</span><ins>+    bool lastShadowIterationShouldDrawText = !stroked &amp;&amp; opaque;
</ins><span class="cx">     if (!opaque)
</span><span class="cx">         context.setFillColor(Color::black, fillColorSpace);
</span><span class="cx"> 
</span><span class="cx">     do {
</span><del>-        if (isEmptyShadow(shadow)) {
</del><ins>+        ShadowApplier shadowApplier(context, shadow, boxRect, lastShadowIterationShouldDrawText, opaque, horizontal ? Horizontal : Vertical);
+        if (shadowApplier.nothingToDraw()) {
</ins><span class="cx">             shadow = shadow-&gt;next();
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        IntSize extraOffset;
-        bool didSaveContext = false;
-        if (shadow)
-            extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, horizontal, didSaveContext));
-        else if (!opaque)
</del><ins>+        IntSize extraOffset = roundedIntSize(shadowApplier.extraOffset());
+        if (!shadow &amp;&amp; !opaque)
</ins><span class="cx">             context.setFillColor(fillColor, fillColorSpace);
</span><span class="cx"> 
</span><span class="cx">         if (startOffset &lt;= endOffset)
</span><span class="lines">@@ -107,13 +147,8 @@
</span><span class="cx">         if (!shadow)
</span><span class="cx">             break;
</span><span class="cx"> 
</span><del>-        if (didSaveContext)
-            context.restore();
-        else
-            context.clearShadow();
-
</del><span class="cx">         shadow = shadow-&gt;next();
</span><del>-    } while (shadow || stroked || !opaque);
</del><ins>+    } while (shadow || !lastShadowIterationShouldDrawText);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextPainter::paintText()
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit26SourceWebCorerenderingTextPainterh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.h (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.h        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/TextPainter.h        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AffineTransform.h&quot;
</span><span class="cx"> #include &quot;DashArray.h&quot;
</span><ins>+#include &quot;FontOrientation.h&quot;
</ins><span class="cx"> #include &quot;RenderText.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -73,6 +74,34 @@
</span><span class="cx">     bool m_textBoxIsHorizontal;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class ShadowApplier {
+public:
+    ShadowApplier(GraphicsContext&amp;, const ShadowData*, const FloatRect&amp; textRect, bool lastShadowIterationShouldDrawText = true, bool opaque = false, FontOrientation = Horizontal);
+    FloatSize extraOffset() const { return m_extraOffset; }
+    bool nothingToDraw() const { return m_nothingToDraw; }
+    bool didSaveContext() const { return m_didSaveContext; }
+    ~ShadowApplier();
+
+private:
+    bool isLastShadowIteration()
+    {
+        return m_shadow &amp;&amp; !m_shadow-&gt;next();
+    }
+
+    bool shadowIsCompletelyCoveredByText(bool textIsOpaque)
+    {
+        return textIsOpaque &amp;&amp; m_shadow &amp;&amp; m_shadow-&gt;location() == IntPoint() &amp;&amp; !m_shadow-&gt;radius();
+    }
+
+    FloatSize m_extraOffset;
+    GraphicsContext&amp; m_context;
+    const ShadowData* m_shadow;
+    bool m_onlyDrawsShadow : 1;
+    bool m_avoidDrawingShadow : 1;
+    bool m_nothingToDraw : 1;
+    bool m_didSaveContext : 1;
+};
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // TextPainter_h
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit26SourceWebCorerenderingsvgSVGInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (174433 => 174434)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2014-10-08 11:23:45 UTC (rev 174433)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2014-10-08 11:34:54 UTC (rev 174434)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include &quot;SVGResourcesCache.h&quot;
</span><span class="cx"> #include &quot;SVGRootInlineBox.h&quot;
</span><span class="cx"> #include &quot;SVGTextRunRenderingContext.h&quot;
</span><ins>+#include &quot;TextPainter.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -594,23 +595,17 @@
</span><span class="cx">         if (!prepareGraphicsContextForTextPainting(context, scalingFactor, textRun, style))
</span><span class="cx">             break;
</span><span class="cx"> 
</span><del>-        FloatSize extraOffset;
-        bool didSaveContext = false;
-        if (shadow)
-            extraOffset = applyShadowToGraphicsContext(*context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */, didSaveContext);
</del><ins>+        {
+            ShadowApplier shadowApplier(*context, shadow, shadowRect);
</ins><span class="cx"> 
</span><del>-        context-&gt;save();
-        context-&gt;scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
</del><ins>+            if (!shadowApplier.didSaveContext())
+                context-&gt;save();
+            context-&gt;scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
</ins><span class="cx"> 
</span><del>-        scaledFont.drawText(context, textRun, textOrigin + extraOffset, startPosition, endPosition);
</del><ins>+            scaledFont.drawText(context, textRun, textOrigin + shadowApplier.extraOffset(), startPosition, endPosition);
</ins><span class="cx"> 
</span><del>-        context-&gt;restore();
-
-        if (shadow) {
-            if (didSaveContext)
</del><ins>+            if (!shadowApplier.didSaveContext())
</ins><span class="cx">                 context-&gt;restore();
</span><del>-            else
-                context-&gt;clearShadow();
</del><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         restoreGraphicsContextAfterTextPainting(context, textRun);
</span></span></pre>
</div>
</div>

</body>
</html>