RunResolver::RunResolver(const RenderBlockFlow& flow, const Layout& layout) : m_flowRenderer(flow) , m_layout(layout) , m_flowContents(flow) , m_lineHeight(lineHeightFromFlow(flow)) , m_baseline(baselineFromFlow(flow)) , m_borderAndPaddingBefore(flow.borderAndPaddingBefore()) , m_ascent(flow.style().fontCascade().fontMetrics().ascent()) , m_descent(flow.style().fontCascade().fontMetrics().descent()) , m_visualOverflowOffset(visualOverflowForDecorations(flow.style(), nullptr).bottom) , m_inQuirksMode(flow.document().inQuirksMode()) { }
static void createTextRuns(Layout::RunVector& runs, RenderBlockFlow& flow, unsigned& lineCount) { LayoutUnit borderAndPaddingBefore = flow.borderAndPaddingBefore(); LayoutUnit lineHeight = lineHeightFromFlow(flow); LineState line; bool isEndOfContent = false; TextFragmentIterator textFragmentIterator = TextFragmentIterator(flow); do { flow.setLogicalHeight(lineHeight * lineCount + borderAndPaddingBefore); LineState previousLine = line; unsigned previousRunCount = runs.size(); line = LineState(); updateLineConstrains(flow, line, !lineCount); isEndOfContent = createLineRuns(line, previousLine, runs, textFragmentIterator); closeLineEndingAndAdjustRuns(line, runs, previousRunCount, lineCount, textFragmentIterator); } while (!isEndOfContent); }
void createTextRuns(Layout::RunVector& runs, unsigned& lineCount, RenderBlockFlow& flow, RenderText& textRenderer) { const Style style(flow.style()); const CharacterType* text = textRenderer.text()->characters<CharacterType>(); const unsigned textLength = textRenderer.textLength(); LayoutUnit borderAndPaddingBefore = flow.borderAndPaddingBefore(); LayoutUnit lineHeight = lineHeightFromFlow(flow); LazyLineBreakIterator lineBreakIterator(textRenderer.text(), flow.style().locale()); unsigned lineEnd = 0; while (lineEnd < textLength) { if (style.collapseWhitespace) lineEnd = skipWhitespaces(text, lineEnd, textLength, style.preserveNewline); unsigned lineStart = lineEnd; // LineWidth reads the current y position from the flow so keep it updated. flow.setLogicalHeight(lineHeight * lineCount + borderAndPaddingBefore); LineWidth lineWidth(flow, false, DoNotIndentText); auto lineRuns = createLineRuns(lineStart, lineWidth, lineBreakIterator, style, text, textLength, textRenderer); lineEnd = lineRuns.last().end; if (lineStart == lineEnd) continue; lineRuns.last().isEndOfLine = true; float lineLeft = computeLineLeft(style.textAlign, lineWidth); adjustRunOffsets(lineRuns, lineLeft); for (unsigned i = 0; i < lineRuns.size(); ++i) runs.append(lineRuns[i]); ++lineCount; } }