Diff
Modified: trunk/Source/WebCore/ChangeLog (271348 => 271349)
--- trunk/Source/WebCore/ChangeLog 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/ChangeLog 2021-01-10 12:04:02 UTC (rev 271349)
@@ -1,3 +1,39 @@
+2021-01-10 Antti Koivisto <[email protected]>
+
+ Remove InlineBox::hasSelectedChildren bit
+ https://bugs.webkit.org/show_bug.cgi?id=220240
+
+ Reviewed by Sam Weinig.
+
+ It is only needed for selection gap painting and easily computed.
+
+ * rendering/ComplexLineLayout.cpp:
+ (WebCore::ComplexLineLayout::constructLine):
+ * rendering/InlineBox.h:
+ (WebCore::InlineBox::setCanHaveLeftExpansion):
+ (WebCore::InlineBox::InlineBoxBitfields::InlineBoxBitfields):
+ (WebCore::InlineBox::hasEllipsisBox const):
+ (WebCore::InlineBox::canHaveLeftExpansion const):
+ (WebCore::InlineBox::hasSelectedChildren const): Deleted.
+ (WebCore::InlineBox::setHasSelectedChildren): Deleted.
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::inlineSelectionGaps):
+ * rendering/RenderLineBreak.cpp:
+ (WebCore::RenderLineBreak::setSelectionState): Deleted.
+ * rendering/RenderLineBreak.h:
+ * rendering/RenderListMarker.cpp:
+ (WebCore::RenderListMarker::setSelectionState): Deleted.
+ * rendering/RenderListMarker.h:
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::setSelectionState): Deleted.
+ * rendering/RenderReplaced.h:
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::setSelectionState):
+ * rendering/RenderTextLineBoxes.cpp:
+ (WebCore::RenderTextLineBoxes::setSelectionState): Deleted.
+ * rendering/RenderTextLineBoxes.h:
+ * rendering/RootInlineBox.h:
+
2021-01-09 Zalan Bujtas <[email protected]>
play.google.com: App preview images are clipped
Modified: trunk/Source/WebCore/rendering/ComplexLineLayout.cpp (271348 => 271349)
--- trunk/Source/WebCore/rendering/ComplexLineLayout.cpp 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/ComplexLineLayout.cpp 2021-01-10 12:04:02 UTC (rev 271349)
@@ -294,7 +294,6 @@
{
ASSERT(bidiRuns.firstRun());
- bool rootHasSelectedChildren = false;
InlineFlowBox* parentBox = 0;
int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace();
@@ -310,9 +309,6 @@
InlineBox* box = createInlineBoxForRenderer(&r->renderer(), isOnlyRun);
r->setBox(box);
- if (!rootHasSelectedChildren && box->renderer().selectionState() != RenderObject::HighlightState::None)
- rootHasSelectedChildren = true;
-
// If we have no parent box yet, or if the run is not simply a sibling,
// then we need to construct inline boxes as necessary to properly enclose the
// run's inline box. Segments can only be siblings at the root level, as
@@ -343,11 +339,6 @@
// be the last continuation of our line list.
ASSERT(lastRootBox() && !lastRootBox()->isConstructed());
- // Set the m_selectedChildren flag on the root inline box if one of the leaf inline box
- // from the bidi runs walk above has a selection state.
- if (rootHasSelectedChildren)
- lastRootBox()->root().setHasSelectedChildren(true);
-
// Set bits on our inline flow boxes that indicate which sides should
// paint borders/margins/padding. This knowledge will ultimately be used when
// we determine the horizontal positions and widths of all the inline boxes on
Modified: trunk/Source/WebCore/rendering/InlineBox.h (271348 => 271349)
--- trunk/Source/WebCore/rendering/InlineBox.h 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/InlineBox.h 2021-01-10 12:04:02 UTC (rev 271349)
@@ -275,7 +275,7 @@
float expansion() const { return m_expansion; }
void setHasHyphen(bool hasHyphen) { m_bitfields.setHasEllipsisBoxOrHyphen(hasHyphen); }
- void setCanHaveLeftExpansion(bool canHaveLeftExpansion) { m_bitfields.setHasSelectedChildrenOrCanHaveLeftExpansion(canHaveLeftExpansion); }
+ void setCanHaveLeftExpansion(bool canHaveLeftExpansion) { m_bitfields.setCanHaveLeftExpansion(canHaveLeftExpansion); }
void setCanHaveRightExpansion(bool canHaveRightExpansion) { m_bitfields.setCanHaveRightExpansion(canHaveRightExpansion); }
void setForceRightExpansion() { m_bitfields.setForceRightExpansion(true); }
void setForceLeftExpansion() { m_bitfields.setForceLeftExpansion(true); }
@@ -311,7 +311,7 @@
, m_hasVirtualLogicalHeight(false)
, m_isHorizontal(isHorizontal)
, m_endsWithBreak(false)
- , m_hasSelectedChildrenOrCanHaveLeftExpansion(false)
+ , m_canHaveLeftExpansion(false)
, m_canHaveRightExpansion(false)
, m_knownToHaveNoOverflow(true)
, m_hasEllipsisBoxOrHyphen(false)
@@ -343,7 +343,7 @@
// for RootInlineBox
ADD_BOOLEAN_BITFIELD(endsWithBreak, EndsWithBreak); // Whether the line ends with a <br>.
// shared between RootInlineBox and InlineTextBox
- ADD_BOOLEAN_BITFIELD(hasSelectedChildrenOrCanHaveLeftExpansion, HasSelectedChildrenOrCanHaveLeftExpansion);
+ ADD_BOOLEAN_BITFIELD(canHaveLeftExpansion, CanHaveLeftExpansion);
ADD_BOOLEAN_BITFIELD(canHaveRightExpansion, CanHaveRightExpansion);
ADD_BOOLEAN_BITFIELD(knownToHaveNoOverflow, KnownToHaveNoOverflow);
ADD_BOOLEAN_BITFIELD(hasEllipsisBoxOrHyphen, HasEllipsisBoxOrHyphen);
@@ -392,13 +392,11 @@
bool endsWithBreak() const { return m_bitfields.endsWithBreak(); }
void setEndsWithBreak(bool endsWithBreak) { m_bitfields.setEndsWithBreak(endsWithBreak); }
bool hasEllipsisBox() const { return m_bitfields.hasEllipsisBoxOrHyphen(); }
- bool hasSelectedChildren() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeftExpansion(); }
- void setHasSelectedChildren(bool hasSelectedChildren) { m_bitfields.setHasSelectedChildrenOrCanHaveLeftExpansion(hasSelectedChildren); }
void setHasEllipsisBox(bool hasEllipsisBox) { m_bitfields.setHasEllipsisBoxOrHyphen(hasEllipsisBox); }
// For InlineTextBox
bool hasHyphen() const { return m_bitfields.hasEllipsisBoxOrHyphen(); }
- bool canHaveLeftExpansion() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeftExpansion(); }
+ bool canHaveLeftExpansion() const { return m_bitfields.canHaveLeftExpansion(); }
bool canHaveRightExpansion() const { return m_bitfields.canHaveRightExpansion(); }
bool forceRightExpansion() const { return m_bitfields.forceRightExpansion(); }
bool forceLeftExpansion() const { return m_bitfields.forceLeftExpansion(); }
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2021-01-10 12:04:02 UTC (rev 271349)
@@ -3202,12 +3202,47 @@
return result;
}
+ auto hasSelectedChildren = [&](const RootInlineBox& root) {
+ for (auto* box = root.firstLeafDescendant(); box; box = box->nextLeafOnLine()) {
+ if (!is<InlineTextBox>(*box)) {
+ if (box->selectionState() != HighlightState::None)
+ return true;
+ continue;
+ }
+
+ auto start = view().selection().startOffset();
+ auto end = view().selection().endOffset();
+
+ auto& textBox = downcast<InlineTextBox>(*box);
+ switch (textBox.renderer().selectionState()) {
+ case RenderObject::HighlightState::None:
+ continue;
+ case RenderObject::HighlightState::Inside:
+ return true;
+ case RenderObject::HighlightState::Start:
+ end = textBox.renderer().text().length();
+ // to handle selection from end of text to end of line
+ if (start && start == end)
+ start = end - 1;
+ break;
+ case RenderObject::HighlightState::End:
+ start = 0;
+ break;
+ case RenderObject::HighlightState::Both:
+ break;
+ }
+ if (textBox.isSelected(start, end))
+ return true;
+ }
+ return false;
+ };
+
RootInlineBox* lastSelectedLine = 0;
RootInlineBox* curr;
- for (curr = firstRootBox(); curr && !curr->hasSelectedChildren(); curr = curr->nextRootBox()) { }
+ for (curr = firstRootBox(); curr && !hasSelectedChildren(*curr); curr = curr->nextRootBox()) { }
// Now paint the gaps for the lines.
- for (; curr && curr->hasSelectedChildren(); curr = curr->nextRootBox()) {
+ for (; curr && hasSelectedChildren(*curr); curr = curr->nextRootBox()) {
LayoutUnit selTop = curr->selectionTopAdjustedForPrecedingBlock();
LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock();
Modified: trunk/Source/WebCore/rendering/RenderLineBreak.cpp (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderLineBreak.cpp 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.cpp 2021-01-10 12:04:02 UTC (rev 271349)
@@ -142,14 +142,6 @@
return createVisiblePosition(0, Affinity::Downstream);
}
-void RenderLineBreak::setSelectionState(HighlightState state)
-{
- RenderBoxModelObject::setSelectionState(state);
- if (!m_inlineBoxWrapper)
- return;
- m_inlineBoxWrapper->root().setHasSelectedChildren(state != HighlightState::None);
-}
-
IntRect RenderLineBreak::linesBoundingBox() const
{
auto run = LayoutIntegration::runFor(*this);
Modified: trunk/Source/WebCore/rendering/RenderLineBreak.h (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderLineBreak.h 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.h 2021-01-10 12:04:02 UTC (rev 271349)
@@ -65,7 +65,6 @@
int caretMinOffset() const final;
int caretMaxOffset() const final;
bool canBeSelectionLeaf() const final;
- void setSelectionState(HighlightState) final;
LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode) const final;
int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode) const final;
Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderListMarker.cpp 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp 2021-01-10 12:04:02 UTC (rev 271349)
@@ -1948,15 +1948,6 @@
return relativeRect;
}
-void RenderListMarker::setSelectionState(HighlightState state)
-{
- // The selection state for our containing block hierarchy is updated by the base class call.
- RenderBox::setSelectionState(state);
-
- if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())
- m_inlineBoxWrapper->root().setHasSelectedChildren(state != HighlightState::None);
-}
-
LayoutRect RenderListMarker::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent)
{
ASSERT(!needsLayout());
Modified: trunk/Source/WebCore/rendering/RenderListMarker.h (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderListMarker.h 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderListMarker.h 2021-01-10 12:04:02 UTC (rev 271349)
@@ -74,7 +74,6 @@
bool isImage() const override;
bool isText() const { return !isImage(); }
- void setSelectionState(HighlightState) override;
LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) override;
bool canBeSelectionLeaf() const override { return true; }
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2021-01-10 12:04:02 UTC (rev 271349)
@@ -736,15 +736,6 @@
return LayoutRect(newLogicalTop, 0_lu, rootBox.selectionHeight(), height());
}
-void RenderReplaced::setSelectionState(HighlightState state)
-{
- // The selection state for our containing block hierarchy is updated by the base class call.
- RenderBox::setSelectionState(state);
-
- if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())
- m_inlineBoxWrapper->root().setHasSelectedChildren(isHighlighted(selectionState(), view().selection()));
-}
-
bool RenderReplaced::isSelected() const
{
return isHighlighted(selectionState(), view().selection());
Modified: trunk/Source/WebCore/rendering/RenderReplaced.h (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderReplaced.h 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderReplaced.h 2021-01-10 12:04:02 UTC (rev 271349)
@@ -57,8 +57,6 @@
virtual LayoutUnit minimumReplacedHeight() const { return 0_lu; }
- void setSelectionState(HighlightState) override;
-
bool isSelected() const;
void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2021-01-10 12:04:02 UTC (rev 271349)
@@ -1276,9 +1276,6 @@
{
RenderObject::setSelectionState(state);
- if (canUpdateSelectionOnRootLineBoxes())
- m_lineBoxes.setSelectionState(*this, state);
-
// The containing block can be null in case of an orphaned tree.
RenderBlock* containingBlock = this->containingBlock();
if (containingBlock && !containingBlock->isRenderView())
Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp 2021-01-10 12:04:02 UTC (rev 271349)
@@ -170,30 +170,6 @@
return rect;
}
-void RenderTextLineBoxes::setSelectionState(RenderText& renderer, RenderObject::HighlightState state)
-{
- if (state == RenderObject::HighlightState::Inside || state == RenderObject::HighlightState::None) {
- for (auto* box = m_first; box; box = box->nextTextBox())
- box->root().setHasSelectedChildren(state == RenderObject::HighlightState::Inside);
- return;
- }
-
- auto start = renderer.view().selection().startOffset();
- auto end = renderer.view().selection().endOffset();
- if (state == RenderObject::HighlightState::Start) {
- end = renderer.text().length();
- // to handle selection from end of text to end of line
- if (start && start == end)
- start = end - 1;
- } else if (state == RenderObject::HighlightState::End)
- start = 0;
-
- for (auto* box = m_first; box; box = box->nextTextBox()) {
- if (box->isSelected(start, end))
- box->root().setHasSelectedChildren(true);
- }
-}
-
void RenderTextLineBoxes::dirtyAll()
{
for (auto* box = m_first; box; box = box->nextTextBox())
Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.h (271348 => 271349)
--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.h 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.h 2021-01-10 12:04:02 UTC (rev 271349)
@@ -56,8 +56,6 @@
InlineTextBox* findNext(int offset, int& position) const;
- void setSelectionState(RenderText&, RenderObject::HighlightState);
-
LayoutRect visualOverflowBoundingBox(const RenderText&) const;
#if ASSERT_ENABLED
Modified: trunk/Source/WebCore/rendering/RootInlineBox.h (271348 => 271349)
--- trunk/Source/WebCore/rendering/RootInlineBox.h 2021-01-09 13:14:18 UTC (rev 271348)
+++ trunk/Source/WebCore/rendering/RootInlineBox.h 2021-01-10 12:04:02 UTC (rev 271349)
@@ -122,9 +122,6 @@
void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override;
bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override;
- using InlineBox::hasSelectedChildren;
- using InlineBox::setHasSelectedChildren;
-
RenderObject::HighlightState selectionState() final;
InlineBox* firstSelectedBox();
InlineBox* lastSelectedBox();