RenderBox::parent/firstChild/nextSibling/previousSiblingBox() functions should type...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2018 20:51:06 +0000 (20:51 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2018 20:51:06 +0000 (20:51 +0000)
commit0ca818972c22fcdccf5a61c5c5c902c6bd898651
tree2acbc94120883e079b1958a6d0fd59383adf640f
parent78511680bb7be6a9a005c3a243d45c389c813616
RenderBox::parent/firstChild/nextSibling/previousSiblingBox() functions should type check.
https://bugs.webkit.org/show_bug.cgi?id=184032
<rdar://problem/38384984>

Reviewed by Antti Koivisto.

Source/WebCore:

We cannot rely on the correctness of the render tree structure when querying for parent/child/next and previous
sibling since some features (multicolumn/spanners) move subtrees out of their original position (which is highly
undesired and should not be encouraged at all though).
It should also be noted that these functions are not equivalent of typeOfChildren<RenderBox> and the following usage
    for (auto* boxChild = firstChildBox(); boxChild; boxChild = boxChild->nextSiblingBox())
can lead to unexpected result.

Test: fast/multicol/parent-box-when-spanner-is-present.html

* rendering/RenderBox.h:
(WebCore::RenderBox::parentBox const):
(WebCore::RenderBox::firstChildBox const):
(WebCore::RenderBox::lastChildBox const):
(WebCore::RenderBox::previousSiblingBox const):
(WebCore::RenderBox::nextSiblingBox const):
* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::positionListMarker):
* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::layout):
* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::updateLogicalWidth):

LayoutTests:

* fast/multicol/parent-box-when-spanner-is-present-expected.txt: Added.
* fast/multicol/parent-box-when-spanner-is-present.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230004 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/multicol/parent-box-when-spanner-is-present-expected.txt [new file with mode: 0644]
LayoutTests/fast/multicol/parent-box-when-spanner-is-present.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderListItem.cpp
Source/WebCore/rendering/RenderListMarker.cpp
Source/WebCore/rendering/RenderMultiColumnSet.cpp