Title: [181667] trunk
Revision
181667
Author
za...@apple.com
Date
2015-03-17 15:20:30 -0700 (Tue, 17 Mar 2015)

Log Message

Simple line layout: Split fragments on renderer boundary on the fly.
https://bugs.webkit.org/show_bug.cgi?id=142579

Reviewed by Antti Koivisto.

Fragment splitting at renderers' boundary at the end of the line is no longer needed.
This patch ensures that TextFragmentIterator::nextTextFragment() does not concatenate
fragments across renderer boundary.

Source/WebCore:

Test: fast/text/simple-line-with-multiple-renderers.html

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::revertRuns):
(WebCore::SimpleLineLayout::LineState::isEmpty):
(WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded): Check if fragments need a new run and
whether neighboring fragments need collapsing.
(WebCore::SimpleLineLayout::LineState::revertUncommitted): Revert fragments over multiple renderers if they form
a fragment continuation.
(WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace):
(WebCore::SimpleLineLayout::forceFragmentToLine): Ensure that if a fragment has continuation across multiple renderers,
they all get added to the current line.
(WebCore::SimpleLineLayout::createLineRuns):
(WebCore::SimpleLineLayout::LineState::appendFragment): Deleted.
(WebCore::SimpleLineLayout::FragmentForwardIterator::FragmentForwardIterator): Deleted.
(WebCore::SimpleLineLayout::FragmentForwardIterator::operator++): Deleted.
(WebCore::SimpleLineLayout::FragmentForwardIterator::operator!=): Deleted.
(WebCore::SimpleLineLayout::FragmentForwardIterator::operator*): Deleted.
(WebCore::SimpleLineLayout::begin): Deleted.
(WebCore::SimpleLineLayout::end): Deleted.
(WebCore::SimpleLineLayout::preWrap): Deleted.
(WebCore::SimpleLineLayout::removeTrailingWhitespace): Deleted.
(WebCore::SimpleLineLayout::updateLineConstrains): Deleted.
(WebCore::SimpleLineLayout::splitRunsAtRendererBoundary): Deleted.
(WebCore::SimpleLineLayout::createTextRuns): Deleted.
(WebCore::SimpleLineLayout::create): Deleted.
(WebCore::SimpleLineLayout::Layout::create): Deleted.
* rendering/SimpleLineLayoutFlowContents.h:
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator+):
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator*):
(WebCore::SimpleLineLayout::FlowContents::Iterator::operator->):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow): Unrelated fix on non-collapsed tab position.
* rendering/SimpleLineLayoutTextFragmentIterator.cpp:
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragmentIterator):
(WebCore::SimpleLineLayout::TextFragmentIterator::nextTextFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::revertToFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
(WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):
* rendering/SimpleLineLayoutTextFragmentIterator.h:
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::TextFragment):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::overlapsToNextRenderer):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isCollapsible):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::operator==):
(WebCore::SimpleLineLayout::TextFragmentIterator::isLineBreak):
(WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::split): Deleted.

LayoutTests:

* fast/text/simple-line-with-multiple-renderers-expected.html: Added.
* fast/text/simple-line-with-multiple-renderers.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181666 => 181667)


--- trunk/LayoutTests/ChangeLog	2015-03-17 22:12:46 UTC (rev 181666)
+++ trunk/LayoutTests/ChangeLog	2015-03-17 22:20:30 UTC (rev 181667)
@@ -1,3 +1,17 @@
+2015-03-17  Zalan Bujtas  <za...@apple.com>
+
+        Simple line layout: Split fragments on renderer boundary on the fly.
+        https://bugs.webkit.org/show_bug.cgi?id=142579
+
+        Reviewed by Antti Koivisto.
+
+        Fragment splitting at renderers' boundary at the end of the line is no longer needed.
+        This patch ensures that TextFragmentIterator::nextTextFragment() does not concatenate
+        fragments across renderer boundary.
+
+        * fast/text/simple-line-with-multiple-renderers-expected.html: Added.
+        * fast/text/simple-line-with-multiple-renderers.html: Added.
+
 2015-03-17  Dean Jackson  <d...@apple.com>
 
         Implement Scroll Container Animation Triggers

Added: trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers-expected.html (0 => 181667)


--- trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers-expected.html	2015-03-17 22:20:30 UTC (rev 181667)
@@ -0,0 +1,36 @@
+<!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>

