Title: [161314] trunk/Source/WebCore
Revision
161314
Author
[email protected]
Date
2014-01-04 12:53:51 -0800 (Sat, 04 Jan 2014)

Log Message

Move LineBreaker functions to LineBreaker.cpp
https://bugs.webkit.org/show_bug.cgi?id=126491

Reviewed by Simon Fraser.

- Moves LineBreaker::nextLineBreak() and LineBreaker::nextSegmentBreak() to
  LineBreaker.cpp from RenderBlockLineLayout.cpp
- Moves requiresIndent() to LineWidth.h/cpp from RenderBlockLineLayout.cpp
  so it can be shared.
- Adds missing inline specifier to BreakingContext::handleEndOfLine() to avoid
  duplicate symbols.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::updateLogicalInlinePositions):
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForLine):
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::BreakingContext::handleEndOfLine):
* rendering/line/LineBreaker.cpp:
(WebCore::LineBreaker::nextLineBreak):
(WebCore::LineBreaker::nextSegmentBreak):
* rendering/line/LineWidth.cpp:
(WebCore::requiresIndent):
* rendering/line/LineWidth.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161313 => 161314)


--- trunk/Source/WebCore/ChangeLog	2014-01-04 18:31:57 UTC (rev 161313)
+++ trunk/Source/WebCore/ChangeLog	2014-01-04 20:53:51 UTC (rev 161314)
@@ -1,3 +1,29 @@
+2014-01-04  Sam Weinig  <[email protected]>
+
+        Move LineBreaker functions to LineBreaker.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=126491
+
+        Reviewed by Simon Fraser.
+
+        - Moves LineBreaker::nextLineBreak() and LineBreaker::nextSegmentBreak() to
+          LineBreaker.cpp from RenderBlockLineLayout.cpp
+        - Moves requiresIndent() to LineWidth.h/cpp from RenderBlockLineLayout.cpp
+          so it can be shared.
+        - Adds missing inline specifier to BreakingContext::handleEndOfLine() to avoid
+          duplicate symbols.
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::updateLogicalInlinePositions):
+        (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForLine):
+        * rendering/line/BreakingContextInlineHeaders.h:
+        (WebCore::BreakingContext::handleEndOfLine):
+        * rendering/line/LineBreaker.cpp:
+        (WebCore::LineBreaker::nextLineBreak):
+        (WebCore::LineBreaker::nextSegmentBreak):
+        * rendering/line/LineWidth.cpp:
+        (WebCore::requiresIndent):
+        * rendering/line/LineWidth.h:
+
 2014-01-04  Martin Robinson  <[email protected]>
 
         [GTK] [CMake] Fix the video and audio build

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (161313 => 161314)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2014-01-04 18:31:57 UTC (rev 161313)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2014-01-04 20:53:51 UTC (rev 161314)
@@ -592,34 +592,15 @@
     }
 }
 
-static IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBreak, const RenderStyle& style)
+static void updateLogicalInlinePositions(RenderBlockFlow& block, float& lineLogicalLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight)
 {
-    IndentTextOrNot shouldIndentText = DoNotIndentText;
-    if (isFirstLine)
-        shouldIndentText = IndentText;
-#if ENABLE(CSS3_TEXT)
-    else if (isAfterHardLineBreak && style.textIndentLine() == TextIndentEachLine)
-        shouldIndentText = IndentText;
-
-    if (style.textIndentType() == TextIndentHanging)
-        shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : IndentText;
-#else
-    UNUSED_PARAM(isAfterHardLineBreak);
-    UNUSED_PARAM(style);
-#endif
-    return shouldIndentText;
-}
-
-static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogicalLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight)
-{
-    LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(firstLine, boxLogicalHeight);
-    lineLogicalLeft = block->pixelSnappedLogicalLeftOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight);
-    lineLogicalRight = block->pixelSnappedLogicalRightOffsetForLine(block->logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight);
+    LayoutUnit lineLogicalHeight = block.minLineHeightForReplacedRenderer(firstLine, boxLogicalHeight);
+    lineLogicalLeft = block.pixelSnappedLogicalLeftOffsetForLine(block.logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight);
+    lineLogicalRight = block.pixelSnappedLogicalRightOffsetForLine(block.logicalHeight(), shouldIndentText == IndentText, lineLogicalHeight);
     availableLogicalWidth = lineLogicalRight - lineLogicalLeft;
 }
 
