void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo& lineInfo, LineWidth& width) { while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(), lineInfo, LeadingWhitespace)) { LineLayoutItem lineLayoutItem = resolver.position().getLineLayoutItem(); if (lineLayoutItem.isOutOfFlowPositioned()) { setStaticPositions(m_block, LineLayoutBox(lineLayoutItem), width.indentText()); if (lineLayoutItem.style()->isOriginalDisplayInlineType()) { resolver.runs().addRun(createRun(0, 1, LineLayoutItem(lineLayoutItem), resolver)); lineInfo.incrementRunsFromLeadingWhitespace(); } } else if (lineLayoutItem.isFloating()) { m_block.insertFloatingObject(LineLayoutBox(lineLayoutItem)); m_block.positionNewFloats(&width); } resolver.position().increment(&resolver); } resolver.commitExplicitEmbedding(resolver.runs()); }
void TrailingObjects::updateMidpointsForTrailingObjects(LineMidpointState& lineMidpointState, const InlineIterator& lBreak, CollapseFirstSpaceOrNot collapseFirstSpace) { if (!m_whitespace) return; // This object is either going to be part of the last midpoint, or it is going to be the actual endpoint. // In both cases we just decrease our pos by 1 level to exclude the space, allowing it to - in effect - collapse into the newline. if (lineMidpointState.numMidpoints() % 2) { // Find the trailing space object's midpoint. int trailingSpaceMidpoint = lineMidpointState.numMidpoints() - 1; for ( ; trailingSpaceMidpoint > 0 && lineMidpointState.midpoints()[trailingSpaceMidpoint].object() != m_whitespace; --trailingSpaceMidpoint) { } ASSERT(trailingSpaceMidpoint >= 0); if (collapseFirstSpace == CollapseFirstSpace) lineMidpointState.midpoints()[trailingSpaceMidpoint].setOffset(lineMidpointState.midpoints()[trailingSpaceMidpoint].offset() -1); // Now make sure every single trailingPositionedBox following the trailingSpaceMidpoint properly stops and starts // ignoring spaces. size_t currentMidpoint = trailingSpaceMidpoint + 1; for (size_t i = 0; i < m_objects.size(); ++i) { if (currentMidpoint >= lineMidpointState.numMidpoints()) { // We don't have a midpoint for this box yet. ensureLineBoxInsideIgnoredSpaces(&lineMidpointState, LineLayoutItem(m_objects[i])); } else { ASSERT(lineMidpointState.midpoints()[currentMidpoint].object() == m_objects[i]); ASSERT(lineMidpointState.midpoints()[currentMidpoint + 1].object() == m_objects[i]); } currentMidpoint += 2; } } else if (!lBreak.object()) { ASSERT(collapseFirstSpace == CollapseFirstSpace); // Add a new end midpoint that stops right at the very end. unsigned length = m_whitespace.textLength(); unsigned pos = length >= 2 ? length - 2 : UINT_MAX; InlineIterator endMid(0, m_whitespace, pos); lineMidpointState.startIgnoringSpaces(endMid); for (size_t i = 0; i < m_objects.size(); ++i) { ensureLineBoxInsideIgnoredSpaces(&lineMidpointState, m_objects[i]); } } }
InlineTextBox* LayoutSVGInlineText::createTextBox(int start, unsigned short length) { InlineTextBox* box = new SVGInlineTextBox(LineLayoutItem(this), start, length); box->setHasVirtualLogicalHeight(); return box; }
InlineFlowBox* LayoutSVGInline::createInlineFlowBox() { InlineFlowBox* box = new SVGInlineFlowBox(LineLayoutItem(this)); box->setHasVirtualLogicalHeight(); return box; }