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

Address VK spec review comments. #317

Merged
merged 7 commits into from
Jul 29, 2021
Merged

Conversation

snianu
Copy link
Contributor

@snianu snianu commented Jul 23, 2021

#314

Closes #????

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:

@snianu
Copy link
Contributor Author

snianu commented Jul 23, 2021

There are some ReSpec errors related to Reflect, ReflectOnly & DOMRect. Not sure why is it not able to find DOMRect from [geometry]? Maybe @johanneswilm knows?

@snianu snianu changed the title Address spec review comments. Address VK spec review comments. Jul 23, 2021
@saschanaz
Copy link
Member

There are some ReSpec errors related to Reflect, ReflectOnly & DOMRect. Not sure why is it not able to find DOMRect from [geometry]? Maybe @johanneswilm knows?

Line 43 should be "geometry-1" instead, since that's what specref recognizes. @sidvishnoi, do you know why that difference happens, since https://respec.org/xref shows "geometry" instead?

@saschanaz
Copy link
Member

(While you are at it, could you please remove line 46 and replace line 6 to refer to respec-w3c instead?)

@snianu
Copy link
Contributor Author

snianu commented Jul 23, 2021

@saschanaz That fixed the DOMRect errors, thank you so much! I'm still getting errors for Reflect & ReflectOnly, do you know how to resolve those?

@saschanaz
Copy link
Member

Reflect/ReflectOnly have never been defined in any spec, see whatwg/html#3238. I recommend to follow what WICG/attribution-reporting-api#67 says until it resolves.

Instead, imitate https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element:reflect by saying things like "The IDL attribute conversiondestination, impressiondata, ... must reflect the respective content attributes of the same name."

@@ -167,15 +166,24 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
</dt>
<dd>
<p>
When this attribute is set to `true`, a user agent MUST NOT resize its layout viewport or visual viewport.
A boolean, initially false. When this attribute is set to `true`, a user agent MUST NOT resize its layout viewport or 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.

false => false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@sidvishnoi
Copy link
Member

sidvishnoi commented Jul 24, 2021

@sidvishnoi, do you know why that difference happens, since https://respec.org/xref shows "geometry" instead?

@saschanaz https://respec.org/xref (xref UI) makes use of data from webref, while respec uses specref. Filed speced/respec-web-services#224, though it's probably something that specref needs to update.

Copy link

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

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

A few comments

@@ -119,7 +118,7 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
The method must follow these steps:
</p>
<ol>
<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>If the <a href="https://heycam.github.io/webidl/#this">this's </a><a href="https://html.spec.whatwg.org/#concept-relevant-global">relevant global object</a> is a <a href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window object</a> and does not 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.

The links could use cross-references

Choose a reason for hiding this comment

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

"the" is not needed before this. The "'s" following this would be better outside the link.

Choose a reason for hiding this comment

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

Could this be called from a worker? If not, it's better to put this's relevant global in a variable, assert that it's a Window, and then abort if there's no user activation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -131,7 +130,7 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
Call the system API to show the VK.
</li>
<li>
When the VK is shown by the system, fire {{VirtualKeyboard/ongeometrychange()}} event.
When the VK is shown by the system, the OS reports the bounding rectangle of the keyboard. Calculate the {{VirtualKeyboard/boundingRect}} which is the intersection of the keyboard rectangle reported by the OS and the layout viewport. Fire {{VirtualKeyboard/ongeometrychange()}} event to JS.

Choose a reason for hiding this comment

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

It'd be good to define what a "bounding rectangle" is. https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect outlines an algorithm that calculates one. It'd be good to have a similar processing model here.

Choose a reason for hiding this comment

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

"Calculate..." should call an algorithm that actually does this calculation.

Choose a reason for hiding this comment

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

This step should run in parallel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -143,7 +142,7 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
The method must follow these steps:
</p>
<ol>
<li>If the browsing context is not focused, abort these steps.
<li>If the <a href="https://heycam.github.io/webidl/#this">this's </a><a href="https://html.spec.whatwg.org/#concept-relevant-global">relevant global object</a> is a <a href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window object</a> and does not 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.

Same comments as above. May be useful to pack this in a helper algorithm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just couple of algorithm steps so didn't create a helper

A boolean, initially false. When this attribute is set to `true`, a user agent MUST NOT resize its layout viewport or visual viewport.
</p>
<p>
The {{VirtualKeyboard/overlaysContent}} getter steps are to return <a href="https://heycam.github.io/webidl/#this">this's </a>{{VirtualKeyboard/overlaysContent}}.

Choose a reason for hiding this comment

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

It'd be better to set and get a separate internal boolean variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you give me an example? I'm following https://xhr.spec.whatwg.org/#dom-xmlhttprequest-timeout

Choose a reason for hiding this comment

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

On a second look, this is fine as is. It'd have been slightly better to define the getter as a separate concept, but that's not critical.

@snianu
Copy link
Contributor Author

snianu commented Jul 27, 2021

@yoavweiss Addressed all comments. PTAL.

Copy link

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

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

A few more comments

