This source file includes following definitions.
- skipLeadingWhitespace
- reset
- nextLineBreak
#include "config.h"
#include "core/rendering/line/LineBreaker.h"
#include "core/rendering/line/BreakingContextInlineHeaders.h"
namespace WebCore {
void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo& lineInfo,
FloatingObject* lastFloatFromPreviousLine, LineWidth& width)
{
while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(), lineInfo, LeadingWhitespace)) {
RenderObject* object = resolver.position().object();
if (object->isOutOfFlowPositioned()) {
setStaticPositions(m_block, toRenderBox(object));
if (object->style()->isOriginalDisplayInlineType()) {
resolver.runs().addRun(createRun(0, 1, object, resolver));
lineInfo.incrementRunsFromLeadingWhitespace();
}
} else if (object->isFloating()) {
m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, lineInfo, width);
} else if (object->isText() && object->style()->hasTextCombine() && object->isCombineText() && !toRenderCombineText(object)->isCombined()) {
toRenderCombineText(object)->combineText();
if (toRenderCombineText(object)->isCombined())
continue;
}
resolver.position().increment(&resolver);
}
resolver.commitExplicitEmbedding();
}
void LineBreaker::reset()
{
m_positionedObjects.clear();
m_hyphenated = false;
m_clear = CNONE;
}
InlineIterator LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordMeasurements)
{
reset();
ASSERT(resolver.position().root() == m_block);
bool appliedStartWidth = resolver.position().offset() > 0;
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(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)) {
return context.lineBreak();
}
} else {
ASSERT_NOT_REACHED();
}
if (context.atEnd())
return context.handleEndOfLine();
context.commitAndUpdateLineBreakIfNeeded();
if (context.atEnd())
return context.handleEndOfLine();
context.increment();
}
context.clearLineBreakIfFitsOnLine();
return context.handleEndOfLine();
}
}