Title: [158107] trunk/Source/WebCore
Revision
158107
Author
[email protected]
Date
2013-10-28 06:39:23 -0700 (Mon, 28 Oct 2013)

Log Message

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()

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158106 => 158107)


--- trunk/Source/WebCore/ChangeLog	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/ChangeLog	2013-10-28 13:39:23 UTC (rev 158107)
@@ -1,3 +1,23 @@
+2013-10-28  Antti Koivisto  <[email protected]>
+
+        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  <[email protected]>
 
         [GTK] Expose title and alternative text for links in image maps

Modified: trunk/Source/WebCore/editing/TextIterator.cpp (158106 => 158107)


--- trunk/Source/WebCore/editing/TextIterator.cpp	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/editing/TextIterator.cpp	2013-10-28 13:39:23 UTC (rev 158107)
@@ -520,7 +520,7 @@
         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.

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (158106 => 158107)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2013-10-28 13:39:23 UTC (rev 158107)
@@ -531,7 +531,7 @@
         return;
     }
 
-    m_simpleLines = nullptr;
+    m_simpleLineLayout = nullptr;
     layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
 }
 
@@ -1652,9 +1652,9 @@
     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 @@
 {
     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 @@
     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 @@
              + (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 @@
 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 @@
 {
     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 @@
 {
     ASSERT(childrenInline());
 
-    if (m_simpleLines)
-        return !m_simpleLines->isEmpty();
+    if (m_simpleLineLayout)
+        return m_simpleLineLayout->lineCount;
 
     return lineBoxes().firstLineBox();
 }
@@ -3012,9 +3012,9 @@
 {
     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 @@
 {
     m_lineLayoutPath = ForceLineBoxesPath;
 
-    if (!m_simpleLines)
+    if (!m_simpleLineLayout)
         return;
-    m_simpleLines = nullptr;
+    m_simpleLineLayout = nullptr;
 
 #if !ASSERT_DISABLED
     LayoutUnit oldHeight = logicalHeight();

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (158106 => 158107)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.h	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h	2013-10-28 13:39:23 UTC (rev 158107)
@@ -324,7 +324,7 @@
 
     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 @@
     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;

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (158106 => 158107)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-10-28 13:39:23 UTC (rev 158107)
@@ -1840,7 +1840,7 @@
 
 void RenderBlockFlow::layoutLineBoxes(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
 {
-    ASSERT(!m_simpleLines);
+    ASSERT(!m_simpleLineLayout);
 
     setLogicalHeight(borderAndPaddingBefore());
     
@@ -3517,9 +3517,9 @@
 
 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();

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (158106 => 158107)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2013-10-28 13:39:23 UTC (rev 158107)
@@ -877,7 +877,7 @@
     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 @@
     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 @@
 
 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::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent)
 {
     ASSERT(!needsLayout());
-    ASSERT(!simpleLines());
+    ASSERT(!simpleLineLayout());
 
     if (selectionState() == SelectionNone)
         return LayoutRect();
@@ -1187,41 +1187,41 @@
 
 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();
 }
 

Modified: trunk/Source/WebCore/rendering/RenderText.h (158106 => 158107)


--- trunk/Source/WebCore/rendering/RenderText.h	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/RenderText.h	2013-10-28 13:39:23 UTC (rev 158107)
@@ -154,7 +154,7 @@
 
     void ensureLineBoxes();
     void deleteLineBoxesBeforeSimpleLineLayout();
-    const SimpleLineLayout::Lines* simpleLines() const;
+    const SimpleLineLayout::Layout* simpleLineLayout() const;
 
 protected:
     virtual void computePreferredLogicalWidths(float leadWidth);

Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (158106 => 158107)


--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2013-10-28 13:39:23 UTC (rev 158107)
@@ -246,7 +246,7 @@
         // 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 @@
 
     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()) {

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (158106 => 158107)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2013-10-28 13:39:23 UTC (rev 158107)
@@ -231,9 +231,9 @@
     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 @@
         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;
 }
 
 }

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.h (158106 => 158107)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.h	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.h	2013-10-28 13:39:23 UTC (rev 158107)
@@ -37,17 +37,22 @@
 
 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&);
+
 }
 }
 

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (158106 => 158107)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp	2013-10-28 13:39:23 UTC (rev 158107)
@@ -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 @@
 
     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 @@
 
     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 @@
     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 @@
     }
 }
 
-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)

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h (158106 => 158107)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h	2013-10-28 13:39:23 UTC (rev 158107)
@@ -42,19 +42,19 @@
 
 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 @@
 
 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 @@
     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;

Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (158106 => 158107)


