From dda2fc0dedd730ad63251ad3532762d3ea34bcd0 Mon Sep 17 00:00:00 2001 From: JC Alvarado Date: Tue, 21 Mar 2023 16:24:45 -0700 Subject: [PATCH] Cherry-pick 259548.465@safari-7615-branch (cf0b3436ba58). rdar://104064235 Increase max scrollbar update passes rdar://104064235 Reviewed by Simon Fraser. Scrollbars are not fully updated in a single layout which can lead to an additional layout in the scriptDisallowedScope in FrameView::scrollRectToVisibleInChildView. * LayoutTests/fast/editing/frame-selection-in-child-view-crash-expected.txt: Added. * LayoutTests/fast/editing/frame-selection-in-child-view-crash.html: Added. * Source/WebCore/platform/ScrollView.cpp: (WebCore::ScrollView::updateScrollbars): * Tools/TestWebKitAPI/Tests/WebKitCocoa/CSSViewportUnits.mm: (TEST): Add scrollbarSize to width in WritingMode tests because we should expect vertical overflow in these cases. This test would pass prior to this patch despite the displayed WebView having both a vertical and horizontal scroll bar. Canonical link: https://commits.webkit.org/259548.465@safari-7615-branch --- ...selection-in-child-view-crash-expected.txt | 1 + .../frame-selection-in-child-view-crash.html | 19 +++++++++++++++++++ Source/WebCore/platform/ScrollView.cpp | 2 +- .../Tests/WebKitCocoa/CSSViewportUnits.mm | 4 ++-- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 LayoutTests/fast/editing/frame-selection-in-child-view-crash-expected.txt create mode 100644 LayoutTests/fast/editing/frame-selection-in-child-view-crash.html diff --git a/LayoutTests/fast/editing/frame-selection-in-child-view-crash-expected.txt b/LayoutTests/fast/editing/frame-selection-in-child-view-crash-expected.txt new file mode 100644 index 000000000000..71c4f8559439 --- /dev/null +++ b/LayoutTests/fast/editing/frame-selection-in-child-view-crash-expected.txt @@ -0,0 +1 @@ +This test passes if it does not crash diff --git a/LayoutTests/fast/editing/frame-selection-in-child-view-crash.html b/LayoutTests/fast/editing/frame-selection-in-child-view-crash.html new file mode 100644 index 000000000000..9cae2eb8f7d0 --- /dev/null +++ b/LayoutTests/fast/editing/frame-selection-in-child-view-crash.html @@ -0,0 +1,19 @@ + + + + + This test passes if it does not crash + \ No newline at end of file diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp index c05427f136f4..5e5ded386dc8 100644 --- a/Source/WebCore/platform/ScrollView.cpp +++ b/Source/WebCore/platform/ScrollView.cpp @@ -711,7 +711,7 @@ void ScrollView::updateScrollbars(const ScrollPosition& desiredPosition) } } - const unsigned cMaxUpdateScrollbarsPass = 2; + const unsigned cMaxUpdateScrollbarsPass = 3; if ((sendContentResizedNotification || needAnotherPass) && m_updateScrollbarsPass < cMaxUpdateScrollbarsPass) { m_updateScrollbarsPass++; availableContentSizeChanged(AvailableSizeChangeReason::ScrollbarsChanged); diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/CSSViewportUnits.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/CSSViewportUnits.mm index ac128fab4f46..055147ee4db2 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/CSSViewportUnits.mm +++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/CSSViewportUnits.mm @@ -499,7 +499,7 @@ static void changeCSSPropertyOfElements(RetainPtr& webView, NSStr EXPECT_FLOAT_EQ(458, viewportUnitLength(webView, @"lvi")); { - double fixedWidth = widthOfElementWithID(webView, @"fixed"); // No vertical overflow. + double fixedWidth = widthOfElementWithID(webView, @"fixed") + scrollbarSize; double fixedHeight = heightOfElementWithID(webView, @"fixed") + scrollbarSize; EXPECT_FLOAT_EQ(fixedWidth, viewportUnitLength(webView, @"dvw")); EXPECT_FLOAT_EQ(fixedHeight, viewportUnitLength(webView, @"dvh")); @@ -576,7 +576,7 @@ static void changeCSSPropertyOfElements(RetainPtr& webView, NSStr EXPECT_FLOAT_EQ(500, viewportUnitLength(webView, @"lvi")); { - double fixedWidth = widthOfElementWithID(webView, @"fixed"); // No vertical overflow. + double fixedWidth = widthOfElementWithID(webView, @"fixed") + scrollbarSize; double fixedHeight = heightOfElementWithID(webView, @"fixed") + scrollbarSize; EXPECT_FLOAT_EQ(fixedWidth, viewportUnitLength(webView, @"dvw")); EXPECT_FLOAT_EQ(fixedHeight, viewportUnitLength(webView, @"dvh"));