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

Allow the 'root' argument to be a Document. #411

Merged
merged 2 commits into from
Jan 28, 2020

Conversation

szager-chromium
Copy link
Collaborator

@szager-chromium szager-chromium commented Jan 21, 2020

Issue #372

Closes #???

The following tasks have been completed:

  • Modified Web platform tests (link to pull request)

Implementation commitment:


Preview | Diff

index.bs Outdated

<dt>If the <a>intersection root</a> has an overflow clip,
<dt>If the <a>intersection root</a> is a {{document}},
<dd>it's the size of the {{document}}'s viewport.

Choose a reason for hiding this comment

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

Where is "the document's viewport" defined? Is it defined for documents that are not in a browsing context or are not fully active?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is sort of intentionally vague. The existing spec says this:

"If the intersection root is the implicit root, it [the root intersection rectangle] is the viewport’s size."

Elsewhere it mentions "the viewport of the document" and "viewport of the nested browsing context". It also says this in a highlighted note:

"Root intersection rectangle is not affected by pinch zoom and will report the unadjusted viewport, consistent with the intent of pinch zooming (to act like a magnifying glass and NOT change layout.)"

However, all of that text is likely to change with the resolution of this issue:

#95

The intention here is to use "viewport" in a way that is consistent with existing usage in the spec, until the above issue is resolved.

Choose a reason for hiding this comment

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

I understand all that, but the implicit root, being the active document of a toplevel browsing context, always has at least some concept of a viewport. If there's some random document involved (e.g. an XHR responseXML document, or a document from an iframe that is now removed from the DOM or whatever), there may be no concept of a viewport at all. #95 does not cover that, as far as I can tell.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only spec language I could find that defines browser viewport is this unhelpful bit:

https://drafts.csswg.org/css2/visuren.html#viewport

But I'm not sure it's necessary to determine what the browser viewport of a detached document is, since the "Update the rendering" steps in the HTML event loop -- which is where IntersectionObserver runs -- only applies to fully active (connected) documents:

https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model

Choose a reason for hiding this comment

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

Aha. It might be good in the loop to assert that all documents we encounter are fully active. Those might still not have a sane viewport (e.g. if their embedding iframe is display:none), but at least it cuts down on the cases that need to be considered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I added some language there to clarify that the root document must be fully active at this step in processing.

PTAL

Choose a reason for hiding this comment

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

This looks reasonable to me, thank you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bzbarsky Would you mind clicking the "approved" button...

@szager-chromium
Copy link
Collaborator Author

@bzbarsky If you could take another look at this soon-ish, that would be helpful. We're hoping to ship this behavior in the next branch of chromium, which will happen next week.

Thanks

@szager-chromium szager-chromium merged commit e626248 into w3c:master Jan 28, 2020
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.

3 participants