Added: trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers.html (0 => 181667)


--- trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-with-multiple-renderers.html	2015-03-17 22:20:30 UTC (rev 181667)
@@ -0,0 +1,34 @@
+<!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>

Modified: trunk/Source/WebCore/ChangeLog (181666 => 181667)


--- trunk/Source/WebCore/ChangeLog	2015-03-17 22:12:46 UTC (rev 181666)
+++ trunk/Source/WebCore/ChangeLog	2015-03-17 22:20:30 UTC (rev 181667)
@@ -1,3 +1,61 @@
+2015-03-17  Zalan Bujtas  <za...@apple.com>
+
+        Simple line layout: Split fragments on renderer boundary on the fly.
+        https://bugs.webkit.org/show_bug.cgi?id=142579
+
+        Reviewed by Antti Koivisto.
+
+        Fragment splitting at renderers' boundary at the end of the line is no longer needed.
+        This patch ensures that TextFragmentIterator::nextTextFragment() does not concatenate
+        fragments across renderer boundary.
+
+        Test: fast/text/simple-line-with-multiple-renderers.html
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::revertRuns):
+        (WebCore::SimpleLineLayout::LineState::isEmpty):
+        (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded): Check if fragments need a new run and
+        whether neighboring fragments need collapsing.
+        (WebCore::SimpleLineLayout::LineState::revertUncommitted): Revert fragments over multiple renderers if they form
+        a fragment continuation.
+        (WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace):
+        (WebCore::SimpleLineLayout::forceFragmentToLine): Ensure that if a fragment has continuation across multiple renderers,
+        they all get added to the current line.
+        (WebCore::SimpleLineLayout::createLineRuns):
+        (WebCore::SimpleLineLayout::LineState::appendFragment): Deleted.
+        (WebCore::SimpleLineLayout::FragmentForwardIterator::FragmentForwardIterator): Deleted.
+        (WebCore::SimpleLineLayout::FragmentForwardIterator::operator++): Deleted.
+        (WebCore::SimpleLineLayout::FragmentForwardIterator::operator!=): Deleted.
+        (WebCore::SimpleLineLayout::FragmentForwardIterator::operator*): Deleted.
+        (WebCore::SimpleLineLayout::begin): Deleted.
+        (WebCore::SimpleLineLayout::end): Deleted.
+        (WebCore::SimpleLineLayout::preWrap): Deleted.
+        (WebCore::SimpleLineLayout::removeTrailingWhitespace): Deleted.
+        (WebCore::SimpleLineLayout::updateLineConstrains): Deleted.
+        (WebCore::SimpleLineLayout::splitRunsAtRendererBoundary): Deleted.
+        (WebCore::SimpleLineLayout::createTextRuns): Deleted.
+        (WebCore::SimpleLineLayout::create): Deleted.
+        (WebCore::SimpleLineLayout::Layout::create): Deleted.
+        * rendering/SimpleLineLayoutFlowContents.h:
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator+):
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator*):
+        (WebCore::SimpleLineLayout::FlowContents::Iterator::operator->):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::paintFlow): Unrelated fix on non-collapsed tab position.
+        * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
+        (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragmentIterator):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::nextTextFragment):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::revertToFragment):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::textWidth):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::skipToNextPosition):
+        * rendering/SimpleLineLayoutTextFragmentIterator.h:
+        (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::TextFragment):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::overlapsToNextRenderer):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::isCollapsible):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::operator==):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::isLineBreak):
+        (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragment::split): Deleted.
+
 2015-03-17  Jeremy Jones  <jere...@apple.com>
 
         When tab hides, pause fullscreen and exit normally.

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (181666 => 181667)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2015-03-17 22:12:46 UTC (rev 181666)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2015-03-17 22:20:30 UTC (rev 181667)
@@ -231,9 +231,27 @@
     return 0;
 }
 
