-
Notifications
You must be signed in to change notification settings - Fork 16
Update for Shadow DOM #4
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
Conversation
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#in-a-document">in</a> | ||
<p>Pointer lock must succeed only if the <a>target</a>'s | ||
<a href="https://dom.spec.whatwg.org/#concept-shadow-including-root">shadow-including root</a> is | ||
<a href="https://dom.spec.whatwg.org/#in-a-shadow-including-document">in</a> |
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.
I think it's not "in", it's just "is"
I'll review again after previous comments addressed, but looking good to me so far. |
9203577
to
860154b
Compare
Updated the patch. |
@hayatoito FYI |
@@ -275,12 +275,12 @@ | |||
for a subsequent requestPointerLock. | |||
</p> | |||
|
|||
<p>If any element (including this one) in the same document | |||
<p>If any element (including this one) in the same shadow-including document |
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.
"in a shadow-including document" is defined in DOM Standard, but strictly speaking, "in the same shadow-including document" is not defined, I think.
How about "If any element (including this one) who shares the same shadow-including root of the target"?
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.
Assuming the "in the same shadow-including document" PR#273 will be accepted, can I leave this part as is?
The definition is intended to be used in w3c/pointerlock#4.
860154b
to
e750369
Compare
is already locked (or pending lock) the pointer | ||
lock <a>target</a> must be updated to this element and a | ||
<a>pointerlockchange</a> event sent.</p> | ||
|
||
<p>If any element in another document is already locked the request | ||
<p>If any element in another shadow-including document is already locked the request |
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.
This has a similar problem to the above one @hayatoito noted. Although it is probably not a big deal since I think any reader can figure out what it means. But IMO it would be clearer to talk about roots explicitly:
"If any element whose shadow-including root is a different document is already locked, the request must fail..."
e750369
to
4dad448
Compare
Updated the patch draft. |
4dad448
to
3d07201
Compare
Updated the description for Still waiting whatwg/dom#238 to resolve, but I appreciate if you could review the |
<a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant">shadow-including descendant</a> of the | ||
<a href="http://dom.spec.whatwg.org/#context-object">context object</a>, | ||
return the result of the following algorithm: | ||
<dl> |
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.
You can reference shadow DOM for this, sorry for confusing you!
If you did want to inline the algorithm, I think it's better to fit with the conventions of this spec, instead of shadow DOM's idiosyncratic CAPITAL LETTER VARIABLES and input/output <dl>
.
But just referencing shadow DOM's algorith, like you did before, is fine. I just thought it's something that should move to DOM eventually, so I commented on that.
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.
@hayatoito pointed out in the code review (for Blink) that strictly speaking "retargeting" is originally designed for event retargeting and differs from what activeElement
does in that the result should be in the same tree as the context object:
activeElement must be the result of the retargeting algorithm ..., if the result and the context object are in the same tree.
So eventually we have to put an algorithm for activeElement
, pointerLockElement
, and fullscreenElement
which slightly differs from retargeting somewhere (in dom spec).
Fixed CAPITAL LETTER VARIABLES, input/output to make it look more natural in this spec.
e23cf49
to
aff3835
Compare
Updated the patch. |
LGTM! |
Thank you, LGTM but I will wait for @hayatoito to comment before merging. |
<li>If <var>target</var> is in the same tree as the | ||
<a href="http://dom.spec.whatwg.org/#context-object">context object</a>, | ||
let <var>adjusted-target</var> be <var>target</var></li> | ||
<li>Otherwise: let <var>adjusted-target</var> be the shadow host which is a |
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.
Hmm. This definition is not equivalent to the definition which the current activeElement
is using.
In your definition, there are multiple candidates of shadow hosts which meet the condition. You can not use "the" shadow host here. :(
Could you try to update the condition? I am happy to help you if you need it. :)
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.
I thought that
- there should be one shadow host that matches the conditions, so "THE shadow host"
- which meets both of the following conditions (AND condition):
- "A shadow-including ancestor" of target (because there can be multiple ancestor shadow hosts), and
- is "in THE same tree" as the context object (this should filter only one in the same tree)
therefore I can use "THE shadow host" here.
I'll ask some native speaker around.
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.
(talked offline) I understand the condition that can break my assumption :)
I'll update the sentence.
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.
Updated to return the nearest one in the ancestry. PTAL.
<li>If <var>target</var> is in the same tree as the | ||
<a href="http://dom.spec.whatwg.org/#context-object">context object</a>, | ||
let <var>adjusted-target</var> be <var>target</var></li> | ||
<li>Otherwise: let <var>adjusted-target</var> be the shadow host of <var>target</var> and repeat the following substeps: |
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.
Unfortunately, you can not use "shadow host of A" if A is not DocumentFragment. :(
DOM Standard defines "A's host" only if A is a DocumentFragment, I think.
Instead, you might want to use "A's root’s host" (if A's root is a shadow root, of course).
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.
Updated to use "A's root's host" instead of "A's shadow host".
The precondition requires "the target is in the shadow-including descendant of the context object", i.e. if the context's root is not the same as the target's, the target's root must be a shadow root.
@haytoito PTAL |
<dd> | ||
<dfn title="pointerLockElement"></dfn> | ||
|
||
<p>If the element, which is set as the target for mouse events while the pointer is |
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.
I recommend you to use a retargeting algorithm as is so that we do not have a lot of specilized retargeting algorithms.
I am afraid that we will have a maintanace burden.
I think your definition works here because it is for DocumentOrShadowRoot, and it is for Pointer locked element.
If one of these assumption breaks, your definition will not work.
I have to review your definition carefully here...
e.g. The case where the target's root is neither Document nor ShadowRoot. Have you considered this case??
I prefer having one algorithm, and we should refer it from everywhere if we can apply it, instead of customizing it in many places.
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.
Got the point.
Updated to use retargeting algorithm.
PTAL.
ea50ed7
to
3ea549a
Compare
@hayatoito Ping? |
LGTM. |
@hayatoito Thanks for the review! @scheib would you mind merging this? I'll update the reference to the "retargeting algorithm" (from shadow dom spec to DOM spec) |
<a href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant">shadow-including descendant</a> of the | ||
<a href="http://dom.spec.whatwg.org/#context-object">context object</a>, | ||
returns the result of the | ||
<a href="https://https://w3c.github.io/webcomponents/spec/shadow/#dfn-retargeting-algorithm">retargeting algorithm</a> |
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.
double https
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.
Fixed, and other instances of using "http:" instead of "https" also fixed.
ca1c754
to
6b20580
Compare
@hayatoito I updated the algorithm, dropping the condition to check if the target is shadow-including descendant of the context object or not. Without the condition check, the case should be covered by the same tree check of retargeting result and context object. Alternatively, if we keep the shadow-including descendant check, we can drop the same tree check. What do you think? |
I've always used git push -f to update the change here, but just in case you want to see |
</div> | ||
</body> | ||
</pre> | ||
<p>Note: the example uses fictional <code>shadow-root</code> element to denote a |
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.
In this section I think that all ids can be used raw, without needing the element type prefixes. E.g.
canvas#canvas1 -> canvas1
div#host1 -> host1
Thanks for the example. The simplified algorithm is much easier to understand this way as well. I'll wait for hayatoito, but otherwise LGTM. |
Yeah, you should drop it. Please be consistent with activeElement. That's what I suggested. LGTM. |
See discussion about this change at: WICG/webcomponents#192 Splits Document.pointerLockElement into Document.pointerLockElement and ShadowRoot.pointerLockElement and encapsulates shadow tree from document. Other than split, replaces document to use Shadow DOM-aware vocabulary like 'shadow-including root' where necessary. Fixes w3c#3.
a8b6086
to
fc87295
Compare
Thanks for all your reviews! Now I uploaded the final one, fixing #4 (comment) to remove typename where ID exists. |
Now you can use https://dom.spec.whatwg.org/#retarget. Could you update the spec again? |
Sorry for the delay, #8 is the PR for the update. |
See discussion about this change at:
WICG/webcomponents#192
Splits Document.pointerLockElement into Document.pointerLockElement and
ShadowRoot.pointerLockElement and encapsulates shadow tree from
document.
Other than split, replaces document to 'shadow-including document' where
necessary.
Addresses #3.