Diff
Modified: trunk/LayoutTests/ChangeLog (247255 => 247256)
--- trunk/LayoutTests/ChangeLog 2019-07-09 10:03:19 UTC (rev 247255)
+++ trunk/LayoutTests/ChangeLog 2019-07-09 15:21:11 UTC (rev 247256)
@@ -1,3 +1,14 @@
+2019-07-09 Antti Koivisto <[email protected]>
+
+ REGRESSION(r244906): Crash in WebCore::positionOffsetValue
+ https://bugs.webkit.org/show_bug.cgi?id=199613
+ <rdar://problem/51518172>
+
+ Reviewed by Zalan Bujtas.
+
+ * fast/css/getComputedStyle/sticky-scroll-container-crash-expected.txt: Added.
+ * fast/css/getComputedStyle/sticky-scroll-container-crash.html: Added.
+
2019-07-09 Cathie Chen <[email protected]>
Support writing-mode and direction for scrollIntoViewOptions.
Added: trunk/LayoutTests/fast/css/getComputedStyle/sticky-scroll-container-crash-expected.txt (0 => 247256)
--- trunk/LayoutTests/fast/css/getComputedStyle/sticky-scroll-container-crash-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/sticky-scroll-container-crash-expected.txt 2019-07-09 15:21:11 UTC (rev 247256)
@@ -0,0 +1 @@
+This test passes if it doesn't crash
Added: trunk/LayoutTests/fast/css/getComputedStyle/sticky-scroll-container-crash.html (0 => 247256)
--- trunk/LayoutTests/fast/css/getComputedStyle/sticky-scroll-container-crash.html (rev 0)
+++ trunk/LayoutTests/fast/css/getComputedStyle/sticky-scroll-container-crash.html 2019-07-09 15:21:11 UTC (rev 247256)
@@ -0,0 +1,13 @@
+<style>
+#target {
+ position: -webkit-sticky;
+ top: 5%;
+}
+</style>
+<div id=target>This test passes if it doesn't crash</div>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+getComputedStyle(target).top;
+</script>
Modified: trunk/Source/WebCore/ChangeLog (247255 => 247256)
--- trunk/Source/WebCore/ChangeLog 2019-07-09 10:03:19 UTC (rev 247255)
+++ trunk/Source/WebCore/ChangeLog 2019-07-09 15:21:11 UTC (rev 247256)
@@ -1,3 +1,32 @@
+2019-07-09 Antti Koivisto <[email protected]>
+
+ REGRESSION(r244906): Crash in WebCore::positionOffsetValue
+ https://bugs.webkit.org/show_bug.cgi?id=199613
+ <rdar://problem/51518172>
+
+ Reviewed by Zalan Bujtas.
+
+ Test: fast/css/getComputedStyle/sticky-scroll-container-crash.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::positionOffsetValue):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::enclosingScrollportBox const): Deleted.
+
+ The client trivally hits nullptr when this is called for element without overflow scroll parent.
+
+ Fix by removing the whole function and using shared enclosingClippingBoxForStickyPosition instead.
+ It does the same ancestor walk more efficiently via layer tree.
+
+ * rendering/RenderBox.h:
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::enclosingClippingBoxForStickyPosition const):
+
+ Factor into function.
+
+ (WebCore::RenderBoxModelObject::computeStickyPositionConstraints const):
+ * rendering/RenderBoxModelObject.h:
+
2019-07-09 Cathie Chen <[email protected]>
Support writing-mode and direction for scrollIntoViewOptions.
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (247255 => 247256)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2019-07-09 10:03:19 UTC (rev 247255)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2019-07-09 15:21:11 UTC (rev 247256)
@@ -790,12 +790,11 @@
}
LayoutUnit containingBlockSize;
if (box.isStickilyPositioned()) {
- const RenderBox& enclosingScrollportBox =
- box.enclosingScrollportBox();
- if (isVerticalProperty == enclosingScrollportBox.isHorizontalWritingMode())
- containingBlockSize = enclosingScrollportBox.contentLogicalHeight();
+ auto& enclosingClippingBox = box.enclosingClippingBoxForStickyPosition();
+ if (isVerticalProperty == enclosingClippingBox.isHorizontalWritingMode())
+ containingBlockSize = enclosingClippingBox.contentLogicalHeight();
else
- containingBlockSize = enclosingScrollportBox.contentLogicalWidth();
+ containingBlockSize = enclosingClippingBox.contentLogicalWidth();
} else {
if (isVerticalProperty == containingBlock->isHorizontalWritingMode()) {
containingBlockSize = box.isOutOfFlowPositioned()
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (247255 => 247256)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2019-07-09 10:03:19 UTC (rev 247255)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2019-07-09 15:21:11 UTC (rev 247256)
@@ -4726,17 +4726,6 @@
return nullptr;
}
-const RenderBlock& RenderBox::enclosingScrollportBox() const
-{
- const RenderBlock* ancestor = containingBlock();
- for (; ancestor; ancestor = ancestor->containingBlock()) {
- if (ancestor->hasOverflowClip())
- return *ancestor;
- }
- ASSERT_NOT_REACHED();
- return *ancestor;
-}
-
LayoutRect RenderBox::logicalVisualOverflowRectForPropagation(const RenderStyle* parentStyle) const
{
LayoutRect rect = visualOverflowRectForPropagation(parentStyle);
Modified: trunk/Source/WebCore/rendering/RenderBox.h (247255 => 247256)
--- trunk/Source/WebCore/rendering/RenderBox.h 2019-07-09 10:03:19 UTC (rev 247255)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2019-07-09 15:21:11 UTC (rev 247256)
@@ -532,8 +532,6 @@
void removeFloatingOrPositionedChildFromBlockLists();
RenderLayer* enclosingFloatPaintingLayer() const;
-
- const RenderBlock& enclosingScrollportBox() const;
virtual Optional<int> firstLineBaseline() const { return Optional<int>(); }
virtual Optional<int> inlineBlockBaseline(LineDirectionMode) const { return Optional<int>(); } // Returns empty if we should skip this box when computing the baseline of an inline-block.
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (247255 => 247256)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2019-07-09 10:03:19 UTC (rev 247255)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2019-07-09 15:21:11 UTC (rev 247256)
@@ -441,13 +441,24 @@
return referencePoint;
}
+const RenderBox& RenderBoxModelObject::enclosingClippingBoxForStickyPosition(const RenderLayer** enclosingClippingLayer) const
+{
+ ASSERT(isStickilyPositioned());
+
+ auto* clipLayer = layer()->enclosingOverflowClipLayer(ExcludeSelf);
+ if (enclosingClippingLayer)
+ *enclosingClippingLayer = clipLayer;
+
+ return clipLayer ? downcast<RenderBox>(clipLayer->renderer()) : view();
+}
+
void RenderBoxModelObject::computeStickyPositionConstraints(StickyPositionViewportConstraints& constraints, const FloatRect& constrainingRect) const
{
constraints.setConstrainingRectAtLastLayout(constrainingRect);
RenderBlock* containingBlock = this->containingBlock();
- RenderLayer* enclosingClippingLayer = layer()->enclosingOverflowClipLayer(ExcludeSelf);
- RenderBox& enclosingClippingBox = enclosingClippingLayer ? downcast<RenderBox>(enclosingClippingLayer->renderer()) : view();
+ const RenderLayer* enclosingClippingLayer = nullptr;
+ auto& enclosingClippingBox = enclosingClippingBoxForStickyPosition(&enclosingClippingLayer);
LayoutRect containerContentRect;
if (!enclosingClippingLayer || (containingBlock != &enclosingClippingBox))
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (247255 => 247256)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h 2019-07-09 10:03:19 UTC (rev 247255)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h 2019-07-09 15:21:11 UTC (rev 247256)
@@ -111,6 +111,7 @@
LayoutSize relativePositionLogicalOffset() const { return style().isHorizontalWritingMode() ? relativePositionOffset() : relativePositionOffset().transposedSize(); }
FloatRect constrainingRectForStickyPosition() const;
+ const RenderBox& enclosingClippingBoxForStickyPosition(const RenderLayer** enclosingClippingLayer = nullptr) const;
void computeStickyPositionConstraints(StickyPositionViewportConstraints&, const FloatRect& constrainingRect) const;
LayoutSize stickyPositionOffset() const;
LayoutSize stickyPositionLogicalOffset() const { return style().isHorizontalWritingMode() ? stickyPositionOffset() : stickyPositionOffset().transposedSize(); }