Let `lv` be the layout viewport's bounds in CSS pixels.
</li>
<li>
Set [=this=]'s {{VirtualKeyboard/boundingRect}} to be the intersection of `lv` and `osk` in CSS pixels.

Choose a reason for hiding this comment

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

This algorithm feels like a getter, rather than a setter. If so, it should return a DOMRect but it doesn't create one. I'd expect it to do so while initializing it to the right values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a DOMRect object to store the intersection of the rectangles.

</dt>
<dd>
<p>
The attribute reports the intersection of the VK with the layout viewport in client coordinates.
The attribute reports the intersection of the VK with the layout viewport in client coordinates. It is set when {{VirtualKeyboard/ongeometrychange}} event is fired.
Setter steps are as follows:

Choose a reason for hiding this comment

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

There's no setter for a readonly attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, you are right. I'll remove it

</li>
</li>
<li>
When the VK is hidden by the system, the OS reports the bounding rectangle of the keyboard (which has all 0 values). Calculate the {{VirtualKeyboard/boundingRect}} which is the intersection of the keyboard rectangle reported by the OS and the layout viewport. Fire {{VirtualKeyboard/ongeometrychange()}} event to JS.

Choose a reason for hiding this comment

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

"Calculate ...." should call an algorithm, or simply assign a 0 sized DOMRect (since that's the intersection IIUC)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -131,7 +130,7 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
Call the system API to show the VK.
</li>
<li>
When the VK is shown by the system, fire {{VirtualKeyboard/ongeometrychange()}} event.
When the VK is shown by the system, the OS reports the bounding rectangle of the keyboard. Calculate the {{VirtualKeyboard/boundingRect}} which is the intersection of the keyboard rectangle reported by the OS and the layout viewport. Fire {{VirtualKeyboard/ongeometrychange()}} event to JS.

Choose a reason for hiding this comment

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

"Calculate..." should call an algorithm that actually does this calculation.

@@ -131,7 +130,7 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
Call the system API to show the VK.
</li>
<li>
When the VK is shown by the system, fire {{VirtualKeyboard/ongeometrychange()}} event.
When the VK is shown by the system, the OS reports the bounding rectangle of the keyboard. Calculate the {{VirtualKeyboard/boundingRect}} which is the intersection of the keyboard rectangle reported by the OS and the layout viewport. Fire {{VirtualKeyboard/ongeometrychange()}} event to JS.

Choose a reason for hiding this comment

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

This step should run in parallel

@@ -116,7 +126,11 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
The method must follow these steps:
</p>
<ol>
<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>
Let `window` be [=this=]'s <a href="https://html.spec.whatwg.org/#concept-relevant-global">relevant global object</a>. If window is not a <a href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window object</a>, then abort these steps.

Choose a reason for hiding this comment

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

the window variable should be referred to as "|window|".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@snianu
Copy link
Contributor Author

snianu commented Jul 28, 2021

@yoavweiss Addressed all comments. PTAL.

Copy link

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

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

Getting closer... A few more comments

</p>
<dfn>overlaysContent</dfn>
<p>
A boolean, initially `false`. When this attribute is set to `true`, a user agent MUST NOT resize its layout viewport or <a href="https://wicg.github.io/visual-viewport/#dom-visualviewport">visual viewport</a>.

Choose a reason for hiding this comment

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

IntersectionObserver uses the "document's viewport", pointing to https://drafts.csswg.org/css2/#viewport
That seems more precise than "layout viewport".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -116,7 +126,11 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
The method must follow these steps:
</p>
<ol>
<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>
Let |window| be [=this=]'s <a href="https://html.spec.whatwg.org/#concept-relevant-global">relevant global object</a>. If |window| is not a <a href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window object</a>, then abort these steps.

Choose a reason for hiding this comment

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

I think you can replace the abort with an assertion that |window| is a [=Window=] (because this is only exposed on Window)

Nit: You can replace the explicit links (here and elsewhere) with spec references. e.g. "Let |window| be [=this=]'s [=relevant global object=]. Assert that |window| is a {{Window}} object."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

The attribute reports the intersection of the VK with the layout viewport in client coordinates. It is set when {{VirtualKeyboard/ongeometrychange}} event is fired. To create a {{VirtualKeyboard/boundingRect}} follow these steps:
<ol>
<li>
Let `osk` be the on-screen keyboard rectangle in CSS pixels that is provided by the OS when the VK visibility changes.

Choose a reason for hiding this comment

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

All references to variables (osk, lv, bounds, etc) should be of the form "|var|" rather than "var". That enables various features such as variable highlighting, and makes it clearer that they are in fact vaariables

Choose a reason for hiding this comment

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

Also, |osk| and |lv| should be input parameters, and the caller should provide them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

</dt>
<dd>
<p>
The attribute reports the intersection of the VK with the layout viewport in client coordinates.
The attribute reports the intersection of the VK with the layout viewport in client coordinates. It is set when {{VirtualKeyboard/ongeometrychange}} event is fired. To create a {{VirtualKeyboard/boundingRect}} follow these steps:

Choose a reason for hiding this comment

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

No need to mention when it is set here. It'd be sufficient to define an algorithm here (e.g. "set a virtual keyboard bounding rect"), and then call it before the event is fired.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -128,7 +142,7 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
Call the system API to show the VK.
</li>
<li>
When the VK is shown by the system, fire {{VirtualKeyboard/ongeometrychange()}} event.
When the VK is shown by the system, <a href="https://html.spec.whatwg.org/#in-parallel">in parallel</a> the OS reports the bounding rectangle of the keyboard. Update the {{VirtualKeyboard/boundingRect}} which is the intersection of the keyboard rectangle reported by the OS and the layout viewport. Fire {{VirtualKeyboard/ongeometrychange()}} event to JS.

Choose a reason for hiding this comment

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

You can move the "in parallel" bit up, into something like:
"""

  • [=In parallel=], follow these steps: * Wait for the virtual keyboard to be shown by the system. * Call "set the virtual keyboard bounding rect" with the keyboard's OS reported bounding rectangle and the [=document=]'s [=viewport=]. * [=Fire an event=] named "geometrychange" at [=this=].
  • Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Done. Couldn't use [=viewport=] because for some reason css xref's are not working?

    Choose a reason for hiding this comment

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

    @marcoscaceres - can you help on the [=viewport=] front?

    @@ -140,17 +154,21 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
    The method must follow these steps:
    </p>
    <ol>
    <li>If the browsing context is not focused, abort these steps.
    <li>
    Let |window| be [=this=]'s <a href="https://html.spec.whatwg.org/#concept-relevant-global">relevant global object</a>. If |window| is not a <a href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window object</a>, then abort these steps.

    Choose a reason for hiding this comment

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

    Same comment as above on abort and links

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Done.

    Let |window| be [=this=]'s <a href="https://html.spec.whatwg.org/#concept-relevant-global">relevant global object</a>. If |window| is not a <a href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window object</a>, then abort these steps.
    </li>
    <li>
    If |window| does not 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.

    Same nit on replacing links with references

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Done.

    </li>
    </li>
    <li>
    When the VK is hidden by the system, <a href="https://html.spec.whatwg.org/#in-parallel">in parallel</a> the OS reports the bounding rectangle of the keyboard (which has all 0 values). Create a {{DOMRect}} with 0 values and return it when {{VirtualKeyboard/boundingRect}} is queried. Fire {{VirtualKeyboard/ongeometrychange()}} event to JS.

    Choose a reason for hiding this comment

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

    Same comment as above on revamping to multiple steps

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Done.

    Let `bounds` be a {{DOMRect}} object.
    </li>
    <li>
    Set `bounds` to be the intersection of `lv` and `osk` in CSS pixels.

    Choose a reason for hiding this comment

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

    It'd be better to do something like https://www.w3.org/TR/intersection-observer/#calculate-intersection-rect-algo here. You can't really reuse it as is, because |osk| is not a DOM element...

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Done.

    @snianu
    Copy link
    Contributor Author

    snianu commented Jul 29, 2021

    @yoavweiss Addressed all comments. PTAL.

    Copy link

    @yoavweiss yoavweiss left a comment

    Choose a reason for hiding this comment

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

    LGTM

    I still have a few nits around turning links to refs, and one question on the IDL change, but overall this looks great. Thanks for bearing with me! :)

    The attribute reports the intersection of the VK with the layout viewport in client coordinates.
    The attribute reports the intersection of the VK with the [=document=]'s <a href="https://drafts.csswg.org/css2/#viewport">viewport</a> in client coordinates. Call {{VirtualKeyboard/set the virtual keyboard bounding rect}}.
    <p>
    <p><dfn>set the virtual keyboard bounding rect</dfn></p>

    Choose a reason for hiding this comment

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

    "To set the virtual keyboard bounding rect, with |osk| (a DOMRect representing the on-screen keyboard rectangle), and |lv| (a DOMRect representing the document's viewport rectangle) as inputs, run the following steps:"

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    Done.

    @@ -189,17 +250,17 @@ <h2>The <dfn>VirtualKeyboard</dfn> Interface</h2>
    <h2>Extensions to the <dfn>ElementContentEditable</dfn> mixin</h2>
    <pre class="idl">
    partial interface ElementContentEditable {
    [CEReactions, Reflect, ReflectOnly=("auto","manual")] attribute DOMString virtualKeyboardPolicy;
    [CEReactions] attribute DOMString virtualKeyboardPolicy;

    Choose a reason for hiding this comment

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

    Why remove the IDL reflection rules?

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    I was getting ReSpec errors so the recommendation (per this comment) is to just mention it in the definition of the attribute and link it to the IDL. In my case I mentioned it in the virtualKeyboardPolicy definition:

    The virtualKeyboardPolicy is an enumerated attribute whose keywords are the string, auto, and manual. The IDL attribute must reflect the respective content attributes of the same name.

    @snianu
    Copy link
    Contributor Author

    snianu commented Jul 29, 2021

    Thank you @yoavweiss for reviewing it!

    @snianu snianu merged commit 489acb4 into w3c:gh-pages Jul 29, 2021
    @snianu snianu deleted the vk-spec-update branch July 29, 2021 07:09
    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