+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);
+    }
+}
+
 class LineState {
 public:
     void setAvailableWidth(float width) { m_availableWidth = width; }
+    void setCollapedWhitespaceWidth(float width) { m_collapsedWhitespaceWidth = width; }
     void setLogicalLeftOffset(float offset) { m_logicalLeftOffset = offset; }
     void setOverflowedFragment(const TextFragmentIterator::TextFragment& fragment) { m_overflowedFragment = fragment; }
 
@@ -241,25 +259,51 @@
     float logicalLeftOffset() const { return m_logicalLeftOffset; }
     const TextFragmentIterator::TextFragment& overflowedFragment() const { return m_overflowedFragment; }
     bool hasTrailingWhitespace() const { return m_trailingWhitespaceLength; }
+    TextFragmentIterator::TextFragment lastFragment() const { return m_fragments.last(); }
     bool isWhitespaceOnly() const { return m_trailingWhitespaceWidth && m_runsWidth == m_trailingWhitespaceWidth; }
     bool fits(float extra) const { return m_availableWidth >= m_runsWidth + extra; }
     bool firstCharacterFits() const { return m_firstCharacterFits; }
     float width() const { return m_runsWidth; }
+    bool isEmpty() const
+    {
+        if (!m_fragments.size())
+            return true;
+        if (!m_lastCompleteFragment.isEmpty())
+            return false;
+        return m_fragments.last().overlapsToNextRenderer();
+    }
 
-    void appendFragment(const TextFragmentIterator::TextFragment& fragment, Layout::RunVector& runs)
+    void appendFragmentAndCreateRunIfNeeded(const TextFragmentIterator::TextFragment& fragment, Layout::RunVector& runs)
     {
         // Adjust end position while collapsing.
         unsigned endPosition = fragment.isCollapsed() ? fragment.start() + 1 : fragment.end();
-
-        if (m_createNewRun)
+        // New line needs new run.
+        if (!m_runsWidth)
             runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false));
         else {
-            ASSERT(runs.size());
-            Run& lastRun = runs.last();
-            lastRun.end = endPosition;
-            lastRun.logicalRight = m_runsWidth + fragment.width();
+            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();
+            }
         }
-        m_createNewRun = fragment.isCollapsed();
+        m_fragments.append(fragment);
         m_runsWidth += fragment.width();
 
         if (fragment.type() == TextFragmentIterator::TextFragment::Whitespace) {
@@ -274,18 +318,34 @@
             m_firstCharacterFits = fragment.start() + 1 > endPosition || m_runsWidth <= m_availableWidth;
     }
 
+    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;
+    }
+
     void removeTrailingWhitespace(Layout::RunVector& runs)
     {
-        ASSERT(runs.size());
-        Run& lastRun = runs.last();
-        lastRun.logicalRight -= m_trailingWhitespaceWidth;
-        lastRun.end -= m_trailingWhitespaceLength;
-        if (lastRun.start == lastRun.end)
-            runs.removeLast();
-
+        // 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);
         m_runsWidth -= m_trailingWhitespaceWidth;
+        m_trailingWhitespaceLength = 0;
         m_trailingWhitespaceWidth = 0;
-        m_trailingWhitespaceLength = 0;
     }
 
 private:
@@ -293,12 +353,14 @@
     float m_logicalLeftOffset { 0 };
     TextFragmentIterator::TextFragment m_overflowedFragment;
     float m_runsWidth { 0 };
-    bool m_createNewRun { true };
+    TextFragmentIterator::TextFragment m_lastCompleteFragment;
     float m_trailingWhitespaceWidth { 0 }; // Use this to remove trailing whitespace without re-mesuring the text.
     unsigned m_trailingWhitespaceLength { 0 };
+    float m_collapsedWhitespaceWidth { 0 };
     // Having one character on the line does not necessarily mean it actually fits.
     // First character of the first fragment might be forced on to the current line even if it does not fit.
     bool m_firstCharacterFits { false };
+    Vector<TextFragmentIterator::TextFragment> m_fragments;
 };
 
 class FragmentForwardIterator : public std::iterator<std::forward_iterator_tag, unsigned> {
@@ -389,14 +451,36 @@
     }
 
     // Check if we need to skip the leading whitespace.
-    if (style.collapseWhitespace && firstFragment.type() == TextFragmentIterator::TextFragment::Whitespace)
-        firstFragment = textFragmentIterator.nextTextFragment();
+    if (style.collapseWhitespace) {
+        while (firstFragment.type() == TextFragmentIterator::TextFragment::Whitespace)
+            firstFragment = textFragmentIterator.nextTextFragment();
+    }
     return firstFragment;
 }
 
