Diff
Modified: trunk/Source/WebCore/ChangeLog (291480 => 291481)
--- trunk/Source/WebCore/ChangeLog 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/ChangeLog 2022-03-18 13:49:15 UTC (rev 291481)
@@ -1,3 +1,89 @@
+2022-03-18 Alan Bujtas <[email protected]>
+
+ [IFC][Integration] Rename InlineIterator::Line::closestRun* to closestBoxFor*
+ https://bugs.webkit.org/show_bug.cgi?id=238064
+
+ Reviewed by Antti Koivisto.
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXObjectCache::localCaretRectForCharacterOffset):
+ * dom/Position.cpp:
+ (WebCore::Position::upstream const):
+ (WebCore::Position::downstream const):
+ (WebCore::Position::rendersInDifferentPosition const):
+ (WebCore::Position::inlineBoxAndOffset const):
+ (WebCore::searchAheadForBetterMatch):
+ (WebCore::Position::inlineRunAndOffset const): Deleted.
+ * dom/Position.h:
+ * editing/FrameSelection.cpp:
+ (WebCore::FrameSelection::directionOfSelection):
+ * editing/InlineRunAndOffset.h:
+ * editing/RenderedPosition.cpp:
+ (WebCore::RenderedPosition::RenderedPosition):
+ (WebCore::RenderedPosition::previousLeafOnLine const):
+ (WebCore::RenderedPosition::nextLeafOnLine const):
+ (WebCore::RenderedPosition::isEquivalent const):
+ (WebCore::RenderedPosition::bidiLevelOnLeft const):
+ (WebCore::RenderedPosition::bidiLevelOnRight const):
+ (WebCore::RenderedPosition::leftBoundaryOfBidiRun):
+ (WebCore::RenderedPosition::rightBoundaryOfBidiRun):
+ (WebCore::RenderedPosition::atLeftBoundaryOfBidiRun const):
+ (WebCore::RenderedPosition::atRightBoundaryOfBidiRun const):
+ (WebCore::RenderedPosition::absoluteRect const):
+ * editing/RenderedPosition.h:
+ (WebCore::RenderedPosition::line const):
+ (WebCore::RenderedPosition::atLeftmostOffsetInBox const):
+ (WebCore::RenderedPosition::atRightmostOffsetInBox const):
+ * editing/VisiblePosition.cpp:
+ (WebCore::VisiblePosition::leftVisuallyDistinctCandidate const):
+ (WebCore::VisiblePosition::rightVisuallyDistinctCandidate const):
+ (WebCore::VisiblePosition::inlineBoxAndOffset const):
+ (WebCore::VisiblePosition::localCaretRect const):
+ (WebCore::VisiblePosition::absoluteSelectionBoundsForLine const):
+ (WebCore::VisiblePosition::inlineRunAndOffset const): Deleted.
+ * editing/VisiblePosition.h:
+ * editing/VisibleUnits.cpp:
+ (WebCore::isTextOrLineBreakBox):
+ (WebCore::previousTextOrLineBreakBox):
+ (WebCore::nextTextOrLineBreakBox):
+ (WebCore::startTextOrLineBreakBox):
+ (WebCore::endTextOrLineBreakBox):
+ (WebCore::logicallyPreviousBox):
+ (WebCore::logicallyNextBox):
+ (WebCore::wordBreakIteratorForMinOffsetBoundary):
+ (WebCore::wordBreakIteratorForMaxOffsetBoundary):
+ (WebCore::visualWordPosition):
+ (WebCore::startPositionForLine):
+ (WebCore::endPositionForLine):
+ (WebCore::previousLinePosition):
+ (WebCore::nextLinePosition):
+ (WebCore::isTextOrLineBreakRun): Deleted.
+ (WebCore::previousTextOrLineBreakRun): Deleted.
+ (WebCore::nextTextOrLineBreakRun): Deleted.
+ (WebCore::startTextOrLineBreakRun): Deleted.
+ (WebCore::endTextOrLineBreakRun): Deleted.
+ (WebCore::logicallyPreviousRun): Deleted.
+ (WebCore::logicallyNextRun): Deleted.
+ * layout/integration/InlineIteratorLine.cpp:
+ (WebCore::InlineIterator::Line::closestBoxForPoint const):
+ (WebCore::InlineIterator::Line::closestBoxForLogicalLeftPosition const):
+ (WebCore::InlineIterator::Line::closestRunForPoint const): Deleted.
+ (WebCore::InlineIterator::Line::closestRunForLogicalLeftPosition const): Deleted.
+ * layout/integration/InlineIteratorLine.h:
+ * rendering/CaretRectComputation.cpp:
+ (WebCore::computeCaretRectForText):
+ (WebCore::computeCaretRectForLineBreak):
+ (WebCore::computeCaretRectForSVGInlineText):
+ (WebCore::computeCaretRectForBox):
+ (WebCore::computeCaretRectForBlock):
+ (WebCore::computeLocalCaretRect):
+ * rendering/CaretRectComputation.h:
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::positionForRun):
+ (WebCore::RenderBlockFlow::findClosestTextAtAbsolutePoint):
+ (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+ * rendering/RenderObject.h:
+
2022-03-18 Zan Dobersek <[email protected]>
[Linux] GBMDevice as a thread-specific object is problematic
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (291480 => 291481)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -3046,14 +3046,14 @@
if (!range)
return IntRect();
- auto runAndOffset = makeContainerOffsetPosition(range->start).inlineRunAndOffset(Affinity::Downstream);
- if (runAndOffset.run)
- renderer = const_cast<RenderObject*>(&runAndOffset.run->renderer());
+ auto boxAndOffset = makeContainerOffsetPosition(range->start).inlineBoxAndOffset(Affinity::Downstream);
+ if (boxAndOffset.box)
+ renderer = const_cast<RenderObject*>(&boxAndOffset.box->renderer());
- if (is<RenderLineBreak>(renderer) && InlineIterator::boxFor(downcast<RenderLineBreak>(*renderer)) != runAndOffset.run)
+ if (is<RenderLineBreak>(renderer) && InlineIterator::boxFor(downcast<RenderLineBreak>(*renderer)) != boxAndOffset.box)
return IntRect();
- return computeLocalCaretRect(*renderer, runAndOffset);
+ return computeLocalCaretRect(*renderer, boxAndOffset);
}
IntRect AXObjectCache::absoluteCaretBoundsForCharacterOffset(const CharacterOffset& characterOffset)
Modified: trunk/Source/WebCore/dom/Position.cpp (291480 => 291481)
--- trunk/Source/WebCore/dom/Position.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/dom/Position.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -741,8 +741,8 @@
if (is<RenderText>(*renderer)) {
auto& textRenderer = downcast<RenderText>(*renderer);
- auto [firstTextRun, orderCache] = InlineIterator::firstTextBoxInLogicalOrderFor(textRenderer);
- if (!firstTextRun)
+ auto [firstTextBox, orderCache] = InlineIterator::firstTextBoxInLogicalOrderFor(textRenderer);
+ if (!firstTextBox)
continue;
if (¤tNode != startNode) {
@@ -755,15 +755,15 @@
}
unsigned textOffset = currentPosition.offsetInLeafNode();
- for (auto run = firstTextRun; run;) {
- if (textOffset > run->start() && textOffset <= run->end())
+ for (auto box = firstTextBox; box;) {
+ if (textOffset > box->start() && textOffset <= box->end())
return currentPosition;
- auto nextRun = InlineIterator::nextTextBoxInLogicalOrder(run, orderCache);
- if (textOffset == run->end() + 1 && nextRun && run->line() != nextRun->line())
+ auto nextBox = InlineIterator::nextTextBoxInLogicalOrder(box, orderCache);
+ if (textOffset == box->end() + 1 && nextBox && box->line() != nextBox->line())
return currentPosition;
- run = nextRun;
+ box = nextBox;
}
}
}
@@ -848,8 +848,8 @@
if (is<RenderText>(*renderer)) {
auto& textRenderer = downcast<RenderText>(*renderer);
- auto [firstTextRun, orderCache] = InlineIterator::firstTextBoxInLogicalOrderFor(textRenderer);
- if (!firstTextRun)
+ auto [firstTextBox, orderCache] = InlineIterator::firstTextBoxInLogicalOrderFor(textRenderer);
+ if (!firstTextBox)
continue;
if (¤tNode != startNode) {
@@ -858,18 +858,18 @@
}
unsigned textOffset = currentPosition.offsetInLeafNode();
- for (auto run = firstTextRun; run;) {
- if (!run->length() && textOffset == run->start())
+ for (auto box = firstTextBox; box;) {
+ if (!box->length() && textOffset == box->start())
return currentPosition;
- if (textOffset >= run->start() && textOffset < run->end())
+ if (textOffset >= box->start() && textOffset < box->end())
return currentPosition;
- auto nextRun = InlineIterator::nextTextBoxInLogicalOrder(run, orderCache);
- if (textOffset == run->end() && nextRun && run->line() != nextRun->line())
+ auto nextBox = InlineIterator::nextTextBoxInLogicalOrder(box, orderCache);
+ if (textOffset == box->end() && nextBox && box->line() != nextBox->line())
return currentPosition;
- run = nextRun;
+ box = nextBox;
}
}
}
@@ -1081,8 +1081,8 @@
if (renderer == positionRenderer && thisRenderedOffset == positionRenderedOffset)
return false;
- auto run1 = inlineRunAndOffset(Affinity::Downstream).run;
- auto run2 = position.inlineRunAndOffset(Affinity::Downstream).run;
+ auto box1 = inlineBoxAndOffset(Affinity::Downstream).box;
+ auto box2 = position.inlineBoxAndOffset(Affinity::Downstream).box;
LOG(Editing, "renderer: %p\n", renderer);
LOG(Editing, "thisRenderedOffset: %d\n", thisRenderedOffset);
@@ -1092,10 +1092,10 @@
LOG(Editing, "pos node min/max: %d:%d\n", caretMinOffset(*position.deprecatedNode()), caretMaxOffset(*position.deprecatedNode()));
LOG(Editing, "----------------------------------------------------------------------\n");
- if (!run1 || !run2)
+ if (!box1 || !box2)
return false;
- if (run1->line() != run2->line())
+ if (box1->line() != box2->line())
return true;
if (nextRenderedEditable(deprecatedNode()) == position.deprecatedNode()
@@ -1150,9 +1150,9 @@
return { };
}
-InlineRunAndOffset Position::inlineRunAndOffset(Affinity affinity) const
+InlineBoxAndOffset Position::inlineBoxAndOffset(Affinity affinity) const
{
- return inlineRunAndOffset(affinity, primaryDirection());
+ return inlineBoxAndOffset(affinity, primaryDirection());
}
static bool isNonTextLeafChild(RenderObject& object)
@@ -1174,8 +1174,8 @@
if (isNonTextLeafChild(*next))
return { };
if (is<RenderText>(*next)) {
- if (auto [run, orderCache] = InlineIterator::firstTextBoxInLogicalOrderFor(downcast<RenderText>(*next)); run)
- return run;
+ if (auto [box, orderCache] = InlineIterator::firstTextBoxInLogicalOrderFor(downcast<RenderText>(*next)); box)
+ return box;
}
}
return { };
@@ -1201,7 +1201,7 @@
return position;
}
-InlineRunAndOffset Position::inlineRunAndOffset(Affinity affinity, TextDirection primaryDirection) const
+InlineBoxAndOffset Position::inlineBoxAndOffset(Affinity affinity, TextDirection primaryDirection) const
{
auto caretOffset = static_cast<unsigned>(deprecatedEditingOffset());
@@ -1212,27 +1212,27 @@
if (!renderer)
return { { }, caretOffset };
- InlineIterator::LeafBoxIterator run;
+ InlineIterator::LeafBoxIterator box;
if (renderer->isBR()) {
auto& lineBreakRenderer = downcast<RenderLineBreak>(*renderer);
if (!caretOffset)
- run = InlineIterator::boxFor(lineBreakRenderer);
+ box = InlineIterator::boxFor(lineBreakRenderer);
} else if (is<RenderText>(*renderer)) {
auto& textRenderer = downcast<RenderText>(*renderer);
- auto textRun = InlineIterator::firstTextBoxFor(textRenderer);
+ auto textBox = InlineIterator::firstTextBoxFor(textRenderer);
InlineIterator::TextBoxIterator candidate;
- for (; textRun; ++textRun) {
- unsigned caretMinOffset = textRun->minimumCaretOffset();
- unsigned caretMaxOffset = textRun->maximumCaretOffset();
+ for (; textBox; ++textBox) {
+ unsigned caretMinOffset = textBox->minimumCaretOffset();
+ unsigned caretMaxOffset = textBox->maximumCaretOffset();
- if (caretOffset < caretMinOffset || caretOffset > caretMaxOffset || (caretOffset == caretMaxOffset && textRun->isLineBreak()))
+ if (caretOffset < caretMinOffset || caretOffset > caretMaxOffset || (caretOffset == caretMaxOffset && textBox->isLineBreak()))
continue;
if (caretOffset > caretMinOffset && caretOffset < caretMaxOffset)
- return { textRun, caretOffset };
+ return { textBox, caretOffset };
if ((caretOffset == caretMaxOffset) ^ (affinity == Affinity::Downstream))
break;
@@ -1241,21 +1241,21 @@
break;
if (caretOffset == caretMaxOffset) {
- auto nextOnLine = textRun->nextOnLine();
+ auto nextOnLine = textBox->nextOnLine();
if (nextOnLine && nextOnLine->isLineBreak())
break;
}
- candidate = textRun;
+ candidate = textBox;
}
if (candidate && !candidate->nextTextBox() && affinity == Affinity::Downstream) {
- textRun = searchAheadForBetterMatch(textRenderer);
- if (textRun)
- caretOffset = textRun->minimumCaretOffset();
+ textBox = searchAheadForBetterMatch(textRenderer);
+ if (textBox)
+ caretOffset = textBox->minimumCaretOffset();
}
- run = textRun ? textRun : candidate;
+ box = textBox ? textBox : candidate;
} else {
if (canHaveChildrenForEditing(*deprecatedNode()) && is<RenderBlockFlow>(*renderer) && hasRenderedNonAnonymousDescendantsWithHeight(downcast<RenderBlockFlow>(*renderer))) {
// Try a visually equivalent position with possibly opposite editability. This helps in case |this| is in
@@ -1269,29 +1269,29 @@
return { { }, caretOffset };
}
- return equivalent.inlineRunAndOffset(Affinity::Upstream, primaryDirection);
+ return equivalent.inlineBoxAndOffset(Affinity::Upstream, primaryDirection);
}
if (is<RenderBox>(*renderer)) {
- run = InlineIterator::boxFor(downcast<RenderBox>(*renderer));
- if (run && caretOffset > run->minimumCaretOffset() && caretOffset < run->maximumCaretOffset())
- return { run, caretOffset };
+ box = InlineIterator::boxFor(downcast<RenderBox>(*renderer));
+ if (box && caretOffset > box->minimumCaretOffset() && caretOffset < box->maximumCaretOffset())
+ return { box, caretOffset };
}
}
- if (!run)
+ if (!box)
return { { }, caretOffset };
- unsigned char level = run->bidiLevel();
+ unsigned char level = box->bidiLevel();
- if (run->direction() == primaryDirection) {
- if (caretOffset == run->rightmostCaretOffset()) {
- auto nextRun = run->nextOnLine();
- if (!nextRun || nextRun->bidiLevel() >= level)
- return { run, caretOffset };
+ if (box->direction() == primaryDirection) {
+ if (caretOffset == box->rightmostCaretOffset()) {
+ auto nextBox = box->nextOnLine();
+ if (!nextBox || nextBox->bidiLevel() >= level)
+ return { box, caretOffset };
- level = nextRun->bidiLevel();
+ level = nextBox->bidiLevel();
- auto previousRun = run->previousOnLine();
+ auto previousRun = box->previousOnLine();
for (; previousRun; previousRun.traversePreviousOnLine()) {
if (previousRun->bidiLevel() <= level)
break;
@@ -1298,83 +1298,83 @@
}
if (previousRun && previousRun->bidiLevel() == level) // For example, abc FED 123 ^ CBA
- return { run, caretOffset };
+ return { box, caretOffset };
// For example, abc 123 ^ CBA
- for (; nextRun; nextRun.traverseNextOnLine()) {
- if (nextRun->bidiLevel() < level)
+ for (; nextBox; nextBox.traverseNextOnLine()) {
+ if (nextBox->bidiLevel() < level)
break;
- run = nextRun;
+ box = nextBox;
}
- caretOffset = run->rightmostCaretOffset();
+ caretOffset = box->rightmostCaretOffset();
} else {
- auto previousRun = run->previousOnLine();
+ auto previousRun = box->previousOnLine();
if (!previousRun || previousRun->bidiLevel() >= level)
- return { run, caretOffset };
+ return { box, caretOffset };
level = previousRun->bidiLevel();
- auto nextRun = run->nextOnLine();
- for (; nextRun; nextRun.traverseNextOnLine()) {
- if (nextRun->bidiLevel() <= level)
+ auto nextBox = box->nextOnLine();
+ for (; nextBox; nextBox.traverseNextOnLine()) {
+ if (nextBox->bidiLevel() <= level)
break;
}
- if (nextRun && nextRun->bidiLevel() == level)
- return { run, caretOffset };
+ if (nextBox && nextBox->bidiLevel() == level)
+ return { box, caretOffset };
for (; previousRun; previousRun.traversePreviousOnLine()) {
if (previousRun->bidiLevel() < level)
break;
- run = previousRun;
+ box = previousRun;
}
- caretOffset = run->leftmostCaretOffset();
+ caretOffset = box->leftmostCaretOffset();
}
- return { run, caretOffset };
+ return { box, caretOffset };
}
- if (caretOffset == run->leftmostCaretOffset()) {
- auto previousRun = run->previousOnLineIgnoringLineBreak();
+ if (caretOffset == box->leftmostCaretOffset()) {
+ auto previousRun = box->previousOnLineIgnoringLineBreak();
if (!previousRun || previousRun->bidiLevel() < level) {
- // Left edge of a secondary run. Set to the right edge of the entire run.
- for (auto nextRun = run->nextOnLineIgnoringLineBreak(); nextRun; nextRun.traverseNextOnLineIgnoringLineBreak()) {
- if (nextRun->bidiLevel() < level)
+ // Left edge of a secondary box. Set to the right edge of the entire box.
+ for (auto nextBox = box->nextOnLineIgnoringLineBreak(); nextBox; nextBox.traverseNextOnLineIgnoringLineBreak()) {
+ if (nextBox->bidiLevel() < level)
break;
- run = nextRun;
+ box = nextBox;
}
- caretOffset = run->rightmostCaretOffset();
+ caretOffset = box->rightmostCaretOffset();
} else if (previousRun->bidiLevel() > level) {
- // Right edge of a "tertiary" run. Set to the left edge of that run.
- for (auto tertiaryRun = run->previousOnLineIgnoringLineBreak(); tertiaryRun; tertiaryRun.traversePreviousOnLineIgnoringLineBreak()) {
+ // Right edge of a "tertiary" box. Set to the left edge of that box.
+ for (auto tertiaryRun = box->previousOnLineIgnoringLineBreak(); tertiaryRun; tertiaryRun.traversePreviousOnLineIgnoringLineBreak()) {
if (tertiaryRun->bidiLevel() <= level)
break;
- run = tertiaryRun;
+ box = tertiaryRun;
}
- caretOffset = run->leftmostCaretOffset();
+ caretOffset = box->leftmostCaretOffset();
}
} else {
- auto nextRun = run->nextOnLineIgnoringLineBreak();
- if (!nextRun || nextRun->bidiLevel() < level) {
- // Right edge of a secondary run. Set to the left edge of the entire run.
- for (auto previousRun = run->previousOnLineIgnoringLineBreak(); previousRun; previousRun.traversePreviousOnLineIgnoringLineBreak()) {
+ auto nextBox = box->nextOnLineIgnoringLineBreak();
+ if (!nextBox || nextBox->bidiLevel() < level) {
+ // Right edge of a secondary box. Set to the left edge of the entire box.
+ for (auto previousRun = box->previousOnLineIgnoringLineBreak(); previousRun; previousRun.traversePreviousOnLineIgnoringLineBreak()) {
if (previousRun->bidiLevel() < level)
break;
- run = previousRun;
+ box = previousRun;
}
- caretOffset = run->leftmostCaretOffset();
- } else if (nextRun->bidiLevel() > level) {
- // Left edge of a "tertiary" run. Set to the right edge of that run.
- for (auto tertiaryRun = run->nextOnLineIgnoringLineBreak(); tertiaryRun; tertiaryRun.traverseNextOnLineIgnoringLineBreak()) {
+ caretOffset = box->leftmostCaretOffset();
+ } else if (nextBox->bidiLevel() > level) {
+ // Left edge of a "tertiary" box. Set to the right edge of that box.
+ for (auto tertiaryRun = box->nextOnLineIgnoringLineBreak(); tertiaryRun; tertiaryRun.traverseNextOnLineIgnoringLineBreak()) {
if (tertiaryRun->bidiLevel() <= level)
break;
- run = tertiaryRun;
+ box = tertiaryRun;
}
- caretOffset = run->rightmostCaretOffset();
+ caretOffset = box->rightmostCaretOffset();
}
}
- return { run, caretOffset };
+ return { box, caretOffset };
}
TextDirection Position::primaryDirection() const
Modified: trunk/Source/WebCore/dom/Position.h (291480 => 291481)
--- trunk/Source/WebCore/dom/Position.h 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/dom/Position.h 2022-03-18 13:49:15 UTC (rev 291481)
@@ -49,7 +49,7 @@
BackwardDeletion // Subject to platform conventions.
};
-struct InlineRunAndOffset;
+struct InlineBoxAndOffset;
class Position {
public:
@@ -170,8 +170,8 @@
bool isRenderedCharacter() const;
bool rendersInDifferentPosition(const Position&) const;
- InlineRunAndOffset inlineRunAndOffset(Affinity) const;
- InlineRunAndOffset inlineRunAndOffset(Affinity, TextDirection primaryDirection) const;
+ InlineBoxAndOffset inlineBoxAndOffset(Affinity) const;
+ InlineBoxAndOffset inlineBoxAndOffset(Affinity, TextDirection primaryDirection) const;
TextDirection primaryDirection() const;
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (291480 => 291481)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -675,10 +675,10 @@
// can cause layout, which has the potential to invalidate lineboxes.
auto startPosition = m_selection.visibleStart();
auto endPosition = m_selection.visibleEnd();
- auto startRun = startPosition.inlineRunAndOffset().run;
- auto endRun = endPosition.inlineRunAndOffset().run;
- if (startRun && endRun && startRun->direction() == endRun->direction())
- return startRun->direction();
+ auto startBox = startPosition.inlineBoxAndOffset().box;
+ auto endBox = endPosition.inlineBoxAndOffset().box;
+ if (startBox && endBox && startBox->direction() == endBox->direction())
+ return startBox->direction();
return directionOfEnclosingBlock();
}
Modified: trunk/Source/WebCore/editing/InlineRunAndOffset.h (291480 => 291481)
--- trunk/Source/WebCore/editing/InlineRunAndOffset.h 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/editing/InlineRunAndOffset.h 2022-03-18 13:49:15 UTC (rev 291481)
@@ -29,8 +29,8 @@
namespace WebCore {
-struct InlineRunAndOffset {
- InlineIterator::LeafBoxIterator run { };
+struct InlineBoxAndOffset {
+ InlineIterator::LeafBoxIterator box { };
unsigned offset { 0 };
};
Modified: trunk/Source/WebCore/editing/RenderedPosition.cpp (291480 => 291481)
--- trunk/Source/WebCore/editing/RenderedPosition.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/editing/RenderedPosition.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -69,9 +69,9 @@
{
}
-RenderedPosition::RenderedPosition(const RenderObject* renderer, InlineIterator::LeafBoxIterator run, unsigned offset)
+RenderedPosition::RenderedPosition(const RenderObject* renderer, InlineIterator::LeafBoxIterator box, unsigned offset)
: m_renderer(renderer)
- , m_run(run)
+ , m_box(box)
, m_offset(offset)
{
}
@@ -86,11 +86,11 @@
if (position.isNull())
return;
- auto runAndOffset = position.inlineRunAndOffset(affinity);
- m_run = runAndOffset.run;
- m_offset = runAndOffset.offset;
- if (m_run)
- m_renderer = &m_run->renderer();
+ auto boxAndOffset = position.inlineBoxAndOffset(affinity);
+ m_box = boxAndOffset.box;
+ m_offset = boxAndOffset.offset;
+ if (m_box)
+ m_renderer = &m_box->renderer();
else
m_renderer = rendererFromPosition(position);
}
@@ -98,7 +98,7 @@
InlineIterator::LeafBoxIterator RenderedPosition::previousLeafOnLine() const
{
if (!m_previousLeafOnLine)
- m_previousLeafOnLine = m_run->previousOnLineIgnoringLineBreak();
+ m_previousLeafOnLine = m_box->previousOnLineIgnoringLineBreak();
return *m_previousLeafOnLine;
}
@@ -105,41 +105,41 @@
InlineIterator::LeafBoxIterator RenderedPosition::nextLeafOnLine() const
{
if (!m_nextLeafOnLine)
- m_nextLeafOnLine = m_run->nextOnLineIgnoringLineBreak();
+ m_nextLeafOnLine = m_box->nextOnLineIgnoringLineBreak();
return *m_nextLeafOnLine;
}
bool RenderedPosition::isEquivalent(const RenderedPosition& other) const
{
- return (m_renderer == other.m_renderer && m_run == other.m_run && m_offset == other.m_offset)
- || (atLeftmostOffsetInBox() && other.atRightmostOffsetInBox() && previousLeafOnLine() == other.m_run)
- || (atRightmostOffsetInBox() && other.atLeftmostOffsetInBox() && nextLeafOnLine() == other.m_run);
+ return (m_renderer == other.m_renderer && m_box == other.m_box && m_offset == other.m_offset)
+ || (atLeftmostOffsetInBox() && other.atRightmostOffsetInBox() && previousLeafOnLine() == other.m_box)
+ || (atRightmostOffsetInBox() && other.atLeftmostOffsetInBox() && nextLeafOnLine() == other.m_box);
}
unsigned char RenderedPosition::bidiLevelOnLeft() const
{
- auto run = atLeftmostOffsetInBox() ? previousLeafOnLine() : m_run;
- return run ? run->bidiLevel() : 0;
+ auto box = atLeftmostOffsetInBox() ? previousLeafOnLine() : m_box;
+ return box ? box->bidiLevel() : 0;
}
unsigned char RenderedPosition::bidiLevelOnRight() const
{
- auto run = atRightmostOffsetInBox() ? nextLeafOnLine() : m_run;
- return run ? run->bidiLevel() : 0;
+ auto box = atRightmostOffsetInBox() ? nextLeafOnLine() : m_box;
+ return box ? box->bidiLevel() : 0;
}
RenderedPosition RenderedPosition::leftBoundaryOfBidiRun(unsigned char bidiLevelOfRun)
{
- if (!m_run || bidiLevelOfRun > m_run->bidiLevel())
+ if (!m_box || bidiLevelOfRun > m_box->bidiLevel())
return RenderedPosition();
- auto run = m_run;
+ auto box = m_box;
do {
- auto prev = run->previousOnLineIgnoringLineBreak();
+ auto prev = box->previousOnLineIgnoringLineBreak();
if (!prev || prev->bidiLevel() < bidiLevelOfRun)
- return RenderedPosition(&run->renderer(), run, run->leftmostCaretOffset());
- run = prev;
- } while (run);
+ return RenderedPosition(&box->renderer(), box, box->leftmostCaretOffset());
+ box = prev;
+ } while (box);
ASSERT_NOT_REACHED();
return RenderedPosition();
@@ -147,16 +147,16 @@
RenderedPosition RenderedPosition::rightBoundaryOfBidiRun(unsigned char bidiLevelOfRun)
{
- if (!m_run || bidiLevelOfRun > m_run->bidiLevel())
+ if (!m_box || bidiLevelOfRun > m_box->bidiLevel())
return RenderedPosition();
- auto run = m_run;
+ auto box = m_box;
do {
- auto next = run->nextOnLineIgnoringLineBreak();
+ auto next = box->nextOnLineIgnoringLineBreak();
if (!next || next->bidiLevel() < bidiLevelOfRun)
- return RenderedPosition(&run->renderer(), run, run->rightmostCaretOffset());
- run = next;
- } while (run);
+ return RenderedPosition(&box->renderer(), box, box->rightmostCaretOffset());
+ box = next;
+ } while (box);
ASSERT_NOT_REACHED();
return RenderedPosition();
@@ -164,19 +164,19 @@
bool RenderedPosition::atLeftBoundaryOfBidiRun(ShouldMatchBidiLevel shouldMatchBidiLevel, unsigned char bidiLevelOfRun) const
{
- if (!m_run)
+ if (!m_box)
return false;
if (atLeftmostOffsetInBox()) {
if (shouldMatchBidiLevel == IgnoreBidiLevel)
- return !previousLeafOnLine() || previousLeafOnLine()->bidiLevel() < m_run->bidiLevel();
- return m_run->bidiLevel() >= bidiLevelOfRun && (!previousLeafOnLine() || previousLeafOnLine()->bidiLevel() < bidiLevelOfRun);
+ return !previousLeafOnLine() || previousLeafOnLine()->bidiLevel() < m_box->bidiLevel();
+ return m_box->bidiLevel() >= bidiLevelOfRun && (!previousLeafOnLine() || previousLeafOnLine()->bidiLevel() < bidiLevelOfRun);
}
if (atRightmostOffsetInBox()) {
if (shouldMatchBidiLevel == IgnoreBidiLevel)
- return nextLeafOnLine() && m_run->bidiLevel() < nextLeafOnLine()->bidiLevel();
- return nextLeafOnLine() && m_run->bidiLevel() < bidiLevelOfRun && nextLeafOnLine()->bidiLevel() >= bidiLevelOfRun;
+ return nextLeafOnLine() && m_box->bidiLevel() < nextLeafOnLine()->bidiLevel();
+ return nextLeafOnLine() && m_box->bidiLevel() < bidiLevelOfRun && nextLeafOnLine()->bidiLevel() >= bidiLevelOfRun;
}
return false;
@@ -184,19 +184,19 @@
bool RenderedPosition::atRightBoundaryOfBidiRun(ShouldMatchBidiLevel shouldMatchBidiLevel, unsigned char bidiLevelOfRun) const
{
- if (!m_run)
+ if (!m_box)
return false;
if (atRightmostOffsetInBox()) {
if (shouldMatchBidiLevel == IgnoreBidiLevel)
- return !nextLeafOnLine() || nextLeafOnLine()->bidiLevel() < m_run->bidiLevel();
- return m_run->bidiLevel() >= bidiLevelOfRun && (!nextLeafOnLine() || nextLeafOnLine()->bidiLevel() < bidiLevelOfRun);
+ return !nextLeafOnLine() || nextLeafOnLine()->bidiLevel() < m_box->bidiLevel();
+ return m_box->bidiLevel() >= bidiLevelOfRun && (!nextLeafOnLine() || nextLeafOnLine()->bidiLevel() < bidiLevelOfRun);
}
if (atLeftmostOffsetInBox()) {
if (shouldMatchBidiLevel == IgnoreBidiLevel)
- return previousLeafOnLine() && m_run->bidiLevel() < previousLeafOnLine()->bidiLevel();
- return previousLeafOnLine() && m_run->bidiLevel() < bidiLevelOfRun && previousLeafOnLine()->bidiLevel() >= bidiLevelOfRun;
+ return previousLeafOnLine() && m_box->bidiLevel() < previousLeafOnLine()->bidiLevel();
+ return previousLeafOnLine() && m_box->bidiLevel() < bidiLevelOfRun && previousLeafOnLine()->bidiLevel() >= bidiLevelOfRun;
}
return false;
@@ -227,7 +227,7 @@
if (isNull())
return IntRect();
- IntRect localRect = snappedIntRect(computeLocalCaretRect(*m_renderer, { m_run, m_offset }, caretRectMode));
+ IntRect localRect = snappedIntRect(computeLocalCaretRect(*m_renderer, { m_box, m_offset }, caretRectMode));
return localRect == IntRect() ? IntRect() : m_renderer->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoundingBox();
}
Modified: trunk/Source/WebCore/editing/RenderedPosition.h (291480 => 291481)
--- trunk/Source/WebCore/editing/RenderedPosition.h 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/editing/RenderedPosition.h 2022-03-18 13:49:15 UTC (rev 291481)
@@ -50,7 +50,7 @@
bool isEquivalent(const RenderedPosition&) const;
bool isNull() const { return !m_renderer; }
- InlineIterator::LineIterator line() const { return m_run ? m_run->line() : InlineIterator::LineIterator(); }
+ InlineIterator::LineIterator line() const { return m_box ? m_box->line() : InlineIterator::LineIterator(); }
unsigned char bidiLevelOnLeft() const;
unsigned char bidiLevelOnRight() const;
@@ -76,13 +76,13 @@
InlineIterator::LeafBoxIterator previousLeafOnLine() const;
InlineIterator::LeafBoxIterator nextLeafOnLine() const;
- bool atLeftmostOffsetInBox() const { return m_run && m_offset == m_run->leftmostCaretOffset(); }
- bool atRightmostOffsetInBox() const { return m_run && m_offset == m_run->rightmostCaretOffset(); }
+ bool atLeftmostOffsetInBox() const { return m_box && m_offset == m_box->leftmostCaretOffset(); }
+ bool atRightmostOffsetInBox() const { return m_box && m_offset == m_box->rightmostCaretOffset(); }
bool atLeftBoundaryOfBidiRun(ShouldMatchBidiLevel, unsigned char bidiLevelOfRun) const;
bool atRightBoundaryOfBidiRun(ShouldMatchBidiLevel, unsigned char bidiLevelOfRun) const;
const RenderObject* m_renderer { nullptr };
- InlineIterator::LeafBoxIterator m_run;
+ InlineIterator::LeafBoxIterator m_box;
unsigned m_offset { 0 };
mutable std::optional<InlineIterator::LeafBoxIterator> m_previousLeafOnLine;
Modified: trunk/Source/WebCore/editing/VisiblePosition.cpp (291480 => 291481)
--- trunk/Source/WebCore/editing/VisiblePosition.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/editing/VisiblePosition.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -126,125 +126,125 @@
InlineIterator::LineLogicalOrderCache orderCache;
while (true) {
- auto [run, offset] = p.inlineRunAndOffset(m_affinity, primaryDirection);
- if (!run)
+ auto [box, offset] = p.inlineBoxAndOffset(m_affinity, primaryDirection);
+ if (!box)
return primaryDirection == TextDirection::LTR ? previousVisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
- auto* renderer = &run->renderer();
+ auto* renderer = &box->renderer();
while (true) {
- if ((renderer->isReplacedOrInlineBlock() || renderer->isBR()) && offset == run->rightmostCaretOffset())
- return run->isLeftToRightDirection() ? previousVisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
+ if ((renderer->isReplacedOrInlineBlock() || renderer->isBR()) && offset == box->rightmostCaretOffset())
+ return box->isLeftToRightDirection() ? previousVisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
if (!renderer->node()) {
- run.traversePreviousOnLine();
- if (!run)
+ box.traversePreviousOnLine();
+ if (!box)
return primaryDirection == TextDirection::LTR ? previousVisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
- renderer = &run->renderer();
- offset = run->rightmostCaretOffset();
+ renderer = &box->renderer();
+ offset = box->rightmostCaretOffset();
continue;
}
// Note that this may underflow the (unsigned) offset. This is fine and handled below.
- offset = run->isLeftToRightDirection() ? renderer->previousOffset(offset) : renderer->nextOffset(offset);
+ offset = box->isLeftToRightDirection() ? renderer->previousOffset(offset) : renderer->nextOffset(offset);
- auto caretMinOffset = run->minimumCaretOffset();
- auto caretMaxOffset = run->maximumCaretOffset();
+ auto caretMinOffset = box->minimumCaretOffset();
+ auto caretMaxOffset = box->maximumCaretOffset();
if (offset > caretMinOffset && offset < caretMaxOffset)
break;
- if (offset != run->leftmostCaretOffset()) {
+ if (offset != box->leftmostCaretOffset()) {
// Overshot to the left.
- auto previousRun = run->previousOnLineIgnoringLineBreak();
- if (!previousRun) {
+ auto previousBox = box->previousOnLineIgnoringLineBreak();
+ if (!previousBox) {
Position positionOnLeft = primaryDirection == TextDirection::LTR ? previousVisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
- auto runOnLeft = positionOnLeft.inlineRunAndOffset(m_affinity, primaryDirection).run;
- if (runOnLeft && runOnLeft->line() == run->line())
+ auto boxOnLeft = positionOnLeft.inlineBoxAndOffset(m_affinity, primaryDirection).box;
+ if (boxOnLeft && boxOnLeft->line() == box->line())
return Position();
return positionOnLeft;
}
// Reposition at the other logical position corresponding to our edge's visual position and go for another round.
- run = previousRun;
- renderer = &run->renderer();
- offset = previousRun->rightmostCaretOffset();
+ box = previousBox;
+ renderer = &box->renderer();
+ offset = previousBox->rightmostCaretOffset();
continue;
}
- unsigned char level = run->bidiLevel();
- auto previousRun = run->previousOnLine();
+ unsigned char level = box->bidiLevel();
+ auto previousBox = box->previousOnLine();
- if (run->direction() == primaryDirection) {
- if (!previousRun) {
+ if (box->direction() == primaryDirection) {
+ if (!previousBox) {
auto logicalStart = primaryDirection == TextDirection::LTR
- ? InlineIterator::firstLeafOnLineInLogicalOrderWithNode(run->line(), orderCache)
- : InlineIterator::lastLeafOnLineInLogicalOrderWithNode(run->line(), orderCache);
+ ? InlineIterator::firstLeafOnLineInLogicalOrderWithNode(box->line(), orderCache)
+ : InlineIterator::lastLeafOnLineInLogicalOrderWithNode(box->line(), orderCache);
if (logicalStart) {
- run = logicalStart;
- renderer = &run->renderer();
- offset = primaryDirection == TextDirection::LTR ? run->minimumCaretOffset() : run->maximumCaretOffset();
+ box = logicalStart;
+ renderer = &box->renderer();
+ offset = primaryDirection == TextDirection::LTR ? box->minimumCaretOffset() : box->maximumCaretOffset();
}
break;
}
- if (previousRun->bidiLevel() >= level)
+ if (previousBox->bidiLevel() >= level)
break;
- level = previousRun->bidiLevel();
+ level = previousBox->bidiLevel();
- auto nextRun = run;
+ auto nextBox = box;
do {
- nextRun.traverseNextOnLine();
- } while (nextRun && nextRun->bidiLevel() > level);
+ nextBox.traverseNextOnLine();
+ } while (nextBox && nextBox->bidiLevel() > level);
- if (nextRun && nextRun->bidiLevel() == level)
+ if (nextBox && nextBox->bidiLevel() == level)
break;
- run = previousRun;
- renderer = &run->renderer();
- offset = run->rightmostCaretOffset();
- if (run->direction() == primaryDirection)
+ box = previousBox;
+ renderer = &box->renderer();
+ offset = box->rightmostCaretOffset();
+ if (box->direction() == primaryDirection)
break;
continue;
}
- while (previousRun && !previousRun->renderer().node())
- previousRun.traversePreviousOnLine();
+ while (previousBox && !previousBox->renderer().node())
+ previousBox.traversePreviousOnLine();
- if (previousRun) {
- run = previousRun;
- renderer = &run->renderer();
- offset = run->rightmostCaretOffset();
- if (run->bidiLevel() > level) {
+ if (previousBox) {
+ box = previousBox;
+ renderer = &box->renderer();
+ offset = box->rightmostCaretOffset();
+ if (box->bidiLevel() > level) {
do {
- previousRun = previousRun.traversePreviousOnLine();
- } while (previousRun && previousRun->bidiLevel() > level);
+ previousBox = previousBox.traversePreviousOnLine();
+ } while (previousBox && previousBox->bidiLevel() > level);
- if (!previousRun || previousRun->bidiLevel() < level)
+ if (!previousBox || previousBox->bidiLevel() < level)
continue;
}
} else {
- // Trailing edge of a secondary run. Set to the leading edge of the entire run.
+ // Trailing edge of a secondary box. Set to the leading edge of the entire box.
while (true) {
- while (auto nextRun = run->nextOnLine()) {
- if (nextRun->bidiLevel() < level)
+ while (auto nextBox = box->nextOnLine()) {
+ if (nextBox->bidiLevel() < level)
break;
- run = nextRun;
+ box = nextBox;
}
- if (run->bidiLevel() == level)
+ if (box->bidiLevel() == level)
break;
- level = run->bidiLevel();
- while (auto previousRun = run->previousOnLine()) {
- if (previousRun->bidiLevel() < level)
+ level = box->bidiLevel();
+ while (auto previousBox = box->previousOnLine()) {
+ if (previousBox->bidiLevel() < level)
break;
- run = previousRun;
+ box = previousBox;
}
- if (run->bidiLevel() == level)
+ if (box->bidiLevel() == level)
break;
- level = run->bidiLevel();
+ level = box->bidiLevel();
}
- renderer = &run->renderer();
- offset = primaryDirection == TextDirection::LTR ? run->minimumCaretOffset() : run->maximumCaretOffset();
+ renderer = &box->renderer();
+ offset = primaryDirection == TextDirection::LTR ? box->minimumCaretOffset() : box->maximumCaretOffset();
}
break;
}
@@ -292,129 +292,129 @@
InlineIterator::LineLogicalOrderCache orderCache;
while (true) {
- auto [run, offset] = p.inlineRunAndOffset(m_affinity, primaryDirection);
- if (!run)
+ auto [box, offset] = p.inlineBoxAndOffset(m_affinity, primaryDirection);
+ if (!box)
return primaryDirection == TextDirection::LTR ? nextVisuallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
- auto* renderer = &run->renderer();
+ auto* renderer = &box->renderer();
while (true) {
- if ((renderer->isReplacedOrInlineBlock() || renderer->isBR()) && offset == run->leftmostCaretOffset())
- return run->isLeftToRightDirection() ? nextVisuallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
+ if ((renderer->isReplacedOrInlineBlock() || renderer->isBR()) && offset == box->leftmostCaretOffset())
+ return box->isLeftToRightDirection() ? nextVisuallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
if (!renderer->node()) {
- run.traverseNextOnLine();
- if (!run)
+ box.traverseNextOnLine();
+ if (!box)
return primaryDirection == TextDirection::LTR ? nextVisuallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
- renderer = &run->renderer();
- offset = run->leftmostCaretOffset();
+ renderer = &box->renderer();
+ offset = box->leftmostCaretOffset();
continue;
}
// Note that this may underflow the (unsigned) offset. This is fine and handled below.
- offset = run->isLeftToRightDirection() ? renderer->nextOffset(offset) : renderer->previousOffset(offset);
+ offset = box->isLeftToRightDirection() ? renderer->nextOffset(offset) : renderer->previousOffset(offset);
- auto caretMinOffset = run->minimumCaretOffset();
- auto caretMaxOffset = run->maximumCaretOffset();
+ auto caretMinOffset = box->minimumCaretOffset();
+ auto caretMaxOffset = box->maximumCaretOffset();
if (offset > caretMinOffset && offset < caretMaxOffset)
break;
- if (offset != run->rightmostCaretOffset()) {
+ if (offset != box->rightmostCaretOffset()) {
// Overshot to the right.
- auto nextRun = run->nextOnLineIgnoringLineBreak();
- if (!nextRun) {
+ auto nextBox = box->nextOnLineIgnoringLineBreak();
+ if (!nextBox) {
Position positionOnRight = primaryDirection == TextDirection::LTR ? nextVisuallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
- auto runOnRight = positionOnRight.inlineRunAndOffset(m_affinity, primaryDirection).run;
- if (runOnRight && runOnRight->line() == run->line())
+ auto boxOnRight = positionOnRight.inlineBoxAndOffset(m_affinity, primaryDirection).box;
+ if (boxOnRight && boxOnRight->line() == box->line())
return Position();
return positionOnRight;
}
// Reposition at the other logical position corresponding to our edge's visual position and go for another round.
- run = nextRun;
- renderer = &run->renderer();
- offset = nextRun->leftmostCaretOffset();
+ box = nextBox;
+ renderer = &box->renderer();
+ offset = nextBox->leftmostCaretOffset();
continue;
}
- unsigned char level = run->bidiLevel();
- auto nextRun = run->nextOnLine();
+ unsigned char level = box->bidiLevel();
+ auto nextBox = box->nextOnLine();
- if (run->direction() == primaryDirection) {
- if (!nextRun) {
+ if (box->direction() == primaryDirection) {
+ if (!nextBox) {
auto logicalEnd = primaryDirection == TextDirection::LTR
- ? InlineIterator::lastLeafOnLineInLogicalOrderWithNode(run->line(), orderCache)
- : InlineIterator::firstLeafOnLineInLogicalOrderWithNode(run->line(), orderCache);
+ ? InlineIterator::lastLeafOnLineInLogicalOrderWithNode(box->line(), orderCache)
+ : InlineIterator::firstLeafOnLineInLogicalOrderWithNode(box->line(), orderCache);
if (logicalEnd) {
- run = logicalEnd;
- renderer = &run->renderer();
- offset = primaryDirection == TextDirection::LTR ? run->maximumCaretOffset() : run->minimumCaretOffset();
+ box = logicalEnd;
+ renderer = &box->renderer();
+ offset = primaryDirection == TextDirection::LTR ? box->maximumCaretOffset() : box->minimumCaretOffset();
}
break;
}
- if (nextRun->bidiLevel() >= level)
+ if (nextBox->bidiLevel() >= level)
break;
- level = nextRun->bidiLevel();
+ level = nextBox->bidiLevel();
- auto previousRun = run;
+ auto previousBox = box;
do {
- previousRun.traversePreviousOnLine();
- } while (previousRun && previousRun->bidiLevel() > level);
+ previousBox.traversePreviousOnLine();
+ } while (previousBox && previousBox->bidiLevel() > level);
- if (previousRun && previousRun->bidiLevel() == level) // For example, abc FED 123 ^ CBA
+ if (previousBox && previousBox->bidiLevel() == level) // For example, abc FED 123 ^ CBA
break;
// For example, abc 123 ^ CBA or 123 ^ CBA abc
- run = nextRun;
- renderer = &run->renderer();
- offset = run->leftmostCaretOffset();
- if (run->direction() == primaryDirection)
+ box = nextBox;
+ renderer = &box->renderer();
+ offset = box->leftmostCaretOffset();
+ if (box->direction() == primaryDirection)
break;
continue;
}
- while (nextRun && !nextRun->renderer().node())
- nextRun.traverseNextOnLine();
+ while (nextBox && !nextBox->renderer().node())
+ nextBox.traverseNextOnLine();
- if (nextRun) {
- run = nextRun;
- renderer = &run->renderer();
- offset = run->leftmostCaretOffset();
+ if (nextBox) {
+ box = nextBox;
+ renderer = &box->renderer();
+ offset = box->leftmostCaretOffset();
- if (run->bidiLevel() > level) {
+ if (box->bidiLevel() > level) {
do {
- nextRun.traverseNextOnLine();
- } while (nextRun && nextRun->bidiLevel() > level);
+ nextBox.traverseNextOnLine();
+ } while (nextBox && nextBox->bidiLevel() > level);
- if (!nextRun || nextRun->bidiLevel() < level)
+ if (!nextBox || nextBox->bidiLevel() < level)
continue;
}
} else {
- // Trailing edge of a secondary run. Set to the leading edge of the entire run.
+ // Trailing edge of a secondary box. Set to the leading edge of the entire box.
while (true) {
- while (auto previousRun = run->previousOnLine()) {
- if (previousRun->bidiLevel() < level)
+ while (auto previousBox = box->previousOnLine()) {
+ if (previousBox->bidiLevel() < level)
break;
- run = previousRun;
+ box = previousBox;
}
- if (run->bidiLevel() == level)
+ if (box->bidiLevel() == level)
break;
- level = run->bidiLevel();
- while (auto nextRun = run->nextOnLine()) {
- if (nextRun->bidiLevel() < level)
+ level = box->bidiLevel();
+ while (auto nextBox = box->nextOnLine()) {
+ if (nextBox->bidiLevel() < level)
break;
- run = nextRun;
+ box = nextBox;
}
- if (run->bidiLevel() == level)
+ if (box->bidiLevel() == level)
break;
- level = run->bidiLevel();
+ level = box->bidiLevel();
}
- renderer = &run->renderer();
- offset = primaryDirection == TextDirection::LTR ? run->maximumCaretOffset() : run->minimumCaretOffset();
+ renderer = &box->renderer();
+ offset = primaryDirection == TextDirection::LTR ? box->maximumCaretOffset() : box->minimumCaretOffset();
}
break;
}
@@ -632,14 +632,14 @@
return ch;
}
-InlineRunAndOffset VisiblePosition::inlineRunAndOffset() const
+InlineBoxAndOffset VisiblePosition::inlineBoxAndOffset() const
{
- return m_deepPosition.inlineRunAndOffset(m_affinity);
+ return m_deepPosition.inlineBoxAndOffset(m_affinity);
}
-InlineRunAndOffset VisiblePosition::inlineRunAndOffset(TextDirection primaryDirection) const
+InlineBoxAndOffset VisiblePosition::inlineBoxAndOffset(TextDirection primaryDirection) const
{
- return m_deepPosition.inlineRunAndOffset(m_affinity, primaryDirection);
+ return m_deepPosition.inlineBoxAndOffset(m_affinity, primaryDirection);
}
auto VisiblePosition::localCaretRect() const -> LocalCaretRect
@@ -648,12 +648,12 @@
if (!node)
return { };
- auto runAndOffset = inlineRunAndOffset();
- auto renderer = runAndOffset.run ? &runAndOffset.run->renderer() : node->renderer();
+ auto boxAndOffset = inlineBoxAndOffset();
+ auto renderer = boxAndOffset.box ? &boxAndOffset.box->renderer() : node->renderer();
if (!renderer)
return { };
- return { computeLocalCaretRect(*renderer, runAndOffset), const_cast<RenderObject*>(renderer) };
+ return { computeLocalCaretRect(*renderer, boxAndOffset), const_cast<RenderObject*>(renderer) };
}
IntRect VisiblePosition::absoluteCaretBounds(bool* insideFixed) const
@@ -665,11 +665,11 @@
FloatRect VisiblePosition::absoluteSelectionBoundsForLine() const
{
- auto run = inlineRunAndOffset().run;
- if (!run)
+ auto box = inlineBoxAndOffset().box;
+ if (!box)
return { };
- auto line = run->line();
+ auto line = box->line();
return line->containingBlock().localToAbsoluteQuad(FloatRect { LineSelection::physicalRect(*line) }).boundingBox();
}
Modified: trunk/Source/WebCore/editing/VisiblePosition.h (291480 => 291481)
--- trunk/Source/WebCore/editing/VisiblePosition.h 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/editing/VisiblePosition.h 2022-03-18 13:49:15 UTC (rev 291481)
@@ -67,8 +67,8 @@
// FIXME: This does not handle [table, 0] correctly.
Element* rootEditableElement() const { return m_deepPosition.isNotNull() ? m_deepPosition.deprecatedNode()->rootEditableElement() : 0; }
- InlineRunAndOffset inlineRunAndOffset() const;
- InlineRunAndOffset inlineRunAndOffset(TextDirection primaryDirection) const;
+ InlineBoxAndOffset inlineBoxAndOffset() const;
+ InlineBoxAndOffset inlineBoxAndOffset(TextDirection primaryDirection) const;
struct LocalCaretRect {
LayoutRect rect;
Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (291480 => 291481)
--- trunk/Source/WebCore/editing/VisibleUnits.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -125,60 +125,60 @@
return Position();
}
-static bool isTextOrLineBreakRun(InlineIterator::LeafBoxIterator run)
+static bool isTextOrLineBreakBox(InlineIterator::LeafBoxIterator box)
{
- return run && (run->isText() || run->renderer().isBR());
+ return box && (box->isText() || box->renderer().isBR());
}
-static InlineIterator::LeafBoxIterator previousTextOrLineBreakRun(InlineIterator::LeafBoxIterator run, InlineIterator::LineLogicalOrderCache& orderCache)
+static InlineIterator::LeafBoxIterator previousTextOrLineBreakBox(InlineIterator::LeafBoxIterator box, InlineIterator::LineLogicalOrderCache& orderCache)
{
- while (run) {
- run = InlineIterator::previousLeafOnLineInLogicalOrder(run, orderCache);
- if (isTextOrLineBreakRun(run))
- return run;
+ while (box) {
+ box = InlineIterator::previousLeafOnLineInLogicalOrder(box, orderCache);
+ if (isTextOrLineBreakBox(box))
+ return box;
}
return { };
}
-static InlineIterator::LeafBoxIterator nextTextOrLineBreakRun(InlineIterator::LeafBoxIterator run, InlineIterator::LineLogicalOrderCache& orderCache)
+static InlineIterator::LeafBoxIterator nextTextOrLineBreakBox(InlineIterator::LeafBoxIterator box, InlineIterator::LineLogicalOrderCache& orderCache)
{
- while (run) {
- run = InlineIterator::nextLeafOnLineInLogicalOrder(run, orderCache);
- if (isTextOrLineBreakRun(run))
- return run;
+ while (box) {
+ box = InlineIterator::nextLeafOnLineInLogicalOrder(box, orderCache);
+ if (isTextOrLineBreakBox(box))
+ return box;
}
return { };
}
-static InlineIterator::LeafBoxIterator startTextOrLineBreakRun(InlineIterator::LineIterator line, InlineIterator::LineLogicalOrderCache& orderCache)
+static InlineIterator::LeafBoxIterator startTextOrLineBreakBox(InlineIterator::LineIterator line, InlineIterator::LineLogicalOrderCache& orderCache)
{
- auto run = InlineIterator::firstLeafOnLineInLogicalOrder(line, orderCache);
- if (isTextOrLineBreakRun(run))
- return run;
- return nextTextOrLineBreakRun(run, orderCache);
+ auto box = InlineIterator::firstLeafOnLineInLogicalOrder(line, orderCache);
+ if (isTextOrLineBreakBox(box))
+ return box;
+ return nextTextOrLineBreakBox(box, orderCache);
}
-static InlineIterator::LeafBoxIterator endTextOrLineBreakRun(InlineIterator::LineIterator line, InlineIterator::LineLogicalOrderCache& orderCache)
+static InlineIterator::LeafBoxIterator endTextOrLineBreakBox(InlineIterator::LineIterator line, InlineIterator::LineLogicalOrderCache& orderCache)
{
- auto run = InlineIterator::lastLeafOnLineInLogicalOrder(line, orderCache);
- if (isTextOrLineBreakRun(run))
- return run;
- return previousTextOrLineBreakRun(run, orderCache);
+ auto box = InlineIterator::lastLeafOnLineInLogicalOrder(line, orderCache);
+ if (isTextOrLineBreakBox(box))
+ return box;
+ return previousTextOrLineBreakBox(box, orderCache);
}
-static const InlineIterator::LeafBoxIterator logicallyPreviousRun(const VisiblePosition& visiblePosition, InlineIterator::LeafBoxIterator startRun, InlineIterator::LineLogicalOrderCache& orderCache, bool& previousBoxInDifferentLine)
+static const InlineIterator::LeafBoxIterator logicallyPreviousBox(const VisiblePosition& visiblePosition, InlineIterator::LeafBoxIterator startBox, InlineIterator::LineLogicalOrderCache& orderCache, bool& previousBoxInDifferentLine)
{
- if (auto previousRun = previousTextOrLineBreakRun(startRun, orderCache))
- return previousRun;
+ if (auto previousBox = previousTextOrLineBreakBox(startBox, orderCache))
+ return previousBox;
- if (auto previousLine = startRun->line()->previous()) {
+ if (auto previousLine = startBox->line()->previous()) {
// FIXME: Why isn't previousBoxInDifferentLine set here?
- if (auto previousRun = endTextOrLineBreakRun(previousLine, orderCache))
- return previousRun;
+ if (auto previousBox = endTextOrLineBreakBox(previousLine, orderCache))
+ return previousBox;
}
while (1) {
- auto* startNode = startRun->renderer().nonPseudoNode();
+ auto* startNode = startBox->renderer().nonPseudoNode();
if (!startNode)
break;
@@ -191,32 +191,32 @@
if (!previousLine)
break;
- if (previousLine != startRun->line()) {
- if (auto previousRun = endTextOrLineBreakRun(previousLine, orderCache)) {
+ if (previousLine != startBox->line()) {
+ if (auto previousBox = endTextOrLineBreakBox(previousLine, orderCache)) {
previousBoxInDifferentLine = true;
- return previousRun;
+ return previousBox;
}
}
- startRun = InlineIterator::firstLeafOnLineInLogicalOrder(previousLine, orderCache);
+ startBox = InlineIterator::firstLeafOnLineInLogicalOrder(previousLine, orderCache);
}
return { };
}
-static const InlineIterator::LeafBoxIterator logicallyNextRun(const VisiblePosition& visiblePosition, InlineIterator::LeafBoxIterator startRun, InlineIterator::LineLogicalOrderCache& orderCache, bool& nextBoxInDifferentLine)
+static const InlineIterator::LeafBoxIterator logicallyNextBox(const VisiblePosition& visiblePosition, InlineIterator::LeafBoxIterator startBox, InlineIterator::LineLogicalOrderCache& orderCache, bool& nextBoxInDifferentLine)
{
- if (auto nextRun = nextTextOrLineBreakRun(startRun, orderCache))
- return nextRun;
+ if (auto nextBox = nextTextOrLineBreakBox(startBox, orderCache))
+ return nextBox;
- if (auto nextLine = startRun->line()->next()) {
+ if (auto nextLine = startBox->line()->next()) {
// FIXME: Why isn't previousBoxInDifferentLine set here?
- if (auto nextRun = startTextOrLineBreakRun(nextLine, orderCache))
- return nextRun;
+ if (auto nextBox = startTextOrLineBreakBox(nextLine, orderCache))
+ return nextBox;
}
while (1) {
- auto* startNode = startRun->renderer().nonPseudoNode();
+ auto* startNode = startBox->renderer().nonPseudoNode();
if (!startNode)
break;
@@ -229,62 +229,62 @@
if (!nextLine)
break;
- if (nextLine != startRun->line()) {
- if (auto nextRun = startTextOrLineBreakRun(nextLine, orderCache)) {
+ if (nextLine != startBox->line()) {
+ if (auto nextBox = startTextOrLineBreakBox(nextLine, orderCache)) {
nextBoxInDifferentLine = true;
- return nextRun;
+ return nextBox;
}
}
- startRun = InlineIterator::lastLeafOnLineInLogicalOrderWithNode(nextLine, orderCache);
+ startBox = InlineIterator::lastLeafOnLineInLogicalOrderWithNode(nextLine, orderCache);
}
return { };
}
-static UBreakIterator* wordBreakIteratorForMinOffsetBoundary(const VisiblePosition& visiblePosition, InlineIterator::TextBoxIterator textRun,
- unsigned& previousRunLength, bool& previousRunInDifferentLine, Vector<UChar, 1024>& string)
+static UBreakIterator* wordBreakIteratorForMinOffsetBoundary(const VisiblePosition& visiblePosition, InlineIterator::TextBoxIterator textBox,
+ unsigned& previousBoxLength, bool& previousBoxInDifferentLine, Vector<UChar, 1024>& string)
{
- previousRunInDifferentLine = false;
+ previousBoxInDifferentLine = false;
InlineIterator::LineLogicalOrderCache orderCache;
- auto previousRun = logicallyPreviousRun(visiblePosition, textRun, orderCache, previousRunInDifferentLine);
- while (previousRun && !previousRun->isText()) {
- ASSERT(previousRun->renderer().isBR());
- previousRunInDifferentLine = true;
- previousRun = logicallyPreviousRun(visiblePosition, previousRun, orderCache, previousRunInDifferentLine);
+ auto previousBox = logicallyPreviousBox(visiblePosition, textBox, orderCache, previousBoxInDifferentLine);
+ while (previousBox && !previousBox->isText()) {
+ ASSERT(previousBox->renderer().isBR());
+ previousBoxInDifferentLine = true;
+ previousBox = logicallyPreviousBox(visiblePosition, previousBox, orderCache, previousBoxInDifferentLine);
}
string.clear();
- if (previousRun) {
- auto& previousTextRun = downcast<InlineIterator::TextBoxIterator>(previousRun);
- previousRunLength = previousTextRun->length();
- append(string, previousTextRun->text());
+ if (previousBox) {
+ auto& previousTextBox = downcast<InlineIterator::TextBoxIterator>(previousBox);
+ previousBoxLength = previousTextBox->length();
+ append(string, previousTextBox->text());
}
- append(string, textRun->text());
+ append(string, textBox->text());
return wordBreakIterator(StringView(string.data(), string.size()));
}
-static UBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePosition& visiblePosition, InlineIterator::TextBoxIterator textRun,
- bool& nextRunInDifferentLine, Vector<UChar, 1024>& string)
+static UBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePosition& visiblePosition, InlineIterator::TextBoxIterator textBox,
+ bool& nextBoxInDifferentLine, Vector<UChar, 1024>& string)
{
- nextRunInDifferentLine = false;
+ nextBoxInDifferentLine = false;
InlineIterator::LineLogicalOrderCache orderCache;
- auto nextRun = logicallyNextRun(visiblePosition, textRun, orderCache, nextRunInDifferentLine);
- while (nextRun && !nextRun->isText()) {
- ASSERT(nextRun->renderer().isBR());
- nextRunInDifferentLine = true;
- nextRun = logicallyNextRun(visiblePosition, nextRun, orderCache, nextRunInDifferentLine);
+ auto nextBox = logicallyNextBox(visiblePosition, textBox, orderCache, nextBoxInDifferentLine);
+ while (nextBox && !nextBox->isText()) {
+ ASSERT(nextBox->renderer().isBR());
+ nextBoxInDifferentLine = true;
+ nextBox = logicallyNextBox(visiblePosition, nextBox, orderCache, nextBoxInDifferentLine);
}
string.clear();
- append(string, textRun->text());
+ append(string, textBox->text());
- if (nextRun) {
- auto& nextTextRun = downcast<InlineIterator::TextBoxIterator>(nextRun);
- append(string, nextTextRun->text());
+ if (nextBox) {
+ auto& nextTextBox = downcast<InlineIterator::TextBoxIterator>(nextBox);
+ append(string, nextTextBox->text());
}
return wordBreakIterator(StringView(string.data(), string.size()));
@@ -318,7 +318,7 @@
visiblePosition.deepEquivalent().document()->updateLayoutIgnorePendingStylesheets();
TextDirection blockDirection = directionOfEnclosingBlock(visiblePosition.deepEquivalent());
- InlineIterator::LeafBoxIterator previouslyVisitedRun;
+ InlineIterator::LeafBoxIterator previouslyVisitedBox;
VisiblePosition current = visiblePosition;
std::optional<VisiblePosition> previousPosition;
UBreakIterator* iter = nullptr;
@@ -333,29 +333,29 @@
if (previousPosition && adjacentCharacterPosition == previousPosition.value())
return VisiblePosition();
- // FIXME: Why force the use of upstream affinity here instead of VisiblePosition::inlineRunAndOffset, which will get affinity from adjacentCharacterPosition?
- auto [run, offsetInRun] = adjacentCharacterPosition.deepEquivalent().inlineRunAndOffset(Affinity::Upstream);
+ // FIXME: Why force the use of upstream affinity here instead of VisiblePosition::inlineBoxAndOffset, which will get affinity from adjacentCharacterPosition?
+ auto [box, offsetInBox] = adjacentCharacterPosition.deepEquivalent().inlineBoxAndOffset(Affinity::Upstream);
- if (!run)
+ if (!box)
break;
- if (!run->isText()) {
+ if (!box->isText()) {
current = adjacentCharacterPosition;
continue;
}
- auto& textRun = downcast<InlineIterator::TextBoxIterator>(run);
- unsigned previousRunLength = 0;
- bool previousRunInDifferentLine = false;
- bool nextRunInDifferentLine = false;
- bool movingIntoNewRun = previouslyVisitedRun != run;
+ auto& textBox = downcast<InlineIterator::TextBoxIterator>(box);
+ unsigned previousBoxLength = 0;
+ bool previousBoxInDifferentLine = false;
+ bool nextBoxInDifferentLine = false;
+ bool movingIntoNewBox = previouslyVisitedBox != box;
- if (offsetInRun == textRun->minimumCaretOffset())
- iter = wordBreakIteratorForMinOffsetBoundary(adjacentCharacterPosition, textRun, previousRunLength, previousRunInDifferentLine, string);
- else if (offsetInRun == textRun->maximumCaretOffset())
- iter = wordBreakIteratorForMaxOffsetBoundary(adjacentCharacterPosition, textRun, nextRunInDifferentLine, string);
- else if (movingIntoNewRun) {
- iter = wordBreakIterator(textRun->text());
- previouslyVisitedRun = run;
+ if (offsetInBox == textBox->minimumCaretOffset())
+ iter = wordBreakIteratorForMinOffsetBoundary(adjacentCharacterPosition, textBox, previousBoxLength, previousBoxInDifferentLine, string);
+ else if (offsetInBox == textBox->maximumCaretOffset())
+ iter = wordBreakIteratorForMaxOffsetBoundary(adjacentCharacterPosition, textBox, nextBoxInDifferentLine, string);
+ else if (movingIntoNewBox) {
+ iter = wordBreakIterator(textBox->text());
+ previouslyVisitedBox = box;
}
if (!iter)
@@ -362,21 +362,21 @@
break;
ubrk_first(iter);
- int offsetInIterator = offsetInRun - textRun->start() + previousRunLength;
+ int offsetInIterator = offsetInBox - textBox->start() + previousBoxLength;
bool isWordBreak;
- bool boxHasSameDirectionalityAsBlock = run->direction() == blockDirection;
- bool movingBackward = (direction == MoveLeft && run->direction() == TextDirection::LTR) || (direction == MoveRight && run->direction() == TextDirection::RTL);
+ bool boxHasSameDirectionalityAsBlock = box->direction() == blockDirection;
+ bool movingBackward = (direction == MoveLeft && box->direction() == TextDirection::LTR) || (direction == MoveRight && box->direction() == TextDirection::RTL);
if ((skipsSpaceWhenMovingRight && boxHasSameDirectionalityAsBlock)
|| (!skipsSpaceWhenMovingRight && movingBackward)) {
- bool logicalStartInRenderer = offsetInRun == textRun->start() && previousRunInDifferentLine;
+ bool logicalStartInRenderer = offsetInBox == textBox->start() && previousBoxInDifferentLine;
isWordBreak = isLogicalStartOfWord(iter, offsetInIterator, logicalStartInRenderer);
- if (isWordBreak && offsetInRun == run->maximumCaretOffset() && nextRunInDifferentLine)
+ if (isWordBreak && offsetInBox == box->maximumCaretOffset() && nextBoxInDifferentLine)
isWordBreak = false;
} else {
- bool logicalEndInRenderer = offsetInRun == textRun->end() && nextRunInDifferentLine;
+ bool logicalEndInRenderer = offsetInBox == textBox->end() && nextBoxInDifferentLine;
isWordBreak = islogicalEndOfWord(iter, offsetInIterator, logicalEndInRenderer);
- if (isWordBreak && offsetInRun == run->minimumCaretOffset() && previousRunInDifferentLine)
+ if (isWordBreak && offsetInBox == box->minimumCaretOffset() && previousBoxInDifferentLine)
isWordBreak = false;
}
@@ -752,24 +752,24 @@
InlineIterator::LineLogicalOrderCache orderCache;
Node* startNode = nullptr;
- auto startRun = mode == UseLogicalOrdering ? InlineIterator::firstLeafOnLineInLogicalOrderWithNode(line, orderCache) : line->firstLeafBox();
+ auto startBox = mode == UseLogicalOrdering ? InlineIterator::firstLeafOnLineInLogicalOrderWithNode(line, orderCache) : line->firstLeafBox();
// Generated content (e.g. list markers and CSS :before and :after pseudoelements) have no corresponding DOM element,
// and so cannot be represented by a VisiblePosition. Use whatever follows instead.
while (true) {
- if (!startRun)
+ if (!startBox)
return VisiblePosition();
- startNode = startRun->renderer().nonPseudoNode();
+ startNode = startBox->renderer().nonPseudoNode();
if (startNode)
break;
if (mode == UseLogicalOrdering)
- startRun = InlineIterator::nextLeafOnLineInLogicalOrder(startRun, orderCache);
+ startBox = InlineIterator::nextLeafOnLineInLogicalOrder(startBox, orderCache);
else
- startRun.traverseNextOnLine();
+ startBox.traverseNextOnLine();
}
- return is<Text>(*startNode) ? Position(downcast<Text>(startNode), downcast<InlineIterator::TextBox>(*startRun).start())
+ return is<Text>(*startNode) ? Position(downcast<Text>(startNode), downcast<InlineIterator::TextBox>(*startBox).start())
: positionBeforeNode(startNode);
}
@@ -824,31 +824,31 @@
InlineIterator::LineLogicalOrderCache orderCache;
Node* endNode = nullptr;
- auto endRun = mode == UseLogicalOrdering ? InlineIterator::lastLeafOnLineInLogicalOrder(line, orderCache) : line->lastLeafBox();
+ auto endBox = mode == UseLogicalOrdering ? InlineIterator::lastLeafOnLineInLogicalOrder(line, orderCache) : line->lastLeafBox();
// Generated content (e.g. list markers and CSS :before and :after pseudoelements) have no corresponding DOM element,
// and so cannot be represented by a VisiblePosition. Use whatever precedes instead.
while (true) {
- if (!endRun)
+ if (!endBox)
return VisiblePosition();
- endNode = endRun->renderer().nonPseudoNode();
+ endNode = endBox->renderer().nonPseudoNode();
if (endNode)
break;
if (mode == UseLogicalOrdering)
- endRun = InlineIterator::previousLeafOnLineInLogicalOrder(endRun, orderCache);
+ endBox = InlineIterator::previousLeafOnLineInLogicalOrder(endBox, orderCache);
else
- endRun.traversePreviousOnLine();
+ endBox.traversePreviousOnLine();
}
Position pos;
if (is<HTMLBRElement>(*endNode))
pos = positionBeforeNode(endNode);
- else if (is<InlineIterator::TextBox>(*endRun) && is<Text>(*endNode)) {
- auto& endTextRun = downcast<InlineIterator::TextBox>(*endRun);
- int endOffset = endTextRun.start();
- if (!endTextRun.isLineBreak())
- endOffset += endTextRun.length();
+ else if (is<InlineIterator::TextBox>(*endBox) && is<Text>(*endNode)) {
+ auto& endTextBox = downcast<InlineIterator::TextBox>(*endBox);
+ int endOffset = endTextBox.start();
+ if (!endTextBox.isLineBreak())
+ endOffset += endTextBox.length();
pos = Position(downcast<Text>(endNode), endOffset);
} else
pos = positionAfterNode(endNode);
@@ -969,8 +969,8 @@
return VisiblePosition();
InlineIterator::LineIterator line;
- if (auto run = visiblePosition.inlineRunAndOffset().run) {
- line = run->line()->previous();
+ if (auto box = visiblePosition.inlineBoxAndOffset().box) {
+ line = box->line()->previous();
// We want to skip zero height boxes.
// This could happen in case it is a LegacyRootInlineBox with trailing floats.
if (!line || !line->lineBoxHeight() || !line->firstLeafBox())
@@ -990,10 +990,10 @@
if (line) {
// FIXME: Can be wrong for multi-column layout and with transforms.
auto pointInLine = absoluteLineDirectionPointToLocalPointInBlock(line, lineDirectionPoint);
- auto run = line->closestRunForPoint(pointInLine, isEditablePosition(p));
- if (!run)
+ auto box = line->closestBoxForPoint(pointInLine, isEditablePosition(p));
+ if (!box)
return VisiblePosition();
- auto& renderer = run->renderer();
+ auto& renderer = box->renderer();
Node* node = renderer.node();
if (node && editingIgnoresContent(*node))
return positionInParentBeforeNode(node);
@@ -1022,8 +1022,8 @@
return VisiblePosition();
InlineIterator::LineIterator line;
- if (auto run = visiblePosition.inlineRunAndOffset().run) {
- line = run->line()->next();
+ if (auto box = visiblePosition.inlineBoxAndOffset().box) {
+ line = box->line()->next();
// We want to skip zero height boxes.
// This could happen in case it is a LegacyRootInlineBox with trailing floats.
if (!line || !line->lineBoxHeight() || !line->firstLeafBox())
@@ -1046,10 +1046,10 @@
if (line) {
// FIXME: Can be wrong for multi-column layout and with transforms.
auto pointInLine = absoluteLineDirectionPointToLocalPointInBlock(line, lineDirectionPoint);
- auto run = line->closestRunForPoint(pointInLine, isEditablePosition(p));
- if (!run)
+ auto box = line->closestBoxForPoint(pointInLine, isEditablePosition(p));
+ if (!box)
return VisiblePosition();
- auto& renderer = run->renderer();
+ auto& renderer = box->renderer();
Node* node = renderer.node();
if (node && editingIgnoresContent(*node))
return positionInParentBeforeNode(node);
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp (291480 => 291481)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -115,46 +115,46 @@
});
}
-LeafBoxIterator Line::closestRunForPoint(const IntPoint& pointInContents, bool editableOnly) const
+LeafBoxIterator Line::closestBoxForPoint(const IntPoint& pointInContents, bool editableOnly) const
{
- return closestRunForLogicalLeftPosition(isHorizontal() ? pointInContents.x() : pointInContents.y(), editableOnly);
+ return closestBoxForLogicalLeftPosition(isHorizontal() ? pointInContents.x() : pointInContents.y(), editableOnly);
}
-LeafBoxIterator Line::closestRunForLogicalLeftPosition(int leftPosition, bool editableOnly) const
+LeafBoxIterator Line::closestBoxForLogicalLeftPosition(int leftPosition, bool editableOnly) const
{
- auto isEditable = [&](auto run) {
- return run && run->renderer().node() && run->renderer().node()->hasEditableStyle();
+ auto isEditable = [&](auto box) {
+ return box && box->renderer().node() && box->renderer().node()->hasEditableStyle();
};
- auto firstRun = this->firstLeafBox();
- auto lastRun = this->lastLeafBox();
+ auto firstBox = this->firstLeafBox();
+ auto lastBox = this->lastLeafBox();
- if (firstRun != lastRun) {
- if (firstRun->isLineBreak())
- firstRun = firstRun->nextOnLineIgnoringLineBreak();
- else if (lastRun->isLineBreak())
- lastRun = lastRun->previousOnLineIgnoringLineBreak();
+ if (firstBox != lastBox) {
+ if (firstBox->isLineBreak())
+ firstBox = firstBox->nextOnLineIgnoringLineBreak();
+ else if (lastBox->isLineBreak())
+ lastBox = lastBox->previousOnLineIgnoringLineBreak();
}
- if (firstRun == lastRun && (!editableOnly || isEditable(firstRun)))
- return firstRun;
+ if (firstBox == lastBox && (!editableOnly || isEditable(firstBox)))
+ return firstBox;
- if (firstRun && leftPosition <= firstRun->logicalLeft() && !firstRun->renderer().isListMarker() && (!editableOnly || isEditable(firstRun)))
- return firstRun;
+ if (firstBox && leftPosition <= firstBox->logicalLeft() && !firstBox->renderer().isListMarker() && (!editableOnly || isEditable(firstBox)))
+ return firstBox;
- if (lastRun && leftPosition >= lastRun->logicalRight() && !lastRun->renderer().isListMarker() && (!editableOnly || isEditable(lastRun)))
- return lastRun;
+ if (lastBox && leftPosition >= lastBox->logicalRight() && !lastBox->renderer().isListMarker() && (!editableOnly || isEditable(lastBox)))
+ return lastBox;
- auto closestRun = lastRun;
- for (auto run = firstRun; run; run = run.traverseNextOnLineIgnoringLineBreak()) {
- if (!run->renderer().isListMarker() && (!editableOnly || isEditable(run))) {
- if (leftPosition < run->logicalRight())
- return run;
- closestRun = run;
+ auto closestBox = lastBox;
+ for (auto box = firstBox; box; box = box.traverseNextOnLineIgnoringLineBreak()) {
+ if (!box->renderer().isListMarker() && (!editableOnly || isEditable(box))) {
+ if (leftPosition < box->logicalRight())
+ return box;
+ closestBox = box;
}
}
- return closestRun;
+ return closestBox;
}
int Line::blockDirectionPointInLine() const
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291480 => 291481)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h 2022-03-18 13:49:15 UTC (rev 291481)
@@ -87,8 +87,8 @@
LineIterator next() const;
LineIterator previous() const;
- LeafBoxIterator closestRunForPoint(const IntPoint& pointInContents, bool editableOnly) const;
- LeafBoxIterator closestRunForLogicalLeftPosition(int position, bool editableOnly = false) const;
+ LeafBoxIterator closestBoxForPoint(const IntPoint& pointInContents, bool editableOnly) const;
+ LeafBoxIterator closestBoxForLogicalLeftPosition(int position, bool editableOnly = false) const;
private:
friend class LineIterator;
Modified: trunk/Source/WebCore/rendering/CaretRectComputation.cpp (291480 => 291481)
--- trunk/Source/WebCore/rendering/CaretRectComputation.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/rendering/CaretRectComputation.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -167,33 +167,33 @@
return containingBlock.style().isHorizontalWritingMode() ? rect : rect.transposedRect();
}
-static LayoutRect computeCaretRectForText(const InlineRunAndOffset& runAndOffset, CaretRectMode caretRectMode)
+static LayoutRect computeCaretRectForText(const InlineBoxAndOffset& boxAndOffset, CaretRectMode caretRectMode)
{
- if (!runAndOffset.run)
+ if (!boxAndOffset.box)
return { };
- auto& textRun = downcast<InlineIterator::TextBoxIterator>(runAndOffset.run);
- auto line = textRun->line();
+ auto& textBox = downcast<InlineIterator::TextBoxIterator>(boxAndOffset.box);
+ auto line = textBox->line();
- float position = textRun->positionForOffset(runAndOffset.offset);
+ float position = textBox->positionForOffset(boxAndOffset.offset);
return computeCaretRectForLinePosition(line, position, caretRectMode);
}
-static LayoutRect computeCaretRectForLineBreak(const InlineRunAndOffset& runAndOffset, CaretRectMode caretRectMode)
+static LayoutRect computeCaretRectForLineBreak(const InlineBoxAndOffset& boxAndOffset, CaretRectMode caretRectMode)
{
- ASSERT(!runAndOffset.offset);
+ ASSERT(!boxAndOffset.offset);
- if (!runAndOffset.run)
+ if (!boxAndOffset.box)
return { };
- auto line = runAndOffset.run->line();
+ auto line = boxAndOffset.box->line();
return computeCaretRectForLinePosition(line, line->contentLogicalLeft(), caretRectMode);
}
-static LayoutRect computeCaretRectForSVGInlineText(const InlineRunAndOffset& runAndOffset, CaretRectMode)
+static LayoutRect computeCaretRectForSVGInlineText(const InlineBoxAndOffset& boxAndOffset, CaretRectMode)
{
- auto* box = runAndOffset.run ? runAndOffset.run->legacyInlineBox() : nullptr;
- auto caretOffset = runAndOffset.offset;
+ auto* box = boxAndOffset.box ? boxAndOffset.box->legacyInlineBox() : nullptr;
+ auto caretOffset = boxAndOffset.offset;
if (!is<LegacyInlineTextBox>(box))
return { };
@@ -214,7 +214,7 @@
return { x, rect.y(), caretWidth, rect.height() };
}
-static LayoutRect computeCaretRectForBox(const RenderBox& renderer, const InlineRunAndOffset& runAndOffset, CaretRectMode caretRectMode)
+static LayoutRect computeCaretRectForBox(const RenderBox& renderer, const InlineBoxAndOffset& boxAndOffset, CaretRectMode caretRectMode)
{
// VisiblePositions at offsets inside containers either a) refer to the positions before/after
// those containers (tables and select elements) or b) refer to the position inside an empty block.
@@ -222,13 +222,13 @@
// FIXME: Paint the carets inside empty blocks differently than the carets before/after elements.
LayoutRect rect(renderer.location(), LayoutSize(caretWidth, renderer.height()));
- bool ltr = runAndOffset.run ? runAndOffset.run->isLeftToRightDirection() : renderer.style().isLeftToRightDirection();
+ bool ltr = boxAndOffset.box ? boxAndOffset.box->isLeftToRightDirection() : renderer.style().isLeftToRightDirection();
- if ((!runAndOffset.offset) ^ ltr)
+ if ((!boxAndOffset.offset) ^ ltr)
rect.move(LayoutSize(renderer.width() - caretWidth, 0_lu));
- if (runAndOffset.run) {
- auto line = runAndOffset.run->line();
+ if (boxAndOffset.box) {
+ auto line = boxAndOffset.box->line();
LayoutUnit top = line->top();
rect.setY(top);
rect.setHeight(line->bottom() - top);
@@ -263,11 +263,11 @@
return renderer.isHorizontalWritingMode() ? rect : rect.transposedRect();
}
-static LayoutRect computeCaretRectForBlock(const RenderBlock& renderer, const InlineRunAndOffset& runAndOffset, CaretRectMode caretRectMode)
+static LayoutRect computeCaretRectForBlock(const RenderBlock& renderer, const InlineBoxAndOffset& boxAndOffset, CaretRectMode caretRectMode)
{
// Do the normal calculation in most cases.
if (renderer.firstChild())
- return computeCaretRectForBox(renderer, runAndOffset, caretRectMode);
+ return computeCaretRectForBox(renderer, boxAndOffset, caretRectMode);
return computeCaretRectForEmptyElement(renderer, renderer.width(), renderer.textIndentOffset(), caretRectMode);
}
@@ -291,22 +291,22 @@
return caretRect;
}
-LayoutRect computeLocalCaretRect(const RenderObject& renderer, const InlineRunAndOffset& runAndOffset, CaretRectMode caretRectMode)
+LayoutRect computeLocalCaretRect(const RenderObject& renderer, const InlineBoxAndOffset& boxAndOffset, CaretRectMode caretRectMode)
{
if (is<RenderSVGInlineText>(renderer))
- return computeCaretRectForSVGInlineText(runAndOffset, caretRectMode);
+ return computeCaretRectForSVGInlineText(boxAndOffset, caretRectMode);
if (is<RenderText>(renderer))
- return computeCaretRectForText(runAndOffset, caretRectMode);
+ return computeCaretRectForText(boxAndOffset, caretRectMode);
if (is<RenderLineBreak>(renderer))
- return computeCaretRectForLineBreak(runAndOffset, caretRectMode);
+ return computeCaretRectForLineBreak(boxAndOffset, caretRectMode);
if (is<RenderBlock>(renderer))
- return computeCaretRectForBlock(downcast<RenderBlock>(renderer), runAndOffset, caretRectMode);
+ return computeCaretRectForBlock(downcast<RenderBlock>(renderer), boxAndOffset, caretRectMode);
if (is<RenderBox>(renderer))
- return computeCaretRectForBox(downcast<RenderBox>(renderer), runAndOffset, caretRectMode);
+ return computeCaretRectForBox(downcast<RenderBox>(renderer), boxAndOffset, caretRectMode);
if (is<RenderInline>(renderer))
return computeCaretRectForInline(downcast<RenderInline>(renderer));
Modified: trunk/Source/WebCore/rendering/CaretRectComputation.h (291480 => 291481)
--- trunk/Source/WebCore/rendering/CaretRectComputation.h 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/rendering/CaretRectComputation.h 2022-03-18 13:49:15 UTC (rev 291481)
@@ -35,6 +35,6 @@
ExpandToEndOfLine
};
-LayoutRect computeLocalCaretRect(const RenderObject&, const InlineRunAndOffset&, CaretRectMode = CaretRectMode::Normal);
+LayoutRect computeLocalCaretRect(const RenderObject&, const InlineBoxAndOffset&, CaretRectMode = CaretRectMode::Normal);
};
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291480 => 291481)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-03-18 13:49:15 UTC (rev 291481)
@@ -3282,19 +3282,19 @@
return false;
}
-static Position positionForRun(const RenderBlockFlow& flow, InlineIterator::BoxIterator run, bool start)
+static Position positionForRun(const RenderBlockFlow& flow, InlineIterator::BoxIterator box, bool start)
{
- if (!run)
+ if (!box)
return Position();
- if (!run->renderer().nonPseudoNode())
+ if (!box->renderer().nonPseudoNode())
return makeDeprecatedLegacyPosition(flow.nonPseudoElement(), start ? flow.caretMinOffset() : flow.caretMaxOffset());
- if (!is<InlineIterator::TextBoxIterator>(run))
- return makeDeprecatedLegacyPosition(run->renderer().nonPseudoNode(), start ? run->renderer().caretMinOffset() : run->renderer().caretMaxOffset());
+ if (!is<InlineIterator::TextBoxIterator>(box))
+ return makeDeprecatedLegacyPosition(box->renderer().nonPseudoNode(), start ? box->renderer().caretMinOffset() : box->renderer().caretMaxOffset());
- auto& textRun = downcast<InlineIterator::TextBoxIterator>(run);
- return makeDeprecatedLegacyPosition(textRun->renderer().nonPseudoNode(), start ? textRun->start() : textRun->end());
+ auto& textBox = downcast<InlineIterator::TextBoxIterator>(box);
+ return makeDeprecatedLegacyPosition(textBox->renderer().nonPseudoNode(), start ? textBox->start() : textBox->end());
}
RenderText* RenderBlockFlow::findClosestTextAtAbsolutePoint(const FloatPoint& point)
@@ -3353,9 +3353,9 @@
return nullptr;
if (localPoint.y() > *previousRootInlineBoxBottom && localPoint.y() < box->logicalTop()) {
- auto run = box->line()->closestRunForLogicalLeftPosition(localPoint.x());
- if (run && is<RenderText>(run->renderer()))
- return const_cast<RenderText*>(&downcast<RenderText>(run->renderer()));
+ auto closestBox = box->line()->closestBoxForLogicalLeftPosition(localPoint.x());
+ if (closestBox && is<RenderText>(closestBox->renderer()))
+ return const_cast<RenderText*>(&downcast<RenderText>(closestBox->renderer()));
}
}
previousRootInlineBoxBottom = box->logicalBottom();
@@ -3376,7 +3376,7 @@
bool blocksAreFlipped = style().isFlippedBlocksWritingMode();
// look for the closest line box in the root box which is at the passed-in y coordinate
- InlineIterator::LeafBoxIterator closestRun;
+ InlineIterator::LeafBoxIterator closestBox;
InlineIterator::LineIterator firstLineWithChildren;
InlineIterator::LineIterator lastLineWithChildren;
for (auto line = firstLine; line; line.traverseNext()) {
@@ -3406,8 +3406,8 @@
&& (pointInLogicalContents.y() > nextLineWithChildren->lineBoxTop() || (!blocksAreFlipped && pointInLogicalContents.y() == nextLineWithChildren->lineBoxTop())))
continue;
}
- closestRun = line->closestRunForLogicalLeftPosition(pointInLogicalContents.x());
- if (closestRun)
+ closestBox = line->closestBoxForLogicalLeftPosition(pointInLogicalContents.x());
+ if (closestBox)
break;
}
}
@@ -3414,33 +3414,33 @@
bool moveCaretToBoundary = frame().editor().behavior().shouldMoveCaretToHorizontalBoundaryWhenPastTopOrBottom();
- if (!moveCaretToBoundary && !closestRun && lastLineWithChildren) {
+ if (!moveCaretToBoundary && !closestBox && lastLineWithChildren) {
// y coordinate is below last root line box, pretend we hit it
- closestRun = lastLineWithChildren->closestRunForLogicalLeftPosition(pointInLogicalContents.x());
+ closestBox = lastLineWithChildren->closestBoxForLogicalLeftPosition(pointInLogicalContents.x());
}
- if (closestRun) {
+ if (closestBox) {
if (moveCaretToBoundary) {
LayoutUnit firstLineWithChildrenTop = std::min(firstLineWithChildren->enclosingTopForHitTesting(), LayoutUnit(firstLineWithChildren->top()));
if (pointInLogicalContents.y() < firstLineWithChildrenTop
|| (blocksAreFlipped && pointInLogicalContents.y() == firstLineWithChildrenTop)) {
- auto run = firstLineWithChildren->firstLeafBox();
- if (run->isLineBreak()) {
- if (auto next = run->nextOnLineIgnoringLineBreak())
- run = next;
+ auto box = firstLineWithChildren->firstLeafBox();
+ if (box->isLineBreak()) {
+ if (auto next = box->nextOnLineIgnoringLineBreak())
+ box = next;
}
// y coordinate is above first root line box, so return the start of the first
- return positionForRun(*this, run, true);
+ return positionForRun(*this, box, true);
}
}
// pass the box a top position that is inside it
- LayoutPoint point(pointInLogicalContents.x(), closestRun->line()->blockDirectionPointInLine());
+ LayoutPoint point(pointInLogicalContents.x(), closestBox->line()->blockDirectionPointInLine());
if (!isHorizontalWritingMode())
point = point.transposedPoint();
- if (closestRun->renderer().isReplacedOrInlineBlock())
- return positionForPointRespectingEditingBoundaries(*this, const_cast<RenderBox&>(downcast<RenderBox>(closestRun->renderer())), point);
- return const_cast<RenderObject&>(closestRun->renderer()).positionForPoint(point, nullptr);
+ if (closestBox->renderer().isReplacedOrInlineBlock())
+ return positionForPointRespectingEditingBoundaries(*this, const_cast<RenderBox&>(downcast<RenderBox>(closestBox->renderer())), point);
+ return const_cast<RenderObject&>(closestBox->renderer()).positionForPoint(point, nullptr);
}
if (lastLineWithChildren) {
@@ -3447,8 +3447,8 @@
// We hit this case for Mac behavior when the Y coordinate is below the last box.
ASSERT(moveCaretToBoundary);
InlineIterator::LineLogicalOrderCache orderCache;
- if (auto logicallyLastRun = InlineIterator::lastLeafOnLineInLogicalOrderWithNode(lastLineWithChildren, orderCache))
- return positionForRun(*this, logicallyLastRun, false);
+ if (auto logicallyLastBox = InlineIterator::lastLeafOnLineInLogicalOrderWithNode(lastLineWithChildren, orderCache))
+ return positionForRun(*this, logicallyLastBox, false);
}
// Can't reach this. We have a root line box, but it has no kids.
Modified: trunk/Source/WebCore/rendering/RenderObject.h (291480 => 291481)
--- trunk/Source/WebCore/rendering/RenderObject.h 2022-03-18 13:30:31 UTC (rev 291480)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2022-03-18 13:49:15 UTC (rev 291481)
@@ -78,7 +78,7 @@
class SelectionGeometry;
#endif
-struct InlineRunAndOffset;
+struct InlineBoxAndOffset;
struct PaintInfo;
struct SimpleRange;