-void RenderBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* lineBox, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd,
-                                                         GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMeasurements& wordMeasurements)
+void RenderBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* lineBox, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMeasurements& wordMeasurements)
 {
     ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWithBreak());
     
@@ -633,7 +614,7 @@
     float lineLogicalLeft;
     float lineLogicalRight;
     float availableLogicalWidth;
-    updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, 0);
+    updateLogicalInlinePositions(*this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, 0);
     bool needsWordSpacing;
 #if ENABLE(CSS_SHAPES)
     ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo();
@@ -669,7 +650,7 @@
 
     if (firstRun && firstRun->renderer().isReplaced()) {
         RenderBox& renderBox = toRenderBox(firstRun->renderer());
-        updateLogicalInlinePositions(this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, renderBox.logicalHeight());
+        updateLogicalInlinePositions(*this, lineLogicalLeft, lineLogicalRight, availableLogicalWidth, isFirstLine, shouldIndentText, renderBox.logicalHeight());
     }
 
     computeInlineDirectionPositionsForSegment(lineBox, lineInfo, textAlign, lineLogicalLeft, availableLogicalWidth, firstRun, trailingSpaceRun, textBoxDataMap, verticalPositionCache, wordMeasurements);
@@ -1996,115 +1977,6 @@
     return !it.atEnd();
 }
 
-InlineIterator LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
-{
-#if !ENABLE(CSS_SHAPES)
-    return nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
-#else
-    ShapeInsideInfo* shapeInsideInfo = m_block.layoutShapeInsideInfo();
-
-    if (!shapeInsideInfo || !shapeInsideInfo->lineOverlapsShapeBounds())
-        return nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
-
-    InlineIterator end = resolver.position();
-    InlineIterator oldEnd = end;
-
-    if (!shapeInsideInfo->hasSegments()) {
-        end = nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
-        resolver.setPositionIgnoringNestedIsolates(oldEnd);
-        return oldEnd;
-    }
-
-    const SegmentList& segments = shapeInsideInfo->segments();
-    SegmentRangeList& segmentRanges = shapeInsideInfo->segmentRanges();
-
-    for (unsigned i = 0; i < segments.size() && !end.atEnd(); i++) {
-        InlineIterator segmentStart = resolver.position();
-        end = nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
-
-        ASSERT(segmentRanges.size() == i);
-        if (resolver.position().atEnd()) {
-            segmentRanges.append(LineSegmentRange(segmentStart, end));
-            break;
-        }
-        if (resolver.position() == end) {
-            // Nothing fit this segment
-            end = segmentStart;
-            segmentRanges.append(LineSegmentRange(segmentStart, segmentStart));
-            resolver.setPositionIgnoringNestedIsolates(segmentStart);
-        } else {
-            // Note that resolver.position is already skipping some of the white space at the beginning of the line,
-            // so that's why segmentStart might be different than resolver.position().
-            LineSegmentRange range(resolver.position(), end);
-            segmentRanges.append(range);
-            resolver.setPosition(end, numberOfIsolateAncestors(end));
-
-            if (lineInfo.previousLineBrokeCleanly()) {
-                // If we hit a new line break, just stop adding anything to this line.
-                break;
-            }
-        }
-    }
-    resolver.setPositionIgnoringNestedIsolates(oldEnd);
-    return end;
-#endif
-}
-
-InlineIterator LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
-{
-    reset();
-
-    ASSERT(resolver.position().root() == &m_block);
-
-    bool appliedStartWidth = resolver.position().offset();
-
-    LineWidth width(m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isFirstLine(), lineInfo.previousLineBrokeCleanly(), m_block.style()));
-
-    skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width);
-
-    if (resolver.position().atEnd())
-        return resolver.position();
-
-    BreakingContext context(*this, resolver, lineInfo, width, renderTextInfo, lastFloatFromPreviousLine, appliedStartWidth, m_block);
-
-    while (context.currentObject()) {
-        context.initializeForCurrentObject();
-        if (context.currentObject()->isBR()) {
-            context.handleBR(m_clear);
-        } else if (context.currentObject()->isOutOfFlowPositioned()) {
-            context.handleOutOfFlowPositioned(m_positionedObjects);
-        } else if (context.currentObject()->isFloating()) {
-            context.handleFloat();
-        } else if (context.currentObject()->isRenderInline()) {
-            context.handleEmptyInline();
-        } else if (context.currentObject()->isReplaced()) {
-            context.handleReplaced();
-        } else if (context.currentObject()->isText()) {
-            if (context.handleText(wordMeasurements, m_hyphenated, consecutiveHyphenatedLines)) {
-                // We've hit a hard text line break. Our line break iterator is updated, so go ahead and early return.
-                return context.lineBreak();
-            }
-        } else if (context.currentObject()->isLineBreakOpportunity())
-            context.commitLineBreakAtCurrentWidth(context.currentObject());
-        else
-            ASSERT_NOT_REACHED();
-
-        if (context.atEnd())
-            return context.handleEndOfLine();
-
-        context.commitAndUpdateLineBreakIfNeeded();
-
-        if (context.atEnd())
-            return context.handleEndOfLine();
-
-        context.increment();
-    }
-
-    context.clearLineBreakIfFitsOnLine(true);
-
-    return context.handleEndOfLine();
-}
-
 void RenderBlockFlow::addOverflowFromInlineChildren()
 {
     if (auto layout = simpleLineLayout()) {

Modified: trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h (161313 => 161314)


--- trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h	2014-01-04 18:31:57 UTC (rev 161313)
+++ trunk/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h	2014-01-04 20:53:51 UTC (rev 161314)
@@ -1085,7 +1085,7 @@
     }
 }
 
