Skip to content

Commit

Permalink
RenderListBox::setScrollTop should allow out-of-range values but clam…
Browse files Browse the repository at this point in the history
…p them

https://bugs.webkit.org/show_bug.cgi?id=248327
rdar://102656180

Reviewed by Cameron McCormack.

The CSSOM View spec allows out-of-range values when scrolling, but it requires clamping:
https://w3c.github.io/csswg-drafts/cssom-view/#scroll-an-element

* LayoutTests/imported/w3c/web-platform-tests/css/css-writing-modes/forms/select-multiple-scrolling.optional-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-writing-modes/forms/select-size-scrolling-and-sizing.optional-expected.txt:
* LayoutTests/platform/gtk/TestExpectations:
* Source/WebCore/rendering/RenderListBox.cpp:
(WebCore::RenderListBox::setScrollTop):

Canonical link: https://commits.webkit.org/257012@main
  • Loading branch information
nt1m committed Nov 25, 2022
1 parent 70230d1 commit cb92b7a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
@@ -1,6 +1,6 @@


FAIL select[multiple][style="writing-mode: horizontal-tb"] scrolls correctly assert_equals: Setting scrollTop to a negative value of the list does not work for writing-mode: horizontal-tb expected 0 but got 98
PASS select[multiple][style="writing-mode: horizontal-tb"] scrolls correctly
FAIL select[multiple][style="writing-mode: vertical-lr"] scrolls correctly assert_true: select should be scrollable in block axis expected true got false
FAIL select[multiple][style="writing-mode: vertical-rl"] scrolls correctly assert_true: select should be scrollable in block axis expected true got false

@@ -1,6 +1,6 @@


FAIL select[size][style="writing-mode: horizontal-tb"] scrolls correctly assert_equals: Setting scrollTop to a negative value of the list does not work for writing-mode: horizontal-tb expected 0 but got 98
PASS select[size][style="writing-mode: horizontal-tb"] scrolls correctly
PASS select[size][style="writing-mode: horizontal-tb"] sizing works correctly
FAIL select[size][style="writing-mode: vertical-lr"] scrolls correctly assert_true: select should be scrollable in block axis expected true got false
FAIL select[size][style="writing-mode: vertical-lr"] sizing works correctly assert_true: clientWidth increased when increasing size expected true got false
Expand Down
2 changes: 0 additions & 2 deletions LayoutTests/platform/gtk/TestExpectations
Expand Up @@ -1966,5 +1966,3 @@ webkit.org/b/246952 imported/w3c/web-platform-tests/css/css-fonts/font-variant-a

# vertical form controls
imported/w3c/web-platform-tests/css/css-writing-modes/forms/progress-appearance-native-computed-style.optional.html [ Failure ]
imported/w3c/web-platform-tests/css/css-writing-modes/forms/select-multiple-scrolling.optional.html [ Failure ]
imported/w3c/web-platform-tests/css/css-writing-modes/forms/select-size-scrolling-and-sizing.optional.html [ Failure ]
5 changes: 3 additions & 2 deletions Source/WebCore/rendering/RenderListBox.cpp
Expand Up @@ -805,9 +805,10 @@ static void setupWheelEventTestMonitor(RenderListBox& renderer)

void RenderListBox::setScrollTop(int newTop, const ScrollPositionChangeOptions&)
{
// Determine an index and scroll to it.
// Determine an index and scroll to it.
int index = newTop / itemHeight();
if (index < 0 || index >= numItems() || index == m_indexOffset)
index = std::clamp(index, 0, std::max(0, numItems() - 1));
if (index == m_indexOffset)
return;

setupWheelEventTestMonitor(*this);
Expand Down

0 comments on commit cb92b7a

Please sign in to comment.