+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);
+}
+
 static bool createLineRuns(LineState& line, const LineState& previousLine, Layout::RunVector& runs, TextFragmentIterator& textFragmentIterator)
 {
     const auto& style = textFragmentIterator.style();
+    line.setCollapedWhitespaceWidth(style.spaceWidth);
     bool lineCanBeWrapped = style.wrapLines || style.breakWordOnOverflow;
     auto fragment = firstFragment(textFragmentIterator, previousLine);
     while (fragment.type() != TextFragmentIterator::TextFragment::ContentEnd) {
@@ -404,7 +488,7 @@
         if (fragment.type() == TextFragmentIterator::TextFragment::LineBreak) {
             // 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.)
             if (!line.width())
-                line.appendFragment(fragment, runs);
+                line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
             break;
         }
         if (lineCanBeWrapped && !line.fits(fragment.width())) {
@@ -413,13 +497,13 @@
             // 2. Whitespace collapse off: whitespace is wrapped.
             // 3. First, non-whitespace fragment is either wrapped or kept on the line. (depends on overflow-wrap)
             // 4. Non-whitespace fragment when there's already another fragment on the line gets pushed to the next line.
-            bool emptyLine = !line.width();
+            bool emptyLine = line.isEmpty();
             // Whitespace fragment.
             if (fragment.type() == TextFragmentIterator::TextFragment::Whitespace) {
                 if (!style.collapseWhitespace) {
                     // Split the fragment; (modified)fragment stays on this line, overflowedFragment is pushed to next line.
                     line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, textFragmentIterator));
-                    line.appendFragment(fragment, runs);
+                    line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
                 }
                 // When whitespace collapse is on, whitespace that doesn't fit is simply skipped.
                 break;
@@ -428,23 +512,30 @@
             if ((emptyLine && style.breakWordOnOverflow) || !style.wrapLines) {
                 // Split the fragment; (modified)fragment stays on this line, overflowedFragment is pushed to next line.
                 line.setOverflowedFragment(splitFragmentToFitLine(fragment, line.availableWidth() - line.width(), emptyLine, textFragmentIterator));
-                line.appendFragment(fragment, runs);
+                line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
                 break;
             }
             // Non-breakable non-whitespace first fragment. Add it to the current line. -it overflows though.
+            ASSERT(fragment.type() == TextFragmentIterator::TextFragment::NonWhitespace);
             if (emptyLine) {
-                line.appendFragment(fragment, runs);
+                forceFragmentToLine(line, textFragmentIterator, runs, fragment);
                 break;
             }
             // Non-breakable non-whitespace fragment when there's already content on the line. Push it to the next line.
+            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;
+            }
             line.setOverflowedFragment(fragment);
             break;
         }
-        line.appendFragment(fragment, runs);
+        line.appendFragmentAndCreateRunIfNeeded(fragment, runs);
         // Find the next text fragment.
         fragment = textFragmentIterator.nextTextFragment(line.width());
     }
-    return fragment.type() == TextFragmentIterator::TextFragment::ContentEnd && line.overflowedFragment().isEmpty();
+    return (fragment.type() == TextFragmentIterator::TextFragment::ContentEnd && line.overflowedFragment().isEmpty()) || line.overflowedFragment().type() == TextFragmentIterator::TextFragment::ContentEnd;
 }
 
 static void closeLineEndingAndAdjustRuns(LineState& line, Layout::RunVector& runs, unsigned previousRunCount, unsigned& lineCount, const TextFragmentIterator& textFragmentIterator)
@@ -466,28 +557,6 @@
     ++lineCount;
 }
 
-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());
-}
-
 static void createTextRuns(Layout::RunVector& runs, RenderBlockFlow& flow, unsigned& lineCount)
 {
     LayoutUnit borderAndPaddingBefore = flow.borderAndPaddingBefore();
@@ -505,9 +574,6 @@
         isEndOfContent = createLineRuns(line, previousLine, runs, textFragmentIterator);
         closeLineEndingAndAdjustRuns(line, runs, previousRunCount, lineCount, textFragmentIterator);
     } while (!isEndOfContent);
-
-    if (flow.firstChild() != flow.lastChild())
-        splitRunsAtRendererBoundary(runs, textFragmentIterator);
 }
 
 std::unique_ptr<Layout> create(RenderBlockFlow& flow)

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h (181666 => 181667)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h	2015-03-17 22:12:46 UTC (rev 181666)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFlowContents.h	2015-03-17 22:20:30 UTC (rev 181667)
@@ -55,9 +55,11 @@
         }
 
         Iterator& operator++();