-InlineIterator BreakingContext::handleEndOfLine()
+inline InlineIterator BreakingContext::handleEndOfLine()
 {
 #if ENABLE(CSS_SHAPES)
     ShapeInsideInfo* shapeInfo = m_block.layoutShapeInsideInfo();

Modified: trunk/Source/WebCore/rendering/line/LineBreaker.cpp (161313 => 161314)


--- trunk/Source/WebCore/rendering/line/LineBreaker.cpp	2014-01-04 18:31:57 UTC (rev 161313)
+++ trunk/Source/WebCore/rendering/line/LineBreaker.cpp	2014-01-04 20:53:51 UTC (rev 161314)
@@ -25,7 +25,9 @@
 #include "config.h"
 #include "LineBreaker.h"
 
+#include "BreakingContextInlineHeaders.h"
 #include "RenderCombineText.h"
+#include "ShapeInsideInfo.h"
 
 namespace WebCore {
 
@@ -76,4 +78,113 @@
     resolver.commitExplicitEmbedding();
 }
 
+InlineIterator LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
+{
+#if !ENABLE(CSS_SHAPES)
+    return nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
+#else
+    ShapeInsideInfo* shapeInsideInfo = m_block.layoutShapeInsideInfo();
+
+    if (!shapeInsideInfo || !shapeInsideInfo->lineOverlapsShapeBounds())
+        return nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
+
+    InlineIterator end = resolver.position();
+    InlineIterator oldEnd = end;
+
+    if (!shapeInsideInfo->hasSegments()) {
+        end = nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
+        resolver.setPositionIgnoringNestedIsolates(oldEnd);
+        return oldEnd;
+    }
+
+    const SegmentList& segments = shapeInsideInfo->segments();
+    SegmentRangeList& segmentRanges = shapeInsideInfo->segmentRanges();
+
+    for (unsigned i = 0; i < segments.size() && !end.atEnd(); i++) {
+        InlineIterator segmentStart = resolver.position();
+        end = nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
+
+        ASSERT(segmentRanges.size() == i);
+        if (resolver.position().atEnd()) {
+            segmentRanges.append(LineSegmentRange(segmentStart, end));
+            break;
+        }
+        if (resolver.position() == end) {
+            // Nothing fit this segment
+            end = segmentStart;
+            segmentRanges.append(LineSegmentRange(segmentStart, segmentStart));
+            resolver.setPositionIgnoringNestedIsolates(segmentStart);
+        } else {
+            // Note that resolver.position is already skipping some of the white space at the beginning of the line,
+            // so that's why segmentStart might be different than resolver.position().
+            LineSegmentRange range(resolver.position(), end);
+            segmentRanges.append(range);
+            resolver.setPosition(end, numberOfIsolateAncestors(end));
+
+            if (lineInfo.previousLineBrokeCleanly()) {
+                // If we hit a new line break, just stop adding anything to this line.
+                break;
+            }
+        }
+    }
+    resolver.setPositionIgnoringNestedIsolates(oldEnd);
+    return end;
+#endif
 }
+
+InlineIterator LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
+{
+    reset();
+
+    ASSERT(resolver.position().root() == &m_block);
+
+    bool appliedStartWidth = resolver.position().offset();
+
+    LineWidth width(m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isFirstLine(), lineInfo.previousLineBrokeCleanly(), m_block.style()));
+
+    skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width);
+
+    if (resolver.position().atEnd())
+        return resolver.position();
+
+    BreakingContext context(*this, resolver, lineInfo, width, renderTextInfo, lastFloatFromPreviousLine, appliedStartWidth, m_block);
+
+    while (context.currentObject()) {
+        context.initializeForCurrentObject();
+        if (context.currentObject()->isBR()) {
+            context.handleBR(m_clear);
+        } else if (context.currentObject()->isOutOfFlowPositioned()) {
+            context.handleOutOfFlowPositioned(m_positionedObjects);
+        } else if (context.currentObject()->isFloating()) {
+            context.handleFloat();
+        } else if (context.currentObject()->isRenderInline()) {
+            context.handleEmptyInline();
+        } else if (context.currentObject()->isReplaced()) {
+            context.handleReplaced();
+        } else if (context.currentObject()->isText()) {
+            if (context.handleText(wordMeasurements, m_hyphenated, consecutiveHyphenatedLines)) {
+                // We've hit a hard text line break. Our line break iterator is updated, so go ahead and early return.
+                return context.lineBreak();
+            }
+        } else if (context.currentObject()->isLineBreakOpportunity())
+            context.commitLineBreakAtCurrentWidth(context.currentObject());
+        else
+            ASSERT_NOT_REACHED();
+
+        if (context.atEnd())
+            return context.handleEndOfLine();
+
+        context.commitAndUpdateLineBreakIfNeeded();
+
+        if (context.atEnd())
+            return context.handleEndOfLine();
+
+        context.increment();
+    }
+
+    context.clearLineBreakIfFitsOnLine(true);
+
+    return context.handleEndOfLine();
+}
+
+}

