Skip to content
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

Merged
merged 40 commits into from
Mar 13, 2024
Merged
Changes from 7 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5a3eac7
Initial commit - building.
sanketj Dec 1, 2023
26daf8a
Add definitions for writingsuggestion attribute and values.
sanketj Dec 1, 2023
c9abb7a
Further updates to spec text.
sanketj Dec 2, 2023
ea0bfc1
Initial iteration of writing suggestions spec.
sanketj Dec 22, 2023
abc1c85
Merge branch 'main' into new-writing-attribute
sanketj Dec 22, 2023
95524a1
Add IDL entry.
sanketj Dec 22, 2023
9aecd89
Update behavior of spellcheck attribute setter.
sanketj Dec 22, 2023
7fda857
Specify attribute inheritance with shadow trees.
sanketj Jan 9, 2024
d119757
Switch from on/off to true/false.
sanketj Jan 9, 2024
ccaac6c
Wording fixup.
sanketj Jan 10, 2024
ac65d83
Remove default behavior and rework states with inherit and true as de…
sanketj Jan 11, 2024
d16055e
Update spec for getter/setter.
sanketj Jan 11, 2024
71cdc44
Delete default behavior section.
sanketj Jan 11, 2024
d5a1d16
Simplify algorithm and misc editorial fixup.
sanketj Jan 11, 2024
1482e04
Editorial fixup.
sanketj Jan 11, 2024
2c9f530
Fix wording of inherit case in algorithm.
sanketj Jan 11, 2024
a7481ab
Fix return type in IDL interface.
sanketj Jan 11, 2024
3ba33e6
Minor cleanup.
sanketj Jan 11, 2024
b6a32bb
Align spec for inheritance behavior with spellcheck.
sanketj Jan 11, 2024
7cdd6d5
Address editorial suggestions
dandclark Jan 19, 2024
15dfeca
Use inclusive ancestor
dandclark Jan 19, 2024
ecb2b3d
Make the steps to determine if suggestions should be shown a bit more…
dandclark Jan 19, 2024
8e850bd
Wrap lines at length 100
dandclark Jan 19, 2024
f29afd0
Fix build break from wrong attribute name
dandclark Jan 19, 2024
443fd10
IDL attribute to camelCase
dandclark Feb 3, 2024
2b0ab55
Scope w-nodev to only IDL definitions
dandclark Feb 6, 2024
f68ba72
Combine algorithms to determine if UA should show suggestions
dandclark Feb 6, 2024
d10905b
Change writingSuggestions IDL getter/setter to use modern style
dandclark Feb 6, 2024
c927b6a
Switch verbiage of non-normative IDL section to match spellcheck
dandclark Feb 6, 2024
ec26b8d
Remove the dependency of missing value default on the element. Push t…
dandclark Feb 6, 2024
fc447b5
Typos
dandclark Feb 6, 2024
39cf165
Add 'empty string' to attributes table
dandclark Feb 6, 2024
743eeb1
Fix formatting of "true"/"false" strings
dandclark Feb 9, 2024
a6b2931
Define 'computed writing suggestions value' instead of using public IDL
dandclark Feb 9, 2024
57a5499
Fix list punctuation
dandclark Feb 9, 2024
d44464b
<li><p></p></li>
dandclark Feb 9, 2024
c36127a
For the IDL setter, just set the content attribute to the given value…
dandclark Feb 9, 2024
f017063
Fix typos, indentation, extra tag
dandclark Feb 9, 2024
17410f5
Add input[type=telephone] to element types that can get writing sugge…
dandclark Feb 20, 2024
3ac0bb0
Change 'must' to 'should' in language about UAs not showing spell che…
dandclark Mar 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
159 changes: 159 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -11710,6 +11710,7 @@ interface <dfn interface>HTMLElement</dfn> : <span>Element</span> {
readonly attribute DOMString <span data-x="dom-accessKeyLabel">accessKeyLabel</span>;
[<span>CEReactions</span>] attribute boolean <span data-x="dom-draggable">draggable</span>;
[<span>CEReactions</span>] attribute boolean <span data-x="dom-spellcheck">spellcheck</span>;
[<span>CEReactions</span>] attribute boolean <span data-x="dom-writingsuggestions">writingsuggestions</span>;
domenic marked this conversation as resolved.
Show resolved Hide resolved
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-autocapitalize">autocapitalize</span>;

[<span>CEReactions</span>] attribute [<span>LegacyNullToEmptyString</span>] DOMString <span data-x="dom-innerText">innerText</span>;
Expand Down Expand Up @@ -12979,6 +12980,7 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%
<li><code data-x="attr-tabindex">tabindex</code></li>
<li><code data-x="attr-title">title</code></li>
<li><code data-x="attr-translate">translate</code></li>
<li><code data-x="attr-writingsuggestions">writingsuggestions</code></li>
</ul>

<div w-nodev>
Expand Down Expand Up @@ -80813,6 +80815,157 @@ body { display:none }
checkers. A user agent could offer on-demand checking, could perform continuous checking while the
checking is enabled, or could use other interfaces.</p>

<h4>Writing suggestions</h4>

<div w-nodev>
domenic marked this conversation as resolved.
Show resolved Hide resolved

<p>User agents may offer writing suggestions as users type into editable regions, either in form
sanketj marked this conversation as resolved.
Show resolved Hide resolved
controls (ex. the <code>textarea</code> element) or in elements in an <span data-x="editing host">
domenic marked this conversation as resolved.
Show resolved Hide resolved
editing host</span>.</p>

<p>For each element, user agents must establish a <dfn data-x="concept-writingsuggestions-default">default
sanketj marked this conversation as resolved.
Show resolved Hide resolved
behavior</dfn> from amongst the following behaviors:</p>

<dl>
<dt><dfn data-x="concept-writingsuggestions-default-on">on</dfn>
sanketj marked this conversation as resolved.
Show resolved Hide resolved

<dd>The user agent may offer writing suggestions on this element.

<dt><dfn data-x="concept-writingsuggestions-default-off">off</dfn>

<dd>The user agent must not offer writing suggestions on this element.
sanketj marked this conversation as resolved.
Show resolved Hide resolved

<dt><dfn data-x="concept-writingsuggestions-state-inherit">inherit</dfn>

<dd>The element's default writing suggestions state is the same as its parent element's.
Elements that have no parent element cannot have this as their default state.
sanketj marked this conversation as resolved.
Show resolved Hide resolved
</dl>

<p>The <dfn element-attr for="html-global"><code
data-x="attr-writingsuggestions">writingsuggestions</code></dfn> content attribute is an
<span>enumerated attribute</span> with the following keywords and states:</p>

<table>
<thead>
<tr>
<th>Keyword
<th>State
<th>Brief description
<tbody>
<tr>
<td><dfn attr-value for="html-global/writingsuggestions"><code
data-x="attr-writingsuggestions-on">on</code></dfn>
<td rowspan="2"><dfn data-x="attr-writingsuggestions-on-state">on</dfn>
<td rowspan="2">The user agent may offer writing suggestions on this element.
</tr>
<tr>
<td>(The empty string)
<tr>
domenic marked this conversation as resolved.
Show resolved Hide resolved
<td><dfn attr-value for="html-global/writingsuggestions"><code
data-x="attr-writingsuggestions-off">off</code></dfn>
<td><dfn data-x="attr-writingsuggestions-off-state">off</dfn>
<td>The user agent must not offer writing suggestions on this element.
</tr>
</table>

sanketj marked this conversation as resolved.
Show resolved Hide resolved
<p>The attribute's <i data-x="missing value default">missing value default</i> and <i
data-x="invalid value default">invalid value default</i> are both the <dfn
domenic marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
data-x="attr-writingsuggestions-default-state">default</dfn> state. The default state
indicates that the element is to act according to its established
domenic marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't take this into account whether the attribute is actually applicable and would have an effect? That makes it far less useful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the current design is the same as spellcheck and autocapitalize, and avoids exposing privacy-sensitive information about user preferences.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't suggesting exposing user preferences though. Mainly that we wouldn't return true for <input type=date> or <input disabled>.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even in that respect we're following the precedent for spellcheck here, which returns true even for element types that the spec says it can never apply to. The conditions under User agents must only consider the following pieces of text as checkable... do not affect the value of the spellcheck attribute.

A practical reason not to do this is that different UAs may make different decisions about where to support writing suggestions, e.g. some may support them in input type="text" elements and some may not. Either behavior is allowed per spec, and we don't want to expose these specific choices for the aforementioned privacy/fingerprinting reasons. So if developers get in the habit of checking writingSuggestions on different element types to see where it is supported, they could get the wrong idea about where a particular UA will end up providing writing suggestions.

<span data-x="concept-writingsuggestions-default">default behavior</span>.</p>

<dl class="domintro">
domenic marked this conversation as resolved.
Show resolved Hide resolved
<dt><code data-x=""><var>element</var>.<span subdfn data-x="dom-writingsuggestions">writingsuggestions</span> [ = <var>value</var> ]</code></dt>

domenic marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
<dd>
<p>Returns the keyword value corresponding to the writing suggestions state for the current <var>element</var>.</p>

<p>Can be set, to override the default and set the <code
data-x="attr-writingsuggestions">writingsuggestions</code> content attribute.</p>
</dd>
domenic marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
</dl>

<p>The <dfn attribute for="HTMLElement"><code data-x="dom-writingsuggestions">writingsuggestions</code></dfn> IDL
attribute, on getting, must return "on" if the element's <code data-x="attr-writingsuggestions">writingsuggestions</code> content attribute
is in the <i>on</i> state, or if the element's <code data-x="attr-writingsuggestions">writingsuggestions</code> content attribute is in the
<i>default</i> state and the element's <span data-x="concept-writingsuggestions-default">default behavior</span> is
<span data-x="concept-writingsuggestions-default-on">on</span>, or if the element's <code data-x="attr-writingsuggestions">
writingsuggestions</code> content attribute is in the <i>default</i> state and the element's
<span data-x="concept-writingsuggestions-default">default behavior</span> is <span data-x="concept-writingsuggestions-state-inherit">
inherit-by-default</span> and the element's parent element's <code data-x="dom-writingsuggestions">writingsuggestions</code> IDL attribute
sanketj marked this conversation as resolved.
Show resolved Hide resolved
would return "on"; otherwise, if none of those conditions applies, then the attribute must instead return "off".</p>

<p class="note">The <code data-x="dom-writingsuggestions">writingsuggestions</code> IDL attribute
domenic marked this conversation as resolved.
Show resolved Hide resolved
is not affected by user preferences that override the <code data-x="attr-writingsuggestions">writingsuggestions</code> content
attribute, and therefore might not reflect the actual writing suggestions state.</p>

<p>On setting, if the new state is "on", then the element's <code data-x="attr-writingsuggestions">writingsuggestions</code>
domenic marked this conversation as resolved.
Show resolved Hide resolved
content attribute must be set to the literal string "<code data-x="attr-writingsuggestions-on-state">on</code>", otherwise it must be set to the literal string
"<code data-x="attr-writingsuggestions-off-state">off</code>".

<p>User agents may only offer writing suggestions within the scope of the following element types.</p>

<ul>

sanketj marked this conversation as resolved.
Show resolved Hide resolved
<li><code>input</code> elements whose <code data-x="attr-input-type">type</code> attributes are in the
<span data-x="attr-input-type-text">Text</span>, <span data-x="attr-input-type-search">Search</span>,
<span data-x="attr-input-type-url">URL</span>, or <span data-x="attr-input-type-email">Email</span> states
and that are <i data-x="concept-fe-mutable">mutable</i> (i.e. that do not have the <code
data-x="attr-input-readonly">readonly</code> attribute specified and that are not <span
data-x="concept-fe-disabled">disabled</span>).</li>

<li><code>textarea</code> elements that do not have a <code data-x="attr-textarea-readonly">readonly</code>
domenic marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
attribute and that are not <span data-x="concept-fe-disabled">disabled</span>.</li>

<li><span data-x="editing host">Editing hosts</span> or <span>editable</span> elements.</li>

domenic marked this conversation as resolved.
Show resolved Hide resolved
</ul>

<p>To determine if writing suggestions may be provided within a given element's scope, the user agent must use
the following algorithm:</p>

<ol>
domenic marked this conversation as resolved.
Show resolved Hide resolved
<!-- user override -->

domenic marked this conversation as resolved.
Show resolved Hide resolved
<li>If the user has disabled writing suggestions for this element, then writing suggestions must be disabled.</li>
sanketj marked this conversation as resolved.
Show resolved Hide resolved

<!-- content attribute: on, off -->
domenic marked this conversation as resolved.
Show resolved Hide resolved

sanketj marked this conversation as resolved.
Show resolved Hide resolved
<li>Otherwise, if the element has a <code data-x="attr-writingsuggestions">writingsuggestions</code> content
attribute, then: if that attribute is in the <i>on</i> state, then writing suggestions may be enabled;
sanketj marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
otherwise, if that attribute is in the <i>off</i> state, then writing suggestions must be disabled.</li>

<!-- inherit, if there is one to inherit from -->
domenic marked this conversation as resolved.
Show resolved Hide resolved

<li>Otherwise, if there is an ancestor element with a <code data-x="attr-writingsuggestions">
writingsuggestions</code> content attribute that is not in the <i>default</i> state, then: if the
nearest such ancestor's <code data-x="attr-writingsuggestions">writingsuggestions</code> content
attribute is in the <i>on</i> state, then writing suggestions may be enabled; otherwise, if the
nearest such ancestor's <code data-x="attr-writingsuggestions">writingsuggestions</code> content
attribute is in the <i>off</i> state, then writing suggestions must be disabled.</li>

sanketj marked this conversation as resolved.
Show resolved Hide resolved
<!-- default -->

<li>Otherwise, if the element's <span data-x="concept-writingsuggestions-default">default behavior</span>
is <span data-x="concept-writingsuggestions-default-on">on</span>, then writing suggestions may be
enabled.</li>

sanketj marked this conversation as resolved.
Show resolved Hide resolved
<li>Otherwise, if the element's <span data-x="concept-writingsuggestions-default">default behavior</span>
is <span data-x="concept-writingsuggestions-default-off">off</span>, then writing suggestions must be
disabled.</li>

<!-- default inheritance -->

<li>Otherwise, if the element's parent element has writing suggestions enabled within <em>its</em> scope,
sanketj marked this conversation as resolved.
Show resolved Hide resolved
then writing suggestions may be enabled within this element's scope too.</li>

<li>Otherwise, writing suggestions must be disabled within this element's scope.</li>
sanketj marked this conversation as resolved.
Show resolved Hide resolved
</ol>

<p class="note">This specification does not define the user interface for writing suggestions.
sanketj marked this conversation as resolved.
Show resolved Hide resolved
A user agent could offer on-demand suggestions, continuous suggestions as the user types, inline
suggestions, autofill-like suggestions in a popup, or could use other interfaces.</p>

<h4>Autocapitalization</h4>

<p>Some methods of entering text, for example virtual keyboards on mobile devices, and also voice
Expand Down Expand Up @@ -138722,6 +138875,11 @@ interface <dfn interface>External</dfn> {
<td> How the value of the form control is to be wrapped for <span>form submission</span>
<td> "<code data-x="attr-textarea-wrap-soft">soft</code>";
"<code data-x="attr-textarea-wrap-hard">hard</code>"
<tr>
<th> <code data-x="">writingsuggestions</code>
<td> <span data-x="attr-writingsuggestions">HTML elements</span>
<td> Whether the element can offer writing suggestions or not.
<td> "<code data-x="attr-writingsuggestions-on">on</code>"; "<code data-x="attr-writingsuggestions-off">off</code>"
</table>

<p class="tablenote"><small>An asterisk (*) in a cell indicates that the actual rules are more
Expand Down Expand Up @@ -141751,6 +141909,7 @@ INSERT INTERFACES HERE
Samy Kamkar,
Sander van Lambalgen,
Sanjoy Pal,
Sanket Joshi,
Sarah Gebauer,
Sarven Capadisli,
Satrujit Behera,
Expand Down