-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add a new attribute called writingsuggestions
to control UA-provided writing assistance
#10018
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I've addressed/responded to all the comments so far.
https://bugs.webkit.org/show_bug.cgi?id=266824 rdar://114989563 Reviewed by Aditya Keerthi. Implement support for the new DOM `writingsuggstions` web API attribute, as defined by the corresponding spec PR (whatwg/html#10018). * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WTF/wtf/PlatformEnable.h: * Source/WebCore/dom/Element.cpp: (WebCore::Element::isWritingSuggestionsEnabled const): * Source/WebCore/dom/Element.h: * Source/WebCore/editing/VisibleSelection.cpp: (WebCore::VisibleSelection::canEnableWritingSuggestions const): * Source/WebCore/editing/VisibleSelection.h: * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLElement.cpp: (WebCore::HTMLElement::writingsuggestions const): (WebCore::HTMLElement::setWritingsuggestions): * Source/WebCore/html/HTMLElement.h: * Source/WebCore/html/HTMLElement.idl: * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::supportsWritingSuggestions const): * Source/WebCore/html/HTMLInputElement.h: * Source/WebKit/Shared/EditorState.cpp: (WebKit::operator<<): * Source/WebKit/Shared/EditorState.h: * Source/WebKit/Shared/EditorState.serialization.in: * Source/WebKit/Shared/FocusedElementInformation.h: * Source/WebKit/Shared/FocusedElementInformation.serialization.in: * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _updateTextInputTraits:]): * Source/WebKit/UIProcess/mac/WebViewImpl.mm: (WebKit::WebViewImpl::postLayoutDataForContentEditable): (WebKit::WebViewImpl::allowsInlinePredictions const): * Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::getPlatformEditorStateCommon const): * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::focusedElementInformation): * Tools/TestWebKitAPI/SourcesCocoa.txt: * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WritingSuggestions.mm: Added. (-[WritingSuggestionsWebAPIWKWebView initWithHTMLString:]): (-[WritingSuggestionsWebAPIWKWebView focusElementAndEnsureEditorStateUpdate:]): (TEST): Canonical link: https://commits.webkit.org/274912@main
@annevk and @domenic, I went ahead and added Telephone to the list of valid input types for writingsuggestions in this PR based on comments here: [1], [2]. @annevk, do you have thoughts on my answer here regarding the attribute not returning different values for elements that don't support writing suggestions? I’d like to try to come to a decision on this one way or another to unblock this spec. |
@dandclark if as you say implementations can do whatever and none of it is exposed to script, how is any of it actually relevant? |
@annevk That section is an attempt to follow the example of I think the purpose of having a section like this for |
Spellchecking also has the concept of "true-by-default", but it's not clear that's actually implemented (it doesn't seem implemented in WebKit at least). Not sure what to make of it. Unless we have some way of testing it I suppose I rather we don't make requirements around this and file a follow-up issue against |
I'd rather keep consistency with It's true that We do have ways of testing; we can test that |
No we can't test that. I suggested testing that it's false for disabled form controls for instance, but as @dandclark pointed out nothing requires the IDL attribute to be false for that case. |
Oh, I see what you mean. I still think the simplified-spellcheck model (i.e., without true/false by default) is a reasonable one. Here's a crux case: <div writingsuggestions="true" spellcheck="true">
<span>
<input type="text">
</span>
</div> http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=12426 Both models under consideration suggest that However, the model in this PR suggests that Similarly, the model in this PR suggests |
I don't think I suggested that the Anyway, my further point was that if we are not going to take into account |
I thought the suggestion was to reflect all of "User agents must only offer suggestions within an element's scope if the result of running the following algorithm given element returns true:", except I guess not the user-preference portions per #10018 (comment), in the API. If that's not the suggestion, maybe you could make it more concrete exactly which portions you're proposing to reflect in the API, and why those portions specifically you think are best reflected in the API and not others?
It seems reasonable for the spec to require that the user not be bothered by writing suggestions in disabled input elements, just like it currently requires that the user not be bothered by spellchecking in such elements. Since the whole section is about browser UI, I agree that it's not 100% clear we're providing value with such requirements; it's not web-observable and probably implementers would figure that out anyway. But I can imagine authors being confused why they get red squiggles or "write for me" popups in We could soften both spellcheck and writing suggestions from "must" to "should", though. That would be congruent with how we treat most other browser UI suggestions. |
@annevk, would this address your concern? |
Yeah, I think that would work, thanks! |
…cking and writing suggestions UI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience!
Thanks everyone for the feedback and reviews. |
This PR proposes the addition of a new attribute called
writingsuggestions
to control UA-provided writing assistance, addressing #9065. Some browsers provide this capability to users (see https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/WritingSuggestions/explainer.md#use-case) but there are scenarios in which developers may want to turn off browser provided writing assistance, such as writing extensions like Grammarly or sites providing their own solutions. This new attribute will have values "on" and "off", and each element will have a default behavior as determined by the UA. This attribute's state is also inheritable from ancestor elements.💥 Error: Wattsi server error 💥
PR Preview failed to build. (Last tried on Mar 11, 2024, 5:56 PM UTC).
More
PR Preview relies on a number of web services to run. There seems to be an issue with the following one:
🚨 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.
🔗 Related URL
If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.