Modified: trunk/Source/WebCore/rendering/line/LineWidth.cpp (161313 => 161314)


--- trunk/Source/WebCore/rendering/line/LineWidth.cpp	2014-01-04 18:31:57 UTC (rev 161313)
+++ trunk/Source/WebCore/rendering/line/LineWidth.cpp	2014-01-04 20:53:51 UTC (rev 161314)
@@ -241,4 +241,22 @@
     return currentWidth() - m_trailingCollapsedWhitespaceWidth <= m_availableWidth;
 }
 
+IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBreak, const RenderStyle& style)
+{
+    IndentTextOrNot shouldIndentText = DoNotIndentText;
+    if (isFirstLine)
+        shouldIndentText = IndentText;
+#if ENABLE(CSS3_TEXT)
+    else if (isAfterHardLineBreak && style.textIndentLine() == TextIndentEachLine)
+        shouldIndentText = IndentText;
+
+    if (style.textIndentType() == TextIndentHanging)
+        shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : IndentText;
+#else
+    UNUSED_PARAM(isAfterHardLineBreak);
+    UNUSED_PARAM(style);
+#endif
+    return shouldIndentText;
 }
+
+}

Modified: trunk/Source/WebCore/rendering/line/LineWidth.h (161313 => 161314)


--- trunk/Source/WebCore/rendering/line/LineWidth.h	2014-01-04 18:31:57 UTC (rev 161313)
+++ trunk/Source/WebCore/rendering/line/LineWidth.h	2014-01-04 20:53:51 UTC (rev 161314)
@@ -38,6 +38,7 @@
 class RenderBlockFlow;
 class RenderObject;
 class RenderRubyRun;
+class RenderStyle;
 
 struct LineSegment;
 
@@ -92,6 +93,8 @@
     IndentTextOrNot m_shouldIndentText;
 };
 
+IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBreak, const RenderStyle&);
+
 }
 
 #endif // LineWidth_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to