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 38 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 156 additions & 1 deletion 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 DOMString <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,149 @@ 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>

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

domenic marked this conversation as resolved.
Show resolved Hide resolved
<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>
sanketj marked this conversation as resolved.
Show resolved Hide resolved

<table>
<thead>
<tr>
sanketj marked this conversation as resolved.
Show resolved Hide resolved
<th>Keyword
<th>State
<th>Brief description
<tbody>
<tr>
<td><dfn attr-value for="html-global/writingsuggestions"><code
sanketj marked this conversation as resolved.
Show resolved Hide resolved
data-x="attr-writingsuggestions-true">true</code></dfn>
<td rowspan="2"><dfn data-x="attr-writingsuggestions-true-state">true</dfn>
<td rowspan="2">Writing suggestions should be offered on this element.
</tr>
<tr>
sanketj marked this conversation as resolved.
Show resolved Hide resolved
<td>(The empty string)
<tr>
<td><dfn attr-value for="html-global/writingsuggestions"><code
data-x="attr-writingsuggestions-false">false</code></dfn>
<td><dfn data-x="attr-writingsuggestions-false-state">false</dfn>
<td>Writing suggestions should not be offered on this element.
</tr>
</table>

<p>The attribute's <i data-x="missing value default">missing value default</i> is the <dfn
data-x="attr-writingsuggestions-default-state">default</dfn> state. The default state indicates
that the element is to act according to a default behavior, possibly based on the parent
element's own <code data-x="attr-writingsuggestions">writingsuggestions</code> state, as defined
below.</p>

<p>The attribute's <i data-x="invalid value default">invalid value default</i> is the <span
data-x="attr-writingsuggestions-true-state">true</span> state.</p>

<dl class="domintro">
<dt><code data-x=""><var>element</var>.<span subdfn data-x="dom-writingSuggestions">writingSuggestions</span> [ = <var>value</var> ]</code></dt>

<dd>
domenic marked this conversation as resolved.
Show resolved Hide resolved
<p>Returns "<code data-x="">true</code>" if the user agent is to offer writing suggestions under
the scope of the element; otherwise, returns "<code data-x="">false</code>".</p>

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

<div w-nodev>
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
<p>The <dfn>computed writing suggestions value</dfn> of a given <var>element</var> is
determined by running the following steps:</p>
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.


<ol>
<li><p>If <var>element</var>'s <code data-x="attr-writingsuggestions">writingsuggestions</code>
domenic marked this conversation as resolved.
Show resolved Hide resolved
content attribute is in the <span data-x="attr-writingsuggestions-false-state">false</span>
state, return "<code data-x="">false</code>".</p></li>
domenic marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved

<li><p>If <var>element</var>'s <code
data-x="attr-writingsuggestions">writingsuggestions</code> content attribute is in the <span
data-x="attr-writingsuggestions-default-state">default</span> state, <var>element</var> has a
parent element, and the <span>computed writing suggestions value</span> of
<var>element</var>'s parent element is "<code data-x="">false</code>", then return
domenic marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
"<code data-x="">false</code>".</p></li>

<li><p>Return "<code data-x="">true</code>".</p></li>
</ol>

<p>The <dfn attribute for="HTMLElement"><code
data-x="dom-writingSuggestions">writingSuggestions</code></dfn> getter steps are:</p>

<ol>
<li><p>Return <span>this</span>'s <span>computed writing suggestions value</span>.</p></li>
sanketj marked this conversation as resolved.
Show resolved Hide resolved
</ol>

<p class="note">The <code data-x="dom-writingSuggestions">writingSuggestions</code> IDL
domenic marked this conversation as resolved.
Show resolved Hide resolved
attribute 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>

domenic marked this conversation as resolved.
Show resolved Hide resolved
<p>The <code data-x="dom-writingSuggestions">writingSuggestions</code> setter steps are:</p>

<ol>
<li><p>Set <span>this</span>'s <code data-x="attr-writingsuggestions">writingsuggestions</code>
content attribute to the given value.</p></li>
</ol>
</div>
sanketj marked this conversation as resolved.
Show resolved Hide resolved

<hr>

<p>User agents must only offer suggestions within an element's scope if the
result of running the following algorithm given <var>element</var> returns true:</p>

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

<li><p>If the user has disabled writing suggestions, then return false.</p></li>

<!-- element type -->
domenic marked this conversation as resolved.
Show resolved Hide resolved
<li>
<p>If none of the following conditions are true:</p>

<ul>
<li><p><var>element</var> is an <code>input</code> element whose <code
data-x="attr-input-type">type</code> attribute is in either the <span
domenic marked this conversation as resolved.
Show resolved Hide resolved
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>,
domenic marked this conversation as resolved.
Show resolved Hide resolved
or <span data-x="attr-input-type-email">Email</span> state and is <i
sanketj marked this conversation as resolved.
Show resolved Hide resolved
data-x="concept-fe-mutable">mutable</i>;</p></li>

domenic marked this conversation as resolved.
Show resolved Hide resolved
<li><p><var>element</var> is a <code>textarea</code> element that is <i
sanketj marked this conversation as resolved.
Show resolved Hide resolved
data-x="concept-fe-mutable">mutable</i>; or</p></li>

sanketj marked this conversation as resolved.
Show resolved Hide resolved
domenic marked this conversation as resolved.
Show resolved Hide resolved
<li><p><var>element</var> is an <span data-x="editing host">editing host</span> or is
<span>editable</span></p></li>
</ul>
domenic marked this conversation as resolved.
Show resolved Hide resolved

<p>then return false.</p>
</li>

<!--
content attribute: false on this element, or inherit if there is an ancestor to inherit from
-->

sanketj marked this conversation as resolved.
Show resolved Hide resolved
<li><p>If <var>element</var> has an <span>inclusive ancestor</span> with a <code
data-x="attr-writingsuggestions">writingsuggestions</code> content attribute that's not in the
<span data-x="attr-writingsuggestions-default-state">default</span> and the nearest such
ancestor's <code data-x="attr-writingsuggestions">writingsuggestions</code> content attribute is
in the <span data-x="attr-writingsuggestions-false-state">false</span> state, then return
false.</p></li>
sanketj marked this conversation as resolved.
Show resolved Hide resolved

<li><p>Otherwise, return true.</p></li>
</ol>

<p class="note">This specification does not define the user interface for writing suggestions.
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>
sanketj marked this conversation as resolved.
Show resolved Hide resolved

<h4>Autocapitalization</h4>

sanketj marked this conversation as resolved.
Show resolved Hide resolved
<p>Some methods of entering text, for example virtual keyboards on mobile devices, and also voice
Expand Down Expand Up @@ -138534,7 +138679,9 @@ interface <dfn interface>External</dfn> {
<th> <code data-x="">spellcheck</code>
<td> <span data-x="attr-spellcheck">HTML elements</span>
<td> Whether the element is to have its spelling and grammar checked
<td> "<code data-x="">true</code>"; "<code data-x="">false</code>"
<td> "<code data-x="attr-spellcheck-true">true</code>";
"<code data-x="attr-spellcheck-false">false</code>";
the empty string
<tr>
<th> <code data-x="">src</code>
<td> <code data-x="attr-media-src">audio</code>;
Expand Down Expand Up @@ -138722,6 +138869,13 @@ 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-true">true</code>";
"<code data-x="attr-writingsuggestions-false">false</code>";
the empty string
</table>

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