Commit fea51996 authored by antti@apple.com's avatar antti@apple.com
Browse files

Prepare simple line layout to support multiple runs per line

https://bugs.webkit.org/show_bug.cgi?id=123400

Reviewed by Andreas Kling.

Bunch of renaming and some refactoring for future support for text runs.

SimpleLineLayout::Lines -> SimpleLineLayout::Layout and becomes a class instead of a typedef.
SimpleLineLayout::Resolver::Line -> SimpleLineLayout::Resolver::Run
SimpleLineLayout::createLines() -> SimpleLineLayout::create()
RenderBlockFlow::simpleLines() -> RenderBlockFlow::simpleLineLayout()
RenderText::simpleLines() -> RenderText::simpleLineLayout()
        
Added resolver construction functions:
        
SimpleLineLayout::runResolver()
SimpleLineLayout::lineResolver()



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158107 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0931c9ef
2013-10-28 Antti Koivisto <antti@apple.com>
Prepare simple line layout to support multiple runs per line
https://bugs.webkit.org/show_bug.cgi?id=123400
Reviewed by Andreas Kling.
Bunch of renaming and some refactoring for future support for text runs.
SimpleLineLayout::Lines -> SimpleLineLayout::Layout and becomes a class instead of a typedef.
SimpleLineLayout::Resolver::Line -> SimpleLineLayout::Resolver::Run
SimpleLineLayout::createLines() -> SimpleLineLayout::create()
RenderBlockFlow::simpleLines() -> RenderBlockFlow::simpleLineLayout()
RenderText::simpleLines() -> RenderText::simpleLineLayout()
Added resolver construction functions:
SimpleLineLayout::runResolver()
SimpleLineLayout::lineResolver()
2013-10-28 Mario Sanchez Prada <mario.prada@samsung.com>
[GTK] Expose title and alternative text for links in image maps
......
......@@ -520,7 +520,7 @@ bool TextIterator::handleTextNode()
return true;
}
if (renderer->simpleLines()) {
if (renderer->simpleLineLayout()) {
if (renderer->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility)
return true;
// This code aims to produce same results as handleTextBox() below so test results don't change. It does not make much logical sense.
......
......@@ -531,7 +531,7 @@ void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& re
return;
}
m_simpleLines = nullptr;
m_simpleLineLayout = nullptr;
layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
}
......@@ -1652,9 +1652,9 @@ void RenderBlockFlow::deleteLines()
if (containsFloats())
m_floatingObjects->clearLineBoxTreePointers();
if (m_simpleLines) {
if (m_simpleLineLayout) {
ASSERT(!m_lineBoxes.firstLineBox());
m_simpleLines = nullptr;
m_simpleLineLayout = nullptr;
} else
m_lineBoxes.deleteLineBoxTree(renderArena());
......@@ -2438,8 +2438,8 @@ bool RenderBlockFlow::hitTestInlineChildren(const HitTestRequest& request, HitTe
{
ASSERT(childrenInline());
if (m_simpleLines)
return SimpleLineLayout::hitTestFlow(*this, *m_simpleLines, request, result, locationInContainer, accumulatedOffset, hitTestAction);
if (m_simpleLineLayout)
return SimpleLineLayout::hitTestFlow(*this, *m_simpleLineLayout, request, result, locationInContainer, accumulatedOffset, hitTestAction);
return m_lineBoxes.hitTest(this, request, result, locationInContainer, accumulatedOffset, hitTestAction);
}
......@@ -2545,8 +2545,8 @@ int RenderBlockFlow::firstLineBaseline() const
if (!hasLines())
return -1;
if (m_simpleLines)
return SimpleLineLayout::computeFlowFirstLineBaseline(*this, *m_simpleLines);
if (m_simpleLineLayout)
return SimpleLineLayout::computeFlowFirstLineBaseline(*this, *m_simpleLineLayout);
ASSERT(firstLineBox());
return firstLineBox()->logicalTop() + firstLineStyle()->fontMetrics().ascent(firstRootBox()->baselineType());
......@@ -2569,8 +2569,8 @@ int RenderBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const
+ (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
}
if (m_simpleLines)
return SimpleLineLayout::computeFlowLastLineBaseline(*this, *m_simpleLines);
if (m_simpleLineLayout)
return SimpleLineLayout::computeFlowLastLineBaseline(*this, *m_simpleLineLayout);
bool isFirstLine = lastLineBox() == firstLineBox();
RenderStyle* style = isFirstLine ? firstLineStyle() : this->style();
......@@ -2580,7 +2580,7 @@ int RenderBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const
GapRects RenderBlockFlow::inlineSelectionGaps(RenderBlock& rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const LogicalSelectionOffsetCaches& cache, const PaintInfo* paintInfo)
{
ASSERT(!m_simpleLines);
ASSERT(!m_simpleLineLayout);
GapRects result;
......@@ -2939,8 +2939,8 @@ void RenderBlockFlow::paintInlineChildren(PaintInfo& paintInfo, const LayoutPoin
{
ASSERT(childrenInline());
if (m_simpleLines) {
SimpleLineLayout::paintFlow(*this, *m_simpleLines, paintInfo, paintOffset);
if (m_simpleLineLayout) {
SimpleLineLayout::paintFlow(*this, *m_simpleLineLayout, paintInfo, paintOffset);
return;
}
m_lineBoxes.paint(this, paintInfo, paintOffset);
......@@ -3002,8 +3002,8 @@ bool RenderBlockFlow::hasLines() const
{
ASSERT(childrenInline());
if (m_simpleLines)
return !m_simpleLines->isEmpty();
if (m_simpleLineLayout)
return m_simpleLineLayout->lineCount;
return lineBoxes().firstLineBox();
}
......@@ -3012,9 +3012,9 @@ void RenderBlockFlow::layoutSimpleLines(LayoutUnit& repaintLogicalTop, LayoutUni
{
ASSERT(!m_lineBoxes.firstLineBox());
m_simpleLines = SimpleLineLayout::createLines(*this);
m_simpleLineLayout = SimpleLineLayout::create(*this);
LayoutUnit lineLayoutHeight = SimpleLineLayout::computeFlowHeight(*this, *m_simpleLines);
LayoutUnit lineLayoutHeight = SimpleLineLayout::computeFlowHeight(*this, *m_simpleLineLayout);
LayoutUnit lineLayoutTop = borderAndPaddingBefore();
repaintLogicalTop = lineLayoutTop;
......@@ -3034,9 +3034,9 @@ void RenderBlockFlow::ensureLineBoxes()
{
m_lineLayoutPath = ForceLineBoxesPath;
if (!m_simpleLines)
if (!m_simpleLineLayout)
return;
m_simpleLines = nullptr;
m_simpleLineLayout = nullptr;
#if !ASSERT_DISABLED
LayoutUnit oldHeight = logicalHeight();
......
......@@ -324,7 +324,7 @@ public:
bool containsNonZeroBidiLevel() const;
const SimpleLineLayout::Lines* simpleLines() const { return m_simpleLines.get(); }
const SimpleLineLayout::Layout* simpleLineLayout() const { return m_simpleLineLayout.get(); }
void deleteLineBoxesBeforeSimpleLineLayout();
void ensureLineBoxes();
......@@ -487,7 +487,7 @@ protected:
OwnPtr<FloatingObjects> m_floatingObjects;
OwnPtr<RenderBlockFlowRareData> m_rareData;
RenderLineBoxList m_lineBoxes;
std::unique_ptr<SimpleLineLayout::Lines> m_simpleLines;
std::unique_ptr<SimpleLineLayout::Layout> m_simpleLineLayout;
friend class BreakingContext;
friend class LineBreaker;
......
......@@ -1840,7 +1840,7 @@ void RenderBlockFlow::repaintDirtyFloats(Vector<FloatWithRect>& floats)
void RenderBlockFlow::layoutLineBoxes(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
{
ASSERT(!m_simpleLines);
ASSERT(!m_simpleLineLayout);
setLogicalHeight(borderAndPaddingBefore());
......@@ -3517,9 +3517,9 @@ InlineIterator LineBreaker::nextSegmentBreak(InlineBidiResolver& resolver, LineI
void RenderBlockFlow::addOverflowFromInlineChildren()
{
if (auto lines = simpleLines()) {
if (auto layout = simpleLineLayout()) {
ASSERT(!hasOverflowClip());
SimpleLineLayout::collectFlowOverflow(*this, *lines);
SimpleLineLayout::collectFlowOverflow(*this, *layout);
return;
}
LayoutUnit endPadding = hasOverflowClip() ? paddingEnd() : LayoutUnit();
......
......@@ -877,7 +877,7 @@ void RenderText::setTextWithOffset(const String& text, unsigned offset, unsigned
int delta = text.length() - textLength();
unsigned end = len ? offset + len - 1 : offset;
m_linesDirty = simpleLines() || m_lineBoxes.dirtyRange(*this, offset, end, delta);
m_linesDirty = simpleLineLayout() || m_lineBoxes.dirtyRange(*this, offset, end, delta);
setText(text, force || m_linesDirty);
}
......@@ -1057,11 +1057,11 @@ void RenderText::ensureLineBoxes()
toRenderBlockFlow(parent())->ensureLineBoxes();
}
const SimpleLineLayout::Lines* RenderText::simpleLines() const
const SimpleLineLayout::Layout* RenderText::simpleLineLayout() const
{
if (!parent()->isRenderBlockFlow())
return nullptr;
return toRenderBlockFlow(parent())->simpleLines();
return toRenderBlockFlow(parent())->simpleLineLayout();
}
float RenderText::width(unsigned from, unsigned len, float xPos, bool firstLine, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
......@@ -1114,15 +1114,15 @@ float RenderText::width(unsigned from, unsigned len, const Font& f, float xPos,
IntRect RenderText::linesBoundingBox() const
{
if (auto lines = simpleLines())
return SimpleLineLayout::computeTextBoundingBox(*this, *lines);
if (auto layout = simpleLineLayout())
return SimpleLineLayout::computeTextBoundingBox(*this, *layout);
return m_lineBoxes.boundingBox(*this);
}
LayoutRect RenderText::linesVisualOverflowBoundingBox() const
{
ASSERT(!simpleLines());
ASSERT(!simpleLineLayout());
return m_lineBoxes.visualOverflowBoundingBox(*this);
}
......@@ -1145,7 +1145,7 @@ LayoutRect RenderText::clippedOverflowRectForRepaint(const RenderLayerModelObjec
LayoutRect RenderText::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent)
{
ASSERT(!needsLayout());
ASSERT(!simpleLines());
ASSERT(!simpleLineLayout());
if (selectionState() == SelectionNone)
return LayoutRect();
......@@ -1187,41 +1187,41 @@ LayoutRect RenderText::selectionRectForRepaint(const RenderLayerModelObject* rep
int RenderText::caretMinOffset() const
{
if (auto lines = simpleLines())
return SimpleLineLayout::findTextCaretMinimumOffset(*this, *lines);
if (auto layout = simpleLineLayout())
return SimpleLineLayout::findTextCaretMinimumOffset(*this, *layout);
return m_lineBoxes.caretMinOffset();
}
int RenderText::caretMaxOffset() const
{
if (auto lines = simpleLines())
return SimpleLineLayout::findTextCaretMaximumOffset(*this, *lines);
if (auto layout = simpleLineLayout())
return SimpleLineLayout::findTextCaretMaximumOffset(*this, *layout);
return m_lineBoxes.caretMaxOffset(*this);
}
unsigned RenderText::countRenderedCharacterOffsetsUntil(unsigned offset) const
{
ASSERT(!simpleLines());
ASSERT(!simpleLineLayout());
return m_lineBoxes.countCharacterOffsetsUntil(offset);
}
bool RenderText::containsRenderedCharacterOffset(unsigned offset) const
{
ASSERT(!simpleLines());
ASSERT(!simpleLineLayout());
return m_lineBoxes.containsOffset(*this, offset, RenderTextLineBoxes::CharacterOffset);
}
bool RenderText::containsCaretOffset(unsigned offset) const
{
if (auto layout = simpleLines())
if (auto layout = simpleLineLayout())
return SimpleLineLayout::containsTextCaretOffset(*this, *layout, offset);
return m_lineBoxes.containsOffset(*this, offset, RenderTextLineBoxes::CaretOffset);
}
bool RenderText::hasRenderedText() const
{
if (auto lines = simpleLines())
return SimpleLineLayout::isTextRendered(*this, *lines);
if (auto layout = simpleLineLayout())
return SimpleLineLayout::isTextRendered(*this, *layout);
return m_lineBoxes.hasRenderedText();
}
......
......@@ -154,7 +154,7 @@ public:
void ensureLineBoxes();
void deleteLineBoxesBeforeSimpleLineLayout();
const SimpleLineLayout::Lines* simpleLines() const;
const SimpleLineLayout::Layout* simpleLineLayout() const;
protected:
virtual void computePreferredLogicalWidths(float leadWidth);
......
......@@ -246,7 +246,7 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
// many test results.
const RenderText& text = toRenderText(o);
IntRect linesBox = text.linesBoundingBox();
if (text.simpleLines()) {
if (text.simpleLineLayout()) {
int y = linesBox.y();
if (text.containingBlock()->isTableCell())
y -= toRenderTableCell(o.containingBlock())->intrinsicPaddingBefore();
......@@ -593,13 +593,13 @@ void write(TextStream& ts, const RenderObject& o, int indent, RenderAsTextBehavi
if (o.isText()) {
auto& text = toRenderText(o);
if (auto lines = text.simpleLines()) {
if (auto layout = text.simpleLineLayout()) {
ASSERT(!text.firstTextBox());
SimpleLineLayout::Resolver resolver(*lines, toRenderBlockFlow(*text.parent()));
auto resolver = runResolver(toRenderBlockFlow(*text.parent()), *layout);
for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
auto line = *it;
auto run = *it;
writeIndent(ts, indent + 1);
writeSimpleLine(ts, text, line.rect(), line.text());
writeSimpleLine(ts, text, run.rect(), run.text());
}
} else {
for (auto box = text.firstTextBox(); box; box = box->nextTextBox()) {
......
......@@ -231,9 +231,9 @@ static float computeLineLeft(ETextAlign textAlign, float remainingWidth)
return 0;
}
std::unique_ptr<Lines> createLines(RenderBlockFlow& flow)
std::unique_ptr<Layout> create(RenderBlockFlow& flow)
{
auto lines = std::make_unique<Lines>();
auto layout = std::make_unique<Layout>();
RenderText& textRenderer = toRenderText(*flow.firstChild());
ASSERT(!textRenderer.firstTextBox());
......@@ -292,19 +292,20 @@ std::unique_ptr<Lines> createLines(RenderBlockFlow& flow)
float alignedLeft = computeLineLeft(textAlign, lineWidth.availableWidth() - lineWidth.committedWidth());
float alignedRight = alignedLeft + lineWidth.committedWidth();
Line line;
line.textOffset = lineStartOffset;
line.textLength = lineEndOffset - lineStartOffset;
line.left = floor(alignedLeft);
line.width = ceil(alignedRight) - line.left;
Run run;
run.textOffset = lineStartOffset;
run.textLength = lineEndOffset - lineStartOffset;
run.left = floor(alignedLeft);
run.width = ceil(alignedRight) - run.left;
lines->append(line);
layout->runs.append(run);
layout->lineCount++;
}
textRenderer.clearNeedsLayout();
lines->shrinkToFit();
return lines;
layout->runs.shrinkToFit();
return layout;
}
}
......
......@@ -37,16 +37,21 @@ namespace SimpleLineLayout {
bool canUseFor(const RenderBlockFlow&);
struct Line {
struct Run {
unsigned textOffset;
unsigned textLength;
float left;
float width;
};
typedef Vector<Line> Lines;
struct Layout {
Layout() : lineCount(0) { }
std::unique_ptr<Lines> createLines(RenderBlockFlow&);
unsigned lineCount;
Vector<Run> runs;
};
std::unique_ptr<Layout> create(RenderBlockFlow&);
}
}
......
......@@ -45,7 +45,7 @@
namespace WebCore {
namespace SimpleLineLayout {
void paintFlow(const RenderBlockFlow& flow, const Lines& lines, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
void paintFlow(const RenderBlockFlow& flow, const Layout& layout, PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (paintInfo.phase != PaintPhaseForeground)
return;
......@@ -62,19 +62,19 @@ void paintFlow(const RenderBlockFlow& flow, const Lines& lines, PaintInfo& paint
updateGraphicsContext(context, textPaintStyle);
Resolver resolver(lines, flow);
auto resolver = runResolver(flow, layout);
for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
auto line = *it;
context.drawText(font, TextRun(line.text()), line.baseline() + paintOffset);
auto run = *it;
context.drawText(font, TextRun(run.text()), run.baseline() + paintOffset);
}
}
bool hitTestFlow(const RenderBlockFlow& flow, const Lines& lines, const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
bool hitTestFlow(const RenderBlockFlow& flow, const Layout& layout, const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
{
if (hitTestAction != HitTestForeground)
return false;
if (lines.isEmpty())
if (layout.runs.isEmpty())
return false;
RenderStyle& style = *flow.style();
......@@ -83,7 +83,7 @@ bool hitTestFlow(const RenderBlockFlow& flow, const Lines& lines, const HitTestR
RenderText& textRenderer = toRenderText(*flow.firstChild());
Resolver resolver(lines, flow);
auto resolver = lineResolver(flow, layout);
for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
auto line = *it;
auto lineRect = line.rect();
......@@ -98,9 +98,9 @@ bool hitTestFlow(const RenderBlockFlow& flow, const Lines& lines, const HitTestR
return false;
}
void collectFlowOverflow(RenderBlockFlow& flow, const Lines& lines)
void collectFlowOverflow(RenderBlockFlow& flow, const Layout& layout)
{
Resolver resolver(lines, flow);
auto resolver = lineResolver(flow, layout);
for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) {
auto line = *it;
auto rect = line.rect();
......@@ -109,9 +109,9 @@ void collectFlowOverflow(RenderBlockFlow& flow, const Lines& lines)
}
}
IntRect computeTextBoundingBox(const RenderText& textRenderer, const Lines& lines)
IntRect computeTextBoundingBox(const RenderText& textRenderer, const Layout& layout)
{
Resolver resolver(lines, toRenderBlockFlow(*textRenderer.parent()));
auto resolver = lineResolver(toRenderBlockFlow(*textRenderer.parent()), layout);
auto it = resolver.begin();
auto end = resolver.end();
if (it == end)
......
......@@ -42,19 +42,19 @@ struct PaintInfo;
namespace SimpleLineLayout {
LayoutUnit computeFlowHeight(const RenderBlockFlow&, const Lines&);
LayoutUnit computeFlowFirstLineBaseline(const RenderBlockFlow&, const Lines&);
LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow&, const Lines&);
LayoutUnit computeFlowHeight(const RenderBlockFlow&, const Layout&);
LayoutUnit computeFlowFirstLineBaseline(const RenderBlockFlow&, const Layout&);
LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow&, const Layout&);
void paintFlow(const RenderBlockFlow&, const Lines&, PaintInfo&, const LayoutPoint& paintOffset);
bool hitTestFlow(const RenderBlockFlow&, const Lines&, const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
void collectFlowOverflow(RenderBlockFlow&, const Lines&);
void paintFlow(const RenderBlockFlow&, const Layout&, PaintInfo&, const LayoutPoint& paintOffset);
bool hitTestFlow(const RenderBlockFlow&, const Layout&, const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
void collectFlowOverflow(RenderBlockFlow&, const Layout&);
bool isTextRendered(const RenderText&, const Lines&);
bool containsTextCaretOffset(const RenderText&, const Lines&, unsigned);
unsigned findTextCaretMinimumOffset(const RenderText&, const Lines&);
unsigned findTextCaretMaximumOffset(const RenderText&, const Lines&);
IntRect computeTextBoundingBox(const RenderText&, const Lines&);
bool isTextRendered(const RenderText&, const Layout&);
bool containsTextCaretOffset(const RenderText&, const Layout&, unsigned);
unsigned findTextCaretMinimumOffset(const RenderText&, const Layout&);
unsigned findTextCaretMaximumOffset(const RenderText&, const Layout&);
IntRect computeTextBoundingBox(const RenderText&, const Layout&);
LayoutUnit lineHeightFromFlow(const RenderBlockFlow&);
LayoutUnit baselineFromFlow(const RenderBlockFlow&);
......@@ -63,42 +63,42 @@ LayoutUnit baselineFromFlow(const RenderBlockFlow&);
namespace SimpleLineLayout {
inline LayoutUnit computeFlowHeight(const RenderBlockFlow& flow, const Lines& lines)
inline LayoutUnit computeFlowHeight(const RenderBlockFlow& flow, const Layout& layout)
{
return lineHeightFromFlow(flow) * lines.size();
return lineHeightFromFlow(flow) * layout.lineCount;
}
inline LayoutUnit computeFlowFirstLineBaseline(const RenderBlockFlow& flow, const Lines& lines)
inline LayoutUnit computeFlowFirstLineBaseline(const RenderBlockFlow& flow, const Layout& layout)
{
ASSERT_UNUSED(lines, !lines.isEmpty());
ASSERT_UNUSED(layout, !layout.runs.isEmpty());
return flow.borderAndPaddingBefore() + baselineFromFlow(flow);
}
inline LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow& flow, const Lines& lines)
inline LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow& flow, const Layout& layout)
{
ASSERT(!lines.isEmpty());
return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (lines.size() - 1) + baselineFromFlow(flow);
ASSERT(!layout.runs.isEmpty());
return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.runs.size() - 1) + baselineFromFlow(flow);
}
inline unsigned findTextCaretMinimumOffset(const RenderText&, const Lines& lines)
inline unsigned findTextCaretMinimumOffset(const RenderText&, const Layout& layout)
{
if (lines.isEmpty())
if (layout.runs.isEmpty())
return 0;
return lines[0].textOffset;
return layout.runs[0].textOffset;
}
inline unsigned findTextCaretMaximumOffset(const RenderText& renderer, const Lines& lines)
inline unsigned findTextCaretMaximumOffset(const RenderText& renderer, const Layout& layout)
{
if (lines.isEmpty())
if (layout.runs.isEmpty())
return renderer.textLength();
auto& last = lines[lines.size() - 1];
auto& last = layout.runs[layout.runs.size() - 1];
return last.textOffset + last.textLength;
}
inline bool containsTextCaretOffset(const RenderText&, const Lines& lines, unsigned offset)
inline bool containsTextCaretOffset(const RenderText&, const Layout& layout, unsigned offset)
{
for (unsigned i = 0; i < lines.size(); ++i) {
auto& line = lines[i];
for (unsigned i = 0; i < layout.runs.size(); ++i) {
auto& line = layout.runs[i];
if (offset < line.textOffset)
return false;
if (offset <= line.textOffset + line.textLength)
......@@ -107,10 +107,10 @@ inline bool containsTextCaretOffset(const RenderText&, const Lines& lines, unsig
return false;
}
inline bool isTextRendered(const RenderText&, const Lines& lines)
inline bool isTextRendered(const RenderText&, const Layout& layout)
{
for (unsigned i = 0; i < lines.size(); ++i) {
if (lines[i].textLength)
for (unsigned i = 0; i < layout.runs.size(); ++i) {
if (layout.runs[i].textLength)
return true;
}
return false;
......
......@@ -40,9 +40,9 @@ class Resolver {
public:
class Iterator;
class Line {
class Run {
public:
Line(const Resolver&, unsigned lineIndex);
Run(const Resolver&, unsigned lineIndex);
LayoutRect rect() const;
LayoutPoint baseline() const;
......@@ -62,14 +62,14 @@ public:
bool operator==(const Iterator&) const;
bool operator!=(const Iterator&) const;
Line operator*() const;
Run operator*() const;
private:
const Resolver& m_resolver;
unsigned m_lineIndex;
};
Resolver(const Lines&, const RenderBlockFlow