-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REGRESSION (259904@main): @math operation cannot trigger in Quip app #16492
Conversation
EWS run on previous version of this PR (hash d55d863)
|
(Whoops, I need to guard the LoA behind a
(edit: after some more testing, it seems the |
As it turns out, Quip was depending on the fact that
...though, the above test case behaves different in different browsers:
So we now match Gecko's behavior on Safari 17, whereas we used to match Chrome. |
That is very subtle! |
After some more testing: it seems the bug does not reproduce in Firefox. This is because FF doesn't actually mutate the DOM selection when focusing a text field, so if the rangeCount in Quip were 1 before (as is the case when typing As such, a better test case is:
...this yields 0 in Safari 17 with live ranges enabled, and 1 everywhere else. |
EWS run on previous version of this PR (hash e8fc46c) |
EWS run on previous version of this PR (hash bc9956a) |
By the way, can we add a test with nested shadow roots as a follow up? |
Sounds good — will add a test in https://bugs.webkit.org/show_bug.cgi?id=260011. Thanks for the review! |
EWS run on current version of this PR (hash 9c520b5) |
9c520b5
to
1f9db29
Compare
https://bugs.webkit.org/show_bug.cgi?id=259944 rdar://113229516 Reviewed by Ryosuke Niwa. Currently, the `@math` feature in Quip is broken in Safari with Live Range Selection enabled; this is because Quip's JavaScript editor focuses an input element, and expects `selection.rangeCount` to return `1` instead of `0` (the latter of which causes Quip to believe that the user is no longer editing the text field, and therefore leads to Quip dismissing the input field immediately after presenting it). This happens because the `rangeCount` and ranges we expose on `DOMSelection` are different with live range selection in Safari 17, as opposed to both Safari 16 and Chrome (testing against both stable and canary). Whereas we used to expose a single range that was collapsed to the start of the text field, we now expose no ranges at all. To avoid this incompatibility, we restore shipping behavior when the selection is inside of shadow roots, by exposing a selection range that's equivalent to a caret before the shadow host. See also: <w3c/selection-api#166>. Test: fast/forms/shadow-tree-exposure-live-range.html * LayoutTests/fast/forms/shadow-tree-exposure-live-range-expected.txt: * LayoutTests/fast/forms/shadow-tree-exposure-live-range.html: Rebaseline this layout test, such that it verifies that the ranges exposed via the Selection API have the same behavior without live ranges, vs. with live ranges enabled; this also matches the behavior in latest Chrome Canary. * LayoutTests/imported/w3c/web-platform-tests/editing/other/editable-state-and-focus-in-shadow-dom-in-designMode.tentative-expected.txt: * LayoutTests/platform/glib/imported/w3c/web-platform-tests/editing/other/editable-state-and-focus-in-shadow-dom-in-designMode.tentative-expected.txt: * LayoutTests/platform/ios/imported/w3c/web-platform-tests/editing/other/editable-state-and-focus-in-shadow-dom-in-designMode.tentative-expected.txt: Rebaseline a WPT — attempts to change the selection in a UA shadow root in this test now result in the wrong base/anchor nodes and offsets after this patch, rather than the `IndexSizeError`s we currently get. * Source/WebCore/page/DOMSelection.cpp: (WebCore::selectionShadowAncestor): Remove an assertion that's no longer relevant, now that we use this in both live/legacy codepaths. (WebCore::DOMSelection::type const): Keep both `fast/forms/shadow-tree-exposure-live-range.html` and `editing/selection/user-select-js-property.html` passing by adjusting our logic for returning the selection type. Currently, a selection in a shadow root always results in a type of `None`, but this diverges from Chrome (and Safari 16's) behavior, which returns the actual type of the selected range, regardless of whether it's in the shadow tree. (WebCore::DOMSelection::rangeCount const): This is the main fix — return a `rangeCount` of 1 in the case where there are no associated live ranges, if the range is still inside a shadow root. (WebCore::createLiveRangeBeforeShadowHostWithSelection): (WebCore::DOMSelection::getRangeAt): Keep `getRangeAt` consistent with `rangeCount` by returning the caret range at the start of the shadow host in the case where the selected range is in the shadow tree. (WebCore::DOMSelection::shadowAdjustedNode const): (WebCore::DOMSelection::shadowAdjustedOffset const): These methods need to be adjusted as well, to keep the `(base|anchor|focus|extent)(Node|Offset)` properties consistent with the `rangeCount` and selection ranges in the case where the selection is inside of a shadow root. Since the behavior with or without live ranges when the selection is in a shadow tree is now consistent, we no longer require live-range-specific codepaths, so we can simplify this code a bit by just removing the `liveRangeSelectionEnabled()` checks. Canonical link: https://commits.webkit.org/266781@main
1f9db29
to
457eb42
Compare
Committed 266781@main (457eb42): https://commits.webkit.org/266781@main Reviewed commits have been landed. Closing PR #16492 and removing active labels. |
457eb42
9c520b5