[webkit-changes] [WebKit/WebKit] 9fb8e1: [macOS] Double clicking over UI in store.steampowe...
Wenson Hsieh
noreply at github.com
Thu Jan 2 11:47:40 PST 2025
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9fb8e1239267b11deab0e28e637cdbd0bad32642
https://github.com/WebKit/WebKit/commit/9fb8e1239267b11deab0e28e637cdbd0bad32642
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2025-01-02 (Thu, 02 Jan 2025)
Changed paths:
A LayoutTests/editing/selection/double-click-does-not-expand-selection-over-empty-div-expected.txt
A LayoutTests/editing/selection/double-click-does-not-expand-selection-over-empty-div.html
M LayoutTests/platform/mac/fast/events/objc-event-api-expected.txt
M Source/WebCore/editing/TextIterator.cpp
M Source/WebCore/editing/TextIterator.h
M Source/WebCore/page/EventHandler.cpp
M Source/WebCore/page/EventHandler.h
Log Message:
-----------
[macOS] Double clicking over UI in store.steampowered.com, beta.maps.apple.com, and other sites triggers unexpected text selection
https://bugs.webkit.org/show_bug.cgi?id=285204
rdar://137991406
Reviewed by Abrar Rahman Protyasha.
Add a heuristic to prevent double- and triple-clicks from setting the selection using word or
paragraph granularity, in the case where the resulting selection would contain no relevant text or
replaced content.
This helps mitigate scenarios where double clicking interactive UI on various websites creates an
unintended (and often confusing) text selection, and also aligns our behavior more closely with
Chrome and Firefox, when double-clicking to select text.
Also fixes: rdar://138062079
* LayoutTests/editing/selection/double-click-does-not-expand-selection-over-empty-div-expected.txt: Added.
* LayoutTests/editing/selection/double-click-does-not-expand-selection-over-empty-div.html: Added.
Add a new layout test to exercise this scenario, by double-clicking in an empty `div` and checking
that there's no ranged selection.
* LayoutTests/platform/mac/fast/events/objc-event-api-expected.txt:
Rebaseline an existing layout test, now that text selection only starts upon mouse drag rather than
the second mouse down in this test.
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::hasAnyPlainText):
* Source/WebCore/editing/TextIterator.h:
(WebCore::hasAnyPlainText):
Add an option to ignore collapsed ranges when determining whether the given range contains any text.
This allows us to ignore leading newline characters emitted by `TextIterator` for positioning, for
the purposes of determining whether we should extend the selection on double/triple click.
* Source/WebCore/page/EventHandler.cpp:
(WebCore::shouldAvoidExtendingSelectionOnClick):
See description above.
(WebCore::EventHandler::expandAndUpdateSelectionForMouseDownIfNeeded):
Add a helper method to (1) expand the given selection to respect select on mouse down, and (2)
update the selection, dispatching the select start event, only if it passes the check against
`shouldAvoidExtendingSelectionOnClick` above.
(WebCore::EventHandler::selectClosestWordFromHitTestResult):
(WebCore::EventHandler::handleMousePressEventTripleClick):
* Source/WebCore/page/EventHandler.h:
Canonical link: https://commits.webkit.org/288369@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list