Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f22fb0973e728cf1ab06ed5bd217cd2360f71967
      
https://github.com/WebKit/WebKit/commit/f22fb0973e728cf1ab06ed5bd217cd2360f71967
  Author: Diego Pino Garcia <[email protected]>
  Date:   2026-07-16 (Thu, 16 Jul 2026)

  Changed paths:
    R 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/selection/textcontrols/selectionchange-expected.txt
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/html/HTMLInputElement.h
    M Source/WebCore/html/HTMLTextAreaElement.cpp
    M Source/WebCore/html/HTMLTextFormControlElement.cpp
    M Source/WebCore/html/HTMLTextFormControlElement.h

  Log Message:
  -----------
  [WPE] 
imported/w3c/web-platform-tests/selection/textcontrols/selectionchange.html is 
a text failure
https://bugs.webkit.org/show_bug.cgi?id=272224

Reviewed by Ryosuke Niwa.

Selection directionality is platform-dependent: GTK/WPE and Windows treat
selections as directional, while macOS and iOS do not. This is exposed
through 'EditingBehavior::shouldConsiderSelectionAsDirectional()', and
'HTMLInputElement::updateType()', which already accounted for it when
caching the initial selection of a newly-selectable input.

Other call sites that cache a "no selection" state, such as
'HTMLTextAreaElement::setValueCommon()' and
'HTMLInputElement::cacheSelectionInResponseToSetValue()', instead hardcoded
'SelectionHasNoDirection' regardless of platform.

On GTK/WPE this mismatched the direction computed once an actual selection
was made, so restoring the same collapsed selection (e.g. via 
'setSelectionRange(0, 0))'
looked like a direction change and fired a spurious 'selectionchange' event.

Extract the platform-aware logic from 'updateType()' into
'HTMLTextFormControlElement::normalizeSelectionDirection()', which maps
'SelectionHasNoDirection' to 'SelectionHasForwardDirection' on platforms where
selections are directional, and use it from every call site that was
previously hardcoding 'SelectionHasNoDirection'.

* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::updateType):
* Source/WebCore/html/HTMLInputElement.h:
* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::setValueCommon):
* Source/WebCore/html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::normalizeSelectionDirection):
* Source/WebCore/html/HTMLTextFormControlElement.h:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/selection/textcontrols/selectionchange-expected.txt:
 Removed.

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



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

Reply via email to