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

VirtualKeyboardAPI spec draft #309

Merged
merged 20 commits into from
Jul 6, 2021
Merged

VirtualKeyboardAPI spec draft #309

merged 20 commits into from
Jul 6, 2021

Conversation

gked
Copy link

@gked gked commented Jun 22, 2021

This is the first draft of the spec to iterate on.
No tests, so far, just the wording around the behavior of the API.
There are a few respec errors that we'll be looking at as well.

The following tasks have been completed:

  • Confirmed there are no ReSpec/BikeShed errors or warnings.
  • Modified Web platform tests (link to pull request)

Implementation commitment:

<li>If the <a>document</a> doesn't have <a href="https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation">sticky user activation</a>, abort these steps.

</li>
<li>Trigger {{VirtualKeyboard/show()}} call that invokes a system API to show the VK.

Choose a reason for hiding this comment

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

That seems kinda circular. It'd be good to define what the call actually does.

Choose a reason for hiding this comment

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

For example, I'm guessing it's impacting boundingRect in some way.

Choose a reason for hiding this comment

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

Similarly, it probably fires the geometrychange event at some point.

Choose a reason for hiding this comment

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

It might be best to define the processing of what happens when the virtual keyboard is displayed and folded and then hook into that processing from these explicit methods, but also from places where the UA can decide to do that automatically (e.g. from editable content when it's getting focus)

Copy link
Author

Choose a reason for hiding this comment

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

updated

The method must follow these steps:
</p>
<ol>
<li>If the <a>document</a> doesn't have <a href="https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation">sticky user activation</a>, abort these steps.

Choose a reason for hiding this comment

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

If I'm reading the sticky activation algorithm correctly, it applies to a Window object, not a Document.

Choose a reason for hiding this comment

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

It would be good to clarify which Document (or Window) we're talking about

Copy link
Author

Choose a reason for hiding this comment

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

updated

<ol>
<li>If the <a>document</a> doesn't have <a href="https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation">sticky user activation</a>, abort these steps.
</li>
<li>Trigger {{VirtualKeyboard/hide()}}call that invokes a system API to hide the keyboard.

Choose a reason for hiding this comment

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

Same comments as above

Copy link
Author

Choose a reason for hiding this comment

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

updated

Platform heuristics may impose additional restrictions on VK {{VirtualKeyboard/show()}} and {{VirtualKeyboard/hide()}}.
</p>
<p class="note">
A few people have expressed concerns around {{VirtualKeyboard/show()}} and {{VirtualKeyboard/hide()}} methods not being promise-based. However, we couldn't find any real use cases around needing promises in this type of operation.

Choose a reason for hiding this comment

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

Examples below are showing them returning a Promise. Would be good to clarify which variant is implemented.

Copy link
Author

Choose a reason for hiding this comment

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

updated

</dt>
<dd>
<p>
The attribute enables the author to opt-out of resizing the visual viewport.

Choose a reason for hiding this comment

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

Would be good to define a setter that impacts the processing and does the actual opt-out.

Copy link
Author

Choose a reason for hiding this comment

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

updated

</dt>
<dd>
<p>
The attribute reports the intersection of the VK with the layout viewport in client coordinates.

Choose a reason for hiding this comment

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

You should define a getter that defines what's returned here

Copy link
Author

Choose a reason for hiding this comment

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

updated

</pre>
<p>The <dfn><code>virtualKeyboardPolicy</code></dfn> is an <a href=https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute>enumerated attribute</a> whose keywords are the empty string, auto, and manual.
<p>When specified on an element that is a contenteditable host, <dfn><code>auto</code></dfn> causes the corresponding editable element to automatically show the VK when it is focused or tapped & <dfn><code>manual</code></dfn>
decouples focus and tap on the editable element from changes in the VK’s current state - the VK remains as it was.

Choose a reason for hiding this comment

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

Similarly to the above, you probably want to define the processing for this attribute: what happens when it's set, changed, removed, etc.

Copy link
Author

Choose a reason for hiding this comment

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

updated

<th>Value
<tr>
<td><dfn>keyboard-inset-top</dfn>
<td><a href="https://drafts.csswg.org/css-values-3/#length-valuehttps://drafts.csswg.org/css-values-3/#length-value"> length</a>

Choose a reason for hiding this comment

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

You probably want to define the semantics of each of these variables and what its value is set to.

Copy link
Author

Choose a reason for hiding this comment

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

updated

@gked
Copy link
Author

gked commented Jun 28, 2021

@yoavweiss We addressed your feedback. Could you please let us know if they resolve your questions? One thing, I am trying to resolve currently is making adding the ability to make a PR readable with .pr-preview.json file.

<body>
<section id='abstract'>
<p>
The {{VirtualKeyboard}} API provides web developers a more granular control of on-screen keyboard (virtual keyboard or VK). The API also provides information about VK geometry, such as rect occlusion and gives ability to opt-out from resizing of the visual viewport in the browser.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: grammar issue with "a more granular control"

Suggested new abstract: The {{VirtualKeyboard}} API provides authors with greater control over the visibility of the virtual keyboard (VK), and greater ability to adapt the layout of web pages when VK visibility changes.

Copy link
Author

Choose a reason for hiding this comment

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

updated

<h2>Introduction</h2>
<P>This section is non-normative.</P>
<p>
The Virtual Keyboard (VK) is the on-screen keyboard used for input in scenarios where a hardware keyboard may not be available. Unlike hardware keyboard, VK can adapt its shape to optimize for the expected type of input.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest cutting this sentence as it doesn't seem relevant to the API: Unlike hardware keyboard, VK can adapt its shape to optimize for the expected type of input.

I think it was useful in the explainer since we were pointing out a gap that inputMode was overloaded to control both shape and visibility and couldn't do both at once, but in the spec I don't see that it's necessary.

Copy link
Author

Choose a reason for hiding this comment

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

agreed - updated.

<P>This section is non-normative.</P>
<p>
The Virtual Keyboard (VK) is the on-screen keyboard used for input in scenarios where a hardware keyboard may not be available. Unlike hardware keyboard, VK can adapt its shape to optimize for the expected type of input.
In addition, user agents respond to the presence of the VK, without any exposure of this information to web developers. This document proposes a new web API surface for VK that developers can use to enable better customization of their webpage's content and experiences.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be useful in this paragraph to expand on how user agents currently respond to the presence of the VK and what alternatives this API offers. As is I don't think it adds anything compared to the abstract.

Maybe: User agents respond to the presence of the VK by:

  1. Repositioning the user agent above the VK
  2. Reducing the size of the layout viewport so the VK doesn't occlude it
  3. Reducing the size of the visual viewport and padding the layout viewport to ensure it can be shifted above the VK

This API provides a fourth option that allows the user agent to leave its layout and visual viewports unchanged and instead provide information about the intersection of the VK and layout viewport so that the author can adapt the layout of their web pages using JavaScript or CSS environment variables.

It would be good to have graphics illustrating the difference between these behaviors.

Copy link
Author

Choose a reason for hiding this comment

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

updated


[Exposed=Window]
interface VirtualKeyboard : EventTarget {
undefined show();
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

we were getting respec errors when we used void. Web IDL recommends using undefined instead of void https://heycam.github.io/webidl/#idl-undefined

<li>If the browsing context's <a href="https://html.spec.whatwg.org/multipage/browsers.html#active-window">active window</a> does not have <a href="https://html.spec.whatwg.org/multipage/interaction.html#sticky-activation">sticky user activation</a>, abort these steps.
</li>
<li>
If the focused element's <a href="https://html.spec.whatwg.org/multipage/interaction.html#attr-contenteditable">contenteditable</a> value is false, then abort these steps.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is meant to be limited to contenteditable. It should say something like: If the focused (is focused the right word) element is not editable...

We want to include textareas, text-like inputs, and any inputs into which the user can type (in the near future EditContext associated elements too).

Copy link
Author

Choose a reason for hiding this comment

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

updated.

</dd>
<p class="note">
Platform heuristics may impose additional restrictions on VK {{VirtualKeyboard/show()}} and {{VirtualKeyboard/hide()}}. e.g., On Windows the pointer type has to be
touch or pen.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: other paragraphs don't have hard line breaks dividing their content... remove this one?

Copy link
Author

@gked gked Jul 1, 2021

Choose a reason for hiding this comment

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

updated

touch or pen.
</p>
<p class="note">
A few people have expressed concerns around {{VirtualKeyboard/show()}} and {{VirtualKeyboard/hide()}} methods not being promise-based. However, we could not find any real use cases around needing promises in this type of operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you link to an issue?

Copy link
Author

Choose a reason for hiding this comment

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

updated

</dt>
<dd>
<p>
To set the attribute to opt-out of resizing the visual viewport,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you say something slightly stronger here: a user agent MUST NOT resize its layout viewport or visual viewport when overlaysContent is true?

Also, I think only top-level browsing contexts are allowed to set this, right? This would probably be the place to mention requirements like that. I think there are other requirements too (secure origin maybe)?

Copy link
Author

Choose a reason for hiding this comment

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

Updated the spec to reflect on your first comment.

Is defining SecureContext in web idl enough so we don't have to mention it here?

</section>
</section>
<section>
<h2>Privacy and Security Considerations</h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

Several pieces of information in this section seem like a set of claims that this API doesn't come with significant risk to privacy or security. I don't think we need to cover that. I expected this section to enumerate important implementation details that UAs may or must follow to ensure a secure and privacy preserving implementation. Additionally, I think it would be appropriate to enumerate the responsibilities of authors, if any, to ensure they don't create privacy or security issues when using the API.

Maybe IndexedDB is a good example.

Copy link
Author

Choose a reason for hiding this comment

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

Updated. Is this what you had in mind?

</section>
</section>
<section>
<h2>Examples</h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there were good images in the explainer to go with these examples. Can you include them to help illustrate the impact of the code?

Copy link
Author

Choose a reason for hiding this comment

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

added

.pr-preview.json Outdated
@@ -1,4 +1,4 @@
{
"src_file": "index.html",
"src_file": "\\docs\\virtualkeyboard\\index.html",
Copy link
Contributor

Choose a reason for hiding this comment

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

are those Windows-slashes?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! fixed. This is probably why the preview functionality didn't work :)

Copy link
Contributor

@BoCupp-Microsoft BoCupp-Microsoft left a comment

Choose a reason for hiding this comment

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

This looks good enough to me to merge and subsequent issues we can deal with in smaller easier to review PRs.

@gked gked merged commit 73389dc into w3c:gh-pages Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants