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
+2018-03-27 Zalan Bujtas <zalan@apple.com>
+
+ 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.
+
+ * fast/multicol/parent-box-when-spanner-is-present-expected.txt: Added.
+ * fast/multicol/parent-box-when-spanner-is-present.html: Added.
+
2018-03-27 Antoine Quint <graouts@apple.com>
[Web Animations] Stop using internals.pauseAnimationAtTimeOnElement() in favor of Web Animations API for animations tests
--- /dev/null
+PASS if no crash
+
--- /dev/null
+PASS if no crash
+<ul style="column-width: 10px;"><li style="border-bottom-style: solid;"><div style="column-span: all"><input></div></li></ul>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
\ No newline at end of file
+2018-03-27 Zalan Bujtas <zalan@apple.com>
+
+ 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.
+
+ 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):
+
2018-03-27 Brent Fulgham <bfulgham@apple.com>
Further refine cookie read/write logging
// Returns false for the body renderer if its background is propagated to the root.
bool paintsOwnBackground() const;
- // Use this with caution! No type checking is done!
- RenderBox* firstChildBox() const;
- RenderBox* lastChildBox() const;
-
LayoutUnit x() const { return m_frameRect.x(); }
LayoutUnit y() const { return m_frameRect.y(); }
LayoutUnit width() const { return m_frameRect.width(); }
FloatRect repaintRectInLocalCoordinates() const override { return borderBoxRect(); }
FloatRect objectBoundingBox() const override { return borderBoxRect(); }
- // Use this with caution! No type checking is done!
+ // Note these functions are not equivalent of childrenOfType<RenderBox>
+ RenderBox* parentBox() const;
+ RenderBox* firstChildBox() const;
+ RenderBox* lastChildBox() const;
RenderBox* previousSiblingBox() const;
RenderBox* nextSiblingBox() const;
- RenderBox* parentBox() const;
// Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions.
// For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right
static bool s_hadOverflowClip;
};
-inline RenderBox* RenderBox::previousSiblingBox() const
+inline RenderBox* RenderBox::parentBox() const
{
- return downcast<RenderBox>(previousSibling());
+ if (is<RenderBox>(parent()))
+ return downcast<RenderBox>(parent());
+
+ ASSERT(!parent());
+ return nullptr;
}
-inline RenderBox* RenderBox::nextSiblingBox() const
-{
- return downcast<RenderBox>(nextSibling());
+inline RenderBox* RenderBox::firstChildBox() const
+{
+ if (is<RenderBox>(firstChild()))
+ return downcast<RenderBox>(firstChild());
+
+ ASSERT(!firstChild());
+ return nullptr;
}
-inline RenderBox* RenderBox::parentBox() const
+inline RenderBox* RenderBox::lastChildBox() const
{
- return downcast<RenderBox>(parent());
+ if (is<RenderBox>(lastChild()))
+ return downcast<RenderBox>(lastChild());
+
+ ASSERT(!lastChild());
+ return nullptr;
}
-inline RenderBox* RenderBox::firstChildBox() const
+inline RenderBox* RenderBox::previousSiblingBox() const
{
- return downcast<RenderBox>(firstChild());
+ if (is<RenderBox>(previousSibling()))
+ return downcast<RenderBox>(previousSibling());
+
+ ASSERT(!previousSibling());
+ return nullptr;
}
-inline RenderBox* RenderBox::lastChildBox() const
+inline RenderBox* RenderBox::nextSiblingBox() const
{
- return downcast<RenderBox>(lastChild());
+ if (is<RenderBox>(nextSibling()))
+ return downcast<RenderBox>(nextSibling());
+
+ ASSERT(!nextSibling());
+ return nullptr;
}
inline void RenderBox::setInlineBoxWrapper(InlineElementBox* boxWrapper)
LayoutUnit markerOldLogicalLeft = m_marker->logicalLeft();
LayoutUnit blockOffset = 0;
LayoutUnit lineOffset = 0;
- for (RenderBox* o = m_marker->parentBox(); o != this; o = o->parentBox()) {
- blockOffset += o->logicalTop();
- lineOffset += o->logicalLeft();
+ for (auto* ancestor = m_marker->parentBox(); ancestor && ancestor != this; ancestor = ancestor->parentBox()) {
+ blockOffset += ancestor->logicalTop();
+ lineOffset += ancestor->logicalLeft();
}
bool adjustOverflow = false;
ASSERT(needsLayout());
LayoutUnit blockOffset;
- for (auto* box = parentBox(); box && box != &m_listItem; box = box->parentBox())
- blockOffset += box->logicalTop();
+ for (auto* ancestor = parentBox(); ancestor && ancestor != &m_listItem; ancestor = ancestor->parentBox())
+ blockOffset += ancestor->logicalTop();
if (style().isLeftToRightDirection())
m_lineOffsetForListItem = m_listItem.logicalLeftOffsetForLine(blockOffset, DoNotIndentText, LayoutUnit());
else
// FIXME: When we add fragments support, we'll start it off at the width of the multi-column
// block in that particular fragment.
- setLogicalWidth(parentBox()->contentLogicalWidth());
+ setLogicalWidth(multiColumnBlockFlow()->contentLogicalWidth());
}
bool RenderMultiColumnSet::requiresBalancing() const