<!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>[179534] 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/179534">179534</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2015-02-02 19:08:33 -0800 (Mon, 02 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Simple line layout: Rename FlowContentsIterator to TextFragmentIterator.
https://bugs.webkit.org/show_bug.cgi?id=141177
Rubber-stamped by Antti Koivisto
FlowContentsIterator is easy to confuse with FlowContents::Iterator.
TextFragmentIterator reflects the functionality better.
No change in functionality.
* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::LineState::setOverflowedFragment):
(WebCore::SimpleLineLayout::LineState::overflowedFragment):
(WebCore::SimpleLineLayout::LineState::appendFragment):
(WebCore::SimpleLineLayout::begin):
(WebCore::SimpleLineLayout::end):
(WebCore::SimpleLineLayout::preWrap):
(WebCore::SimpleLineLayout::removeTrailingWhitespace):
(WebCore::SimpleLineLayout::splitFragmentToFitLine):
(WebCore::SimpleLineLayout::firstFragment):
(WebCore::SimpleLineLayout::createLineRuns):
(WebCore::SimpleLineLayout::closeLineEndingAndAdjustRuns):
(WebCore::SimpleLineLayout::splitRunsAtRendererBoundary):
(WebCore::SimpleLineLayout::createTextRuns):
* rendering/SimpleLineLayoutTextFragmentIterator.cpp: Renamed from Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp.
(WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragmentIterator):
(WebCore::SimpleLineLayout::TextFragmentIterator::nextTextFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
(WebCore::SimpleLineLayout::nextBreakablePosition):
(WebCore::SimpleLineLayout::TextFragmentIterator::findNextBreakablePosition):
(WebCore::SimpleLineLayout::findNextNonWhitespace):
(WebCore::SimpleLineLayout::TextFragmentIterator::findNextNonWhitespacePosition):
(WebCore::SimpleLineLayout::TextFragmentIterator::runWidth):
* rendering/SimpleLineLayoutTextFragmentIterator.h: Renamed from Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h.
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::TextFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::start):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::end):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::width):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::type):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isCollapsed):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isBreakable):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isEmpty):
(WebCore::SimpleLineLayout::TextFragmentIterator::style):
(WebCore::SimpleLineLayout::TextFragmentIterator::segmentForPosition):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::split):
(WebCore::SimpleLineLayout::TextFragmentIterator::characterAt):
(WebCore::SimpleLineLayout::TextFragmentIterator::isLineBreak):
(WebCore::SimpleLineLayout::TextFragmentIterator::isEnd):</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="#trunkSourceWebCorerenderingSimpleLineLayoutcpp">trunk/Source/WebCore/rendering/SimpleLineLayout.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorcpp">trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorh">trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorcpp">trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorh">trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.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 (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -2351,7 +2351,7 @@
</span><span class="cx"> rendering/ScrollBehavior.cpp
</span><span class="cx"> rendering/SimpleLineLayout.cpp
</span><span class="cx"> rendering/SimpleLineLayoutFlowContents.cpp
</span><del>- rendering/SimpleLineLayoutFlowContentsIterator.cpp
</del><ins>+ rendering/SimpleLineLayoutTextFragmentIterator.cpp
</ins><span class="cx"> rendering/SimpleLineLayoutFunctions.cpp
</span><span class="cx"> rendering/SimpleLineLayoutResolver.cpp
</span><span class="cx"> rendering/TextAutosizer.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/ChangeLog        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2015-02-02 Zalan Bujtas <zalan@apple.com>
+
+ Simple line layout: Rename FlowContentsIterator to TextFragmentIterator.
+ https://bugs.webkit.org/show_bug.cgi?id=141177
+
+ Rubber-stamped by Antti Koivisto
+
+ FlowContentsIterator is easy to confuse with FlowContents::Iterator.
+ TextFragmentIterator reflects the functionality better.
+
+ No change in functionality.
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/SimpleLineLayout.cpp:
+ (WebCore::SimpleLineLayout::LineState::setOverflowedFragment):
+ (WebCore::SimpleLineLayout::LineState::overflowedFragment):
+ (WebCore::SimpleLineLayout::LineState::appendFragment):
+ (WebCore::SimpleLineLayout::begin):
+ (WebCore::SimpleLineLayout::end):
+ (WebCore::SimpleLineLayout::preWrap):
+ (WebCore::SimpleLineLayout::removeTrailingWhitespace):
+ (WebCore::SimpleLineLayout::splitFragmentToFitLine):
+ (WebCore::SimpleLineLayout::firstFragment):
+ (WebCore::SimpleLineLayout::createLineRuns):
+ (WebCore::SimpleLineLayout::closeLineEndingAndAdjustRuns):
+ (WebCore::SimpleLineLayout::splitRunsAtRendererBoundary):
+ (WebCore::SimpleLineLayout::createTextRuns):
+ * rendering/SimpleLineLayoutTextFragmentIterator.cpp: Renamed from Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp.
+ (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragmentIterator):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::nextTextFragment):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
+ (WebCore::SimpleLineLayout::nextBreakablePosition):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::findNextBreakablePosition):
+ (WebCore::SimpleLineLayout::findNextNonWhitespace):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::findNextNonWhitespacePosition):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::runWidth):
+ * rendering/SimpleLineLayoutTextFragmentIterator.h: Renamed from Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h.
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::TextFragment):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::start):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::end):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::width):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::type):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isCollapsed):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isBreakable):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isEmpty):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::style):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::segmentForPosition):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::split):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::characterAt):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::isLineBreak):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::isEnd):
+
</ins><span class="cx"> 2015-02-02 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Add diagnostic logging for ResourceResponse's source
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -11588,7 +11588,7 @@
</span><span class="cx"> <ClCompile Include="..\rendering\SelectionSubtreeRoot.cpp" />
</span><span class="cx"> <ClCompile Include="..\rendering\SimpleLineLayout.cpp" />
</span><span class="cx"> <ClCompile Include="..\rendering\SimpleLineLayoutFlowContents.cpp" />
</span><del>- <ClCompile Include="..\rendering\SimpleLineLayoutFlowContentsIterator.cpp" />
</del><ins>+ <ClCompile Include="..\rendering\SimpleLineLayoutTextFragmentIterator.cpp" />
</ins><span class="cx"> <ClCompile Include="..\rendering\SimpleLineLayoutFunctions.cpp" />
</span><span class="cx"> <ClCompile Include="..\rendering\SimpleLineLayoutResolver.cpp" />
</span><span class="cx"> <ClCompile Include="..\rendering\TextPaintStyle.cpp" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -6769,7 +6769,7 @@
</span><span class="cx"> <ClCompile Include="..\rendering\SimpleLineLayoutFlowContents.cpp">
</span><span class="cx"> <Filter>rendering</Filter>
</span><span class="cx"> </ClCompile>
</span><del>- <ClCompile Include="..\rendering\SimpleLineLayoutFlowContentsIterator.cpp">
</del><ins>+ <ClCompile Include="..\rendering\SimpleLineLayoutTextFragmentIterator.cpp">
</ins><span class="cx"> <Filter>rendering</Filter>
</span><span class="cx"> </ClCompile>
</span><span class="cx"> <ClCompile Include="..\rendering\SimpleLineLayoutFunctions.cpp">
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -2094,8 +2094,8 @@
</span><span class="cx">                 580371611A66F00A00BAF519 /* ClipRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5803715F1A66F00A00BAF519 /* ClipRect.cpp */; };
</span><span class="cx">                 580371621A66F00A00BAF519 /* ClipRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371601A66F00A00BAF519 /* ClipRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 580371641A66F1D300BAF519 /* LayerFragment.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371631A66F1D300BAF519 /* LayerFragment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutFlowContentsIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutFlowContentsIterator.h */; };
-                582CB0551A78A2B200AFFCC4 /* SimpleLineLayoutFlowContentsIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutFlowContentsIterator.cpp */; };
</del><ins>+                582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h */; };
+                582CB0551A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp */; };
</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">@@ -9228,8 +9228,8 @@
</span><span class="cx">                 5803715F1A66F00A00BAF519 /* ClipRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipRect.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 580371601A66F00A00BAF519 /* ClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipRect.h; sourceTree = "<group>"; };
</span><span class="cx">                 580371631A66F1D300BAF519 /* LayerFragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFragment.h; sourceTree = "<group>"; };
</span><del>-                582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutFlowContentsIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFlowContentsIterator.h; sourceTree = "<group>"; };
-                582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutFlowContentsIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutFlowContentsIterator.cpp; sourceTree = "<group>"; };
</del><ins>+                582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutTextFragmentIterator.h; sourceTree = "<group>"; };
+                582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutTextFragmentIterator.cpp; 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">@@ -22596,8 +22596,8 @@
</span><span class="cx">                                 E4C91A0D1802343100A17F6D /* TextPaintStyle.h */,
</span><span class="cx">                                 37FC96DA1104ED71003E1FAD /* TrailingFloatsRootInlineBox.h */,
</span><span class="cx">                                 BCA257141293C010007A263D /* VerticalPositionCache.h */,
</span><del>-                                582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutFlowContentsIterator.h */,
-                                582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutFlowContentsIterator.cpp */,
</del><ins>+                                582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h */,
+                                582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = rendering;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="lines">@@ -23537,7 +23537,7 @@
</span><span class="cx">                                 379E61CC126CA5C400B63E8D /* BaseCheckableInputType.h in Headers */,
</span><span class="cx">                                 F5E0C65C1643C42C00D6CB69 /* BaseChooserOnlyDateAndTimeInputType.h in Headers */,
</span><span class="cx">                                 C33EE5C514FB49610002095A /* BaseClickableWithKeyInputType.h in Headers */,
</span><del>-                                582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutFlowContentsIterator.h in Headers */,
</del><ins>+                                582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */,
</ins><span class="cx">                                 F59C96001255B23F000623C0 /* BaseDateAndTimeInputType.h in Headers */,
</span><span class="cx">                                 F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */,
</span><span class="cx">                                 FBD6AF8A15EF25DF008B7110 /* BasicShapeFunctions.h in Headers */,
</span><span class="lines">@@ -29498,7 +29498,7 @@
</span><span class="cx">                                 BC2441C40E8B65D00055320F /* ScrollView.cpp in Sources */,
</span><span class="cx">                                 E45390450EAFD637003695C8 /* ScrollViewIOS.mm in Sources */,
</span><span class="cx">                                 9353676B09AED88B00D35CD6 /* ScrollViewMac.mm in Sources */,
</span><del>-                                582CB0551A78A2B200AFFCC4 /* SimpleLineLayoutFlowContentsIterator.cpp in Sources */,
</del><ins>+                                582CB0551A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp in Sources */,
</ins><span class="cx">                                 F55B3DD11251F12D003EF269 /* SearchInputType.cpp in Sources */,
</span><span class="cx">                                 976F36EA14686225005E93B4 /* SecurityContext.cpp in Sources */,
</span><span class="cx">                                 BCD0E0FA0E972C3500265DEA /* SecurityOrigin.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -44,8 +44,8 @@
</span><span class="cx"> #include "RenderView.h"
</span><span class="cx"> #include "Settings.h"
</span><span class="cx"> #include "SimpleLineLayoutFlowContents.h"
</span><del>-#include "SimpleLineLayoutFlowContentsIterator.h"
</del><span class="cx"> #include "SimpleLineLayoutFunctions.h"
</span><ins>+#include "SimpleLineLayoutTextFragmentIterator.h"
</ins><span class="cx"> #include "Text.h"
</span><span class="cx"> #include "TextPaintStyle.h"
</span><span class="cx">
</span><span class="lines">@@ -231,18 +231,18 @@
</span><span class="cx"> public:
</span><span class="cx"> void setAvailableWidth(float width) { m_availableWidth = width; }
</span><span class="cx"> void setLogicalLeftOffset(float offset) { m_logicalLeftOffset = offset; }
</span><del>- void setOverflowedFragment(const FlowContentsIterator::TextFragment& fragment) { m_overflowedFragment = fragment; }
</del><ins>+ void setOverflowedFragment(const TextFragmentIterator::TextFragment& fragment) { m_overflowedFragment = fragment; }
</ins><span class="cx">
</span><span class="cx"> float availableWidth() const { return m_availableWidth; }
</span><span class="cx"> float logicalLeftOffset() const { return m_logicalLeftOffset; }
</span><del>- const FlowContentsIterator::TextFragment& overflowedFragment() const { return m_overflowedFragment; }
</del><ins>+ const TextFragmentIterator::TextFragment& overflowedFragment() const { return m_overflowedFragment; }
</ins><span class="cx"> bool hasTrailingWhitespace() const { return m_trailingWhitespaceLength; }
</span><span class="cx"> bool isWhitespaceOnly() const { return m_trailingWhitespaceWidth && m_runsWidth == m_trailingWhitespaceWidth; }
</span><span class="cx"> bool fits(float extra) const { return m_availableWidth >= m_runsWidth + extra; }
</span><span class="cx"> bool firstCharacterFits() const { return m_firstCharacterFits; }
</span><span class="cx"> float width() const { return m_runsWidth; }
</span><span class="cx">
</span><del>- void appendFragment(const FlowContentsIterator::TextFragment& fragment, Layout::RunVector& runs)
</del><ins>+ void appendFragment(const TextFragmentIterator::TextFragment& fragment, Layout::RunVector& runs)
</ins><span class="cx"> {
</span><span class="cx"> // Adjust end position while collapsing.
</span><span class="cx"> unsigned endPosition = fragment.isCollapsed() ? fragment.start() + 1 : fragment.end();
</span><span class="lines">@@ -258,7 +258,7 @@
</span><span class="cx"> m_createNewRun = fragment.isCollapsed();
</span><span class="cx"> m_runsWidth += fragment.width();
</span><span class="cx">
</span><del>- if (fragment.type() == FlowContentsIterator::TextFragment::Whitespace) {
</del><ins>+ if (fragment.type() == TextFragmentIterator::TextFragment::Whitespace) {
</ins><span class="cx"> m_trailingWhitespaceLength += endPosition - fragment.start();
</span><span class="cx"> m_trailingWhitespaceWidth += fragment.width();
</span><span class="cx"> } else {
</span><span class="lines">@@ -287,7 +287,7 @@
</span><span class="cx"> private:
</span><span class="cx"> float m_availableWidth { 0 };
</span><span class="cx"> float m_logicalLeftOffset { 0 };
</span><del>- FlowContentsIterator::TextFragment m_overflowedFragment;
</del><ins>+ TextFragmentIterator::TextFragment m_overflowedFragment;
</ins><span class="cx"> float m_runsWidth { 0 };
</span><span class="cx"> bool m_createNewRun { true };
</span><span class="cx"> float m_trailingWhitespaceWidth { 0 }; // Use this to remove trailing whitespace without re-mesuring the text.
</span><span class="lines">@@ -317,21 +317,21 @@
</span><span class="cx"> unsigned m_fragmentIndex { 0 };
</span><span class="cx"> };
</span><span class="cx">
</span><del>-static FragmentForwardIterator begin(const FlowContentsIterator::TextFragment& fragment) { return FragmentForwardIterator(fragment.start()); }
-static FragmentForwardIterator end(const FlowContentsIterator::TextFragment& fragment) { return FragmentForwardIterator(fragment.end()); }
</del><ins>+static FragmentForwardIterator begin(const TextFragmentIterator::TextFragment& fragment) { return FragmentForwardIterator(fragment.start()); }
+static FragmentForwardIterator end(const TextFragmentIterator::TextFragment& fragment) { return FragmentForwardIterator(fragment.end()); }
</ins><span class="cx">
</span><del>-static bool preWrap(const FlowContentsIterator::Style& style)
</del><ins>+static bool preWrap(const TextFragmentIterator::Style& style)
</ins><span class="cx"> {
</span><span class="cx"> return style.wrapLines && !style.collapseWhitespace;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void removeTrailingWhitespace(LineState& lineState, Layout::RunVector& runs, const FlowContentsIterator& flowContentsIterator)
</del><ins>+static void removeTrailingWhitespace(LineState& lineState, Layout::RunVector& runs, const TextFragmentIterator& textFragmentIterator)
</ins><span class="cx"> {
</span><span class="cx"> if (!lineState.hasTrailingWhitespace())
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> // Remove collapsed whitespace, or non-collapsed pre-wrap whitespace, unless it's the only content on the line -so removing the whitesapce would produce an empty line.
</span><del>- const auto& style = flowContentsIterator.style();
</del><ins>+ const auto& style = textFragmentIterator.style();
</ins><span class="cx"> bool collapseWhitespace = style.collapseWhitespace | preWrap(style);
</span><span class="cx"> if (!collapseWhitespace)
</span><span class="cx"> return;
</span><span class="lines">@@ -351,53 +351,53 @@
</span><span class="cx"> line.setAvailableWidth(std::max<float>(0, logicalRightOffset - line.logicalLeftOffset()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static FlowContentsIterator::TextFragment splitFragmentToFitLine(FlowContentsIterator::TextFragment& fragmentToSplit, float availableWidth, bool keepAtLeastOneCharacter, const FlowContentsIterator& flowContentsIterator)
</del><ins>+static TextFragmentIterator::TextFragment splitFragmentToFitLine(TextFragmentIterator::TextFragment& fragmentToSplit, float availableWidth, bool keepAtLeastOneCharacter, const TextFragmentIterator& textFragmentIterator)
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: add surrogate pair support.
</span><span class="cx"> unsigned start = fragmentToSplit.start();
</span><del>- auto it = std::upper_bound(begin(fragmentToSplit), end(fragmentToSplit), availableWidth, [&flowContentsIterator, start](float availableWidth, unsigned index) {
</del><ins>+ auto it = std::upper_bound(begin(fragmentToSplit), end(fragmentToSplit), availableWidth, [&textFragmentIterator, start](float availableWidth, unsigned index) {
</ins><span class="cx"> // FIXME: use the actual left position of the line (instead of 0) to calculated width. It might give false width for tab characters.
</span><del>- return availableWidth < flowContentsIterator.textWidth(start, index + 1, 0);
</del><ins>+ return availableWidth < textFragmentIterator.textWidth(start, index + 1, 0);
</ins><span class="cx"> });
</span><span class="cx"> unsigned splitPosition = (*it);
</span><span class="cx"> if (keepAtLeastOneCharacter && splitPosition == fragmentToSplit.start())
</span><span class="cx"> ++splitPosition;
</span><del>- return fragmentToSplit.split(splitPosition, flowContentsIterator);
</del><ins>+ return fragmentToSplit.split(splitPosition, textFragmentIterator);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static FlowContentsIterator::TextFragment firstFragment(FlowContentsIterator& flowContentsIterator, const LineState& previousLine)
</del><ins>+static TextFragmentIterator::TextFragment firstFragment(TextFragmentIterator& textFragmentIterator, const LineState& previousLine)
</ins><span class="cx"> {
</span><span class="cx"> // Handle overflowed fragment from previous line.
</span><del>- FlowContentsIterator::TextFragment firstFragment(previousLine.overflowedFragment());
- const auto& style = flowContentsIterator.style();
</del><ins>+ TextFragmentIterator::TextFragment firstFragment(previousLine.overflowedFragment());
+ const auto& style = textFragmentIterator.style();
</ins><span class="cx">
</span><span class="cx"> if (firstFragment.isEmpty())
</span><del>- firstFragment = flowContentsIterator.nextTextFragment();
</del><ins>+ firstFragment = textFragmentIterator.nextTextFragment();
</ins><span class="cx"> else {
</span><span class="cx"> // Special overflow pre-wrap whitespace handling: ignore the overflowed whitespace if we managed to fit at least one character on the previous line.
</span><span class="cx"> // When the line is too short to fit one character (thought it still stays on the line) we continue with the overflow whitespace content on this line.
</span><del>- if (firstFragment.type() == FlowContentsIterator::TextFragment::Whitespace && preWrap(style) && previousLine.firstCharacterFits()) {
- firstFragment = flowContentsIterator.nextTextFragment();
</del><ins>+ if (firstFragment.type() == TextFragmentIterator::TextFragment::Whitespace && preWrap(style) && previousLine.firstCharacterFits()) {
+ firstFragment = textFragmentIterator.nextTextFragment();
</ins><span class="cx"> // If skipping the whitespace puts us on a hard newline, skip the newline too as we already wrapped the line.
</span><del>- if (firstFragment.type() == FlowContentsIterator::TextFragment::LineBreak)
- firstFragment = flowContentsIterator.nextTextFragment();
</del><ins>+ if (firstFragment.type() == TextFragmentIterator::TextFragment::LineBreak)
+ firstFragment = textFragmentIterator.nextTextFragment();
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Check if we need to skip the leading whitespace.
</span><del>- if (style.collapseWhitespace && firstFragment.type() == FlowContentsIterator::TextFragment::Whitespace)
- firstFragment = flowContentsIterator.nextTextFragment();
</del><ins>+ if (style.collapseWhitespace && firstFragment.type() == TextFragmentIterator::TextFragment::Whitespace)
+ firstFragment = textFragmentIterator.nextTextFragment();
</ins><span class="cx"> return firstFragment;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static bool createLineRuns(LineState& line, const LineState& previousLine, Layout::RunVector& runs, FlowContentsIterator& flowContentsIterator)
</del><ins>+static bool createLineRuns(LineState& line, const LineState& previousLine, Layout::RunVector& runs, TextFragmentIterator& textFragmentIterator)
</ins><span class="cx"> {
</span><del>- const auto& style = flowContentsIterator.style();
</del><ins>+ const auto& style = textFragmentIterator.style();
</ins><span class="cx"> bool lineCanBeWrapped = style.wrapLines || style.breakWordOnOverflow;
</span><del>- auto fragment = firstFragment(flowContentsIterator, previousLine);
- while (fragment.type() != FlowContentsIterator::TextFragment::ContentEnd) {
</del><ins>+ auto fragment = firstFragment(textFragmentIterator, previousLine);
+ while (fragment.type() != TextFragmentIterator::TextFragment::ContentEnd) {
</ins><span class="cx"> // Hard linebreak.
</span><del>- if (fragment.type() == FlowContentsIterator::TextFragment::LineBreak) {
</del><ins>+ if (fragment.type() == TextFragmentIterator::TextFragment::LineBreak) {
</ins><span class="cx"> // Add the new line fragment only if there's nothing on the line. (otherwise the extra new line character would show up at the end of the content.)
</span><span class="cx"> if (!line.width())
</span><span class="cx"> line.appendFragment(fragment, runs);
</span><span class="lines">@@ -411,10 +411,10 @@
</span><span class="cx"> // 4. Non-whitespace fragment when there's already another fragment on the line gets pushed to the next line.
</span><span class="cx"> bool emptyLine = !line.width();
</span><span class="cx"> // Whitespace fragment.
</span><del>- if (fragment.type() == FlowContentsIterator::TextFragment::Whitespace) {
</del><ins>+ if (fragment.type() == TextFragmentIterator::TextFragment::Whitespace) {
</ins><span class="cx"> if (!style.collapseWhitespace) {
</span><span class="cx"> // Split the fragment; (modified)fragment stays on this line, overflowedFragment is pushed to next line.
</span><del>- line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, flowContentsIterator));
</del><ins>+ line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, textFragmentIterator));
</ins><span class="cx"> line.appendFragment(fragment, runs);
</span><span class="cx"> }
</span><span class="cx"> // When whitespace collapse is on, whitespace that doesn't fit is simply skipped.
</span><span class="lines">@@ -423,7 +423,7 @@
</span><span class="cx"> // Non-whitespace fragment. (!style.wrapLines: bug138102(preserve existing behavior)
</span><span class="cx"> if ((emptyLine && style.breakWordOnOverflow) || !style.wrapLines) {
</span><span class="cx"> // Split the fragment; (modified)fragment stays on this line, overflowedFragment is pushed to next line.
</span><del>- line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, flowContentsIterator));
</del><ins>+ line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, textFragmentIterator));
</ins><span class="cx"> line.appendFragment(fragment, runs);
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -438,21 +438,21 @@
</span><span class="cx"> }
</span><span class="cx"> line.appendFragment(fragment, runs);
</span><span class="cx"> // Find the next text fragment.
</span><del>- fragment = flowContentsIterator.nextTextFragment(line.width());
</del><ins>+ fragment = textFragmentIterator.nextTextFragment(line.width());
</ins><span class="cx"> }
</span><del>- return fragment.type() == FlowContentsIterator::TextFragment::ContentEnd && line.overflowedFragment().isEmpty();
</del><ins>+ return fragment.type() == TextFragmentIterator::TextFragment::ContentEnd && line.overflowedFragment().isEmpty();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static void closeLineEndingAndAdjustRuns(LineState& line, Layout::RunVector& runs, unsigned previousRunCount, unsigned& lineCount, const FlowContentsIterator& flowContentsIterator)
</del><ins>+static void closeLineEndingAndAdjustRuns(LineState& line, Layout::RunVector& runs, unsigned previousRunCount, unsigned& lineCount, const TextFragmentIterator& textFragmentIterator)
</ins><span class="cx"> {
</span><span class="cx"> if (previousRunCount == runs.size())
</span><span class="cx"> return;
</span><span class="cx"> ASSERT(runs.size());
</span><del>- removeTrailingWhitespace(line, runs, flowContentsIterator);
</del><ins>+ removeTrailingWhitespace(line, runs, textFragmentIterator);
</ins><span class="cx"> if (!runs.size())
</span><span class="cx"> return;
</span><span class="cx"> // Adjust runs' position by taking line's alignment into account.
</span><del>- if (float lineLogicalLeft = computeLineLeft(flowContentsIterator.style().textAlign, line.availableWidth(), line.width(), line.logicalLeftOffset())) {
</del><ins>+ if (float lineLogicalLeft = computeLineLeft(textFragmentIterator.style().textAlign, line.availableWidth(), line.width(), line.logicalLeftOffset())) {
</ins><span class="cx"> for (unsigned i = previousRunCount; i < runs.size(); ++i) {
</span><span class="cx"> runs[i].logicalLeft += lineLogicalLeft;
</span><span class="cx"> runs[i].logicalRight += lineLogicalLeft;
</span><span class="lines">@@ -462,7 +462,7 @@
</span><span class="cx"> ++lineCount;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void splitRunsAtRendererBoundary(Layout::RunVector& lineRuns, const FlowContentsIterator& flowContentsIterator)
</del><ins>+static void splitRunsAtRendererBoundary(Layout::RunVector& lineRuns, const TextFragmentIterator& textFragmentIterator)
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: We should probably split during run construction instead of as a separate pass.
</span><span class="cx"> if (lineRuns.isEmpty())
</span><span class="lines">@@ -471,12 +471,12 @@
</span><span class="cx"> do {
</span><span class="cx"> const Run& run = lineRuns.at(runIndex);
</span><span class="cx"> ASSERT(run.start != run.end);
</span><del>- auto& startSegment = flowContentsIterator.segmentForPosition(run.start);
</del><ins>+ auto& startSegment = textFragmentIterator.segmentForPosition(run.start);
</ins><span class="cx"> if (run.end <= startSegment.end)
</span><span class="cx"> continue;
</span><span class="cx"> // This run overlaps multiple renderers. Split it up.
</span><span class="cx"> // Split run at the renderer's boundary and create a new run for the left side, while use the current run as the right side.
</span><del>- float logicalRightOfLeftRun = run.logicalLeft + flowContentsIterator.textWidth(run.start, startSegment.end, run.logicalLeft);
</del><ins>+ float logicalRightOfLeftRun = run.logicalLeft + textFragmentIterator.textWidth(run.start, startSegment.end, run.logicalLeft);
</ins><span class="cx"> lineRuns.insert(runIndex, Run(run.start, startSegment.end, run.logicalLeft, logicalRightOfLeftRun, false));
</span><span class="cx"> Run& rightSideRun = lineRuns.at(runIndex + 1);
</span><span class="cx"> rightSideRun.start = startSegment.end;
</span><span class="lines">@@ -490,7 +490,7 @@
</span><span class="cx"> LayoutUnit lineHeight = lineHeightFromFlow(flow);
</span><span class="cx"> LineState line;
</span><span class="cx"> bool isEndOfContent = false;
</span><del>- FlowContentsIterator flowContentsIterator = FlowContentsIterator(flow);
</del><ins>+ TextFragmentIterator textFragmentIterator = TextFragmentIterator(flow);
</ins><span class="cx">
</span><span class="cx"> do {
</span><span class="cx"> flow.setLogicalHeight(lineHeight * lineCount + borderAndPaddingBefore);
</span><span class="lines">@@ -498,12 +498,12 @@
</span><span class="cx"> unsigned previousRunCount = runs.size();
</span><span class="cx"> line = LineState();
</span><span class="cx"> updateLineConstrains(flow, line);
</span><del>- isEndOfContent = createLineRuns(line, previousLine, runs, flowContentsIterator);
- closeLineEndingAndAdjustRuns(line, runs, previousRunCount, lineCount, flowContentsIterator);
</del><ins>+ isEndOfContent = createLineRuns(line, previousLine, runs, textFragmentIterator);
+ closeLineEndingAndAdjustRuns(line, runs, previousRunCount, lineCount, textFragmentIterator);
</ins><span class="cx"> } while (!isEndOfContent);
</span><span class="cx">
</span><span class="cx"> if (flow.firstChild() != flow.lastChild())
</span><del>- splitRunsAtRendererBoundary(runs, flowContentsIterator);
</del><ins>+ splitRunsAtRendererBoundary(runs, textFragmentIterator);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<Layout> create(RenderBlockFlow& flow)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -1,190 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleLineLayoutFlowContentsIterator.h"
-
-#include "RenderBlockFlow.h"
-#include "RenderChildIterator.h"
-#include "RenderText.h"
-#include "SimpleLineLayoutFlowContents.h"
-
-namespace WebCore {
-namespace SimpleLineLayout {
-
-FlowContentsIterator::Style::Style(const RenderStyle& style)
- : font(style.fontCascade())
- , textAlign(style.textAlign())
- , collapseWhitespace(style.collapseWhiteSpace())
- , preserveNewline(style.preserveNewline())
- , wrapLines(style.autoWrap())
- , breakWordOnOverflow(style.overflowWrap() == BreakOverflowWrap && (wrapLines || preserveNewline))
- , spaceWidth(font.width(TextRun(&space, 1)))
- , tabWidth(collapseWhitespace ? 0 : style.tabSize())
- , locale(style.locale())
-{
-}
-
-FlowContentsIterator::FlowContentsIterator(const RenderBlockFlow& flow)
- : m_flowContents(flow)
- , m_lineBreakIterator((*m_flowContents.begin()).text, flow.style().locale())
- , m_style(flow.style())
-{
-}
-
-FlowContentsIterator::TextFragment FlowContentsIterator::nextTextFragment(float xPosition)
-{
- // A fragment can either be
- // 1. new line character when preserveNewline is on (not considered as whitespace) or
- // 2. whitespace (collasped, non-collapsed multi or single) or
- // 3. non-whitespace characters.
- // 4. empty, indicating content end.
- if (isEnd(m_position))
- return TextFragment(m_position, m_position, 0, TextFragment::ContentEnd);
- if (isLineBreak(m_position)) {
- TextFragment fragment(m_position, m_position + 1, 0, TextFragment::LineBreak);
- ++m_position;
- return fragment;
- }
- unsigned spaceCount = 0;
- unsigned startPosition = m_position;
- unsigned endPosition = findNextNonWhitespacePosition(startPosition, spaceCount);
- ASSERT(startPosition <= endPosition);
- if (endPosition > startPosition) {
- bool multipleWhitespace = startPosition + 1 < endPosition;
- bool isCollapsed = multipleWhitespace && m_style.collapseWhitespace;
- bool isBreakable = !isCollapsed && multipleWhitespace;
- float width = 0;
- if (isCollapsed)
- width = m_style.spaceWidth;
- else {
- unsigned length = endPosition - startPosition;
- width = length == spaceCount ? length * m_style.spaceWidth : textWidth(startPosition, endPosition, xPosition);
- }
- m_position = endPosition;
- return TextFragment(startPosition, endPosition, width, TextFragment::Whitespace, isCollapsed, isBreakable);
- }
- endPosition = findNextBreakablePosition(startPosition + 1);
- m_position = endPosition;
- return TextFragment(startPosition, endPosition, textWidth(startPosition, endPosition, xPosition), TextFragment::NonWhitespace, false, m_style.breakWordOnOverflow);
-}
-
-float FlowContentsIterator::textWidth(unsigned from, unsigned to, float xPosition) const
-{
- const auto& fromSegment = m_flowContents.segmentForPosition(from);
- if ((m_style.font.isFixedPitch() && fromSegment.end >= to) || (from == fromSegment.start && to == fromSegment.end))
- return fromSegment.renderer.width(from - fromSegment.start, to - from, m_style.font, xPosition, nullptr, nullptr);
-
- const auto* segment = &fromSegment;
- float textWidth = 0;
- unsigned fragmentEnd = 0;
- while (true) {
- fragmentEnd = std::min(to, segment->end);
- textWidth += segment->text.is8Bit() ? runWidth<LChar>(segment->text, from - segment->start, fragmentEnd - segment->start, xPosition + textWidth) :
- runWidth<UChar>(segment->text, from - segment->start, fragmentEnd - segment->start, xPosition + textWidth);
- if (fragmentEnd == to)
- break;
- from = fragmentEnd;
- segment = &m_flowContents.segmentForPosition(fragmentEnd);
- };
-
- return textWidth;
-}
-
-template <typename CharacterType>
-static unsigned nextBreakablePosition(LazyLineBreakIterator& lineBreakIterator, const FlowContents::Segment& segment, unsigned position)
-{
- const auto* characters = segment.text.characters<CharacterType>();
- unsigned segmentLength = segment.end - segment.start;
- unsigned segmentPosition = position - segment.start;
- return nextBreakablePositionNonLoosely<CharacterType, NBSPBehavior::IgnoreNBSP>(lineBreakIterator, characters, segmentLength, segmentPosition);
-}
-
-unsigned FlowContentsIterator::findNextBreakablePosition(unsigned position) const
-{
- while (!isEnd(position)) {
- auto& segment = m_flowContents.segmentForPosition(position);
- if (segment.text.impl() != m_lineBreakIterator.string().impl()) {
- UChar lastCharacter = segment.start > 0 ? characterAt(segment.start - 1) : 0;
- UChar secondToLastCharacter = segment.start > 1 ? characterAt(segment.start - 2) : 0;
- m_lineBreakIterator.setPriorContext(lastCharacter, secondToLastCharacter);
- m_lineBreakIterator.resetStringAndReleaseIterator(segment.text, m_style.locale, LineBreakIteratorModeUAX14);
- }
-
- unsigned breakable = segment.text.is8Bit() ? nextBreakablePosition<LChar>(m_lineBreakIterator, segment, position) : nextBreakablePosition<UChar>(m_lineBreakIterator, segment, position);
- position = segment.start + breakable;
- if (position < segment.end)
- break;
- }
- return position;
-}
-
-template <typename CharacterType>
-static bool findNextNonWhitespace(const FlowContents::Segment& segment, const FlowContentsIterator::Style& style, unsigned& position, unsigned& spaceCount)
-{
- const auto* text = segment.text.characters<CharacterType>();
- for (; position < segment.end; ++position) {
- auto character = text[position - segment.start];
- bool isSpace = character == ' ';
- bool isWhitespace = isSpace || character == '\t' || (!style.preserveNewline && character == '\n');
- if (!isWhitespace)
- return true;
- if (isSpace)
- ++spaceCount;
- }
- return false;
-}
-
-unsigned FlowContentsIterator::findNextNonWhitespacePosition(unsigned position, unsigned& spaceCount) const
-{
- FlowContents::Iterator it(m_flowContents, m_flowContents.segmentIndexForPosition(position));
- for (auto end = m_flowContents.end(); it != end; ++it) {
- bool foundNonWhitespace = (*it).text.is8Bit() ? findNextNonWhitespace<LChar>(*it, m_style, position, spaceCount) : findNextNonWhitespace<UChar>(*it, m_style, position, spaceCount);
- if (foundNonWhitespace)
- break;
- }
- return position;
-}
-
-template <typename CharacterType>
-float FlowContentsIterator::runWidth(const String& text, unsigned from, unsigned to, float xPosition) const
-{
- ASSERT(from <= to);
- if (from == to)
- return 0;
- bool measureWithEndSpace = m_style.collapseWhitespace && to < text.length() && text[to] == ' ';
- if (measureWithEndSpace)
- ++to;
- TextRun run(text.characters<CharacterType>() + from, to - from);
- run.setXPos(xPosition);
- run.setTabSize(!!m_style.tabWidth, m_style.tabWidth);
- float width = m_style.font.width(run);
- if (measureWithEndSpace)
- width -= m_style.spaceWidth;
- return width;
-}
-
-}
-}
</del></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h (179533 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h        2015-02-03 02:22:51 UTC (rev 179533)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -1,151 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SimpleLineLayoutFlowContentsIterator_h
-#define SimpleLineLayoutFlowContentsIterator_h
-
-#include "RenderStyle.h"
-#include "SimpleLineLayoutFlowContents.h"
-#include "TextBreakIterator.h"
-#include "break_lines.h"
-
-namespace WebCore {
-class RenderBlockFlow;
-
-namespace SimpleLineLayout {
-
-class FlowContentsIterator {
-public:
- FlowContentsIterator(const RenderBlockFlow&);
- class TextFragment {
- public:
- enum Type { ContentEnd, LineBreak, Whitespace, NonWhitespace };
- TextFragment() = default;
- TextFragment(unsigned start, unsigned end, float width, Type type, bool isCollapsed = false, bool isBreakable = false)
- : m_start(start)
- , m_end(end)
- , m_type(type)
- , m_width(width)
- , m_isCollapsed(isCollapsed)
- , m_isBreakable(isBreakable)
- {
- }
-
- unsigned start() const { return m_start; }
- unsigned end() const { return m_end; }
- float width() const { return m_width; }
- Type type() const { return m_type; }
- bool isCollapsed() const { return m_isCollapsed; }
- bool isBreakable() const { return m_isBreakable; }
-
- bool isEmpty() const { return start() == end(); }
- TextFragment split(unsigned splitPosition, const FlowContentsIterator&);
-
- private:
- unsigned m_start { 0 };
- unsigned m_end { 0 };
- Type m_type { NonWhitespace };
- float m_width { 0 };
- bool m_isCollapsed { false };
- bool m_isBreakable { false };
- };
- TextFragment nextTextFragment(float xPosition = 0);
- float textWidth(unsigned from, unsigned to, float xPosition) const;
-
- struct Style {
- explicit Style(const RenderStyle&);
-
- const FontCascade& font;
- ETextAlign textAlign;
- bool collapseWhitespace;
- bool preserveNewline;
- bool wrapLines;
- bool breakWordOnOverflow;
- float spaceWidth;
- unsigned tabWidth;
- AtomicString locale;
- };
- const Style& style() const { return m_style; }
- // FIXME: remove splitRunsAtRendererBoundary()
- const FlowContents::Segment& segmentForPosition(unsigned position) const { return m_flowContents.segmentForPosition(position); };
-
-private:
- unsigned findNextNonWhitespacePosition(unsigned position, unsigned& spaceCount) const;
- unsigned findNextBreakablePosition(unsigned position) const;
- UChar characterAt(unsigned position) const;
- bool isLineBreak(unsigned position) const;
- bool isEnd(unsigned position) const;
- template <typename CharacterType> float runWidth(const String&, unsigned from, unsigned to, float xPosition) const;
-
- FlowContents m_flowContents;
- mutable LazyLineBreakIterator m_lineBreakIterator;
- const Style m_style;
- unsigned m_position { 0 };
-};
-
-inline FlowContentsIterator::TextFragment FlowContentsIterator::TextFragment::split(unsigned splitPosition, const FlowContentsIterator& flowContentsIterator)
-{
- auto updateFragmentProperties = [&flowContentsIterator] (TextFragment& fragment)
- {
- fragment.m_width = 0;
- if (fragment.start() != fragment.end())
- fragment.m_width = flowContentsIterator.textWidth(fragment.start(), fragment.end(), 0);
- if (fragment.start() + 1 > fragment.end())
- return;
- fragment.m_isCollapsed = false;
- fragment.m_isBreakable = false;
- };
-
- TextFragment newFragment(*this);
- m_end = splitPosition;
- updateFragmentProperties(*this);
-
- newFragment.m_start = splitPosition;
- updateFragmentProperties(newFragment);
- return newFragment;
-}
-
-inline UChar FlowContentsIterator::characterAt(unsigned position) const
-{
- auto& segment = m_flowContents.segmentForPosition(position);
- return segment.text[position - segment.start];
-}
-
-inline bool FlowContentsIterator::isLineBreak(unsigned position) const
-{
- if (isEnd(position))
- return false;
- return m_style.preserveNewline && characterAt(position) == '\n';
-}
-
-inline bool FlowContentsIterator::isEnd(unsigned position) const
-{
- return position >= m_flowContents.length();
-}
-
-}
-}
-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorcppfromrev179533trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (from rev 179533, trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp) (0 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp         (rev 0)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -0,0 +1,190 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SimpleLineLayoutTextFragmentIterator.h"
+
+#include "RenderBlockFlow.h"
+#include "RenderChildIterator.h"
+#include "RenderText.h"
+#include "SimpleLineLayoutFlowContents.h"
+
+namespace WebCore {
+namespace SimpleLineLayout {
+
+TextFragmentIterator::Style::Style(const RenderStyle& style)
+ : font(style.fontCascade())
+ , textAlign(style.textAlign())
+ , collapseWhitespace(style.collapseWhiteSpace())
+ , preserveNewline(style.preserveNewline())
+ , wrapLines(style.autoWrap())
+ , breakWordOnOverflow(style.overflowWrap() == BreakOverflowWrap && (wrapLines || preserveNewline))
+ , spaceWidth(font.width(TextRun(&space, 1)))
+ , tabWidth(collapseWhitespace ? 0 : style.tabSize())
+ , locale(style.locale())
+{
+}
+
+TextFragmentIterator::TextFragmentIterator(const RenderBlockFlow& flow)
+ : m_flowContents(flow)
+ , m_lineBreakIterator((*m_flowContents.begin()).text, flow.style().locale())
+ , m_style(flow.style())
+{
+}
+
+TextFragmentIterator::TextFragment TextFragmentIterator::nextTextFragment(float xPosition)
+{
+ // A fragment can either be
+ // 1. new line character when preserveNewline is on (not considered as whitespace) or
+ // 2. whitespace (collasped, non-collapsed multi or single) or
+ // 3. non-whitespace characters.
+ // 4. empty, indicating content end.
+ if (isEnd(m_position))
+ return TextFragment(m_position, m_position, 0, TextFragment::ContentEnd);
+ if (isLineBreak(m_position)) {
+ TextFragment fragment(m_position, m_position + 1, 0, TextFragment::LineBreak);
+ ++m_position;
+ return fragment;
+ }
+ unsigned spaceCount = 0;
+ unsigned startPosition = m_position;
+ unsigned endPosition = findNextNonWhitespacePosition(startPosition, spaceCount);
+ ASSERT(startPosition <= endPosition);
+ if (endPosition > startPosition) {
+ bool multipleWhitespace = startPosition + 1 < endPosition;
+ bool isCollapsed = multipleWhitespace && m_style.collapseWhitespace;
+ bool isBreakable = !isCollapsed && multipleWhitespace;
+ float width = 0;
+ if (isCollapsed)
+ width = m_style.spaceWidth;
+ else {
+ unsigned length = endPosition - startPosition;
+ width = length == spaceCount ? length * m_style.spaceWidth : textWidth(startPosition, endPosition, xPosition);
+ }
+ m_position = endPosition;
+ return TextFragment(startPosition, endPosition, width, TextFragment::Whitespace, isCollapsed, isBreakable);
+ }
+ endPosition = findNextBreakablePosition(startPosition + 1);
+ m_position = endPosition;
+ return TextFragment(startPosition, endPosition, textWidth(startPosition, endPosition, xPosition), TextFragment::NonWhitespace, false, m_style.breakWordOnOverflow);
+}
+
+float TextFragmentIterator::textWidth(unsigned from, unsigned to, float xPosition) const
+{
+ const auto& fromSegment = m_flowContents.segmentForPosition(from);
+ if ((m_style.font.isFixedPitch() && fromSegment.end >= to) || (from == fromSegment.start && to == fromSegment.end))
+ return fromSegment.renderer.width(from - fromSegment.start, to - from, m_style.font, xPosition, nullptr, nullptr);
+
+ const auto* segment = &fromSegment;
+ float textWidth = 0;
+ unsigned fragmentEnd = 0;
+ while (true) {
+ fragmentEnd = std::min(to, segment->end);
+ textWidth += segment->text.is8Bit() ? runWidth<LChar>(segment->text, from - segment->start, fragmentEnd - segment->start, xPosition + textWidth) :
+ runWidth<UChar>(segment->text, from - segment->start, fragmentEnd - segment->start, xPosition + textWidth);
+ if (fragmentEnd == to)
+ break;
+ from = fragmentEnd;
+ segment = &m_flowContents.segmentForPosition(fragmentEnd);
+ };
+
+ return textWidth;
+}
+
+template <typename CharacterType>
+static unsigned nextBreakablePosition(LazyLineBreakIterator& lineBreakIterator, const FlowContents::Segment& segment, unsigned position)
+{
+ const auto* characters = segment.text.characters<CharacterType>();
+ unsigned segmentLength = segment.end - segment.start;
+ unsigned segmentPosition = position - segment.start;
+ return nextBreakablePositionNonLoosely<CharacterType, NBSPBehavior::IgnoreNBSP>(lineBreakIterator, characters, segmentLength, segmentPosition);
+}
+
+unsigned TextFragmentIterator::findNextBreakablePosition(unsigned position) const
+{
+ while (!isEnd(position)) {
+ auto& segment = m_flowContents.segmentForPosition(position);
+ if (segment.text.impl() != m_lineBreakIterator.string().impl()) {
+ UChar lastCharacter = segment.start > 0 ? characterAt(segment.start - 1) : 0;
+ UChar secondToLastCharacter = segment.start > 1 ? characterAt(segment.start - 2) : 0;
+ m_lineBreakIterator.setPriorContext(lastCharacter, secondToLastCharacter);
+ m_lineBreakIterator.resetStringAndReleaseIterator(segment.text, m_style.locale, LineBreakIteratorModeUAX14);
+ }
+
+ unsigned breakable = segment.text.is8Bit() ? nextBreakablePosition<LChar>(m_lineBreakIterator, segment, position) : nextBreakablePosition<UChar>(m_lineBreakIterator, segment, position);
+ position = segment.start + breakable;
+ if (position < segment.end)
+ break;
+ }
+ return position;
+}
+
+template <typename CharacterType>
+static bool findNextNonWhitespace(const FlowContents::Segment& segment, const TextFragmentIterator::Style& style, unsigned& position, unsigned& spaceCount)
+{
+ const auto* text = segment.text.characters<CharacterType>();
+ for (; position < segment.end; ++position) {
+ auto character = text[position - segment.start];
+ bool isSpace = character == ' ';
+ bool isWhitespace = isSpace || character == '\t' || (!style.preserveNewline && character == '\n');
+ if (!isWhitespace)
+ return true;
+ if (isSpace)
+ ++spaceCount;
+ }
+ return false;
+}
+
+unsigned TextFragmentIterator::findNextNonWhitespacePosition(unsigned position, unsigned& spaceCount) const
+{
+ FlowContents::Iterator it(m_flowContents, m_flowContents.segmentIndexForPosition(position));
+ for (auto end = m_flowContents.end(); it != end; ++it) {
+ bool foundNonWhitespace = (*it).text.is8Bit() ? findNextNonWhitespace<LChar>(*it, m_style, position, spaceCount) : findNextNonWhitespace<UChar>(*it, m_style, position, spaceCount);
+ if (foundNonWhitespace)
+ break;
+ }
+ return position;
+}
+
+template <typename CharacterType>
+float TextFragmentIterator::runWidth(const String& text, unsigned from, unsigned to, float xPosition) const
+{
+ ASSERT(from <= to);
+ if (from == to)
+ return 0;
+ bool measureWithEndSpace = m_style.collapseWhitespace && to < text.length() && text[to] == ' ';
+ if (measureWithEndSpace)
+ ++to;
+ TextRun run(text.characters<CharacterType>() + from, to - from);
+ run.setXPos(xPosition);
+ run.setTabSize(!!m_style.tabWidth, m_style.tabWidth);
+ float width = m_style.font.width(run);
+ if (measureWithEndSpace)
+ width -= m_style.spaceWidth;
+ return width;
+}
+
+}
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorhfromrev179533trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h (from rev 179533, trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h) (0 => 179534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h         (rev 0)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h        2015-02-03 03:08:33 UTC (rev 179534)
</span><span class="lines">@@ -0,0 +1,151 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SimpleLineLayoutTextFragmentIterator_h
+#define SimpleLineLayoutTextFragmentIterator_h
+
+#include "RenderStyle.h"
+#include "SimpleLineLayoutFlowContents.h"
+#include "TextBreakIterator.h"
+#include "break_lines.h"
+
+namespace WebCore {
+class RenderBlockFlow;
+
+namespace SimpleLineLayout {
+
+class TextFragmentIterator {
+public:
+ TextFragmentIterator(const RenderBlockFlow&);
+ class TextFragment {
+ public:
+ enum Type { ContentEnd, LineBreak, Whitespace, NonWhitespace };
+ TextFragment() = default;
+ TextFragment(unsigned start, unsigned end, float width, Type type, bool isCollapsed = false, bool isBreakable = false)
+ : m_start(start)
+ , m_end(end)
+ , m_type(type)
+ , m_width(width)
+ , m_isCollapsed(isCollapsed)
+ , m_isBreakable(isBreakable)
+ {
+ }
+
+ unsigned start() const { return m_start; }
+ unsigned end() const { return m_end; }
+ float width() const { return m_width; }
+ Type type() const { return m_type; }
+ bool isCollapsed() const { return m_isCollapsed; }
+ bool isBreakable() const { return m_isBreakable; }
+
+ bool isEmpty() const { return start() == end(); }
+ TextFragment split(unsigned splitPosition, const TextFragmentIterator&);
+
+ private:
+ unsigned m_start { 0 };
+ unsigned m_end { 0 };
+ Type m_type { NonWhitespace };
+ float m_width { 0 };
+ bool m_isCollapsed { false };
+ bool m_isBreakable { false };
+ };
+ TextFragment nextTextFragment(float xPosition = 0);
+ float textWidth(unsigned from, unsigned to, float xPosition) const;
+
+ struct Style {
+ explicit Style(const RenderStyle&);
+
+ const FontCascade& font;
+ ETextAlign textAlign;
+ bool collapseWhitespace;
+ bool preserveNewline;
+ bool wrapLines;
+ bool breakWordOnOverflow;
+ float spaceWidth;
+ unsigned tabWidth;
+ AtomicString locale;
+ };
+ const Style& style() const { return m_style; }
+ // FIXME: remove splitRunsAtRendererBoundary()
+ const FlowContents::Segment& segmentForPosition(unsigned position) const { return m_flowContents.segmentForPosition(position); };
+
+private:
+ unsigned findNextNonWhitespacePosition(unsigned position, unsigned& spaceCount) const;
+ unsigned findNextBreakablePosition(unsigned position) const;
+ UChar characterAt(unsigned position) const;
+ bool isLineBreak(unsigned position) const;
+ bool isEnd(unsigned position) const;
+ template <typename CharacterType> float runWidth(const String&, unsigned from, unsigned to, float xPosition) const;
+
+ FlowContents m_flowContents;
+ mutable LazyLineBreakIterator m_lineBreakIterator;
+ const Style m_style;
+ unsigned m_position { 0 };
+};
+
+inline TextFragmentIterator::TextFragment TextFragmentIterator::TextFragment::split(unsigned splitPosition, const TextFragmentIterator& textFragmentIterator)
+{
+ auto updateFragmentProperties = [&textFragmentIterator] (TextFragment& fragment)
+ {
+ fragment.m_width = 0;
+ if (fragment.start() != fragment.end())
+ fragment.m_width = textFragmentIterator.textWidth(fragment.start(), fragment.end(), 0);
+ if (fragment.start() + 1 > fragment.end())
+ return;
+ fragment.m_isCollapsed = false;
+ fragment.m_isBreakable = false;
+ };
+
+ TextFragment newFragment(*this);
+ m_end = splitPosition;
+ updateFragmentProperties(*this);
+
+ newFragment.m_start = splitPosition;
+ updateFragmentProperties(newFragment);
+ return newFragment;
+}
+
+inline UChar TextFragmentIterator::characterAt(unsigned position) const
+{
+ auto& segment = m_flowContents.segmentForPosition(position);
+ return segment.text[position - segment.start];
+}
+
+inline bool TextFragmentIterator::isLineBreak(unsigned position) const
+{
+ if (isEnd(position))
+ return false;
+ return m_style.preserveNewline && characterAt(position) == '\n';
+}
+
+inline bool TextFragmentIterator::isEnd(unsigned position) const
+{
+ return position >= m_flowContents.length();
+}
+
+}
+}
+
+#endif
</ins></span></pre>
</div>
</div>
</body>
</html>