<!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>[194447] 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/194447">194447</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2015-12-30 09:19:03 -0800 (Wed, 30 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move InlineTextBox's text decoration painting to its own class.
https://bugs.webkit.org/show_bug.cgi?id=152587
Reviewed by Myles C. Maxfield.
This is in preparation for adding text decoration support for simple line layout.
No change in functionality.
* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintDecoration):
(WebCore::compareTuples): Deleted.
(WebCore::translateIntersectionPointsToSkipInkBoundaries): Deleted.
(WebCore::drawSkipInkUnderline): Deleted.
(WebCore::textDecorationStyleToStrokeStyle): Deleted.
(WebCore::adjustStepToDecorationLength): Deleted.
(WebCore::strokeWavyTextDecoration): Deleted.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::getTextDecorationColorsAndStyles):
* rendering/RenderObject.h:
* rendering/RenderingAllInOne.cpp:
* rendering/TextDecorationPainter.cpp: Added.
(WebCore::adjustStepToDecorationLength):
(WebCore::strokeWavyTextDecoration):
(WebCore::compareTuples):
(WebCore::translateIntersectionPointsToSkipInkBoundaries):
(WebCore::drawSkipInkUnderline):
(WebCore::textDecorationStyleToStrokeStyle):
(WebCore::TextDecorationPainter::TextDecorationPainter):
(WebCore::TextDecorationPainter::paintTextDecoration):
* rendering/TextDecorationPainter.h: Added.
(WebCore::TextDecorationPainter::setInlineTextBox):
(WebCore::TextDecorationPainter::setFont):
(WebCore::TextDecorationPainter::setIsHorizontal):
(WebCore::TextDecorationPainter::setWidth):
(WebCore::TextDecorationPainter::setBaseline):
(WebCore::TextDecorationPainter::addTextShadow):
* style/InlineTextBoxStyle.cpp:
(WebCore::computeUnderlineOffset):
(WebCore::visualOverflowForDecorations):
* style/InlineTextBoxStyle.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxcpp">trunk/Source/WebCore/rendering/InlineTextBox.cpp</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="#trunkSourceWebCorerenderingRenderingAllInOnecpp">trunk/Source/WebCore/rendering/RenderingAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleInlineTextBoxStylecpp">trunk/Source/WebCore/style/InlineTextBoxStyle.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleInlineTextBoxStyleh">trunk/Source/WebCore/style/InlineTextBoxStyle.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<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="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -2472,6 +2472,7 @@
</span><span class="cx"> rendering/SimpleLineLayoutResolver.cpp
</span><span class="cx"> rendering/SimpleLineLayoutTextFragmentIterator.cpp
</span><span class="cx"> rendering/TextAutosizer.cpp
</span><ins>+ rendering/TextDecorationPainter.cpp
</ins><span class="cx"> rendering/TextPaintStyle.cpp
</span><span class="cx"> rendering/TextPainter.cpp
</span><span class="cx"> rendering/break_lines.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/ChangeLog        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2015-12-30 Zalan Bujtas <zalan@apple.com>
+
+ Move InlineTextBox's text decoration painting to its own class.
+ https://bugs.webkit.org/show_bug.cgi?id=152587
+
+ Reviewed by Myles C. Maxfield.
+
+ This is in preparation for adding text decoration support for simple line layout.
+
+ No change in functionality.
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::paintDecoration):
+ (WebCore::compareTuples): Deleted.
+ (WebCore::translateIntersectionPointsToSkipInkBoundaries): Deleted.
+ (WebCore::drawSkipInkUnderline): Deleted.
+ (WebCore::textDecorationStyleToStrokeStyle): Deleted.
+ (WebCore::adjustStepToDecorationLength): Deleted.
+ (WebCore::strokeWavyTextDecoration): Deleted.
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::getTextDecorationColorsAndStyles):
+ * rendering/RenderObject.h:
+ * rendering/RenderingAllInOne.cpp:
+ * rendering/TextDecorationPainter.cpp: Added.
+ (WebCore::adjustStepToDecorationLength):
+ (WebCore::strokeWavyTextDecoration):
+ (WebCore::compareTuples):
+ (WebCore::translateIntersectionPointsToSkipInkBoundaries):
+ (WebCore::drawSkipInkUnderline):
+ (WebCore::textDecorationStyleToStrokeStyle):
+ (WebCore::TextDecorationPainter::TextDecorationPainter):
+ (WebCore::TextDecorationPainter::paintTextDecoration):
+ * rendering/TextDecorationPainter.h: Added.
+ (WebCore::TextDecorationPainter::setInlineTextBox):
+ (WebCore::TextDecorationPainter::setFont):
+ (WebCore::TextDecorationPainter::setIsHorizontal):
+ (WebCore::TextDecorationPainter::setWidth):
+ (WebCore::TextDecorationPainter::setBaseline):
+ (WebCore::TextDecorationPainter::addTextShadow):
+ * style/InlineTextBoxStyle.cpp:
+ (WebCore::computeUnderlineOffset):
+ (WebCore::visualOverflowForDecorations):
+ * style/InlineTextBoxStyle.h:
+
</ins><span class="cx"> 2015-12-30 Zan Dobersek <zdobersek@igalia.com>
</span><span class="cx">
</span><span class="cx"> [CoordinatedGraphics] VideoRenderRequestScheduler shouldn't dispatch to main thread in threaded compositor
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -13480,6 +13480,20 @@
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\rendering\TextDecorationPainter.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\rendering\TextPainter.cpp">
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</span><span class="lines">@@ -21841,6 +21855,7 @@
</span><span class="cx"> <ClInclude Include="..\rendering\svg\SVGResourcesCache.h" />
</span><span class="cx"> <ClInclude Include="..\rendering\svg\SVGResourcesCycleSolver.h" />
</span><span class="cx"> <ClInclude Include="..\rendering\TableLayout.h" />
</span><ins>+ <ClInclude Include="..\rendering\TextDecorationPainter.h" />
</ins><span class="cx"> <ClInclude Include="..\rendering\TextPaintStyle.h" />
</span><span class="cx"> <ClInclude Include="..\rendering\TextPainter.h" />
</span><span class="cx"> <ClInclude Include="..\rendering\TrailingFloatsRootInlineBox.h" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -2900,6 +2900,9 @@
</span><span class="cx"> <ClCompile Include="..\rendering\svg\SVGTextRunRenderingContext.cpp">
</span><span class="cx"> <Filter>rendering\svg</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\rendering\TextDecorationPainter.cpp">
+ <Filter>rendering</Filter>
+ </ClCompile>
</ins><span class="cx"> <ClCompile Include="..\rendering\TextPainter.cpp">
</span><span class="cx"> <Filter>rendering</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="lines">@@ -9682,6 +9685,9 @@
</span><span class="cx"> <ClInclude Include="..\rendering\TableLayout.h">
</span><span class="cx"> <Filter>rendering</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\rendering\TextDecorationPainter.h">
+ <Filter>rendering</Filter>
+ </ClInclude>
</ins><span class="cx"> <ClInclude Include="..\rendering\TextPainter.h">
</span><span class="cx"> <Filter>rendering</Filter>
</span><span class="cx"> </ClInclude>
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -2288,6 +2288,8 @@
</span><span class="cx">                 5824ABAB1AE849C8009074B7 /* RenderTreePosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 5824ABA91AE849C8009074B7 /* RenderTreePosition.h */; };
</span><span class="cx">                 582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h */; };
</span><span class="cx">                 582CB0551A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp */; };
</span><ins>+                582DE3241C30C85400BE02A8 /* TextDecorationPainter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 582DE3221C30C85400BE02A8 /* TextDecorationPainter.cpp */; };
+                582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */ = {isa = PBXBuildFile; fileRef = 582DE3231C30C85400BE02A8 /* TextDecorationPainter.h */; };
</ins><span class="cx">                 585D6DFC1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */; };
</span><span class="cx">                 585D6E031A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 585D6E011A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.cpp */; };
</span><span class="cx">                 585D6E041A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h in Headers */ = {isa = PBXBuildFile; fileRef = 585D6E021A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h */; };
</span><span class="lines">@@ -9731,6 +9733,8 @@
</span><span class="cx">                 5824ABA91AE849C8009074B7 /* RenderTreePosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreePosition.h; sourceTree = "<group>"; };
</span><span class="cx">                 582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutTextFragmentIterator.h; sourceTree = "<group>"; };
</span><span class="cx">                 582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutTextFragmentIterator.cpp; sourceTree = "<group>"; };
</span><ins>+                582DE3221C30C85400BE02A8 /* TextDecorationPainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextDecorationPainter.cpp; sourceTree = "<group>"; };
+                582DE3231C30C85400BE02A8 /* TextDecorationPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextDecorationPainter.h; sourceTree = "<group>"; };
</ins><span class="cx">                 585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutResolver.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 585D6E011A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutFlowContents.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 585D6E021A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFlowContents.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -23696,6 +23700,8 @@
</span><span class="cx">                                 A8CFF04C0A154F09000A4234 /* TableLayout.h */,
</span><span class="cx">                                 0F54DCE31881051D003EEDBB /* TextAutoSizing.cpp */,
</span><span class="cx">                                 0F54DCE41881051D003EEDBB /* TextAutoSizing.h */,
</span><ins>+                                582DE3221C30C85400BE02A8 /* TextDecorationPainter.cpp */,
+                                582DE3231C30C85400BE02A8 /* TextDecorationPainter.h */,
</ins><span class="cx">                                 1C18DA56181AF6A500C4EF22 /* TextPainter.cpp */,
</span><span class="cx">                                 1C18DA57181AF6A500C4EF22 /* TextPainter.h */,
</span><span class="cx">                                 E4C91A0F1802343900A17F6D /* TextPaintStyle.cpp */,
</span><span class="lines">@@ -25750,6 +25756,7 @@
</span><span class="cx">                                 A871D4560A127CBC00B12A68 /* HTMLPlugInElement.h in Headers */,
</span><span class="cx">                                 4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */,
</span><span class="cx">                                 A8EA7CB00A192B9C00A8EF5F /* HTMLPreElement.h in Headers */,
</span><ins>+                                582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */,
</ins><span class="cx">                                 977B3873122883E900B81FF8 /* HTMLPreloadScanner.h in Headers */,
</span><span class="cx">                                 A43BF5991149290A00C643CA /* HTMLProgressElement.h in Headers */,
</span><span class="cx">                                 A8CFF7A30A156978000A4234 /* HTMLQuoteElement.h in Headers */,
</span><span class="lines">@@ -30543,6 +30550,7 @@
</span><span class="cx">                                 371E65CE13661EED00BEEDB0 /* PageSerializer.cpp in Sources */,
</span><span class="cx">                                 A7197F2617568AE5007B9442 /* PageThrottler.cpp in Sources */,
</span><span class="cx">                                 E1284AEA10447DEE00EAEB52 /* PageTransitionEvent.cpp in Sources */,
</span><ins>+                                582DE3241C30C85400BE02A8 /* TextDecorationPainter.cpp in Sources */,
</ins><span class="cx">                                 51E1ECC20C91C90400DC255B /* PageURLRecord.cpp in Sources */,
</span><span class="cx">                                 FFD5B97A135CC97800D5E92A /* PageVisibilityState.cpp in Sources */,
</span><span class="cx">                                 FD3160A212B026F700C1A359 /* Panner.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.cpp        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "SVGTextRunRenderingContext.h"
</span><span class="cx"> #include "Text.h"
</span><ins>+#include "TextDecorationPainter.h"
</ins><span class="cx"> #include "TextPaintStyle.h"
</span><span class="cx"> #include "TextPainter.h"
</span><span class="cx"> #include "break_lines.h"
</span><span class="lines">@@ -67,71 +68,6 @@
</span><span class="cx"> typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap;
</span><span class="cx"> static InlineTextBoxOverflowMap* gTextBoxesWithOverflow;
</span><span class="cx">
</span><del>-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-static bool compareTuples(std::pair<float, float> l, std::pair<float, float> r)
-{
- return l.first < r.first;
-}
-
-static DashArray translateIntersectionPointsToSkipInkBoundaries(const DashArray& intersections, float dilationAmount, float totalWidth)
-{
- ASSERT(!(intersections.size() % 2));
-
- // Step 1: Make pairs so we can sort based on range starting-point. We dilate the ranges in this step as well.
- Vector<std::pair<float, float>> tuples;
- for (auto i = intersections.begin(); i != intersections.end(); i++, i++)
- tuples.append(std::make_pair(*i - dilationAmount, *(i + 1) + dilationAmount));
- std::sort(tuples.begin(), tuples.end(), &compareTuples);
-
- // Step 2: Deal with intersecting ranges.
- Vector<std::pair<float, float>> intermediateTuples;
- if (tuples.size() >= 2) {
- intermediateTuples.append(*tuples.begin());
- for (auto i = tuples.begin() + 1; i != tuples.end(); i++) {
- float& firstEnd = intermediateTuples.last().second;
- float secondStart = i->first;
- float secondEnd = i->second;
- if (secondStart <= firstEnd && secondEnd <= firstEnd) {
- // Ignore this range completely
- } else if (secondStart <= firstEnd)
- firstEnd = secondEnd;
- else
- intermediateTuples.append(*i);
- }
- } else
- intermediateTuples = tuples;
-
- // Step 3: Output the space between the ranges, but only if the space warrants an underline.
- float previous = 0;
- DashArray result;
- for (const auto& tuple : intermediateTuples) {
- if (tuple.first - previous > dilationAmount) {
- result.append(previous);
- result.append(tuple.first);
- }
- previous = tuple.second;
- }
- if (totalWidth - previous > dilationAmount) {
- result.append(previous);
- result.append(totalWidth);
- }
-
- return result;
-}
-
-static void drawSkipInkUnderline(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& localOrigin,
- float underlineOffset, float width, bool isPrinting, bool doubleLines)
-{
- FloatPoint adjustedLocalOrigin = localOrigin;
- adjustedLocalOrigin.move(0, underlineOffset);
- FloatRect underlineBoundingBox = context.computeLineBoundsForText(adjustedLocalOrigin, width, isPrinting);
- DashArray intersections = font.dashesForIntersectionsWithRect(textRun, textOrigin, underlineBoundingBox);
- DashArray a = translateIntersectionPointsToSkipInkBoundaries(intersections, underlineBoundingBox.height(), width);
- ASSERT(!(a.size() % 2));
- context.drawLinesForText(adjustedLocalOrigin, a, isPrinting, doubleLines);
-}
-#endif
-
</del><span class="cx"> InlineTextBox::~InlineTextBox()
</span><span class="cx"> {
</span><span class="cx"> if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow)
</span><span class="lines">@@ -763,144 +699,6 @@
</span><span class="cx"> context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), compositionColor);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
-{
- StrokeStyle strokeStyle = SolidStroke;
- switch (decorationStyle) {
- case TextDecorationStyleSolid:
- strokeStyle = SolidStroke;
- break;
- case TextDecorationStyleDouble:
- strokeStyle = DoubleStroke;
- break;
- case TextDecorationStyleDotted:
- strokeStyle = DottedStroke;
- break;
- case TextDecorationStyleDashed:
- strokeStyle = DashedStroke;
- break;
- case TextDecorationStyleWavy:
- strokeStyle = WavyStroke;
- break;
- }
-
- return strokeStyle;
-}
-
-static void adjustStepToDecorationLength(float& step, float& controlPointDistance, float length)
-{
- ASSERT(step > 0);
-
- if (length <= 0)
- return;
-
- unsigned stepCount = static_cast<unsigned>(length / step);
-
- // Each Bezier curve starts at the same pixel that the previous one
- // ended. We need to subtract (stepCount - 1) pixels when calculating the
- // length covered to account for that.
- float uncoveredLength = length - (stepCount * step - (stepCount - 1));
- float adjustment = uncoveredLength / stepCount;
- step += adjustment;
- controlPointDistance += adjustment;
-}
-
-/*
- * Draw one cubic Bezier curve and repeat the same pattern long the the decoration's axis.
- * The start point (p1), controlPoint1, controlPoint2 and end point (p2) of the Bezier curve
- * form a diamond shape:
- *
- * step
- * |-----------|
- *
- * controlPoint1
- * +
- *
- *
- * . .
- * . .
- * . .
- * (x1, y1) p1 + . + p2 (x2, y2) - <--- Decoration's axis
- * . . |
- * . . |
- * . . | controlPointDistance
- * |
- * |
- * + -
- * controlPoint2
- *
- * |-----------|
- * step
- */
-static void strokeWavyTextDecoration(GraphicsContext& context, FloatPoint& p1, FloatPoint& p2, float strokeThickness)
-{
- context.adjustLineToPixelBoundaries(p1, p2, strokeThickness, context.strokeStyle());
-
- Path path;
- path.moveTo(p1);
-
- float controlPointDistance;
- float step;
- getWavyStrokeParameters(strokeThickness, controlPointDistance, step);
-
- bool isVerticalLine = (p1.x() == p2.x());
-
- if (isVerticalLine) {
- ASSERT(p1.x() == p2.x());
-
- float xAxis = p1.x();
- float y1;
- float y2;
-
- if (p1.y() < p2.y()) {
- y1 = p1.y();
- y2 = p2.y();
- } else {
- y1 = p2.y();
- y2 = p1.y();
- }
-
- adjustStepToDecorationLength(step, controlPointDistance, y2 - y1);
- FloatPoint controlPoint1(xAxis + controlPointDistance, 0);
- FloatPoint controlPoint2(xAxis - controlPointDistance, 0);
-
- for (float y = y1; y + 2 * step <= y2;) {
- controlPoint1.setY(y + step);
- controlPoint2.setY(y + step);
- y += 2 * step;
- path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(xAxis, y));
- }
- } else {
- ASSERT(p1.y() == p2.y());
-
- float yAxis = p1.y();
- float x1;
- float x2;
-
- if (p1.x() < p2.x()) {
- x1 = p1.x();
- x2 = p2.x();
- } else {
- x1 = p2.x();
- x2 = p1.x();
- }
-
- adjustStepToDecorationLength(step, controlPointDistance, x2 - x1);
- FloatPoint controlPoint1(0, yAxis + controlPointDistance);
- FloatPoint controlPoint2(0, yAxis - controlPointDistance);
-
- for (float x = x1; x + 2 * step <= x2;) {
- controlPoint1.setX(x + step);
- controlPoint2.setX(x + step);
- x += 2 * step;
- path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(x, yAxis));
- }
- }
-
- context.setShouldAntialias(true);
- context.strokePath(path);
-}
-
</del><span class="cx"> void InlineTextBox::paintDecoration(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin,
</span><span class="cx"> TextDecoration decoration, const ShadowData* shadow)
</span><span class="cx"> {
</span><span class="lines">@@ -921,128 +719,16 @@
</span><span class="cx"> localOrigin.move(m_logicalWidth - width, 0);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Get the text decoration colors.
- Color underlineColor, overlineColor, linethroughColor;
- TextDecorationStyle underlineStyle, overlineStyle, linethroughStyle;
- renderer().getTextDecorationColorsAndStyles(decoration, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle);
- if (isFirstLine())
- renderer().getTextDecorationColorsAndStyles(decoration, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle, true);
-
- // Use a special function for underlines to get the positioning exactly right.
- bool isPrinting = renderer().document().printing();
</del><ins>+ int baseline = lineStyle().fontMetrics().ascent();
+ TextDecorationPainter decorationPainter(context, decoration, renderer(), isFirstLine());
+ decorationPainter.setInlineTextBox(this);
+ decorationPainter.setFont(font);
+ decorationPainter.setWidth(width);
+ decorationPainter.setBaseline(baseline);
+ decorationPainter.setIsHorizontal(isHorizontal());
+ decorationPainter.addTextShadow(shadow);
</ins><span class="cx">
</span><del>- float textDecorationThickness = textDecorationStrokeThickness(renderer().style().fontSize());
- context.setStrokeThickness(textDecorationThickness);
-
- bool linesAreOpaque = !isPrinting && (!(decoration & TextDecorationUnderline) || underlineColor.alpha() == 255) && (!(decoration & TextDecorationOverline) || overlineColor.alpha() == 255) && (!(decoration & TextDecorationLineThrough) || linethroughColor.alpha() == 255);
-
- const RenderStyle& lineStyle = this->lineStyle();
- int baseline = lineStyle.fontMetrics().ascent();
-
- bool setClip = false;
- int extraOffset = 0;
- if (!linesAreOpaque && shadow && shadow->next()) {
- FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2));
- for (const ShadowData* s = shadow; s; s = s->next()) {
- int shadowExtent = s->paintingExtent();
- FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2));
- shadowRect.inflate(shadowExtent);
- int shadowX = isHorizontal() ? s->x() : s->y();
- int shadowY = isHorizontal() ? s->y() : -s->x();
- shadowRect.move(shadowX, shadowY);
- clipRect.unite(shadowRect);
- extraOffset = std::max(extraOffset, std::max(0, shadowY) + shadowExtent);
- }
- context.save();
- context.clip(clipRect);
- extraOffset += baseline + 2;
- localOrigin.move(0, extraOffset);
- setClip = true;
- }
-
- bool setShadow = false;
-
- do {
- if (shadow) {
- if (!shadow->next()) {
- // The last set of lines paints normally inside the clip.
- localOrigin.move(0, -extraOffset);
- extraOffset = 0;
- }
- int shadowX = isHorizontal() ? shadow->x() : shadow->y();
- int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
- context.setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow->radius(), shadow->color());
- setShadow = true;
- shadow = shadow->next();
- }
-
- float wavyOffset = wavyOffsetFromDecoration();
-
- // These decorations should match the visual overflows computed in visualOverflowForDecorations()
- if (decoration & TextDecorationUnderline) {
- context.setStrokeColor(underlineColor);
- context.setStrokeStyle(textDecorationStyleToStrokeStyle(underlineStyle));
- const int underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), this, textDecorationThickness);
-
- switch (underlineStyle) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() + underlineOffset + wavyOffset);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() + underlineOffset + wavyOffset);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- default:
-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
- if ((lineStyle.textDecorationSkip() == TextDecorationSkipInk || lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && isHorizontal()) {
- if (!context.paintingDisabled())
- drawSkipInkUnderline(context, font, textRun, textOrigin, localOrigin, underlineOffset, width, isPrinting, underlineStyle == TextDecorationStyleDouble);
- } else
- // FIXME: Need to support text-decoration-skip: none.
-#endif // CSS3_TEXT_DECORATION_SKIP_INK
- context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset), width, isPrinting, underlineStyle == TextDecorationStyleDouble);
- }
- }
- if (decoration & TextDecorationOverline) {
- context.setStrokeColor(overlineColor);
- context.setStrokeStyle(textDecorationStyleToStrokeStyle(overlineStyle));
- switch (overlineStyle) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() - wavyOffset);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() - wavyOffset);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- default:
-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
- if ((lineStyle.textDecorationSkip() == TextDecorationSkipInk || lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && isHorizontal()) {
- if (!context.paintingDisabled())
- drawSkipInkUnderline(context, font, textRun, textOrigin, localOrigin, 0, width, isPrinting, overlineStyle == TextDecorationStyleDouble);
- } else
- // FIXME: Need to support text-decoration-skip: none.
-#endif // CSS3_TEXT_DECORATION_SKIP_INK
- context.drawLineForText(localOrigin, width, isPrinting, overlineStyle == TextDecorationStyleDouble);
- }
- }
- if (decoration & TextDecorationLineThrough) {
- context.setStrokeColor(linethroughColor);
- context.setStrokeStyle(textDecorationStyleToStrokeStyle(linethroughStyle));
- switch (linethroughStyle) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * baseline / 3);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() + 2 * baseline / 3);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- default:
- context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * baseline / 3), width, isPrinting, linethroughStyle == TextDecorationStyleDouble);
- }
- }
- } while (shadow);
-
- if (setClip)
- context.restore();
- else if (setShadow)
- context.clearShadow();
</del><ins>+ decorationPainter.paintTextDecoration(textRun, textOrigin, localOrigin);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentMarker::MarkerType markerType)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -1801,9 +1801,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void RenderObject::getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
</span><del>- TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle)
</del><ins>+ TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle) const
</ins><span class="cx"> {
</span><del>- RenderObject* current = this;
</del><ins>+ const RenderObject* current = this;
</ins><span class="cx"> RenderStyle* styleToUse = nullptr;
</span><span class="cx"> TextDecoration currDecs = TextDecorationNone;
</span><span class="cx"> Color resultColor;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -706,7 +706,7 @@
</span><span class="cx"> virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
</span><span class="cx">
</span><span class="cx"> void getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
</span><del>- TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle = false);
</del><ins>+ TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle = false) const;
</ins><span class="cx">
</span><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></pre></div>
<a id="trunkSourceWebCorerenderingRenderingAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderingAllInOne.cpp (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderingAllInOne.cpp        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/RenderingAllInOne.cpp        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -146,6 +146,7 @@
</span><span class="cx"> #include "SimpleLineLayoutResolver.cpp"
</span><span class="cx"> #include "SimpleLineLayoutTextFragmentIterator.cpp"
</span><span class="cx"> #include "TextAutosizer.cpp"
</span><ins>+#include "TextDecorationPainter.cpp"
</ins><span class="cx"> #include "TextPaintStyle.cpp"
</span><span class="cx"> #include "TextPainter.cpp"
</span><span class="cx"> #include "break_lines.cpp"
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextDecorationPaintercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/rendering/TextDecorationPainter.cpp (0 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextDecorationPainter.cpp         (rev 0)
+++ trunk/Source/WebCore/rendering/TextDecorationPainter.cpp        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -0,0 +1,350 @@
</span><ins>+/*
+ * (C) 1999 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "TextDecorationPainter.h"
+
+#include "FontCascade.h"
+#include "GraphicsContext.h"
+#include "InlineTextBoxStyle.h"
+#include "RenderStyle.h"
+#include "RenderText.h"
+#include "ShadowData.h"
+#include "TextRun.h"
+
+namespace WebCore {
+
+static void adjustStepToDecorationLength(float& step, float& controlPointDistance, float length)
+{
+ ASSERT(step > 0);
+
+ if (length <= 0)
+ return;
+
+ unsigned stepCount = static_cast<unsigned>(length / step);
+
+ // Each Bezier curve starts at the same pixel that the previous one
+ // ended. We need to subtract (stepCount - 1) pixels when calculating the
+ // length covered to account for that.
+ float uncoveredLength = length - (stepCount * step - (stepCount - 1));
+ float adjustment = uncoveredLength / stepCount;
+ step += adjustment;
+ controlPointDistance += adjustment;
+}
+
+/*
+ * Draw one cubic Bezier curve and repeat the same pattern long the the decoration's axis.
+ * The start point (p1), controlPoint1, controlPoint2 and end point (p2) of the Bezier curve
+ * form a diamond shape:
+ *
+ * step
+ * |-----------|
+ *
+ * controlPoint1
+ * +
+ *
+ *
+ * . .
+ * . .
+ * . .
+ * (x1, y1) p1 + . + p2 (x2, y2) - <--- Decoration's axis
+ * . . |
+ * . . |
+ * . . | controlPointDistance
+ * |
+ * |
+ * + -
+ * controlPoint2
+ *
+ * |-----------|
+ * step
+ */
+static void strokeWavyTextDecoration(GraphicsContext& context, const FloatPoint& start, const FloatPoint& end, float strokeThickness)
+{
+ FloatPoint p1 = start;
+ FloatPoint p2 = end;
+ context.adjustLineToPixelBoundaries(p1, p2, strokeThickness, context.strokeStyle());
+
+ Path path;
+ path.moveTo(p1);
+
+ float controlPointDistance;
+ float step;
+ getWavyStrokeParameters(strokeThickness, controlPointDistance, step);
+
+ bool isVerticalLine = (p1.x() == p2.x());
+
+ if (isVerticalLine) {
+ ASSERT(p1.x() == p2.x());
+
+ float xAxis = p1.x();
+ float y1;
+ float y2;
+
+ if (p1.y() < p2.y()) {
+ y1 = p1.y();
+ y2 = p2.y();
+ } else {
+ y1 = p2.y();
+ y2 = p1.y();
+ }
+
+ adjustStepToDecorationLength(step, controlPointDistance, y2 - y1);
+ FloatPoint controlPoint1(xAxis + controlPointDistance, 0);
+ FloatPoint controlPoint2(xAxis - controlPointDistance, 0);
+
+ for (float y = y1; y + 2 * step <= y2;) {
+ controlPoint1.setY(y + step);
+ controlPoint2.setY(y + step);
+ y += 2 * step;
+ path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(xAxis, y));
+ }
+ } else {
+ ASSERT(p1.y() == p2.y());
+
+ float yAxis = p1.y();
+ float x1;
+ float x2;
+
+ if (p1.x() < p2.x()) {
+ x1 = p1.x();
+ x2 = p2.x();
+ } else {
+ x1 = p2.x();
+ x2 = p1.x();
+ }
+
+ adjustStepToDecorationLength(step, controlPointDistance, x2 - x1);
+ FloatPoint controlPoint1(0, yAxis + controlPointDistance);
+ FloatPoint controlPoint2(0, yAxis - controlPointDistance);
+
+ for (float x = x1; x + 2 * step <= x2;) {
+ controlPoint1.setX(x + step);
+ controlPoint2.setX(x + step);
+ x += 2 * step;
+ path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(x, yAxis));
+ }
+ }
+
+ context.setShouldAntialias(true);
+ context.strokePath(path);
+}
+
+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+static bool compareTuples(std::pair<float, float> l, std::pair<float, float> r)
+{
+ return l.first < r.first;
+}
+
+static DashArray translateIntersectionPointsToSkipInkBoundaries(const DashArray& intersections, float dilationAmount, float totalWidth)
+{
+ ASSERT(!(intersections.size() % 2));
+
+ // Step 1: Make pairs so we can sort based on range starting-point. We dilate the ranges in this step as well.
+ Vector<std::pair<float, float>> tuples;
+ for (auto i = intersections.begin(); i != intersections.end(); i++, i++)
+ tuples.append(std::make_pair(*i - dilationAmount, *(i + 1) + dilationAmount));
+ std::sort(tuples.begin(), tuples.end(), &compareTuples);
+
+ // Step 2: Deal with intersecting ranges.
+ Vector<std::pair<float, float>> intermediateTuples;
+ if (tuples.size() >= 2) {
+ intermediateTuples.append(*tuples.begin());
+ for (auto i = tuples.begin() + 1; i != tuples.end(); i++) {
+ float& firstEnd = intermediateTuples.last().second;
+ float secondStart = i->first;
+ float secondEnd = i->second;
+ if (secondStart <= firstEnd && secondEnd <= firstEnd) {
+ // Ignore this range completely
+ } else if (secondStart <= firstEnd)
+ firstEnd = secondEnd;
+ else
+ intermediateTuples.append(*i);
+ }
+ } else
+ intermediateTuples = tuples;
+
+ // Step 3: Output the space between the ranges, but only if the space warrants an underline.
+ float previous = 0;
+ DashArray result;
+ for (const auto& tuple : intermediateTuples) {
+ if (tuple.first - previous > dilationAmount) {
+ result.append(previous);
+ result.append(tuple.first);
+ }
+ previous = tuple.second;
+ }
+ if (totalWidth - previous > dilationAmount) {
+ result.append(previous);
+ result.append(totalWidth);
+ }
+
+ return result;
+}
+
+static void drawSkipInkUnderline(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& localOrigin,
+ float underlineOffset, float width, bool isPrinting, bool doubleLines)
+{
+ FloatPoint adjustedLocalOrigin = localOrigin;
+ adjustedLocalOrigin.move(0, underlineOffset);
+ FloatRect underlineBoundingBox = context.computeLineBoundsForText(adjustedLocalOrigin, width, isPrinting);
+ DashArray intersections = font.dashesForIntersectionsWithRect(textRun, textOrigin, underlineBoundingBox);
+ DashArray a = translateIntersectionPointsToSkipInkBoundaries(intersections, underlineBoundingBox.height(), width);
+ ASSERT(!(a.size() % 2));
+ context.drawLinesForText(adjustedLocalOrigin, a, isPrinting, doubleLines);
+}
+#endif
+
+static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
+{
+ StrokeStyle strokeStyle = SolidStroke;
+ switch (decorationStyle) {
+ case TextDecorationStyleSolid:
+ strokeStyle = SolidStroke;
+ break;
+ case TextDecorationStyleDouble:
+ strokeStyle = DoubleStroke;
+ break;
+ case TextDecorationStyleDotted:
+ strokeStyle = DottedStroke;
+ break;
+ case TextDecorationStyleDashed:
+ strokeStyle = DashedStroke;
+ break;
+ case TextDecorationStyleWavy:
+ strokeStyle = WavyStroke;
+ break;
+ }
+
+ return strokeStyle;
+}
+
+TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, TextDecoration decoration, const RenderText& renderer, bool isFirstLine)
+ : m_context(context)
+ , m_decoration(decoration)
+ , m_wavyOffset(wavyOffsetFromDecoration())
+ , m_isPrinting(renderer.document().printing())
+ , m_lineStyle(isFirstLine ? renderer.firstLineStyle() : renderer.style())
+{
+ 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);
+ }
+}
+
+void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin)
+{
+ ASSERT(m_font);
+ float textDecorationThickness = textDecorationStrokeThickness(m_lineStyle.fontSize());
+ m_context.setStrokeThickness(textDecorationThickness);
+ FloatPoint localOrigin = boxOrigin;
+
+ auto paintDecoration = [&](TextDecorationStyle style, Color color, StrokeStyle strokeStyle,
+ const FloatPoint& start, const FloatPoint& end, int offset) {
+ m_context.setStrokeColor(color);
+ m_context.setStrokeStyle(strokeStyle);
+
+ if (style == TextDecorationStyleWavy) {
+ strokeWavyTextDecoration(m_context, start, end, textDecorationThickness);
+ } else if (m_decoration & TextDecorationUnderline || m_decoration & TextDecorationOverline) {
+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+ if ((m_lineStyle.textDecorationSkip() == TextDecorationSkipInk || m_lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && m_isHorizontal) {
+ if (!m_context.paintingDisabled())
+ drawSkipInkUnderline(m_context, *m_font, textRun, textOrigin, localOrigin, offset, m_width, m_isPrinting, style == TextDecorationStyleDouble);
+ } else
+ // FIXME: Need to support text-decoration-skip: none.
+#endif
+ m_context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + offset), m_width, m_isPrinting, style == TextDecorationStyleDouble);
+
+ } else {
+ ASSERT(m_decoration & TextDecorationLineThrough);
+ m_context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * m_baseline / 3), m_width, m_isPrinting, style == TextDecorationStyleDouble);
+ }
+ };
+
+ bool linesAreOpaque = !m_isPrinting
+ && (!(m_decoration & TextDecorationUnderline) || m_underlineColor.alpha() == 255)
+ && (!(m_decoration & TextDecorationOverline) || m_overlineColor.alpha() == 255)
+ && (!(m_decoration & TextDecorationLineThrough) || m_linethroughColor.alpha() == 255);
+
+ int extraOffset = 0;
+ bool clipping = !linesAreOpaque && m_shadow && m_shadow->next();
+ if (clipping) {
+ FloatRect clipRect(localOrigin, FloatSize(m_width, m_baseline + 2));
+ for (const ShadowData* shadow = m_shadow; shadow; shadow = shadow->next()) {
+ int shadowExtent = shadow->paintingExtent();
+ FloatRect shadowRect(localOrigin, FloatSize(m_width, m_baseline + 2));
+ shadowRect.inflate(shadowExtent);
+ int shadowX = m_isHorizontal ? shadow->x() : shadow->y();
+ int shadowY = m_isHorizontal ? shadow->y() : -shadow->x();
+ shadowRect.move(shadowX, shadowY);
+ clipRect.unite(shadowRect);
+ extraOffset = std::max(extraOffset, std::max(0, shadowY) + shadowExtent);
+ }
+ m_context.save();
+ m_context.clip(clipRect);
+ extraOffset += m_baseline + 2;
+ localOrigin.move(0, extraOffset);
+ }
+
+ const ShadowData* shadow = m_shadow;
+ do {
+ if (shadow) {
+ if (!shadow->next()) {
+ // The last set of lines paints normally inside the clip.
+ localOrigin.move(0, -extraOffset);
+ extraOffset = 0;
+ }
+ int shadowX = m_isHorizontal ? shadow->x() : shadow->y();
+ int shadowY = m_isHorizontal ? shadow->y() : -shadow->x();
+ m_context.setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow->radius(), shadow->color());
+ shadow = shadow->next();
+ }
+
+ // These decorations should match the visual overflows computed in visualOverflowForDecorations()
+ if (m_decoration & TextDecorationUnderline) {
+ const int offset = computeUnderlineOffset(m_lineStyle.textUnderlinePosition(), m_lineStyle.fontMetrics(), m_inlineTextBox, textDecorationThickness);
+ FloatPoint start(localOrigin.x(), localOrigin.y() + offset + m_wavyOffset);
+ FloatPoint end(localOrigin.x() + m_width, localOrigin.y() + offset + m_wavyOffset);
+ paintDecoration(m_underlineStyle, m_underlineColor, textDecorationStyleToStrokeStyle(m_underlineStyle), start, end, offset);
+ }
+ if (m_decoration & TextDecorationOverline) {
+ FloatPoint start(localOrigin.x(), localOrigin.y() - m_wavyOffset);
+ FloatPoint end(localOrigin.x() + m_width, localOrigin.y() - m_wavyOffset);
+ paintDecoration(m_overlineStyle, m_overlineColor, textDecorationStyleToStrokeStyle(m_overlineStyle), start, end, 0);
+ }
+ if (m_decoration & TextDecorationLineThrough) {
+ FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * m_baseline / 3);
+ FloatPoint end(localOrigin.x() + m_width, localOrigin.y() + 2 * m_baseline / 3);
+ paintDecoration(m_linethroughStyle, m_linethroughColor, textDecorationStyleToStrokeStyle(m_linethroughStyle), start, end, 0);
+ }
+ } while (shadow);
+
+ if (clipping)
+ m_context.restore();
+ else if (m_shadow)
+ m_context.clearShadow();
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingTextDecorationPainterh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/rendering/TextDecorationPainter.h (0 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextDecorationPainter.h         (rev 0)
+++ trunk/Source/WebCore/rendering/TextDecorationPainter.h        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+/*
+ * (C) 1999 Lars Knoll (knoll@kde.org)
+ * (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TextDecorationPainter_h
+#define TextDecorationPainter_h
+
+#include "Color.h"
+#include "FloatPoint.h"
+#include "RenderStyleConstants.h"
+
+namespace WebCore {
+
+class FontCascade;
+class GraphicsContext;
+class InlineTextBox;
+class RenderStyle;
+class RenderText;
+class ShadowData;
+class TextRun;
+
+class TextDecorationPainter {
+public:
+ TextDecorationPainter(GraphicsContext&, TextDecoration, const RenderText&, bool isFirstLine);
+
+ void setInlineTextBox(const InlineTextBox* inlineTextBox) { m_inlineTextBox = inlineTextBox; }
+ void setFont(const FontCascade& font) { m_font = &font; }
+ void setIsHorizontal(bool isHorizontal) { m_isHorizontal = isHorizontal; }
+ void setWidth(float width) { m_width = width; }
+ void setBaseline(int baseline) { m_baseline = baseline; }
+ void addTextShadow(const ShadowData* textShadow) { m_shadow = textShadow; }
+
+ void paintTextDecoration(const TextRun&, const FloatPoint& textOrigin, const FloatPoint& boxOrigin);
+
+private:
+ GraphicsContext& m_context;
+ TextDecoration m_decoration;
+ int m_wavyOffset { 0 };
+ bool m_isPrinting { false };
+ float m_width { 0 };
+ int m_baseline { 0 };
+ FloatPoint m_boxOrigin;
+ bool m_isHorizontal { true };
+ const ShadowData* m_shadow { nullptr };
+ const InlineTextBox* m_inlineTextBox { nullptr };
+ const FontCascade* m_font { nullptr };
+
+ Color m_underlineColor;
+ Color m_overlineColor;
+ Color m_linethroughColor;
+ TextDecorationStyle m_underlineStyle;
+ TextDecorationStyle m_overlineStyle;
+ TextDecorationStyle m_linethroughStyle;
+ const RenderStyle& m_lineStyle;
+};
+
+} // namespace WebCore
+
+#endif // TextDecorationPainter_h
</ins></span></pre></div>
<a id="trunkSourceWebCorestyleInlineTextBoxStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/InlineTextBoxStyle.cpp (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/InlineTextBoxStyle.cpp        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/style/InlineTextBoxStyle.cpp        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, InlineTextBox* inlineTextBox, int textDecorationThickness)
</del><ins>+int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, int textDecorationThickness)
</ins><span class="cx"> {
</span><span class="cx"> // This represents the gap between the baseline and the closest edge of the underline.
</span><span class="cx"> int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.0));
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx"> extendMe = std::max(extendMe, static_cast<int>(ceilf(extendTo)));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, InlineTextBox* inlineTextBox)
</del><ins>+GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineTextBox* inlineTextBox)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!inlineTextBox || inlineTextBox->lineStyle() == lineStyle);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorestyleInlineTextBoxStyleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/InlineTextBoxStyle.h (194446 => 194447)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/InlineTextBoxStyle.h        2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/style/InlineTextBoxStyle.h        2015-12-30 17:19:03 UTC (rev 194447)
</span><span class="lines">@@ -44,9 +44,9 @@
</span><span class="cx"> return 2;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, InlineTextBox*);
</del><ins>+GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineTextBox*);
</ins><span class="cx"> void getWavyStrokeParameters(float strokeThickness, float& controlPointDistance, float& step);
</span><del>-int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, InlineTextBox*, int textDecorationThickness);
</del><ins>+int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, const InlineTextBox*, int textDecorationThickness);
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>