Diff
Modified: trunk/Source/WebCore/ChangeLog (250389 => 250390)
--- trunk/Source/WebCore/ChangeLog 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/ChangeLog 2019-09-26 18:25:47 UTC (rev 250390)
@@ -1,3 +1,62 @@
+2019-09-26 Antti Koivisto <[email protected]>
+
+ Use LineLayoutTraversal for RenderText functions
+ https://bugs.webkit.org/show_bug.cgi?id=202266
+
+ Reviewed by Zalan Bujtas.
+
+ Replace a bunch of functions that have separate simple and complex line layout versions with
+ shared functions that use LineLayoutTraversal.
+
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::absoluteRects const):
+ (WebCore::RenderText::firstRunLocation const):
+ (WebCore::RenderText::linesBoundingBox const):
+
+ This is substantially simpler than RenderTextLineBoxes::boundingBox because it uses physical rects for all computations
+ instead of using logical rects and flipping to physical at the end.
+
+ (WebCore::RenderText::caretMinOffset const):
+ (WebCore::RenderText::caretMaxOffset const):
+ (WebCore::RenderText::countRenderedCharacterOffsetsUntil const):
+ (WebCore::containsOffset):
+ (WebCore::RenderText::containsRenderedCharacterOffset const):
+ (WebCore::RenderText::containsCaretOffset const):
+ (WebCore::RenderText::hasRenderedText const):
+ * rendering/RenderTextLineBoxes.cpp:
+ (WebCore::RenderTextLineBoxes::boundingBox const): Deleted.
+ (WebCore::RenderTextLineBoxes::firstRunLocation const): Deleted.
+ (WebCore::RenderTextLineBoxes::hasRenderedText const): Deleted.
+ (WebCore::RenderTextLineBoxes::caretMinOffset const): Deleted.
+ (WebCore::RenderTextLineBoxes::caretMaxOffset const): Deleted.
+ (WebCore::RenderTextLineBoxes::containsOffset const): Deleted.
+ (WebCore::RenderTextLineBoxes::countCharacterOffsetsUntil const): Deleted.
+ (WebCore::RenderTextLineBoxes::absoluteRects const): Deleted.
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::write):
+ * rendering/SimpleLineLayout.cpp:
+ (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):
+ * rendering/SimpleLineLayout.h:
+ (WebCore::SimpleLineLayout::Run::Run):
+ * rendering/SimpleLineLayoutFunctions.cpp:
+ (WebCore::SimpleLineLayout::computeFirstRunLocation): Deleted.
+ * rendering/SimpleLineLayoutFunctions.h:
+ (WebCore::SimpleLineLayout::findCaretMinimumOffset): Deleted.
+ (WebCore::SimpleLineLayout::findCaretMaximumOffset): Deleted.
+ (WebCore::SimpleLineLayout::containsOffset): Deleted.
+ (WebCore::SimpleLineLayout::isTextRendered): Deleted.
+ * rendering/SimpleLineLayoutResolver.h:
+ (WebCore::SimpleLineLayout::RunResolver::Run::isLineBreak const):
+ * rendering/line/LineLayoutTraversal.cpp:
+ (WebCore::LineLayoutTraversal::TextBox::isLineBreak const):
+ (WebCore::LineLayoutTraversal::firstTextBoxFor):
+ (WebCore::LineLayoutTraversal::firstTextBoxInTextOrderFor):
+ (WebCore::LineLayoutTraversal::textBoxesFor):
+ (WebCore::LineLayoutTraversal::firstTextBoxInVisualOrderFor): Deleted.
+ (WebCore::LineLayoutTraversal::textBoxRangeFor): Deleted.
+ * rendering/line/LineLayoutTraversal.h:
+ (WebCore::LineLayoutTraversal::hasTextBoxes):
+
2019-09-26 Truitt Savell <[email protected]>
Unreviewed, rolling out r250381.
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (250389 => 250390)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2019-09-26 18:25:47 UTC (rev 250390)
@@ -37,6 +37,7 @@
#include "HTMLParserIdioms.h"
#include "Hyphenation.h"
#include "InlineTextBox.h"
+#include "LineLayoutTraversal.h"
#include "Range.h"
#include "RenderBlock.h"
#include "RenderCombineText.h"
@@ -318,11 +319,10 @@
void RenderText::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
{
- if (auto* layout = simpleLineLayout()) {
- rects.appendVector(SimpleLineLayout::collectAbsoluteRects(*this, *layout, accumulatedOffset));
- return;
+ for (auto& box : LineLayoutTraversal::textBoxesFor(*this)) {
+ auto rect = box.rect();
+ rects.append(enclosingIntRect(FloatRect(accumulatedOffset + rect.location(), rect.size())));
}
- rects.appendVector(m_lineBoxes.absoluteRects(accumulatedOffset));
}
Vector<IntRect> RenderText::absoluteRectsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
@@ -1080,10 +1080,10 @@
IntPoint RenderText::firstRunLocation() const
{
- if (auto* layout = simpleLineLayout())
- return SimpleLineLayout::computeFirstRunLocation(*this, *layout);
-
- return m_lineBoxes.firstRunLocation();
+ auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+ if (!first)
+ return { };
+ return IntPoint(first->rect().location());
}
void RenderText::setSelectionState(SelectionState state)
@@ -1382,10 +1382,15 @@
IntRect RenderText::linesBoundingBox() const
{
- if (auto* layout = simpleLineLayout())
- return SimpleLineLayout::computeBoundingBox(*this, *layout);
+ auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+ if (!first)
+ return { };
- return m_lineBoxes.boundingBox(*this);
+ auto boundingBox = first->rect();
+ for (auto box = first; ++box;)
+ boundingBox.uniteEvenIfEmpty(box->rect());
+
+ return enclosingIntRect(boundingBox);
}
LayoutRect RenderText::linesVisualOverflowBoundingBox() const
@@ -1468,43 +1473,84 @@
int RenderText::caretMinOffset() const
{
- if (auto* layout = simpleLineLayout())
- return SimpleLineLayout::findCaretMinimumOffset(*this, *layout);
- return m_lineBoxes.caretMinOffset();
+ auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+ if (!first)
+ return 0;
+
+ int minOffset = first->localStartOffset();
+ for (auto box = first; ++box;)
+ minOffset = std::min<int>(minOffset, box->localStartOffset());
+
+ return minOffset;
}
int RenderText::caretMaxOffset() const
{
- if (auto* layout = simpleLineLayout())
- return SimpleLineLayout::findCaretMaximumOffset(*this, *layout);
- return m_lineBoxes.caretMaxOffset(*this);
+ auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+ if (!first)
+ return text().length();
+
+ int maxOffset = first->localEndOffset();
+ for (auto box = first; ++box;)
+ maxOffset = std::max<int>(maxOffset, box->localEndOffset());
+
+ return maxOffset;
}
unsigned RenderText::countRenderedCharacterOffsetsUntil(unsigned offset) const
{
- ASSERT(!simpleLineLayout());
- return m_lineBoxes.countCharacterOffsetsUntil(offset);
+ unsigned result = 0;
+ for (auto& box : LineLayoutTraversal::textBoxesFor(*this)) {
+ auto start = box.localStartOffset();
+ auto length = box.length();
+ if (offset < start)
+ return result;
+ if (offset <= start + length) {
+ result += offset - start;
+ return result;
+ }
+ result += length;
+ }
+ return result;
}
+enum class OffsetType { Character, Caret };
+static bool containsOffset(const RenderText& text, unsigned offset, OffsetType type)
+{
+ for (auto box = LineLayoutTraversal::firstTextBoxInTextOrderFor(text); box; box.traverseNextInTextOrder()) {
+ auto start = box->localStartOffset();
+ if (offset < start)
+ return false;
+ unsigned end = box->localEndOffset();
+ if (offset >= start && offset <= end) {
+ if (offset == end && (type == OffsetType::Character || box->isLineBreak()))
+ continue;
+ if (type == OffsetType::Character)
+ return true;
+ // Return false for offsets inside composed characters.
+ return !offset || offset == static_cast<unsigned>(text.nextOffset(text.previousOffset(offset)));
+ }
+ }
+ return false;
+}
+
bool RenderText::containsRenderedCharacterOffset(unsigned offset) const
{
- if (auto* layout = simpleLineLayout())
- return SimpleLineLayout::containsOffset(*this, *layout, offset, SimpleLineLayout::OffsetType::CharacterOffset);
- return m_lineBoxes.containsOffset(*this, offset, RenderTextLineBoxes::CharacterOffset);
+ return containsOffset(*this, offset, OffsetType::Character);
}
bool RenderText::containsCaretOffset(unsigned offset) const
{
- if (auto* layout = simpleLineLayout())
- return SimpleLineLayout::containsOffset(*this, *layout, offset, SimpleLineLayout::OffsetType::CaretOffset);
- return m_lineBoxes.containsOffset(*this, offset, RenderTextLineBoxes::CaretOffset);
+ return containsOffset(*this, offset, OffsetType::Caret);
}
bool RenderText::hasRenderedText() const
{
- if (auto* layout = simpleLineLayout())
- return SimpleLineLayout::isTextRendered(*this, *layout);
- return m_lineBoxes.hasRenderedText();
+ for (auto& box : LineLayoutTraversal::textBoxesFor(*this)) {
+ if (box.length())
+ return true;
+ }
+ return false;
}
int RenderText::previousOffset(int current) const
Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp (250389 => 250390)
--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2019-09-26 18:25:47 UTC (rev 250390)
@@ -146,37 +146,6 @@
return current;
}
-IntRect RenderTextLineBoxes::boundingBox(const RenderText& renderer) const
-{
- if (!m_first)
- return IntRect();
-
- // Return the width of the minimal left side and the maximal right side.
- float logicalLeftSide = 0;
- float logicalRightSide = 0;
- for (auto* current = m_first; current; current = current->nextTextBox()) {
- if (current == m_first || current->logicalLeft() < logicalLeftSide)
- logicalLeftSide = current->logicalLeft();
- if (current == m_first || current->logicalRight() > logicalRightSide)
- logicalRightSide = current->logicalRight();
- }
-
- bool isHorizontal = renderer.style().isHorizontalWritingMode();
-
- float x = isHorizontal ? logicalLeftSide : m_first->x();
- float y = isHorizontal ? m_first->y() : logicalLeftSide;
- float width = isHorizontal ? logicalRightSide - logicalLeftSide : m_last->logicalBottom() - x;
- float height = isHorizontal ? m_last->logicalBottom() - y : logicalRightSide - logicalLeftSide;
- return enclosingIntRect(FloatRect(x, y, width, height));
-}
-
-IntPoint RenderTextLineBoxes::firstRunLocation() const
-{
- if (!m_first)
- return IntPoint();
- return IntPoint(m_first->topLeft());
-}
-
LayoutRect RenderTextLineBoxes::visualOverflowBoundingBox(const RenderText& renderer) const
{
if (!m_first)
@@ -200,71 +169,6 @@
return rect;
}
-bool RenderTextLineBoxes::hasRenderedText() const
-{
- for (auto* box = m_first; box; box = box->nextTextBox()) {
- if (box->len())
- return true;
- }
- return false;
-}
-
-int RenderTextLineBoxes::caretMinOffset() const
-{
- auto box = m_first;
- if (!box)
- return 0;
- int minOffset = box->start();
- for (box = box->nextTextBox(); box; box = box->nextTextBox())
- minOffset = std::min<int>(minOffset, box->start());
- return minOffset;
-}
-
-int RenderTextLineBoxes::caretMaxOffset(const RenderText& renderer) const
-{
- auto box = m_last;
- if (!box)
- return renderer.text().length();
-
- int maxOffset = box->start() + box->len();
- for (box = box->prevTextBox(); box; box = box->prevTextBox())
- maxOffset = std::max<int>(maxOffset, box->start() + box->len());
- return maxOffset;
-}
-
-bool RenderTextLineBoxes::containsOffset(const RenderText& renderer, unsigned offset, OffsetType type) const
-{
- for (auto* box = m_first; box; box = box->nextTextBox()) {
- if (offset < box->start() && !renderer.containsReversedText())
- return false;
- unsigned boxEnd = box->start() + box->len();
- if (offset >= box->start() && offset <= boxEnd) {
- if (offset == boxEnd && (type == CharacterOffset || box->isLineBreak()))
- continue;
- if (type == CharacterOffset)
- return true;
- // Return false for offsets inside composed characters.
- return !offset || offset == static_cast<unsigned>(renderer.nextOffset(renderer.previousOffset(offset)));
- }
- }
- return false;
-}
-
-unsigned RenderTextLineBoxes::countCharacterOffsetsUntil(unsigned offset) const
-{
- unsigned result = 0;
- for (auto* box = m_first; box; box = box->nextTextBox()) {
- if (offset < box->start())
- return result;
- if (offset <= box->start() + box->len()) {
- result += offset - box->start();
- return result;
- }
- result += box->len();
- }
- return result;
-}
-
enum ShouldAffinityBeDownstream { AlwaysDownstream, AlwaysUpstream, UpstreamIfPositionIsNotAtStart };
static bool lineDirectionPointFitsInBox(int pointLineDirection, const InlineTextBox& box, ShouldAffinityBeDownstream& shouldAffinityBeDownstream)
@@ -505,14 +409,6 @@
}
}
-Vector<IntRect> RenderTextLineBoxes::absoluteRects(const LayoutPoint& accumulatedOffset) const
-{
- Vector<IntRect> rects;
- for (auto* box = m_first; box; box = box->nextTextBox())
- rects.append(enclosingIntRect(FloatRect(accumulatedOffset + box->topLeft(), box->size())));
- return rects;
-}
-
static FloatRect localQuadForTextBox(const InlineTextBox& box, unsigned start, unsigned end, bool useSelectionHeight)
{
unsigned realEnd = std::min(box.end(), end);
Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.h (250389 => 250390)
--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.h 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.h 2019-09-26 18:25:47 UTC (rev 250390)
@@ -56,13 +56,6 @@
InlineTextBox* findNext(int offset, int& position) const;
- bool hasRenderedText() const;
- int caretMinOffset() const;
- int caretMaxOffset(const RenderText&) const;
- enum OffsetType { CaretOffset, CharacterOffset };
- bool containsOffset(const RenderText&, unsigned, OffsetType) const;
- unsigned countCharacterOffsetsUntil(unsigned) const;
-
VisiblePosition positionForPoint(const RenderText&, const LayoutPoint&) const;
void setSelectionState(RenderText&, RenderObject::SelectionState);
@@ -69,11 +62,8 @@
LayoutRect selectionRectForRange(unsigned start, unsigned end);
void collectSelectionRectsForRange(unsigned start, unsigned end, Vector<LayoutRect>& rects);
- IntRect boundingBox(const RenderText&) const;
- IntPoint firstRunLocation() const;
LayoutRect visualOverflowBoundingBox(const RenderText&) const;
- Vector<IntRect> absoluteRects(const LayoutPoint& accumulatedOffset) const;
Vector<IntRect> absoluteRectsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
enum ClippingOption { NoClipping, ClipToEllipsis };
Vector<FloatQuad> absoluteQuads(const RenderText&, bool* wasFixed, ClippingOption) const;
Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (250389 => 250390)
--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2019-09-26 18:25:47 UTC (rev 250390)
@@ -549,7 +549,7 @@
if (is<RenderText>(o)) {
auto& text = downcast<RenderText>(o);
- for (auto& textBox : LineLayoutTraversal::textBoxRangeFor(text)) {
+ for (auto& textBox : LineLayoutTraversal::textBoxesFor(text)) {
ts << indent;
writeTextBox(ts, text, textBox);
}
Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (250389 => 250390)
--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2019-09-26 18:25:47 UTC (rev 250390)
@@ -473,7 +473,7 @@
// New line needs new run.
if (!m_runsWidth) {
ASSERT(!m_uncompletedWidth);
- runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen()));
+ runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen(), fragment.isLineBreak()));
} else {
// Advance last completed fragment when the previous fragment is all set (including multiple parts across renderers)
if ((m_lastFragment.type() != fragment.type()) || !m_lastFragment.overlapsToNextRenderer()) {
@@ -492,7 +492,7 @@
return;
}
if (m_lastFragment.isLastInRenderer() || m_lastFragment.isCollapsed())
- runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen()));
+ runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen(), fragment.isLineBreak()));
else {
Run& lastRun = runs.last();
lastRun.end = endPosition;
Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.h (250389 => 250390)
--- trunk/Source/WebCore/rendering/SimpleLineLayout.h 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.h 2019-09-26 18:25:47 UTC (rev 250390)
@@ -51,19 +51,21 @@
#if COMPILER(MSVC)
Run() { }
#endif
- Run(unsigned start, unsigned end, float logicalLeft, float logicalRight, bool isEndOfLine, bool hasHyphen)
+ Run(unsigned start, unsigned end, float logicalLeft, float logicalRight, bool isEndOfLine, bool hasHyphen, bool isLineBreak)
: end(end)
, start(start)
, isEndOfLine(isEndOfLine)
, hasHyphen(hasHyphen)
+ , isLineBreak(isLineBreak)
, logicalLeft(logicalLeft)
, logicalRight(logicalRight)
{ }
unsigned end;
- unsigned start : 30;
+ unsigned start : 29;
unsigned isEndOfLine : 1;
unsigned hasHyphen : 1;
+ unsigned isLineBreak : 1;
float logicalLeft;
float logicalRight;
// TODO: Move these optional items out of SimpleLineLayout::Run to a supplementary structure.
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (250389 => 250390)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp 2019-09-26 18:25:47 UTC (rev 250390)
@@ -197,16 +197,6 @@
return enclosingIntRect(boundingBoxRect);
}
-IntPoint computeFirstRunLocation(const RenderObject& renderer, const Layout& layout)
-{
- auto& resolver = layout.runResolver();
- auto range = resolver.rangeForRenderer(renderer);
- auto begin = range.begin();
- if (begin == range.end())
- return IntPoint(0, 0);
- return flooredIntPoint((*begin).rect().location());
-}
-
Vector<IntRect> collectAbsoluteRects(const RenderObject& renderer, const Layout& layout, const LayoutPoint& accumulatedOffset)
{
Vector<IntRect> rects;
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h (250389 => 250390)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.h 2019-09-26 18:25:47 UTC (rev 250390)
@@ -49,13 +49,7 @@
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 Layout&);
-enum class OffsetType { CaretOffset, CharacterOffset };
-bool containsOffset(const RenderText&, const Layout&, unsigned, OffsetType);
-unsigned findCaretMinimumOffset(const RenderText&, const Layout&);
-unsigned findCaretMaximumOffset(const RenderText&, const Layout&);
IntRect computeBoundingBox(const RenderObject&, const Layout&);
-IntPoint computeFirstRunLocation(const RenderObject&, const Layout&);
Vector<IntRect> collectAbsoluteRects(const RenderObject&, const Layout&, const LayoutPoint& accumulatedOffset);
Vector<FloatQuad> collectAbsoluteQuads(const RenderObject&, const Layout&, bool* wasFixed);
@@ -102,43 +96,6 @@
return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.lineCount() - 1) + baselineFromFlow(flow);
}
-inline unsigned findCaretMinimumOffset(const RenderText&, const Layout& layout)
-{
- if (!layout.runCount())
- return 0;
- return layout.runAt(0).start;
-}
-
-inline unsigned findCaretMaximumOffset(const RenderText& renderer, const Layout& layout)
-{
- if (!layout.runCount())
- return renderer.text().length();
- auto& last = layout.runAt(layout.runCount() - 1);
- return last.end;
-}
-
-inline bool containsOffset(const RenderText&, const Layout& layout, unsigned offset, OffsetType offsetType)
-{
- for (unsigned i = 0; i < layout.runCount(); ++i) {
- auto& run = layout.runAt(i);
- if (offset < run.start)
- return false;
- if (offset < run.end || (offsetType == OffsetType::CaretOffset && offset == run.end))
- return true;
- }
- return false;
-}
-
-inline bool isTextRendered(const RenderText&, const Layout& layout)
-{
- for (unsigned i = 0; i < layout.runCount(); ++i) {
- auto& run = layout.runAt(i);
- if (run.end > run.start)
- return true;
- }
- return false;
-}
-
inline LayoutUnit lineHeightFromFlow(const RenderBlockFlow& flow)
{
return flow.lineHeight(false, HorizontalLine, PositionOfInteriorLineBoxes);
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h (250389 => 250390)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h 2019-09-26 18:25:47 UTC (rev 250390)
@@ -63,6 +63,7 @@
const RenderObject& renderer() const;
bool isEndOfLine() const;
bool hasHyphen() const { return m_iterator.simpleRun().hasHyphen; }
+ bool isLineBreak() const { return m_iterator.simpleRun().isLineBreak; }
const SimpleLineLayout::Run& simpleRun() const { return m_iterator.simpleRun(); }
unsigned lineIndex() const;
Modified: trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp (250389 => 250390)
--- trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp 2019-09-26 18:25:47 UTC (rev 250390)
@@ -111,6 +111,19 @@
return WTF::switchOn(iterator().m_pathVariant, simple, complex);
}
+bool TextBox::isLineBreak() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).isLineBreak();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->isLineBreak();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
unsigned TextBox::localStartOffset() const
{
auto simple = [](const TextBoxIterator::SimplePath& path) {
@@ -272,7 +285,7 @@
return WTF::switchOn(m_pathVariant, simple, complex);
}
-TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText& text)
+TextBoxIterator firstTextBoxFor(const RenderText& text)
{
if (auto* simpleLineLayout = text.simpleLineLayout()) {
auto range = simpleLineLayout->runResolver().rangeForRenderer(text);
@@ -292,12 +305,12 @@
return TextBoxIterator { WTFMove(sortedTextBoxes), 0 };
}
- return firstTextBoxInVisualOrderFor(text);
+ return firstTextBoxFor(text);
}
-TextBoxRange textBoxRangeFor(const RenderText& text)
+TextBoxRange textBoxesFor(const RenderText& text)
{
- return { firstTextBoxInVisualOrderFor(text) };
+ return { firstTextBoxFor(text) };
}
}
Modified: trunk/Source/WebCore/rendering/line/LineLayoutTraversal.h (250389 => 250390)
--- trunk/Source/WebCore/rendering/line/LineLayoutTraversal.h 2019-09-26 18:17:52 UTC (rev 250389)
+++ trunk/Source/WebCore/rendering/line/LineLayoutTraversal.h 2019-09-26 18:25:47 UTC (rev 250390)
@@ -54,6 +54,7 @@
bool dirOverride() const;
StringView text() const;
+ bool isLineBreak() const;
// These offsets are relative to the text renderer (not flow).
unsigned localStartOffset() const;
@@ -67,6 +68,7 @@
TextBox() = default;
TextBox(const TextBox&) = default;
TextBox(TextBox&&) = default;
+ ~TextBox() = default;
TextBox& operator=(const TextBox&) = default;
TextBox& operator=(TextBox&&) = default;
@@ -130,10 +132,11 @@
TextBoxIterator m_begin;
};
-TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText&);
+TextBoxIterator firstTextBoxFor(const RenderText&);
TextBoxIterator firstTextBoxInTextOrderFor(const RenderText&);
-TextBoxRange textBoxRangeFor(const RenderText&);
-inline bool hasTextBoxes(const RenderText& text) { return !firstTextBoxInVisualOrderFor(text).atEnd(); }
+TextBoxRange textBoxesFor(const RenderText&);
+inline bool hasTextBoxes(const RenderText& text) { return !firstTextBoxFor(text).atEnd(); }
+
}
}