Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7d2bb1ed4f24c36532f26b0cfec4d071faf98036
      
https://github.com/WebKit/WebKit/commit/7d2bb1ed4f24c36532f26b0cfec4d071faf98036
  Author: Kiet Ho <[email protected]>
  Date:   2026-05-07 (Thu, 07 May 2026)

  Changed paths:
    A 
LayoutTests/fast/css/css-anchor-position/anchor-positioned-select-picker-expected.txt
    A 
LayoutTests/fast/css/css-anchor-position/anchor-positioned-select-picker.html
    M LayoutTests/platform/ios/TestExpectations
    M Source/WebCore/html/HTMLSelectElement.cpp
    M Source/WebCore/html/HTMLSelectElement.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl

  Log Message:
  -----------
  REGRESSION (Safari 26): Select picker incorrect position
rdar://175454476
https://bugs.webkit.org/show_bug.cgi?id=313135

Reviewed by Antti Koivisto.

HTMLSelectElement::showPopup() shows the system picker at the same position as
the <select> renderer, computed by localToAbsolute(). It's possible for the
layout info used by localToAbsolute() to be "stale", leading to incorrect
computed position. One case is when <select> is anchor positioned.

Before showPopup() gets called, it's possible that document->resolveStyle() gets
called, either by something else, or by HTMLSelectElement::showPicker() calling
document->updateStyleIfNeeded() before showPickerInternal() -> showPopup().

When the document uses anchor positioning, resolving its style involves multiple
rounds of style resolution and layout. At least two rounds are required: the 
first
round discovers and positions anchors, so the second round can position
anchor-positioned elements according to the positioned anchor. In some cases,
more rounds are required. The main points are (1) only the style/layout 
information
of the last round are valid and (2) all layout except the last one is 
synchronous,
the last layout is asynchronous using the layout timer.

It's possible for showPopup() to be called before the layout timer expires and
updates the layout for the final time. This leads to localToAbsolute using
stale layout info, which leads to the computed position being incorrect.

Fix this by forcing layout before computing the position of the <select> 
element.
The actual fix is one line, the rest is exposing the computed <select> element
position for testing purposes.

Test: fast/css/css-anchor-position/anchor-positioned-select-picker.html

* 
LayoutTests/fast/css/css-anchor-position/anchor-positioned-select-picker-expected.txt:
 Added.
* 
LayoutTests/fast/css/css-anchor-position/anchor-positioned-select-picker.html: 
Added.
* LayoutTests/platform/ios/TestExpectations:
* Source/WebCore/html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::menuListDefaultEventHandler):
* Source/WebCore/html/HTMLSelectElement.h:
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::lastSelectPopupLocation):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:

Canonical link: https://commits.webkit.org/312811@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to