Changeset 280585 in webkit
- Timestamp:
- Aug 2, 2021, 11:54:03 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
dom/Position.cpp (modified) (2 diffs)
-
dom/PositionIterator.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r280584 r280585 1 2021-08-02 Frédéric Wang <fwang@igalia.com> 2 3 Align implementation of PositionIterator::isCandidate() on Position::isCandidate() 4 https://bugs.webkit.org/show_bug.cgi?id=228635 5 6 Reviewed by Darin Adler. 7 8 The bug fixed in r280381 was due to the fact that PositionIterator::isCandidate() and 9 Position::isCandidate() had gone out of sync. To prevent future bugs of this kind, this patch 10 modifies PositionIterator::isCandidate() so that it is aligned with 11 PositionIterator::isCandidate() (except when an m_anchorType check is needed) and add code 12 comments in both functions to ensure the same changes are always applied to them. 13 14 * dom/Position.cpp: 15 (WebCore::Position::isCandidate const): Add a comment to make sure we update PositionIterator 16 when changing that function. Also use auto for a local variable like in PositionIterator. 17 * dom/PositionIterator.cpp: 18 (WebCore::PositionIterator::isCandidate const): Add a comment to make sure we update Position 19 when changing that function. Rearrange the code to use positionBeforeOrAfterNodeIsCandidate 20 and early return when the node is a <html> element (these are not behavior changes). For 21 block flow / grid / flexbox renderers, add a special handling when the anchor node is a root 22 editable element ; also change the fallback value returned at the end of the function (these 23 are two behavior changes). 24 1 25 2021-08-02 Jean-Yves Avenard <jya@apple.com> 2 26 -
trunk/Source/WebCore/dom/Position.cpp
r280174 r280585 968 968 } 969 969 970 // This function should be kept in sync with PositionIterator::isCandidate(). 970 971 bool Position::isCandidate() const 971 972 { … … 998 999 999 1000 if (is<RenderBlockFlow>(*renderer) || is<RenderGrid>(*renderer) || is<RenderFlexibleBox>(*renderer)) { 1000 RenderBlock& block = downcast<RenderBlock>(*renderer);1001 auto& block = downcast<RenderBlock>(*renderer); 1001 1002 if (block.logicalHeight() || is<HTMLBodyElement>(*m_anchorNode) || m_anchorNode->isRootEditableElement()) { 1002 1003 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block)) -
trunk/Source/WebCore/dom/PositionIterator.cpp
r280381 r280585 146 146 } 147 147 148 // This function should be kept in sync with Position::isCandidate(). 148 149 bool PositionIterator::isCandidate() const 149 150 { … … 164 165 return !Position::nodeIsUserSelectNone(m_anchorNode) && downcast<RenderText>(*renderer).containsCaretOffset(m_offsetInAnchor); 165 166 166 if ( isRenderedTable(m_anchorNode) || editingIgnoresContent(*m_anchorNode))167 if (positionBeforeOrAfterNodeIsCandidate(*m_anchorNode)) 167 168 return (atStartOfNode() || atEndOfNode()) && !Position::nodeIsUserSelectNone(m_anchorNode->parentNode()); 168 169 169 if (!is<HTMLHtmlElement>(*m_anchorNode) && (is<RenderBlockFlow>(*renderer) || is<RenderGrid>(*renderer) || is<RenderFlexibleBox>(*renderer))) { 170 if (is<HTMLHtmlElement>(*m_anchorNode)) 171 return false; 172 173 if (is<RenderBlockFlow>(*renderer) || is<RenderGrid>(*renderer) || is<RenderFlexibleBox>(*renderer)) { 170 174 auto& block = downcast<RenderBlock>(*renderer); 171 if (block.logicalHeight() || is<HTMLBodyElement>(*m_anchorNode) ) {175 if (block.logicalHeight() || is<HTMLBodyElement>(*m_anchorNode) || m_anchorNode->isRootEditableElement()) { 172 176 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block)) 173 177 return atStartOfNode() && !Position::nodeIsUserSelectNone(m_anchorNode); 174 178 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNone(m_anchorNode) && Position(*this).atEditingBoundary(); 175 179 } 180 return false; 176 181 } 177 182 178 return false;183 return m_anchorNode->hasEditableStyle() && !Position::nodeIsUserSelectNone(m_anchorNode) && Position(*this).atEditingBoundary(); 179 184 } 180 185
Note:
See TracChangeset
for help on using the changeset viewer.