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/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();
+}
+
+}