+        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]; }
+        const Segment& operator*() const;
+        const Segment* operator->() const;
 
     private:
         const FlowContents& m_flowContents;
@@ -67,15 +69,11 @@
     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;
 
 private:
     unsigned segmentIndexForPositionSlow(unsigned position) const;
-
     const Vector<Segment, 8> m_segments;
-
     mutable unsigned m_lastSegmentIndex;
 };
 
@@ -85,6 +83,12 @@
     return *this;
 }
 
+inline FlowContents::Iterator& FlowContents::Iterator::operator--()
+{
+    --m_segmentIndex;
+    return *this;
+}
+
 inline bool FlowContents::Iterator::operator==(const FlowContents::Iterator& other) const
 {
     return m_segmentIndex == other.m_segmentIndex;
@@ -95,6 +99,18 @@
     return !(*this == other);
 }
 
+inline const FlowContents::Segment& FlowContents::Iterator::operator*() const
+{
+    ASSERT(m_segmentIndex < m_flowContents.m_segments.size());
+    return m_flowContents.m_segments[m_segmentIndex];
+}
+
+inline const FlowContents::Segment* FlowContents::Iterator::operator->() const
+{
+    ASSERT(m_segmentIndex < m_flowContents.m_segments.size());
+    return &(m_flowContents.m_segments[m_segmentIndex]);
+}
+
 inline unsigned FlowContents::segmentIndexForPosition(unsigned position) const
 {
     auto& lastSegment = m_segments[m_lastSegmentIndex];

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (181666 => 181667)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp	2015-03-17 22:12:46 UTC (rev 181666)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp	2015-03-17 22:20:30 UTC (rev 181667)
@@ -84,6 +84,7 @@
             continue;
         TextRun textRun(run.text());
         textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
+        textRun.setXPos(run.rect().x());
         FloatPoint textOrigin = run.baseline() + paintOffset;
         textOrigin.setY(roundToDevicePixel(LayoutUnit(textOrigin.y()), flow.document().deviceScaleFactor()));
         context.drawText(font, textRun, textOrigin);

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (181666 => 181667)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp	2015-03-17 22:12:46 UTC (rev 181666)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp	2015-03-17 22:20:30 UTC (rev 181667)
@@ -48,7 +48,8 @@
 
 TextFragmentIterator::TextFragmentIterator(const RenderBlockFlow& flow)
     : m_flowContents(flow)
-    , m_lineBreakIterator((*m_flowContents.begin()).text, flow.style().locale())
+    , m_currentSegment(m_flowContents.begin())
+    , m_lineBreakIterator(m_currentSegment->text, flow.style().locale())
     , m_style(flow.style())
 {
 }
@@ -60,115 +61,136 @@
     // 2. whitespace (collasped, non-collapsed multi or single) or
     // 3. non-whitespace characters.
     // 4. empty, indicating content end.
-    if (isEnd(m_position))
+    ASSERT(m_currentSegment != m_flowContents.end());
+    if (m_position == m_currentSegment->end)
+        ++m_currentSegment;
+    // Is it content end?
+    if (m_currentSegment == m_flowContents.end())
         return TextFragment(m_position, m_position, 0, TextFragment::ContentEnd);
+    unsigned segmentEndPosition = m_currentSegment->end;
+    unsigned startPosition = m_position;
     if (isLineBreak(m_position)) {
-        TextFragment fragment(m_position, m_position + 1, 0, TextFragment::LineBreak);
-        ++m_position;
-        return fragment;
+        unsigned endPosition = ++m_position;
+        return TextFragment(startPosition, endPosition, 0, TextFragment::LineBreak);
     }
-    unsigned startPosition = m_position;
-    unsigned endPosition = skipToNextPosition(PositionType::NonWhitespace, startPosition);
+    float width = 0;
+    bool overlappingFragment = false;
+    unsigned endPosition = skipToNextPosition(PositionType::NonWhitespace, startPosition, width, xPosition, overlappingFragment);
     ASSERT(startPosition <= endPosition);
-    if (endPosition > startPosition) {
+    if (startPosition < endPosition) {
         bool multipleWhitespace = startPosition + 1 < endPosition;
         bool isCollapsed = multipleWhitespace && m_style.collapseWhitespace;
         bool isBreakable = !isCollapsed && multipleWhitespace;
-        float width = isCollapsed ? m_style.spaceWidth : textWidth(startPosition, endPosition, xPosition);
         m_position = endPosition;
-        return TextFragment(startPosition, endPosition, width, TextFragment::Whitespace, isCollapsed, isBreakable);
+        return TextFragment(startPosition, endPosition, width, TextFragment::Whitespace, endPosition == segmentEndPosition, false, isCollapsed, m_style.collapseWhitespace, isBreakable);
     }
-    endPosition = skipToNextPosition(PositionType::Breakable, startPosition + 1);
+    endPosition = skipToNextPosition(PositionType::Breakable, startPosition, width, xPosition, overlappingFragment);
     m_position = endPosition;
-    return TextFragment(startPosition, endPosition, textWidth(startPosition, endPosition, xPosition), TextFragment::NonWhitespace, false, m_style.breakWordOnOverflow);
+    return TextFragment(startPosition, endPosition, width, TextFragment::NonWhitespace, endPosition == segmentEndPosition, overlappingFragment, false, false, m_style.breakWordOnOverflow);
 }
 
-float TextFragmentIterator::textWidth(unsigned from, unsigned to, float xPosition) const
+void TextFragmentIterator::revertToFragment(const TextFragment& fragment)
 {
-    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;
+    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();
 }
 
 template <typename CharacterType>
-static unsigned nextBreakablePosition(LazyLineBreakIterator& lineBreakIterator, const FlowContents::Segment& segment, unsigned startPosition)
+unsigned TextFragmentIterator::nextBreakablePosition(const FlowContents::Segment& segment, unsigned startPosition)
 {
-    return nextBreakablePositionNonLoosely<CharacterType, NBSPBehavior::IgnoreNBSP>(lineBreakIterator, segment.text.characters<CharacterType>(), segment.end - segment.start, startPosition);
+    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);
 }
 
 template <typename CharacterType>
