Changeset 271349 in webkit
- Timestamp:
- Jan 10, 2021, 4:04:02 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
-
ChangeLog (modified) (1 diff)
-
rendering/ComplexLineLayout.cpp (modified) (3 diffs)
-
rendering/InlineBox.h (modified) (4 diffs)
-
rendering/RenderBlockFlow.cpp (modified) (1 diff)
-
rendering/RenderLineBreak.cpp (modified) (1 diff)
-
rendering/RenderLineBreak.h (modified) (1 diff)
-
rendering/RenderListMarker.cpp (modified) (1 diff)
-
rendering/RenderListMarker.h (modified) (1 diff)
-
rendering/RenderReplaced.cpp (modified) (1 diff)
-
rendering/RenderReplaced.h (modified) (1 diff)
-
rendering/RenderText.cpp (modified) (1 diff)
-
rendering/RenderTextLineBoxes.cpp (modified) (1 diff)
-
rendering/RenderTextLineBoxes.h (modified) (1 diff)
-
rendering/RootInlineBox.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271348 r271349 1 2021-01-10 Antti Koivisto <antti@apple.com> 2 3 Remove InlineBox::hasSelectedChildren bit 4 https://bugs.webkit.org/show_bug.cgi?id=220240 5 6 Reviewed by Sam Weinig. 7 8 It is only needed for selection gap painting and easily computed. 9 10 * rendering/ComplexLineLayout.cpp: 11 (WebCore::ComplexLineLayout::constructLine): 12 * rendering/InlineBox.h: 13 (WebCore::InlineBox::setCanHaveLeftExpansion): 14 (WebCore::InlineBox::InlineBoxBitfields::InlineBoxBitfields): 15 (WebCore::InlineBox::hasEllipsisBox const): 16 (WebCore::InlineBox::canHaveLeftExpansion const): 17 (WebCore::InlineBox::hasSelectedChildren const): Deleted. 18 (WebCore::InlineBox::setHasSelectedChildren): Deleted. 19 * rendering/RenderBlockFlow.cpp: 20 (WebCore::RenderBlockFlow::inlineSelectionGaps): 21 * rendering/RenderLineBreak.cpp: 22 (WebCore::RenderLineBreak::setSelectionState): Deleted. 23 * rendering/RenderLineBreak.h: 24 * rendering/RenderListMarker.cpp: 25 (WebCore::RenderListMarker::setSelectionState): Deleted. 26 * rendering/RenderListMarker.h: 27 * rendering/RenderReplaced.cpp: 28 (WebCore::RenderReplaced::setSelectionState): Deleted. 29 * rendering/RenderReplaced.h: 30 * rendering/RenderText.cpp: 31 (WebCore::RenderText::setSelectionState): 32 * rendering/RenderTextLineBoxes.cpp: 33 (WebCore::RenderTextLineBoxes::setSelectionState): Deleted. 34 * rendering/RenderTextLineBoxes.h: 35 * rendering/RootInlineBox.h: 36 1 37 2021-01-09 Zalan Bujtas <zalan@apple.com> 2 38 -
trunk/Source/WebCore/rendering/ComplexLineLayout.cpp
r269149 r271349 295 295 ASSERT(bidiRuns.firstRun()); 296 296 297 bool rootHasSelectedChildren = false;298 297 InlineFlowBox* parentBox = 0; 299 298 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); … … 311 310 r->setBox(box); 312 311 313 if (!rootHasSelectedChildren && box->renderer().selectionState() != RenderObject::HighlightState::None)314 rootHasSelectedChildren = true;315 316 312 // If we have no parent box yet, or if the run is not simply a sibling, 317 313 // then we need to construct inline boxes as necessary to properly enclose the … … 343 339 // be the last continuation of our line list. 344 340 ASSERT(lastRootBox() && !lastRootBox()->isConstructed()); 345 346 // Set the m_selectedChildren flag on the root inline box if one of the leaf inline box347 // from the bidi runs walk above has a selection state.348 if (rootHasSelectedChildren)349 lastRootBox()->root().setHasSelectedChildren(true);350 341 351 342 // Set bits on our inline flow boxes that indicate which sides should -
trunk/Source/WebCore/rendering/InlineBox.h
r269301 r271349 276 276 277 277 void setHasHyphen(bool hasHyphen) { m_bitfields.setHasEllipsisBoxOrHyphen(hasHyphen); } 278 void setCanHaveLeftExpansion(bool canHaveLeftExpansion) { m_bitfields.set HasSelectedChildrenOrCanHaveLeftExpansion(canHaveLeftExpansion); }278 void setCanHaveLeftExpansion(bool canHaveLeftExpansion) { m_bitfields.setCanHaveLeftExpansion(canHaveLeftExpansion); } 279 279 void setCanHaveRightExpansion(bool canHaveRightExpansion) { m_bitfields.setCanHaveRightExpansion(canHaveRightExpansion); } 280 280 void setForceRightExpansion() { m_bitfields.setForceRightExpansion(true); } … … 312 312 , m_isHorizontal(isHorizontal) 313 313 , m_endsWithBreak(false) 314 , m_ hasSelectedChildrenOrCanHaveLeftExpansion(false)314 , m_canHaveLeftExpansion(false) 315 315 , m_canHaveRightExpansion(false) 316 316 , m_knownToHaveNoOverflow(true) … … 344 344 ADD_BOOLEAN_BITFIELD(endsWithBreak, EndsWithBreak); // Whether the line ends with a <br>. 345 345 // shared between RootInlineBox and InlineTextBox 346 ADD_BOOLEAN_BITFIELD( hasSelectedChildrenOrCanHaveLeftExpansion, HasSelectedChildrenOrCanHaveLeftExpansion);346 ADD_BOOLEAN_BITFIELD(canHaveLeftExpansion, CanHaveLeftExpansion); 347 347 ADD_BOOLEAN_BITFIELD(canHaveRightExpansion, CanHaveRightExpansion); 348 348 ADD_BOOLEAN_BITFIELD(knownToHaveNoOverflow, KnownToHaveNoOverflow); … … 393 393 void setEndsWithBreak(bool endsWithBreak) { m_bitfields.setEndsWithBreak(endsWithBreak); } 394 394 bool hasEllipsisBox() const { return m_bitfields.hasEllipsisBoxOrHyphen(); } 395 bool hasSelectedChildren() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeftExpansion(); }396 void setHasSelectedChildren(bool hasSelectedChildren) { m_bitfields.setHasSelectedChildrenOrCanHaveLeftExpansion(hasSelectedChildren); }397 395 void setHasEllipsisBox(bool hasEllipsisBox) { m_bitfields.setHasEllipsisBoxOrHyphen(hasEllipsisBox); } 398 396 399 397 // For InlineTextBox 400 398 bool hasHyphen() const { return m_bitfields.hasEllipsisBoxOrHyphen(); } 401 bool canHaveLeftExpansion() const { return m_bitfields. hasSelectedChildrenOrCanHaveLeftExpansion(); }399 bool canHaveLeftExpansion() const { return m_bitfields.canHaveLeftExpansion(); } 402 400 bool canHaveRightExpansion() const { return m_bitfields.canHaveRightExpansion(); } 403 401 bool forceRightExpansion() const { return m_bitfields.forceRightExpansion(); } -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r271348 r271349 3203 3203 } 3204 3204 3205 auto hasSelectedChildren = [&](const RootInlineBox& root) { 3206 for (auto* box = root.firstLeafDescendant(); box; box = box->nextLeafOnLine()) { 3207 if (!is<InlineTextBox>(*box)) { 3208 if (box->selectionState() != HighlightState::None) 3209 return true; 3210 continue; 3211 } 3212 3213 auto start = view().selection().startOffset(); 3214 auto end = view().selection().endOffset(); 3215 3216 auto& textBox = downcast<InlineTextBox>(*box); 3217 switch (textBox.renderer().selectionState()) { 3218 case RenderObject::HighlightState::None: 3219 continue; 3220 case RenderObject::HighlightState::Inside: 3221 return true; 3222 case RenderObject::HighlightState::Start: 3223 end = textBox.renderer().text().length(); 3224 // to handle selection from end of text to end of line 3225 if (start && start == end) 3226 start = end - 1; 3227 break; 3228 case RenderObject::HighlightState::End: 3229 start = 0; 3230 break; 3231 case RenderObject::HighlightState::Both: 3232 break; 3233 } 3234 if (textBox.isSelected(start, end)) 3235 return true; 3236 } 3237 return false; 3238 }; 3239 3205 3240 RootInlineBox* lastSelectedLine = 0; 3206 3241 RootInlineBox* curr; 3207 for (curr = firstRootBox(); curr && ! curr->hasSelectedChildren(); curr = curr->nextRootBox()) { }3242 for (curr = firstRootBox(); curr && !hasSelectedChildren(*curr); curr = curr->nextRootBox()) { } 3208 3243 3209 3244 // Now paint the gaps for the lines. 3210 for (; curr && curr->hasSelectedChildren(); curr = curr->nextRootBox()) {3245 for (; curr && hasSelectedChildren(*curr); curr = curr->nextRootBox()) { 3211 3246 LayoutUnit selTop = curr->selectionTopAdjustedForPrecedingBlock(); 3212 3247 LayoutUnit selHeight = curr->selectionHeightAdjustedForPrecedingBlock(); -
trunk/Source/WebCore/rendering/RenderLineBreak.cpp
r270539 r271349 143 143 } 144 144 145 void RenderLineBreak::setSelectionState(HighlightState state)146 {147 RenderBoxModelObject::setSelectionState(state);148 if (!m_inlineBoxWrapper)149 return;150 m_inlineBoxWrapper->root().setHasSelectedChildren(state != HighlightState::None);151 }152 153 145 IntRect RenderLineBreak::linesBoundingBox() const 154 146 { -
trunk/Source/WebCore/rendering/RenderLineBreak.h
r270539 r271349 66 66 int caretMaxOffset() const final; 67 67 bool canBeSelectionLeaf() const final; 68 void setSelectionState(HighlightState) final;69 68 70 69 LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode) const final; -
trunk/Source/WebCore/rendering/RenderListMarker.cpp
r267940 r271349 1949 1949 } 1950 1950 1951 void RenderListMarker::setSelectionState(HighlightState state)1952 {1953 // The selection state for our containing block hierarchy is updated by the base class call.1954 RenderBox::setSelectionState(state);1955 1956 if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())1957 m_inlineBoxWrapper->root().setHasSelectedChildren(state != HighlightState::None);1958 }1959 1960 1951 LayoutRect RenderListMarker::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent) 1961 1952 { -
trunk/Source/WebCore/rendering/RenderListMarker.h
r258680 r271349 75 75 bool isText() const { return !isImage(); } 76 76 77 void setSelectionState(HighlightState) override;78 77 LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) override; 79 78 bool canBeSelectionLeaf() const override { return true; } -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r271129 r271349 737 737 } 738 738 739 void RenderReplaced::setSelectionState(HighlightState state)740 {741 // The selection state for our containing block hierarchy is updated by the base class call.742 RenderBox::setSelectionState(state);743 744 if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())745 m_inlineBoxWrapper->root().setHasSelectedChildren(isHighlighted(selectionState(), view().selection()));746 }747 748 739 bool RenderReplaced::isSelected() const 749 740 { -
trunk/Source/WebCore/rendering/RenderReplaced.h
r268436 r271349 58 58 virtual LayoutUnit minimumReplacedHeight() const { return 0_lu; } 59 59 60 void setSelectionState(HighlightState) override;61 62 60 bool isSelected() const; 63 61 -
trunk/Source/WebCore/rendering/RenderText.cpp
r271055 r271349 1277 1277 RenderObject::setSelectionState(state); 1278 1278 1279 if (canUpdateSelectionOnRootLineBoxes())1280 m_lineBoxes.setSelectionState(*this, state);1281 1282 1279 // The containing block can be null in case of an orphaned tree. 1283 1280 RenderBlock* containingBlock = this->containingBlock(); -
trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp
r269301 r271349 171 171 } 172 172 173 void RenderTextLineBoxes::setSelectionState(RenderText& renderer, RenderObject::HighlightState state)174 {175 if (state == RenderObject::HighlightState::Inside || state == RenderObject::HighlightState::None) {176 for (auto* box = m_first; box; box = box->nextTextBox())177 box->root().setHasSelectedChildren(state == RenderObject::HighlightState::Inside);178 return;179 }180 181 auto start = renderer.view().selection().startOffset();182 auto end = renderer.view().selection().endOffset();183 if (state == RenderObject::HighlightState::Start) {184 end = renderer.text().length();185 // to handle selection from end of text to end of line186 if (start && start == end)187 start = end - 1;188 } else if (state == RenderObject::HighlightState::End)189 start = 0;190 191 for (auto* box = m_first; box; box = box->nextTextBox()) {192 if (box->isSelected(start, end))193 box->root().setHasSelectedChildren(true);194 }195 }196 197 173 void RenderTextLineBoxes::dirtyAll() 198 174 { -
trunk/Source/WebCore/rendering/RenderTextLineBoxes.h
r269301 r271349 57 57 InlineTextBox* findNext(int offset, int& position) const; 58 58 59 void setSelectionState(RenderText&, RenderObject::HighlightState);60 61 59 LayoutRect visualOverflowBoundingBox(const RenderText&) const; 62 60 -
trunk/Source/WebCore/rendering/RootInlineBox.h
r269916 r271349 123 123 bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override; 124 124 125 using InlineBox::hasSelectedChildren;126 using InlineBox::setHasSelectedChildren;127 128 125 RenderObject::HighlightState selectionState() final; 129 126 InlineBox* firstSelectedBox();
Note:
See TracChangeset
for help on using the changeset viewer.