<!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>[181685] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181685">181685</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-03-17 23:09:56 -0700 (Tue, 17 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Unreviewed, rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/181667">r181667</a>, <a href="http://trac.webkit.org/projects/webkit/changeset/181682">r181682</a>, and <a href="http://trac.webkit.org/projects/webkit/changeset/181683">r181683</a>.
https://bugs.webkit.org/show_bug.cgi?id=142812
Broke multiple tests with ASan, plus dependent commits
(Requested by ap on #webkit).
Reverted changesets:
"Simple line layout: Split fragments on renderer boundary on
the fly."
https://bugs.webkit.org/show_bug.cgi?id=142579
http://trac.webkit.org/changeset/181667
"Simple line layout: Change FlowContents::segmentForPosition()
to segmentForRun()."
https://bugs.webkit.org/show_bug.cgi?id=142785
http://trac.webkit.org/changeset/181682
"Simple line layout: Use Vector<>::const_iterator instead of
custom FlowContents::Iterator."
https://bugs.webkit.org/show_bug.cgi?id=142809
http://trac.webkit.org/changeset/181683</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutcpp">trunk/Source/WebCore/rendering/SimpleLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFlowContentscpp">trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsh">trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutFunctionscpp">trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingSimpleLineLayoutResolvercpp">trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp</a></li>
<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="#trunkLayoutTestsfasttextsimplelinewithmultiplerenderersexpectedhtml">trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttextsimplelinewithmultiplerenderershtml">trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/LayoutTests/ChangeLog        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-03-17 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r181667, r181682, and r181683.
+ https://bugs.webkit.org/show_bug.cgi?id=142812
+
+ Broke multiple tests with ASan, plus dependent commits
+ (Requested by ap on #webkit).
+
+ Reverted changesets:
+
+ "Simple line layout: Split fragments on renderer boundary on
+ the fly."
+ https://bugs.webkit.org/show_bug.cgi?id=142579
+ http://trac.webkit.org/changeset/181667
+
+ "Simple line layout: Change FlowContents::segmentForPosition()
+ to segmentForRun()."
+ https://bugs.webkit.org/show_bug.cgi?id=142785
+ http://trac.webkit.org/changeset/181682
+
+ "Simple line layout: Use Vector<>::const_iterator instead of
+ custom FlowContents::Iterator."
+ https://bugs.webkit.org/show_bug.cgi?id=142809
+ http://trac.webkit.org/changeset/181683
+
</ins><span class="cx"> 2015-03-17 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> fast/images/animated-png.html is crashing / failing on Yosemite
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextsimplelinewithmultiplerenderersexpectedhtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers-expected.html (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers-expected.html        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers-expected.html        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -1,36 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<head>
-<title>Test that segments across multiple renderers work fine with simple line layout.</title>
-</head>
-<body>
-<script>
-function injectTextNodes(container, style)
-{
-        container.appendChild(document.createTextNode("         "));
-        container.appendChild(document.createTextNode("        "));
-        container.appendChild(document.createTextNode("        This tests "));
-        container.appendChild(document.createTextNode("          "));
-        container.appendChild(document.createTextNode("whitespace                 overlapping "));
-        container.appendChild(document.createTextNode("        multiple "));
-        container.appendChild(document.createTextNode("                                renderers."));
-        container.appendChild(document.createTextNode("This tests when non-"));
-        container.appendChild(document.createTextNode("whitespace con"));
-        container.appendChild(document.createTextNode("tent o"));
-        container.appendChild(document.createTextNode("verla"));
-        container.appendChild(document.createTextNode("ps multiple ren"));
-        container.appendChild(document.createTextNode("deres."));
-        container.style.cssText = style;
-        document.body.appendChild(container);
-}
-
-if (window.internals)
-        internals.settings.setSimpleLineLayoutEnabled(false)
-injectTextNodes(document.createElement("div"));
-injectTextNodes(document.createElement("div"), "width: 0px");
-injectTextNodes(document.createElement("div"), "width: 10px");
-injectTextNodes(document.createElement("div"), "width: 100px");
-injectTextNodes(document.createElement("pre"));
-</script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkLayoutTestsfasttextsimplelinewithmultiplerenderershtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers.html (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers.html        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers.html        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -1,34 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<head>
-<title>Test that segments across multiple renderers work fine with simple line layout.</title>
-</head>
-<body>
-<script>
-function injectTextNodes(container, style)
-{
-        container.appendChild(document.createTextNode("         "));
-        container.appendChild(document.createTextNode("        "));
-        container.appendChild(document.createTextNode("        This tests "));
-        container.appendChild(document.createTextNode("          "));
-        container.appendChild(document.createTextNode("whitespace                 overlapping "));
-        container.appendChild(document.createTextNode("        multiple "));
-        container.appendChild(document.createTextNode("                                renderers."));
-        container.appendChild(document.createTextNode("This tests when non-"));
-        container.appendChild(document.createTextNode("whitespace con"));
-        container.appendChild(document.createTextNode("tent o"));
-        container.appendChild(document.createTextNode("verla"));
-        container.appendChild(document.createTextNode("ps multiple ren"));
-        container.appendChild(document.createTextNode("deres."));
-        container.style.cssText = style;
-        document.body.appendChild(container);
-}
-
-injectTextNodes(document.createElement("div"));
-injectTextNodes(document.createElement("div"), "width: 0px");
-injectTextNodes(document.createElement("div"), "width: 10px");
-injectTextNodes(document.createElement("div"), "width: 100px");
-injectTextNodes(document.createElement("pre"));
-</script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/ChangeLog        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-03-17 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r181667, r181682, and r181683.
+ https://bugs.webkit.org/show_bug.cgi?id=142812
+
+ Broke multiple tests with ASan, plus dependent commits
+ (Requested by ap on #webkit).
+
+ Reverted changesets:
+
+ "Simple line layout: Split fragments on renderer boundary on
+ the fly."
+ https://bugs.webkit.org/show_bug.cgi?id=142579
+ http://trac.webkit.org/changeset/181667
+
+ "Simple line layout: Change FlowContents::segmentForPosition()
+ to segmentForRun()."
+ https://bugs.webkit.org/show_bug.cgi?id=142785
+ http://trac.webkit.org/changeset/181682
+
+ "Simple line layout: Use Vector<>::const_iterator instead of
+ custom FlowContents::Iterator."
+ https://bugs.webkit.org/show_bug.cgi?id=142809
+ http://trac.webkit.org/changeset/181683
+
</ins><span class="cx"> 2015-03-17 Zalan Bujtas <zalan@apple.com>
</span><span class="cx">
</span><span class="cx"> Simple line layout: Use Vector<>::const_iterator instead of custom FlowContents::Iterator.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -231,27 +231,9 @@
</span><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void revertRuns(Layout::RunVector& runs, unsigned length, float width)
-{
- ASSERT(runs.size());
- while (length) {
- Run& lastRun = runs.last();
- unsigned lastRunLength = lastRun.end - lastRun.start;
- if (lastRunLength > length) {
- lastRun.logicalRight -= width;
- lastRun.end -= length;
- break;
- }
- runs.removeLast();
- length -= lastRunLength;
- width -= (lastRun.logicalRight - lastRun.logicalLeft);
- }
-}
-
</del><span class="cx"> class LineState {
</span><span class="cx"> public:
</span><span class="cx"> void setAvailableWidth(float width) { m_availableWidth = width; }
</span><del>- void setCollapedWhitespaceWidth(float width) { m_collapsedWhitespaceWidth = width; }
</del><span class="cx"> void setLogicalLeftOffset(float offset) { m_logicalLeftOffset = offset; }
</span><span class="cx"> void setOverflowedFragment(const TextFragmentIterator::TextFragment& fragment) { m_overflowedFragment = fragment; }
</span><span class="cx">
</span><span class="lines">@@ -259,51 +241,25 @@
</span><span class="cx"> float logicalLeftOffset() const { return m_logicalLeftOffset; }
</span><span class="cx"> const TextFragmentIterator::TextFragment& overflowedFragment() const { return m_overflowedFragment; }
</span><span class="cx"> bool hasTrailingWhitespace() const { return m_trailingWhitespaceLength; }
</span><del>- TextFragmentIterator::TextFragment lastFragment() const { return m_fragments.last(); }
</del><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><del>- bool isEmpty() const
- {
- if (!m_fragments.size())
- return true;
- if (!m_lastCompleteFragment.isEmpty())
- return false;
- return m_fragments.last().overlapsToNextRenderer();
- }
</del><span class="cx">
</span><del>- void appendFragmentAndCreateRunIfNeeded(const TextFragmentIterator::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><del>- // New line needs new run.
- if (!m_runsWidth)
</del><ins>+
+ if (m_createNewRun)
</ins><span class="cx"> runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false));
</span><span class="cx"> else {
</span><del>- const auto& lastFragment = m_fragments.last();
- // Advance last completed fragment when the previous fragment is all set (including multiple parts across renderers)
- if ((lastFragment.type() != fragment.type()) || !lastFragment.overlapsToNextRenderer())
- m_lastCompleteFragment = lastFragment;
- // Collapse neighbouring whitespace, if they are across multiple renderers and are not collapsed yet.
- if (lastFragment.isCollapsible() && fragment.isCollapsible()) {
- ASSERT(lastFragment.isLastInRenderer());
- if (!lastFragment.isCollapsed()) {
- // Line width needs to be reset so that now it takes collapsing into consideration.
- m_runsWidth -= (lastFragment.width() - m_collapsedWhitespaceWidth);
- }
- // This fragment is collapsed completely. No run is needed.
- return;
- }
- if (lastFragment.isLastInRenderer() || lastFragment.isCollapsed())
- runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false));
- else {
- Run& lastRun = runs.last();
- lastRun.end = endPosition;
- lastRun.logicalRight += fragment.width();
- }
</del><ins>+ ASSERT(runs.size());
+ Run& lastRun = runs.last();
+ lastRun.end = endPosition;
+ lastRun.logicalRight = m_runsWidth + fragment.width();
</ins><span class="cx"> }
</span><del>- m_fragments.append(fragment);
</del><ins>+ m_createNewRun = fragment.isCollapsed();
</ins><span class="cx"> m_runsWidth += fragment.width();
</span><span class="cx">
</span><span class="cx"> if (fragment.type() == TextFragmentIterator::TextFragment::Whitespace) {
</span><span class="lines">@@ -318,34 +274,18 @@
</span><span class="cx"> m_firstCharacterFits = fragment.start() + 1 > endPosition || m_runsWidth <= m_availableWidth;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- TextFragmentIterator::TextFragment revertToLastCompleteFragment(Layout::RunVector& runs)
- {
- ASSERT(m_fragments.size());
- unsigned revertLength = 0;
- float revertWidth = 0;
- while (m_fragments.size()) {
- const auto& current = m_fragments.last();
- if (current == m_lastCompleteFragment)
- break;
- revertLength += current.end() - current.start();
- revertWidth += current.width();
- m_fragments.removeLast();
- }
- m_runsWidth -= revertWidth;
- if (revertLength)
- revertRuns(runs, revertLength, revertWidth);
- return m_lastCompleteFragment;
- }
-
</del><span class="cx"> void removeTrailingWhitespace(Layout::RunVector& runs)
</span><span class="cx"> {
</span><del>- // FIXME: sync m_fragment, but it's ok for now as we don't use m_fragment anymore after removeTrailingWhitespace.
- if (!m_trailingWhitespaceLength)
- return;
- revertRuns(runs, m_trailingWhitespaceLength, m_trailingWhitespaceWidth);
</del><ins>+ ASSERT(runs.size());
+ Run& lastRun = runs.last();
+ lastRun.logicalRight -= m_trailingWhitespaceWidth;
+ lastRun.end -= m_trailingWhitespaceLength;
+ if (lastRun.start == lastRun.end)
+ runs.removeLast();
+
</ins><span class="cx"> m_runsWidth -= m_trailingWhitespaceWidth;
</span><del>- m_trailingWhitespaceLength = 0;
</del><span class="cx"> m_trailingWhitespaceWidth = 0;
</span><ins>+ m_trailingWhitespaceLength = 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -353,14 +293,12 @@
</span><span class="cx"> float m_logicalLeftOffset { 0 };
</span><span class="cx"> TextFragmentIterator::TextFragment m_overflowedFragment;
</span><span class="cx"> float m_runsWidth { 0 };
</span><del>- TextFragmentIterator::TextFragment m_lastCompleteFragment;
</del><ins>+ bool m_createNewRun { true };
</ins><span class="cx"> float m_trailingWhitespaceWidth { 0 }; // Use this to remove trailing whitespace without re-mesuring the text.
</span><span class="cx"> unsigned m_trailingWhitespaceLength { 0 };
</span><del>- float m_collapsedWhitespaceWidth { 0 };
</del><span class="cx"> // Having one character on the line does not necessarily mean it actually fits.
</span><span class="cx"> // First character of the first fragment might be forced on to the current line even if it does not fit.
</span><span class="cx"> bool m_firstCharacterFits { false };
</span><del>- Vector<TextFragmentIterator::TextFragment> m_fragments;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> class FragmentForwardIterator : public std::iterator<std::forward_iterator_tag, unsigned> {
</span><span class="lines">@@ -451,36 +389,14 @@
</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) {
- while (firstFragment.type() == TextFragmentIterator::TextFragment::Whitespace)
- firstFragment = textFragmentIterator.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 void forceFragmentToLine(LineState& line, TextFragmentIterator& textFragmentIterator, Layout::RunVector& runs, const TextFragmentIterator::TextFragment& fragment)
-{
- line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
- // Check if there are more fragments to add to the current line.
- if (!fragment.overlapsToNextRenderer())
- return;
- auto nextFragment = textFragmentIterator.nextTextFragment();
- while (true) {
- if (nextFragment.type() != fragment.type())
- break;
- line.appendFragmentAndCreateRunIfNeeded(nextFragment, runs);
- // Does it overlap to the next segment?
- if (!nextFragment.overlapsToNextRenderer())
- return;
- nextFragment = textFragmentIterator.nextTextFragment();
- }
- line.setOverflowedFragment(nextFragment);
-}
-
</del><span class="cx"> static bool createLineRuns(LineState& line, const LineState& previousLine, Layout::RunVector& runs, TextFragmentIterator& textFragmentIterator)
</span><span class="cx"> {
</span><span class="cx"> const auto& style = textFragmentIterator.style();
</span><del>- line.setCollapedWhitespaceWidth(style.spaceWidth);
</del><span class="cx"> bool lineCanBeWrapped = style.wrapLines || style.breakWordOnOverflow;
</span><span class="cx"> auto fragment = firstFragment(textFragmentIterator, previousLine);
</span><span class="cx"> while (fragment.type() != TextFragmentIterator::TextFragment::ContentEnd) {
</span><span class="lines">@@ -488,7 +404,7 @@
</span><span class="cx"> if (fragment.type() == TextFragmentIterator::TextFragment::LineBreak) {
</span><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><del>- line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
</del><ins>+ line.appendFragment(fragment, runs);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> if (lineCanBeWrapped && !line.fits(fragment.width())) {
</span><span class="lines">@@ -497,13 +413,13 @@
</span><span class="cx"> // 2. Whitespace collapse off: whitespace is wrapped.
</span><span class="cx"> // 3. First, non-whitespace fragment is either wrapped or kept on the line. (depends on overflow-wrap)
</span><span class="cx"> // 4. Non-whitespace fragment when there's already another fragment on the line gets pushed to the next line.
</span><del>- bool emptyLine = line.isEmpty();
</del><ins>+ bool emptyLine = !line.width();
</ins><span class="cx"> // Whitespace fragment.
</span><span class="cx"> if (fragment.type() == TextFragmentIterator::TextFragment::Whitespace) {
</span><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><span class="cx"> line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, textFragmentIterator));
</span><del>- line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
</del><ins>+ line.appendFragment(fragment, runs);
</ins><span class="cx"> }
</span><span class="cx"> // When whitespace collapse is on, whitespace that doesn't fit is simply skipped.
</span><span class="cx"> break;
</span><span class="lines">@@ -512,30 +428,23 @@
</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><span class="cx"> line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, textFragmentIterator));
</span><del>- line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
</del><ins>+ line.appendFragment(fragment, runs);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> // Non-breakable non-whitespace first fragment. Add it to the current line. -it overflows though.
</span><del>- ASSERT(fragment.type() == TextFragmentIterator::TextFragment::NonWhitespace);
</del><span class="cx"> if (emptyLine) {
</span><del>- forceFragmentToLine(line, textFragmentIterator, runs, fragment);
</del><ins>+ line.appendFragment(fragment, runs);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> // Non-breakable non-whitespace fragment when there's already content on the line. Push it to the next line.
</span><del>- if (line.lastFragment().overlapsToNextRenderer()) {
- // Check if this fragment is a continuation of a previous segment. In such cases, we need to remove them all.
- const auto& currentFragment = line.revertToLastCompleteFragment(runs);
- textFragmentIterator.revertToFragment(currentFragment);
- break;
- }
</del><span class="cx"> line.setOverflowedFragment(fragment);
</span><span class="cx"> break;
</span><span class="cx"> }
</span><del>- line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
</del><ins>+ line.appendFragment(fragment, runs);
</ins><span class="cx"> // Find the next text fragment.
</span><span class="cx"> fragment = textFragmentIterator.nextTextFragment(line.width());
</span><span class="cx"> }
</span><del>- return (fragment.type() == TextFragmentIterator::TextFragment::ContentEnd && line.overflowedFragment().isEmpty()) || line.overflowedFragment().type() == TextFragmentIterator::TextFragment::ContentEnd;
</del><ins>+ return fragment.type() == TextFragmentIterator::TextFragment::ContentEnd && line.overflowedFragment().isEmpty();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void closeLineEndingAndAdjustRuns(LineState& line, Layout::RunVector& runs, unsigned previousRunCount, unsigned& lineCount, const TextFragmentIterator& textFragmentIterator)
</span><span class="lines">@@ -557,6 +466,28 @@
</span><span class="cx"> ++lineCount;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void splitRunsAtRendererBoundary(Layout::RunVector& lineRuns, const TextFragmentIterator& textFragmentIterator)
+{
+ // FIXME: We should probably split during run construction instead of as a separate pass.
+ if (lineRuns.isEmpty())
+ return;
+ unsigned runIndex = 0;
+ do {
+ const Run& run = lineRuns.at(runIndex);
+ ASSERT(run.start != run.end);
+ auto& startSegment = textFragmentIterator.segmentForPosition(run.start);
+ if (run.end <= startSegment.end)
+ continue;
+ // This run overlaps multiple renderers. Split it up.
+ // 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.
+ float logicalRightOfLeftRun = run.logicalLeft + textFragmentIterator.textWidth(run.start, startSegment.end, run.logicalLeft);
+ lineRuns.insert(runIndex, Run(run.start, startSegment.end, run.logicalLeft, logicalRightOfLeftRun, false));
+ Run& rightSideRun = lineRuns.at(runIndex + 1);
+ rightSideRun.start = startSegment.end;
+ rightSideRun.logicalLeft = logicalRightOfLeftRun;
+ } while (++runIndex < lineRuns.size());
+}
+
</ins><span class="cx"> static void createTextRuns(Layout::RunVector& runs, RenderBlockFlow& flow, unsigned& lineCount)
</span><span class="cx"> {
</span><span class="cx"> LayoutUnit borderAndPaddingBefore = flow.borderAndPaddingBefore();
</span><span class="lines">@@ -574,6 +505,9 @@
</span><span class="cx"> isEndOfContent = createLineRuns(line, previousLine, runs, textFragmentIterator);
</span><span class="cx"> closeLineEndingAndAdjustRuns(line, runs, previousRunCount, lineCount, textFragmentIterator);
</span><span class="cx"> } while (!isEndOfContent);
</span><ins>+
+ if (flow.firstChild() != flow.lastChild())
+ 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="trunkSourceWebCorerenderingSimpleLineLayoutFlowContentscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.cpp        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -51,13 +51,12 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-unsigned FlowContents::segmentIndexForRunSlow(unsigned start, unsigned end) const
</del><ins>+unsigned FlowContents::segmentIndexForPositionSlow(unsigned position) const
</ins><span class="cx"> {
</span><del>- auto it = std::lower_bound(m_segments.begin(), m_segments.end(), start, [](const Segment& segment, unsigned start) {
- return segment.end <= start;
</del><ins>+ auto it = std::lower_bound(m_segments.begin(), m_segments.end(), position, [](const Segment& segment, unsigned position) {
+ return segment.end <= position;
</ins><span class="cx"> });
</span><span class="cx"> ASSERT(it != m_segments.end());
</span><del>- ASSERT_UNUSED(end, end <= it->end);
</del><span class="cx"> auto index = it - m_segments.begin();
</span><span class="cx"> m_lastSegmentIndex = index;
</span><span class="cx"> return index;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -43,29 +43,72 @@
</span><span class="cx"> String text;
</span><span class="cx"> const RenderObject& renderer;
</span><span class="cx"> };
</span><del>- const Segment& segmentForRun(unsigned start, unsigned end) const;
</del><ins>+ const Segment& segmentForPosition(unsigned) const;
</ins><span class="cx"> const Segment& segmentForRenderer(const RenderObject&) const;
</span><span class="cx">
</span><del>- typedef Vector<Segment, 8>::const_iterator Iterator;
- Iterator begin() const { return m_segments.begin(); }
- Iterator end() const { return m_segments.end(); }
</del><ins>+ class Iterator {
+ public:
+ Iterator(const FlowContents& flowContents, unsigned segmentIndex)
+ : m_flowContents(flowContents)
+ , m_segmentIndex(segmentIndex)
+ {
+ }
</ins><span class="cx">
</span><ins>+ Iterator& operator++();
+ bool operator==(const Iterator& other) const;
+ bool operator!=(const Iterator& other) const;
+ const Segment& operator*() const { return m_flowContents.m_segments[m_segmentIndex]; }
+
+ private:
+ const FlowContents& m_flowContents;
+ unsigned m_segmentIndex;
+ };
+
+ Iterator begin() const { return Iterator(*this, 0); }
+ Iterator end() const { return Iterator(*this, m_segments.size()); }
+
+ unsigned length() const { return m_segments.last().end; };
+
+ unsigned segmentIndexForPosition(unsigned position) const;
+
</ins><span class="cx"> private:
</span><del>- unsigned segmentIndexForRunSlow(unsigned start, unsigned end) const;
</del><ins>+ unsigned segmentIndexForPositionSlow(unsigned position) const;
+
</ins><span class="cx"> const Vector<Segment, 8> m_segments;
</span><ins>+
</ins><span class="cx"> mutable unsigned m_lastSegmentIndex;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-inline const FlowContents::Segment& FlowContents::segmentForRun(unsigned start, unsigned end) const
</del><ins>+inline FlowContents::Iterator& FlowContents::Iterator::operator++()
</ins><span class="cx"> {
</span><del>- ASSERT(start < end);
</del><ins>+ ++m_segmentIndex;
+ return *this;
+}
+
+inline bool FlowContents::Iterator::operator==(const FlowContents::Iterator& other) const
+{
+ return m_segmentIndex == other.m_segmentIndex;
+}
+
+inline bool FlowContents::Iterator::operator!=(const FlowContents::Iterator& other) const
+{
+ return !(*this == other);
+}
+
+inline unsigned FlowContents::segmentIndexForPosition(unsigned position) const
+{
</ins><span class="cx"> auto& lastSegment = m_segments[m_lastSegmentIndex];
</span><del>- if (lastSegment.start <= start && end <= lastSegment.end)
- return m_segments[m_lastSegmentIndex];
- return m_segments[segmentIndexForRunSlow(start, end)];
</del><ins>+ if (lastSegment.start <= position && position < lastSegment.end)
+ return m_lastSegmentIndex;
+ return segmentIndexForPositionSlow(position);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+inline const FlowContents::Segment& FlowContents::segmentForPosition(unsigned position) const
+{
+ return m_segments[segmentIndexForPosition(position)];
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> }
</span><ins>+}
</ins><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFunctionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -84,7 +84,6 @@
</span><span class="cx"> continue;
</span><span class="cx"> TextRun textRun(run.text());
</span><span class="cx"> textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
</span><del>- textRun.setXPos(run.rect().x());
</del><span class="cx"> FloatPoint textOrigin = run.baseline() + paintOffset;
</span><span class="cx"> textOrigin.setY(roundToDevicePixel(LayoutUnit(textOrigin.y()), flow.document().deviceScaleFactor()));
</span><span class="cx"> context.drawText(font, textRun, textOrigin);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -76,8 +76,7 @@
</span><span class="cx"> {
</span><span class="cx"> auto& resolver = m_iterator.resolver();
</span><span class="cx"> auto& run = m_iterator.simpleRun();
</span><del>- ASSERT(run.start < run.end);
- auto& segment = resolver.m_flowContents.segmentForRun(run.start, run.end);
</del><ins>+ auto& segment = resolver.m_flowContents.segmentForPosition(run.start);
</ins><span class="cx"> // We currently split runs on segment boundaries (different RenderObject).
</span><span class="cx"> ASSERT(run.end <= segment.end);
</span><span class="cx"> if (segment.text.is8Bit())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -48,8 +48,7 @@
</span><span class="cx">
</span><span class="cx"> TextFragmentIterator::TextFragmentIterator(const RenderBlockFlow& flow)
</span><span class="cx"> : m_flowContents(flow)
</span><del>- , m_currentSegment(m_flowContents.begin())
- , m_lineBreakIterator(m_currentSegment->text, flow.style().locale())
</del><ins>+ , m_lineBreakIterator((*m_flowContents.begin()).text, flow.style().locale())
</ins><span class="cx"> , m_style(flow.style())
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -61,135 +60,115 @@
</span><span class="cx"> // 2. whitespace (collasped, non-collapsed multi or single) or
</span><span class="cx"> // 3. non-whitespace characters.
</span><span class="cx"> // 4. empty, indicating content end.
</span><del>- ASSERT(m_currentSegment != m_flowContents.end());
- if (m_position == m_currentSegment->end)
- ++m_currentSegment;
- // Is it content end?
- if (m_currentSegment == m_flowContents.end())
</del><ins>+ if (isEnd(m_position))
</ins><span class="cx"> return TextFragment(m_position, m_position, 0, TextFragment::ContentEnd);
</span><del>- unsigned segmentEndPosition = m_currentSegment->end;
- unsigned startPosition = m_position;
</del><span class="cx"> if (isLineBreak(m_position)) {
</span><del>- unsigned endPosition = ++m_position;
- return TextFragment(startPosition, endPosition, 0, TextFragment::LineBreak);
</del><ins>+ TextFragment fragment(m_position, m_position + 1, 0, TextFragment::LineBreak);
+ ++m_position;
+ return fragment;
</ins><span class="cx"> }
</span><del>- float width = 0;
- bool overlappingFragment = false;
- unsigned endPosition = skipToNextPosition(PositionType::NonWhitespace, startPosition, width, xPosition, overlappingFragment);
</del><ins>+ unsigned startPosition = m_position;
+ unsigned endPosition = skipToNextPosition(PositionType::NonWhitespace, startPosition);
</ins><span class="cx"> ASSERT(startPosition <= endPosition);
</span><del>- if (startPosition < endPosition) {
</del><ins>+ if (endPosition > startPosition) {
</ins><span class="cx"> bool multipleWhitespace = startPosition + 1 < endPosition;
</span><span class="cx"> bool isCollapsed = multipleWhitespace && m_style.collapseWhitespace;
</span><span class="cx"> bool isBreakable = !isCollapsed && multipleWhitespace;
</span><ins>+ float width = isCollapsed ? m_style.spaceWidth : textWidth(startPosition, endPosition, xPosition);
</ins><span class="cx"> m_position = endPosition;
</span><del>- return TextFragment(startPosition, endPosition, width, TextFragment::Whitespace, endPosition == segmentEndPosition, false, isCollapsed, m_style.collapseWhitespace, isBreakable);
</del><ins>+ return TextFragment(startPosition, endPosition, width, TextFragment::Whitespace, isCollapsed, isBreakable);
</ins><span class="cx"> }
</span><del>- endPosition = skipToNextPosition(PositionType::Breakable, startPosition, width, xPosition, overlappingFragment);
</del><ins>+ endPosition = skipToNextPosition(PositionType::Breakable, startPosition + 1);
</ins><span class="cx"> m_position = endPosition;
</span><del>- return TextFragment(startPosition, endPosition, width, TextFragment::NonWhitespace, endPosition == segmentEndPosition, overlappingFragment, false, false, m_style.breakWordOnOverflow);
</del><ins>+ return TextFragment(startPosition, endPosition, textWidth(startPosition, endPosition, xPosition), TextFragment::NonWhitespace, false, m_style.breakWordOnOverflow);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void TextFragmentIterator::revertToFragment(const TextFragment& fragment)
</del><ins>+float TextFragmentIterator::textWidth(unsigned from, unsigned to, float xPosition) const
</ins><span class="cx"> {
</span><del>- ASSERT(m_position >= fragment.end());
- ASSERT(fragment.start() >= 0);
- // Revert segment first.
- while (m_currentSegment->start > fragment.start())
- --m_currentSegment;
- // TODO: It reverts to the last fragment on the same position, but that's ok for now as we don't need to
- // differentiate multiple renderers on the same position.
- m_position = fragment.start();
</del><ins>+ const auto& fromSegment = m_flowContents.segmentForPosition(from);
+ ASSERT(is<RenderText>(fromSegment.renderer));
+ if ((m_style.font.isFixedPitch() && fromSegment.end >= to) || (from == fromSegment.start && to == fromSegment.end))
+ return downcast<RenderText>(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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename CharacterType>
</span><del>-unsigned TextFragmentIterator::nextBreakablePosition(const FlowContents::Segment& segment, unsigned startPosition)
</del><ins>+static unsigned nextBreakablePosition(LazyLineBreakIterator& lineBreakIterator, const FlowContents::Segment& segment, unsigned startPosition)
</ins><span class="cx"> {
</span><del>- ASSERT(startPosition < segment.end);
- if (segment.text.impl() != m_lineBreakIterator.string().impl()) {
- const String& currentText = m_lineBreakIterator.string();
- unsigned textLength = currentText.length();
- UChar lastCharacter = textLength > 0 ? currentText[textLength - 1] : 0;
- UChar secondToLastCharacter = textLength > 1 ? currentText[textLength - 2] : 0;
- m_lineBreakIterator.setPriorContext(lastCharacter, secondToLastCharacter);
- m_lineBreakIterator.resetStringAndReleaseIterator(segment.text, m_style.locale, LineBreakIteratorModeUAX14);
- }
- const auto* characters = segment.text.characters<CharacterType>();
- unsigned segmentLength = segment.end - segment.start;
- unsigned segmentPosition = startPosition - segment.start;
- return segment.start + nextBreakablePositionNonLoosely<CharacterType, NBSPBehavior::IgnoreNBSP>(m_lineBreakIterator, characters, segmentLength, segmentPosition);
</del><ins>+ return nextBreakablePositionNonLoosely<CharacterType, NBSPBehavior::IgnoreNBSP>(lineBreakIterator, segment.text.characters<CharacterType>(), segment.end - segment.start, startPosition);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename CharacterType>
</span><del>-unsigned TextFragmentIterator::nextNonWhitespacePosition(const FlowContents::Segment& segment, unsigned startPosition)
</del><ins>+static unsigned nextNonWhitespacePosition(const FlowContents::Segment& segment, unsigned startPosition, const TextFragmentIterator::Style& style)
</ins><span class="cx"> {
</span><del>- ASSERT(startPosition < segment.end);
</del><span class="cx"> const auto* text = segment.text.characters<CharacterType>();
</span><span class="cx"> unsigned position = startPosition;
</span><del>- for (; position < segment.end; ++position) {
- auto character = text[position - segment.start];
- bool isWhitespace = character == ' ' || character == '\t' || (!m_style.preserveNewline && character == '\n');
</del><ins>+ unsigned length = segment.end - segment.start;
+ for (; position < length; ++position) {
+ auto character = text[position];
+ bool isWhitespace = character == ' ' || character == '\t' || (!style.preserveNewline && character == '\n');
</ins><span class="cx"> if (!isWhitespace)
</span><span class="cx"> return position;
</span><span class="cx"> }
</span><span class="cx"> return position;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-float TextFragmentIterator::textWidth(unsigned from, unsigned to, float xPosition) const
</del><ins>+unsigned TextFragmentIterator::skipToNextPosition(PositionType positionType, unsigned startPosition) const
</ins><span class="cx"> {
</span><del>- auto& segment = *m_currentSegment;
- ASSERT(segment.start <= from && from <= segment.end && segment.start <= to && to <= segment.end);
- ASSERT(is<RenderText>(segment.renderer));
- if (m_style.font.isFixedPitch() || (from == segment.start && to == segment.end))
- return downcast<RenderText>(segment.renderer).width(from - segment.start, to - from, m_style.font, xPosition, nullptr, nullptr);
- return segment.text.is8Bit() ? runWidth<LChar>(segment, from, to, xPosition) : runWidth<UChar>(segment, from, to, xPosition);
-}
</del><ins>+ if (isEnd(startPosition))
+ return startPosition;
</ins><span class="cx">
</span><del>-unsigned TextFragmentIterator::skipToNextPosition(PositionType positionType, unsigned startPosition, float& width, float xPosition, bool& overlappingFragment)
-{
- overlappingFragment = false;
</del><span class="cx"> unsigned currentPosition = startPosition;
</span><del>- unsigned nextPosition = currentPosition;
- // Collapsed whitespace has constant width. Do not measure it.
- if (positionType == NonWhitespace)
- nextPosition = m_currentSegment->text.is8Bit() ? nextNonWhitespacePosition<LChar>(*m_currentSegment, currentPosition) : nextNonWhitespacePosition<UChar>(*m_currentSegment, currentPosition);
- else if (positionType == Breakable) {
- // nextBreakablePosition returns the same position for certain characters such as hyphens. Call next again with modified position unless it's the end of the segment.
- nextPosition = m_currentSegment->text.is8Bit() ? nextBreakablePosition<LChar>(*m_currentSegment, currentPosition) : nextBreakablePosition<UChar>(*m_currentSegment, currentPosition);
- // We need to know whether the word actually finishes at the end of this renderer or not.
- if (nextPosition == m_currentSegment->end) {
- const auto nextSegment = m_currentSegment + 1;
- if (nextSegment != m_flowContents.end())
- overlappingFragment = nextPosition < (nextSegment->text.is8Bit() ? nextBreakablePosition<LChar>(*nextSegment, nextPosition) : nextBreakablePosition<UChar>(*nextSegment, nextPosition));
- } else if (nextPosition == currentPosition) {
- if (++nextPosition < m_currentSegment->end)
- nextPosition = m_currentSegment->text.is8Bit() ? nextBreakablePosition<LChar>(*m_currentSegment, currentPosition + 1) : nextBreakablePosition<UChar>(*m_currentSegment, currentPosition + 1);
- }
</del><ins>+ FlowContents::Iterator it(m_flowContents, m_flowContents.segmentIndexForPosition(currentPosition));
+ for (auto end = m_flowContents.end(); it != end; ++it) {
+ auto& segment = *it;
+ unsigned currentPositonRelativeToSegment = currentPosition - segment.start;
+ unsigned nextPositionRelativeToSegment = 0;
+ if (positionType == NonWhitespace) {
+ nextPositionRelativeToSegment = segment.text.is8Bit() ? nextNonWhitespacePosition<LChar>(segment, currentPositonRelativeToSegment, m_style) :
+ nextNonWhitespacePosition<UChar>(segment, currentPositonRelativeToSegment, m_style);
+ } else if (positionType == Breakable) {
+ 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);
+ }
+ nextPositionRelativeToSegment = segment.text.is8Bit() ? nextBreakablePosition<LChar>(m_lineBreakIterator, segment, currentPositonRelativeToSegment) :
+ nextBreakablePosition<UChar>(m_lineBreakIterator, segment, currentPositonRelativeToSegment);
+ } else
+ ASSERT_NOT_REACHED();
+ currentPosition = segment.start + nextPositionRelativeToSegment;
+ if (currentPosition < segment.end)
+ break;
</ins><span class="cx"> }
</span><del>- width = 0;
- if (nextPosition == currentPosition)
- return currentPosition;
- bool measureText = positionType != NonWhitespace || !m_style.collapseWhitespace;
- if (measureText) {
- float textWidth = this->textWidth(currentPosition, nextPosition, xPosition);
- xPosition += textWidth;
- width += textWidth;
- } else if (startPosition < nextPosition)
- width = m_style.spaceWidth;
- return nextPosition;
</del><ins>+ return currentPosition;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename CharacterType>
</span><del>-float TextFragmentIterator::runWidth(const FlowContents::Segment& segment, unsigned startPosition, unsigned endPosition, float xPosition) const
</del><ins>+float TextFragmentIterator::runWidth(const String& text, unsigned from, unsigned to, float xPosition) const
</ins><span class="cx"> {
</span><del>- ASSERT(startPosition <= endPosition);
- if (startPosition == endPosition)
</del><ins>+ ASSERT(from <= to);
+ if (from == to)
</ins><span class="cx"> return 0;
</span><del>- unsigned segmentFrom = startPosition - segment.start;
- unsigned segmentTo = endPosition - segment.start;
- bool measureWithEndSpace = m_style.collapseWhitespace && segmentTo < segment.text.length() && segment.text[segmentTo] == ' ';
</del><ins>+ bool measureWithEndSpace = m_style.collapseWhitespace && to < text.length() && text[to] == ' ';
</ins><span class="cx"> if (measureWithEndSpace)
</span><del>- ++segmentTo;
- TextRun run(segment.text.characters<CharacterType>() + segmentFrom, segmentTo - segmentFrom);
</del><ins>+ ++to;
+ TextRun run(text.characters<CharacterType>() + from, to - from);
</ins><span class="cx"> run.setXPos(xPosition);
</span><span class="cx"> run.setTabSize(!!m_style.tabWidth, m_style.tabWidth);
</span><span class="cx"> float width = m_style.font.width(run);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutTextFragmentIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h (181684 => 181685)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h        2015-03-18 05:38:20 UTC (rev 181684)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h        2015-03-18 06:09:56 UTC (rev 181685)
</span><span class="lines">@@ -43,15 +43,12 @@
</span><span class="cx"> public:
</span><span class="cx"> enum Type { ContentEnd, LineBreak, Whitespace, NonWhitespace };
</span><span class="cx"> TextFragment() = default;
</span><del>- TextFragment(unsigned start, unsigned end, float width, Type type, bool isLastInRenderer = false, bool overlapsToNextRenderer = false, bool isCollapsed = false, bool isCollapsible = false, bool isBreakable = false)
</del><ins>+ TextFragment(unsigned start, unsigned end, float width, Type type, bool isCollapsed = false, bool isBreakable = false)
</ins><span class="cx"> : m_start(start)
</span><span class="cx"> , m_end(end)
</span><del>- , m_width(width)
</del><span class="cx"> , m_type(type)
</span><del>- , m_isLastInRenderer(isLastInRenderer)
- , m_overlapsToNextRenderer(overlapsToNextRenderer)
</del><ins>+ , m_width(width)
</ins><span class="cx"> , m_isCollapsed(isCollapsed)
</span><del>- , m_isCollapsible(isCollapsible)
</del><span class="cx"> , m_isBreakable(isBreakable)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -60,41 +57,22 @@
</span><span class="cx"> unsigned end() const { return m_end; }
</span><span class="cx"> float width() const { return m_width; }
</span><span class="cx"> Type type() const { return m_type; }
</span><del>- bool isLastInRenderer() const { return m_isLastInRenderer; }
- bool overlapsToNextRenderer() const { return m_overlapsToNextRenderer; }
</del><span class="cx"> bool isCollapsed() const { return m_isCollapsed; }
</span><del>- bool isCollapsible() const { return m_isCollapsible; }
</del><span class="cx"> bool isBreakable() const { return m_isBreakable; }
</span><span class="cx">
</span><span class="cx"> bool isEmpty() const { return start() == end(); }
</span><span class="cx"> TextFragment split(unsigned splitPosition, const TextFragmentIterator&);
</span><del>- bool operator==(const TextFragment& other) const
- {
- return m_start == other.m_start
- && m_end == other.m_end
- && m_width == other.m_width
- && m_type == other.m_type
- && m_isLastInRenderer == other.m_isLastInRenderer
- && m_overlapsToNextRenderer == other.m_overlapsToNextRenderer
- && m_isCollapsed == other.m_isCollapsed
- && m_isCollapsible == other.m_isCollapsible
- && m_isBreakable == other.m_isBreakable;
- }
</del><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> unsigned m_start { 0 };
</span><span class="cx"> unsigned m_end { 0 };
</span><del>- float m_width { 0 };
</del><span class="cx"> Type m_type { NonWhitespace };
</span><del>- bool m_isLastInRenderer { false };
- bool m_overlapsToNextRenderer { false };
</del><ins>+ float m_width { 0 };
</ins><span class="cx"> bool m_isCollapsed { false };
</span><del>- bool m_isCollapsible { false };
</del><span class="cx"> bool m_isBreakable { false };
</span><span class="cx"> };
</span><span class="cx"> TextFragment nextTextFragment(float xPosition = 0);
</span><del>- void revertToFragment(const TextFragment&);
- float textWidth(unsigned startPosition, unsigned endPosition, float xPosition) const;
</del><ins>+ float textWidth(unsigned from, unsigned to, float xPosition) const;
</ins><span class="cx">
</span><span class="cx"> struct Style {
</span><span class="cx"> explicit Style(const RenderStyle&);
</span><span class="lines">@@ -110,18 +88,19 @@
</span><span class="cx"> AtomicString locale;
</span><span class="cx"> };
</span><span class="cx"> const Style& style() const { return m_style; }
</span><ins>+ // FIXME: remove splitRunsAtRendererBoundary()
+ const FlowContents::Segment& segmentForPosition(unsigned position) const { return m_flowContents.segmentForPosition(position); };
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> enum PositionType { Breakable, NonWhitespace };
</span><del>- unsigned skipToNextPosition(PositionType, unsigned startPosition, float& width, float xPosition, bool& overlappingFragment);
</del><ins>+ unsigned skipToNextPosition(PositionType, unsigned startPosition) const;
+ UChar characterAt(unsigned position) const;
</ins><span class="cx"> bool isLineBreak(unsigned position) const;
</span><del>- template <typename CharacterType> unsigned nextBreakablePosition(const FlowContents::Segment&, unsigned startPosition);
- template <typename CharacterType> unsigned nextNonWhitespacePosition(const FlowContents::Segment&, unsigned startPosition);
- template <typename CharacterType> float runWidth(const FlowContents::Segment&, unsigned startPosition, unsigned endPosition, float xPosition) const;
</del><ins>+ bool isEnd(unsigned position) const;
+ template <typename CharacterType> float runWidth(const String&, unsigned from, unsigned to, float xPosition) const;
</ins><span class="cx">
</span><span class="cx"> FlowContents m_flowContents;
</span><del>- FlowContents::Iterator m_currentSegment;
- LazyLineBreakIterator m_lineBreakIterator;
</del><ins>+ mutable LazyLineBreakIterator m_lineBreakIterator;
</ins><span class="cx"> const Style m_style;
</span><span class="cx"> unsigned m_position { 0 };
</span><span class="cx"> };
</span><span class="lines">@@ -148,14 +127,25 @@
</span><span class="cx"> return newFragment;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline UChar TextFragmentIterator::characterAt(unsigned position) const
+{
+ auto& segment = m_flowContents.segmentForPosition(position);
+ return segment.text[position - segment.start];
+}
+
</ins><span class="cx"> inline bool TextFragmentIterator::isLineBreak(unsigned position) const
</span><span class="cx"> {
</span><del>- const auto& segment = *m_currentSegment;
- ASSERT(segment.start <= position && position < segment.end);
- return m_style.preserveNewline && segment.text[position - segment.start] == '\n';
</del><ins>+ if (isEnd(position))
+ return false;
+ return m_style.preserveNewline && characterAt(position) == '\n';
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+inline bool TextFragmentIterator::isEnd(unsigned position) const
+{
+ return position >= m_flowContents.length();
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> }
</span><ins>+}
</ins><span class="cx">
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>