-static unsigned nextNonWhitespacePosition(const FlowContents::Segment& segment, unsigned startPosition, const TextFragmentIterator::Style& style)
+unsigned TextFragmentIterator::nextNonWhitespacePosition(const FlowContents::Segment& segment, unsigned startPosition)
 {
+    ASSERT(startPosition < segment.end);
     const auto* text = segment.text.characters<CharacterType>();
     unsigned position = startPosition;
-    unsigned length = segment.end - segment.start;
-    for (; position < length; ++position) {
-        auto character = text[position];
-        bool isWhitespace = character == ' ' || character == '\t' || (!style.preserveNewline && character == '\n');
+    for (; position < segment.end; ++position) {
+        auto character = text[position - segment.start];
+        bool isWhitespace = character == ' ' || character == '\t' || (!m_style.preserveNewline && character == '\n');
         if (!isWhitespace)
             return position;
     }
     return position;
 }
 
-unsigned TextFragmentIterator::skipToNextPosition(PositionType positionType, unsigned startPosition) const
+float TextFragmentIterator::textWidth(unsigned from, unsigned to, float xPosition) const
 {
-    if (isEnd(startPosition))
-        return startPosition;
+    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);
+}
 
+unsigned TextFragmentIterator::skipToNextPosition(PositionType positionType, unsigned startPosition, float& width, float xPosition, bool& overlappingFragment)
+{
+    overlappingFragment = false;
     unsigned currentPosition = startPosition;
-    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;
+    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) {
+            auto nextSegment = m_currentSegment;
+            ++nextSegment;
+            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);
+        }
     }
-    return currentPosition;
+    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;
 }
 
 template <typename CharacterType>