--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2013-10-28 12:32:33 UTC (rev 158106)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h	2013-10-28 13:39:23 UTC (rev 158107)
@@ -40,9 +40,9 @@
 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 @@
         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&);
+    Resolver(const RenderBlockFlow&, const Layout&);
 
     unsigned size() const;
 
@@ -79,7 +79,7 @@
     Iterator operator[](unsigned) const;
 
 private:
-    const Lines& m_lines;
+    const Layout& m_layout;
     const String m_string;
     const LayoutUnit m_lineHeight;
     const LayoutUnit m_baseline;
@@ -88,33 +88,36 @@
     const LayoutPoint m_contentOffset;
 };
 
-inline Resolver::Line::Line(const Resolver& resolver, unsigned lineIndex)
+Resolver runResolver(const RenderBlockFlow&, const Layout&);
+Resolver lineResolver(const RenderBlockFlow&, const Layout&);
+
+inline Resolver::Run::Run(const Resolver& resolver, unsigned lineIndex)
     : m_resolver(resolver)
     , m_lineIndex(lineIndex)
 {
 }
 
-inline LayoutRect Resolver::Line::rect() const
+inline LayoutRect Resolver::Run::rect() const
 {
-    auto& line = m_resolver.m_lines[m_lineIndex];
+    auto& run = m_resolver.m_layout.runs[m_lineIndex];
 
-    LayoutPoint linePosition(line.left, m_resolver.m_lineHeight * m_lineIndex + m_resolver.m_baseline - m_resolver.m_ascent);
-    LayoutSize lineSize(line.width, m_resolver.m_ascent + m_resolver.m_descent);
+    LayoutPoint linePosition(run.left, m_resolver.m_lineHeight * m_lineIndex + m_resolver.m_baseline - m_resolver.m_ascent);
+    LayoutSize lineSize(run.width, m_resolver.m_ascent + m_resolver.m_descent);
     return LayoutRect(linePosition + m_resolver.m_contentOffset, lineSize);
 }
 
-inline LayoutPoint Resolver::Line::baseline() const
+inline LayoutPoint Resolver::Run::baseline() const
 {
-    auto& line = m_resolver.m_lines[m_lineIndex];
+    auto& run = m_resolver.m_layout.runs[m_lineIndex];
 
     float baselineY = m_resolver.m_lineHeight * m_lineIndex + m_resolver.m_baseline;
-    return LayoutPoint(line.left, baselineY) + m_resolver.m_contentOffset;
+    return LayoutPoint(run.left, baselineY) + m_resolver.m_contentOffset;
 }
 
-inline String Resolver::Line::text() const
+inline String Resolver::Run::text() const
 {
-    auto& line = m_resolver.m_lines[m_lineIndex];
-    return m_resolver.m_string.substringSharingImpl(line.textOffset, line.textLength);
+    auto& run = m_resolver.m_layout.runs[m_lineIndex];
+    return m_resolver.m_string.substringSharingImpl(run.textOffset, run.textLength);
 }
 
 inline Resolver::Iterator::Iterator(const Resolver& resolver, unsigned lineIndex)
@@ -146,13 +149,13 @@
     return !(*this == other);
 }
 
-inline Resolver::Line Resolver::Iterator::operator*() const
+inline Resolver::Run Resolver::Iterator::operator*() const
 {
-    return Line(m_resolver, m_lineIndex);
+    return Run(m_resolver, m_lineIndex);
 }
 
-inline Resolver::Resolver(const Lines& lines, const RenderBlockFlow& flow)
-    : m_lines(lines)
+inline Resolver::Resolver(const RenderBlockFlow& flow, const Layout& layout)
+    : m_layout(layout)
     , m_string(toRenderText(*flow.firstChild()).text())
     , m_lineHeight(lineHeightFromFlow(flow))
     , m_baseline(baselineFromFlow(flow))
@@ -164,7 +167,7 @@
 
 inline unsigned Resolver::size() const
 {
-    return m_lines.size();
+    return m_layout.runs.size();
 }
 
 inline Resolver::Iterator Resolver::begin() const
@@ -189,7 +192,17 @@
     return Iterator(*this, index);
 }
 
+inline Resolver runResolver(const RenderBlockFlow& flow, const Layout& layout)
+{
+    return Resolver(flow, layout);
 }
+
+inline Resolver lineResolver(const RenderBlockFlow& flow, const Layout& layout)
+{
+    return Resolver(flow, layout);
 }
 
+}
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to