<!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>[179438] 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/179438">179438</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2015-01-30 22:26:02 -0800 (Fri, 30 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Simple line layout: Improve FlowContentsIterator::TextFragment's encapsulation.
https://bugs.webkit.org/show_bug.cgi?id=141090

Reviewed by Andreas Kling.

Make members private to avoid accidental change in TextFragment.

No change in functionality.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::LineState::addFragment):
(WebCore::SimpleLineLayout::LineState::addWhitespace):
(WebCore::SimpleLineLayout::splitFragmentToFitLine):
(WebCore::SimpleLineLayout::firstFragment):
(WebCore::SimpleLineLayout::createLineRuns):
* rendering/SimpleLineLayoutFlowContentsIterator.cpp:
(WebCore::SimpleLineLayout::FlowContentsIterator::nextTextFragment):
* rendering/SimpleLineLayoutFlowContentsIterator.h:
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::TextFragment):
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::start):
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::end):
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::width):
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::type):
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::isCollapsed):
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::isBreakable):
(WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::isEmpty):</pre>

<h3>Modified Paths</h3>
<ul>
<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="#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="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179437 => 179438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-31 05:27:06 UTC (rev 179437)
+++ trunk/Source/WebCore/ChangeLog        2015-01-31 06:26:02 UTC (rev 179438)
</span><span class="lines">@@ -1,5 +1,34 @@
</span><span class="cx"> 2015-01-30  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Simple line layout: Improve FlowContentsIterator::TextFragment's encapsulation.
+        https://bugs.webkit.org/show_bug.cgi?id=141090
+
+        Reviewed by Andreas Kling.
+
+        Make members private to avoid accidental change in TextFragment.
+
+        No change in functionality.
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::LineState::addFragment):
+        (WebCore::SimpleLineLayout::LineState::addWhitespace):
+        (WebCore::SimpleLineLayout::splitFragmentToFitLine):
+        (WebCore::SimpleLineLayout::firstFragment):
+        (WebCore::SimpleLineLayout::createLineRuns):
+        * rendering/SimpleLineLayoutFlowContentsIterator.cpp:
+        (WebCore::SimpleLineLayout::FlowContentsIterator::nextTextFragment):
+        * rendering/SimpleLineLayoutFlowContentsIterator.h:
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::TextFragment):
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::start):
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::end):
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::width):
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::type):
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::isCollapsed):
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::isBreakable):
+        (WebCore::SimpleLineLayout::FlowContentsIterator::TextFragment::isEmpty):
+
+2015-01-30  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
</ins><span class="cx">         Simple line layout: Make LineState fragment handling simpler.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=141100
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (179437 => 179438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2015-01-31 05:27:06 UTC (rev 179437)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp        2015-01-31 06:26:02 UTC (rev 179438)
</span><span class="lines">@@ -235,7 +235,7 @@
</span><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>-    FlowContentsIterator::TextFragment overflowedFragment() const { return m_overflowedFragment; }
</del><ins>+    const FlowContentsIterator::TextFragment&amp; 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 &amp;&amp; m_runsWidth == m_trailingWhitespaceWidth; }
</span><span class="cx">     bool fits(float extra) const { return m_availableWidth &gt;= m_runsWidth + extra; }
</span><span class="lines">@@ -245,29 +245,29 @@
</span><span class="cx">     void appendFragment(const FlowContentsIterator::TextFragment&amp; fragment, Layout::RunVector&amp; runs)
</span><span class="cx">     {
</span><span class="cx">         // Adjust end position while collapsing.
</span><del>-        unsigned endPosition = fragment.isCollapsed ? fragment.start + 1 : fragment.end;
</del><ins>+        unsigned endPosition = fragment.isCollapsed() ? fragment.start() + 1 : fragment.end();
</ins><span class="cx"> 
</span><span class="cx">         if (m_createNewRun)
</span><del>-            runs.append(Run(fragment.start, endPosition, m_runsWidth, m_runsWidth + fragment.width, false));
</del><ins>+            runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false));
</ins><span class="cx">         else {
</span><span class="cx">             ASSERT(runs.size());
</span><span class="cx">             Run&amp; lastRun = runs.last();
</span><span class="cx">             lastRun.end = endPosition;
</span><del>-            lastRun.logicalRight = m_runsWidth + fragment.width;
</del><ins>+            lastRun.logicalRight = m_runsWidth + fragment.width();
</ins><span class="cx">         }
</span><del>-        m_createNewRun = fragment.isCollapsed;
-        m_runsWidth += fragment.width;
</del><ins>+        m_createNewRun = fragment.isCollapsed();
+        m_runsWidth += fragment.width();
</ins><span class="cx"> 
</span><del>-        if (fragment.type == FlowContentsIterator::TextFragment::Whitespace) {
-            m_trailingWhitespaceLength += endPosition - fragment.start;
-            m_trailingWhitespaceWidth += fragment.width;
</del><ins>+        if (fragment.type() == FlowContentsIterator::TextFragment::Whitespace) {
+            m_trailingWhitespaceLength += endPosition - fragment.start();
+            m_trailingWhitespaceWidth += fragment.width();
</ins><span class="cx">         } else {
</span><span class="cx">             m_trailingWhitespaceLength = 0;
</span><span class="cx">             m_trailingWhitespaceWidth = 0;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (!m_firstCharacterFits)
</span><del>-            m_firstCharacterFits = fragment.start + 1 &gt; fragment.end || m_runsWidth &lt;= m_availableWidth;
</del><ins>+            m_firstCharacterFits = fragment.start() + 1 &gt; endPosition || m_runsWidth &lt;= m_availableWidth;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void removeTrailingWhitespace(Layout::RunVector&amp; runs)
</span><span class="lines">@@ -331,23 +331,23 @@
</span><span class="cx"> static FlowContentsIterator::TextFragment splitFragmentToFitLine(FlowContentsIterator::TextFragment&amp; fragmentToSplit, float availableWidth, bool keepAtLeastOneCharacter, const FlowContentsIterator&amp; flowContentsIterator)
</span><span class="cx"> {
</span><span class="cx">     // Fast path for single char fragments.
</span><del>-    if (fragmentToSplit.start + 1 == fragmentToSplit.end) {
</del><ins>+    if (fragmentToSplit.start() + 1 == fragmentToSplit.end()) {
</ins><span class="cx">         if (keepAtLeastOneCharacter)
</span><span class="cx">             return FlowContentsIterator::TextFragment();
</span><span class="cx"> 
</span><span class="cx">         FlowContentsIterator::TextFragment fragmentForNextLine(fragmentToSplit);
</span><del>-        fragmentToSplit.end = fragmentToSplit.start;
-        fragmentToSplit.width = 0;
</del><ins>+        // Make it empty fragment.
+        fragmentToSplit = FlowContentsIterator::TextFragment(fragmentToSplit.start(), fragmentToSplit.start(), 0, fragmentToSplit.type());
</ins><span class="cx">         return fragmentForNextLine;
</span><span class="cx">     }
</span><span class="cx">     // Simple binary search to find out what fits the current line.
</span><span class="cx">     // FIXME: add surrogate pair support.
</span><del>-    unsigned left = fragmentToSplit.start;
-    unsigned right = fragmentToSplit.end - 1; // We can ignore the last character. It surely does not fit.
</del><ins>+    unsigned left = fragmentToSplit.start();
+    unsigned right = fragmentToSplit.end() - 1; // We can ignore the last character. It surely does not fit.
</ins><span class="cx">     float width = 0;
</span><span class="cx">     while (left &lt; right) {
</span><span class="cx">         unsigned middle = (left + right) / 2;
</span><del>-        width = flowContentsIterator.textWidth(fragmentToSplit.start, middle + 1, 0);
</del><ins>+        width = flowContentsIterator.textWidth(fragmentToSplit.start(), middle + 1, 0);
</ins><span class="cx">         if (availableWidth &gt; width)
</span><span class="cx">             left = middle + 1;
</span><span class="cx">         else if (availableWidth &lt; width)
</span><span class="lines">@@ -358,21 +358,25 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (keepAtLeastOneCharacter &amp;&amp; right == fragmentToSplit.start)
</del><ins>+    if (keepAtLeastOneCharacter &amp;&amp; right == fragmentToSplit.start())
</ins><span class="cx">         ++right;
</span><del>-    FlowContentsIterator::TextFragment fragmentForNextLine(fragmentToSplit);
-    fragmentToSplit.end = right;
-    fragmentToSplit.width = fragmentToSplit.isEmpty() ? 0 : flowContentsIterator.textWidth(fragmentToSplit.start, fragmentToSplit.end, 0);
</del><span class="cx"> 
</span><del>-    fragmentForNextLine.start = fragmentToSplit.end;
-    fragmentForNextLine.width -= fragmentToSplit.width;
-    return fragmentForNextLine;
</del><ins>+    // Fragment for next line.
+    unsigned nextLineStart = right;
+    unsigned nextLineEnd = fragmentToSplit.end();
+    float nextLineWidth = flowContentsIterator.textWidth(nextLineStart, nextLineEnd, 0);
+
+    unsigned thisLineStart = fragmentToSplit.start();
+    unsigned thisLineEnd = right;
+    float thisLineWidth = flowContentsIterator.textWidth(thisLineStart, thisLineEnd, 0);
+    fragmentToSplit = FlowContentsIterator::TextFragment(thisLineStart, thisLineEnd, thisLineWidth, fragmentToSplit.type(), fragmentToSplit.isCollapsed(), fragmentToSplit.isBreakable());
+    return FlowContentsIterator::TextFragment(nextLineStart, nextLineEnd, nextLineWidth, fragmentToSplit.type(), fragmentToSplit.isCollapsed(), fragmentToSplit.isBreakable());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static FlowContentsIterator::TextFragment firstFragment(FlowContentsIterator&amp; flowContentsIterator, const LineState&amp; previousLine)
</span><span class="cx"> {
</span><span class="cx">     // Handle overflowed fragment from previous line.
</span><del>-    FlowContentsIterator::TextFragment firstFragment = previousLine.overflowedFragment();
</del><ins>+    FlowContentsIterator::TextFragment firstFragment(previousLine.overflowedFragment());
</ins><span class="cx">     const auto&amp; style = flowContentsIterator.style();
</span><span class="cx"> 
</span><span class="cx">     if (firstFragment.isEmpty())
</span><span class="lines">@@ -380,16 +384,16 @@
</span><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 &amp;&amp; preWrap(style) &amp;&amp; previousLine.firstCharacterFits()) {
</del><ins>+        if (firstFragment.type() == FlowContentsIterator::TextFragment::Whitespace &amp;&amp; preWrap(style) &amp;&amp; previousLine.firstCharacterFits()) {
</ins><span class="cx">             firstFragment = flowContentsIterator.nextTextFragment();
</span><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)
</del><ins>+            if (firstFragment.type() == FlowContentsIterator::TextFragment::LineBreak)
</ins><span class="cx">                 firstFragment = flowContentsIterator.nextTextFragment();
</span><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 &amp;&amp; firstFragment.type == FlowContentsIterator::TextFragment::Whitespace)
</del><ins>+    if (style.collapseWhitespace &amp;&amp; firstFragment.type() == FlowContentsIterator::TextFragment::Whitespace)
</ins><span class="cx">         firstFragment = flowContentsIterator.nextTextFragment();
</span><span class="cx">     return firstFragment;
</span><span class="cx"> }
</span><span class="lines">@@ -399,15 +403,15 @@
</span><span class="cx">     const auto&amp; style = flowContentsIterator.style();
</span><span class="cx">     bool lineCanBeWrapped = style.wrapLines || style.breakWordOnOverflow;
</span><span class="cx">     auto fragment = firstFragment(flowContentsIterator, previousLine);
</span><del>-    while (!fragment.isEmpty()) {
</del><ins>+    while (fragment.type() != FlowContentsIterator::TextFragment::ContentEnd) {
</ins><span class="cx">         // Hard linebreak.
</span><del>-        if (fragment.type == FlowContentsIterator::TextFragment::LineBreak) {
</del><ins>+        if (fragment.type() == FlowContentsIterator::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="cx">             break;
</span><span class="cx">         }
</span><del>-        if (lineCanBeWrapped &amp;&amp; !line.fits(fragment.width)) {
</del><ins>+        if (lineCanBeWrapped &amp;&amp; !line.fits(fragment.width())) {
</ins><span class="cx">             // Overflow wrapping behaviour:
</span><span class="cx">             // 1. Whitesapce collapse on: whitespace is skipped. Jump to next line.
</span><span class="cx">             // 2. Whitespace collapse off: whitespace is wrapped.
</span><span class="lines">@@ -415,7 +419,7 @@
</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() == FlowContentsIterator::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><span class="cx">                     line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, flowContentsIterator));
</span><span class="lines">@@ -444,7 +448,7 @@
</span><span class="cx">         // Find the next text fragment.
</span><span class="cx">         fragment = flowContentsIterator.nextTextFragment(line.width());
</span><span class="cx">     }
</span><del>-    return fragment.isEmpty() &amp;&amp; line.overflowedFragment().isEmpty();
</del><ins>+    return fragment.type() == FlowContentsIterator::TextFragment::ContentEnd &amp;&amp; line.overflowedFragment().isEmpty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void closeLineEndingAndAdjustRuns(LineState&amp; line, Layout::RunVector&amp; runs, unsigned previousRunCount, unsigned&amp; lineCount, const FlowContentsIterator&amp; flowContentsIterator)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp (179437 => 179438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp        2015-01-31 05:27:06 UTC (rev 179437)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.cpp        2015-01-31 06:26:02 UTC (rev 179438)
</span><span class="lines">@@ -61,47 +61,34 @@
</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>-    TextFragment fragment;
-    fragment.start = m_position;
-    if (isEnd(fragment.start)) {
-        fragment.end = fragment.start;
</del><ins>+    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;
</ins><span class="cx">         return fragment;
</span><span class="cx">     }
</span><del>-    if (isLineBreak(fragment.start)) {
-        fragment.type = TextFragment::LineBreak;
-        fragment.end = fragment.start + 1;
-        m_position = fragment.end;
-        return fragment;
-    }
-
</del><span class="cx">     unsigned spaceCount = 0;
</span><del>-    unsigned whitespaceEnd = findNextNonWhitespacePosition(fragment.start, spaceCount);
-    ASSERT(fragment.start &lt;= whitespaceEnd);
-    if (fragment.start != whitespaceEnd) {
-        fragment.type = TextFragment::Whitespace;
-        fragment.end = whitespaceEnd;
-        bool multipleWhitespace = fragment.start + 1 &lt; fragment.end;
-        fragment.isCollapsed = multipleWhitespace &amp;&amp; m_style.collapseWhitespace;
-        fragment.isBreakable = !fragment.isCollapsed &amp;&amp; multipleWhitespace;
-        if (fragment.isCollapsed)
-            fragment.width = m_style.spaceWidth;
</del><ins>+    unsigned startPosition = m_position;
+    unsigned endPosition = findNextNonWhitespacePosition(startPosition, spaceCount);
+    ASSERT(startPosition &lt;= endPosition);
+    if (endPosition &gt; startPosition) {
+        bool multipleWhitespace = startPosition + 1 &lt; endPosition;
+        bool isCollapsed = multipleWhitespace &amp;&amp; m_style.collapseWhitespace;
+        bool isBreakable = !isCollapsed &amp;&amp; multipleWhitespace;
+        float width = 0;
+        if (isCollapsed)
+            width = m_style.spaceWidth;
</ins><span class="cx">         else {
</span><del>-            unsigned fragmentLength = fragment.end - fragment.start;
-            if (fragmentLength == spaceCount)
-                fragment.width = fragmentLength * m_style.spaceWidth;
-            else
-                fragment.width = textWidth(fragment.start, fragment.end, xPosition);
</del><ins>+            unsigned length = endPosition - startPosition;
+            width = length == spaceCount ? length * m_style.spaceWidth : textWidth(startPosition, endPosition, xPosition);
</ins><span class="cx">         }
</span><del>-        m_position = fragment.end;
-        return fragment;
</del><ins>+        m_position = endPosition;
+        return TextFragment(startPosition, endPosition, width, TextFragment::Whitespace, isCollapsed, isBreakable);
</ins><span class="cx">     }
</span><del>-
-    fragment.type = TextFragment::NonWhitespace;
-    fragment.isBreakable = m_style.breakWordOnOverflow;
-    fragment.end = findNextBreakablePosition(fragment.start + 1);
-    fragment.width = textWidth(fragment.start, fragment.end, xPosition);
-    m_position = fragment.end;
-    return fragment;
</del><ins>+    endPosition = findNextBreakablePosition(startPosition + 1);
+    m_position = endPosition;
+    return TextFragment(startPosition, endPosition, textWidth(startPosition, endPosition, xPosition), TextFragment::NonWhitespace, false, m_style.breakWordOnOverflow);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float FlowContentsIterator::textWidth(unsigned from, unsigned to, float xPosition) const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingSimpleLineLayoutFlowContentsIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h (179437 => 179438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h        2015-01-31 05:27:06 UTC (rev 179437)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContentsIterator.h        2015-01-31 06:26:02 UTC (rev 179438)
</span><span class="lines">@@ -39,29 +39,35 @@
</span><span class="cx"> class FlowContentsIterator  {
</span><span class="cx"> public:
</span><span class="cx">     FlowContentsIterator(const RenderBlockFlow&amp;);
</span><del>-
-    struct TextFragment {
</del><ins>+    class TextFragment {
+    public:
+        enum Type { ContentEnd, LineBreak, Whitespace, NonWhitespace };
</ins><span class="cx">         TextFragment() = default;
</span><del>-        TextFragment(unsigned textStart, unsigned textEnd, float textWidth, bool isWhitespaceOnly)
-            : start(textStart)
-            , end(textEnd)
-            , type(isWhitespaceOnly ? Whitespace : NonWhitespace)
-            , width(textWidth)
</del><ins>+        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)
</ins><span class="cx">         {
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        bool isEmpty() const
-        {
-            return start == end;
-        }
</del><ins>+        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(); }
</ins><span class="cx"> 
</span><del>-        enum Type { LineBreak, Whitespace, NonWhitespace };
-        unsigned start { 0 };
-        unsigned end  {0 };
-        Type type { NonWhitespace };
-        bool isCollapsed { false };
-        bool isBreakable { false };
-        float width { 0 };
</del><ins>+    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 };
</ins><span class="cx">     };
</span><span class="cx">     TextFragment nextTextFragment(float xPosition = 0);
</span><span class="cx">     float textWidth(unsigned from, unsigned to, float xPosition) const;
</span></span></pre>
</div>
</div>

</body>
</html>