-float TextFragmentIterator::runWidth(const String& text, unsigned from, unsigned to, float xPosition) const
+float TextFragmentIterator::runWidth(const FlowContents::Segment& segment, unsigned startPosition, unsigned endPosition, float xPosition) const
 {
-    ASSERT(from <= to);
-    if (from == to)
+    ASSERT(startPosition <= endPosition);
+    if (startPosition == endPosition)
         return 0;
-    bool measureWithEndSpace = m_style.collapseWhitespace && to < text.length() && text[to] == ' ';
+    unsigned segmentFrom = startPosition - segment.start;
+    unsigned segmentTo = endPosition - segment.start;
+    bool measureWithEndSpace = m_style.collapseWhitespace && segmentTo < segment.text.length() && segment.text[segmentTo] == ' ';
     if (measureWithEndSpace)
-        ++to;
-    TextRun run(text.characters<CharacterType>() + from, to - from);
+        ++segmentTo;
+    TextRun run(segment.text.characters<CharacterType>() + segmentFrom, segmentTo - segmentFrom);
     run.setXPos(xPosition);
     run.setTabSize(!!m_style.tabWidth, m_style.tabWidth);
     float width = m_style.font.width(run);

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h (181666 => 181667)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h	2015-03-17 22:12:46 UTC (rev 181666)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h	2015-03-17 22:20:30 UTC (rev 181667)
@@ -43,12 +43,15 @@
     public:
         enum Type { ContentEnd, LineBreak, Whitespace, NonWhitespace };
         TextFragment() = default;
-        TextFragment(unsigned start, unsigned end, float width, Type type, bool isCollapsed = false, bool isBreakable = false)
+        TextFragment(unsigned start, unsigned end, float width, Type type, bool isLastInRenderer = false, bool overlapsToNextRenderer = false, bool isCollapsed = false, bool isCollapsible = false, bool isBreakable = false)
             : m_start(start)
             , m_end(end)
+            , m_width(width)
             , m_type(type)
-            , m_width(width)
+            , m_isLastInRenderer(isLastInRenderer)
+            , m_overlapsToNextRenderer(overlapsToNextRenderer)
             , m_isCollapsed(isCollapsed)
+            , m_isCollapsible(isCollapsible)
             , m_isBreakable(isBreakable)
         {
         }
@@ -57,22 +60,41 @@
         unsigned end() const { return m_end; }
         float width() const { return m_width; }
         Type type() const { return m_type; }
+        bool isLastInRenderer() const { return m_isLastInRenderer; }
+        bool overlapsToNextRenderer() const { return m_overlapsToNextRenderer; }
         bool isCollapsed() const { return m_isCollapsed; }
+        bool isCollapsible() const { return m_isCollapsible; }
         bool isBreakable() const { return m_isBreakable; }
 
         bool isEmpty() const { return start() == end(); }
         TextFragment split(unsigned splitPosition, const TextFragmentIterator&);
+        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;
+        }
 
     private:
         unsigned m_start { 0 };
         unsigned m_end { 0 };
+        float m_width { 0 };
         Type m_type { NonWhitespace };
-        float m_width { 0 };
+        bool m_isLastInRenderer { false };
+        bool m_overlapsToNextRenderer { false };
         bool m_isCollapsed { false };
+        bool m_isCollapsible { false };
         bool m_isBreakable { false };
     };
     TextFragment nextTextFragment(float xPosition = 0);
-    float textWidth(unsigned from, unsigned to, float xPosition) const;
+    void revertToFragment(const TextFragment&);
+    float textWidth(unsigned startPosition, unsigned endPosition, float xPosition) const;
 
     struct Style {
         explicit Style(const RenderStyle&);
@@ -88,19 +110,18 @@
         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:
     enum PositionType { Breakable, NonWhitespace };
-    unsigned skipToNextPosition(PositionType, unsigned startPosition) const;
-    UChar characterAt(unsigned position) const;
+    unsigned skipToNextPosition(PositionType, unsigned startPosition, float& width, float xPosition, bool& overlappingFragment);
     bool isLineBreak(unsigned position) const;
-    bool isEnd(unsigned position) const;
-    template <typename CharacterType> float runWidth(const String&, unsigned from, unsigned to, float xPosition) const;
+    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;
 
     FlowContents m_flowContents;
-    mutable LazyLineBreakIterator m_lineBreakIterator;
+    FlowContents::Iterator m_currentSegment;
+    LazyLineBreakIterator m_lineBreakIterator;
     const Style m_style;
     unsigned m_position { 0 };
 };
@@ -127,25 +148,14 @@
     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';
+    const auto& segment = *m_currentSegment;
+    ASSERT(segment.start <= position && position < segment.end);
+    return m_style.preserveNewline && segment.text[position - segment.start] == '\n';
 }
 
-inline bool TextFragmentIterator::isEnd(unsigned position) const
-{
-    return position >= m_flowContents.length();
 }
-
 }
-}
 
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to