Skip to content

[cssom-view] Change scrollIntoView(undefined) to be like true #1505

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

Merged
merged 4 commits into from
Sep 11, 2017

Conversation

zcorpan
Copy link
Member

@zcorpan zcorpan commented Jun 7, 2017

This aligns with the behavior of Gecko/WebKit/Chromium; EdgeHTML
treats explicit undefined like false.

Fixes #1367.

Tests: web-platform-tests/wpt#6253

@syncbot syncbot force-pushed the zcorpan/scrollintoview-undefined-like-true branch from 21c997e to 763f7e7 Compare June 8, 2017 19:22
zcorpan added a commit to web-platform-tests/wpt that referenced this pull request Jun 15, 2017
@zcorpan zcorpan force-pushed the zcorpan/scrollintoview-undefined-like-true branch from 763f7e7 to 0c667c7 Compare June 21, 2017 06:22
@zcorpan
Copy link
Member Author

zcorpan commented Jun 21, 2017

Ping @travisleithead - is this change OK for Edge?

@syncbot syncbot force-pushed the zcorpan/scrollintoview-undefined-like-true branch from 0c667c7 to 763f7e7 Compare July 13, 2017 14:20
@zcorpan
Copy link
Member Author

zcorpan commented Aug 23, 2017

@@ -1082,8 +1082,7 @@ dictionary ScrollIntoViewOptions : ScrollOptions {
partial interface Element {
sequence<DOMRect> getClientRects();
[NewObject] DOMRect getBoundingClientRect();
void scrollIntoView();
void scrollIntoView((boolean or object) arg);
void scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = true);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need to define a default here. I had a similar situation with addEventListener. Basically if no argument is given you'll end up getting a dictionary passed to your algorithm and that dictionary should have the appropriate defaults already. Does that make sense?

1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise:
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
1. If <var>arg</var> is true, set the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> to "<code>start</code>", and set the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> to "<code>nearest</code>".
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> to "<code>end</code>", and set the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> to "<code>nearest</code>".
Copy link
Member

Choose a reason for hiding this comment

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

This should basically no longer be needed. All you need is some logic for what to do when arg is a boolean. Or is there another caller of sorts?

<code>false</code> is equivalent to
<code>{&nbsp;block:&nbsp;"end",&nbsp;inline:&nbsp;"nearest"&nbsp;}</code>. Since centering is a
common case, passing in an empty dictionary <code>{}</code> is equivalent to
<code>{&nbsp;block:&nbsp;"center",&nbsp;inline:&nbsp;"center"&nbsp;}</code>.
Copy link
Member

Choose a reason for hiding this comment

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

I thought we wouldn't do this?

@zcorpan
Copy link
Member Author

zcorpan commented Sep 8, 2017

Anne, this is for fixing #1367 -- my thought was that the fix for #1720 would be on top of this change.

@annevk
Copy link
Member

annevk commented Sep 8, 2017

Okay, isn't that a little confusing?

@zcorpan
Copy link
Member Author

zcorpan commented Sep 8, 2017

Maybe it is, yeah. I can address both issues at once. I'll push new commits here and update the tests.

This aligns with the behavior of Gecko/WebKit/Chromium; EdgeHTML
treats explicit undefined like false.

Fixes #1367.

Tests: web-platform-tests/wpt#6253
@zcorpan zcorpan force-pushed the zcorpan/scrollintoview-undefined-like-true branch from 763f7e7 to 73f06e5 Compare September 8, 2017 10:38
zcorpan added a commit to web-platform-tests/wpt that referenced this pull request Sep 8, 2017
@zcorpan
Copy link
Member Author

zcorpan commented Sep 8, 2017

@annevk PTAL

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

let/set nit must be fixed, the rest would be nice.

1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>end</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise:
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> to "<code>end</code>".
Copy link
Member

Choose a reason for hiding this comment

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

then set

1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
1. If <var>arg</var> is not specified or is true, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>start</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>end</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise:
Copy link
Member

Choose a reason for hiding this comment

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

seems clearer if Otherwise is a new step

dictionary <code>{}</code> to {{Element/scrollIntoView()}} is equivalent to
<code>{&nbsp;block:&nbsp;"start",&nbsp;inline:&nbsp;"nearest"&nbsp;}</code>. Passing in
<code>false</code> is equivalent to
<code>{&nbsp;block:&nbsp;"end",&nbsp;inline:&nbsp;"nearest"&nbsp;}</code>.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is needed as we don't explain all the other nuances of IDL either.

1. If <var>arg</var> is not specified or is true, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>start</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>end</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise:
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
Copy link
Member

Choose a reason for hiding this comment

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

I wish this could be avoided somehow, but I guess it's okay. It's a little ugly to invoke JS->IDL conversions when you're supposedly already in IDL-prose land.

@@ -1301,7 +1298,9 @@ The <dfn attribute for=Element>clientHeight</dfn> attribute must run these steps
<h3 id=element-scrolling-members>{{Element}} Scrolling Members</h3>

To <dfn>scroll an element into view</dfn> <var>element</var>,
with a {{ScrollIntoViewOptions}} dictionary <var>options</var>,
with a scroll behavior <var>behavior</var>,
a block flow direction position <var>block</var>,
Copy link
Member

Choose a reason for hiding this comment

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

and an optional block flow ... and an inline base ...

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure I follow. Would you like me to tweak the wording? Or make these optional? Both?

Copy link
Member

Choose a reason for hiding this comment

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

I think you treat the second and third argument as optional because there's one invocation that just invokes this with "auto", afaict.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see that. Within cssom-view it's only invoked here

1. <a lt='scroll an element into view'>Scroll the element into view</a>
    with <var>behavior</var>, <var>block</var>, and <var>inline</var>.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah you're right. I got confused with "scroll an element".

zcorpan added a commit to web-platform-tests/wpt that referenced this pull request Sep 11, 2017
@zcorpan zcorpan merged commit 232957f into master Sep 11, 2017
@zcorpan zcorpan deleted the zcorpan/scrollintoview-undefined-like-true branch September 11, 2017 14:25
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.

2 participants