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

Rough history traversal algorithm #250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

jakearchibald
Copy link
Collaborator

No description provided.

@@ -233,6 +233,8 @@ Navigations within portals are subject to certain security restrictions for load

Navigation errors within portals may cause portal activation to be rejected. Instead of, for example, the user agent showing an error page to the user as with a conventional navigation, the promise returned by the activate method allows a page to gracefully handle the rejection. Furthermore, user agents have existing limitations on navigations initiated by the page where they may be ignored if they are considered to conflict with a user's intent to perform a different navigation. Such cases are not described by the existing navigation spec (see [#218](https://github.com/WICG/portals/issues/218)), but portal activations are subject to these limitations. In the case where another navigation takes precedence over portal activation, the promise returned by the activate method rejects.

See the [rough algorithms](history-traversal.md) for cases where portals may be auto-activated, and pages may be reportaled, when traversing session history.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this the right way to link to another doc from a README.md?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, this works.


## Activate a portal in a 'push' style

This is a regular activation that clears any 'forward' items in join session history and adds a new top-level history entry for the portaled document.
Copy link
Collaborator

Choose a reason for hiding this comment

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

here and elsewhere, is this "joint"?

## Definitions

<dl>
<dt>Navigable</dt>
Copy link
Collaborator

Choose a reason for hiding this comment

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

i.e., a browsing context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Portals can navigate, and when they do so they change browsing context each time.

If you navigate and it requires isolation due to COOP+COEP, that also involves a change in browsing context.

This is one of the "boil the ocean" things that needs to happen, because the spec doesn't carter for this at all, it assumes that browsing contexts stay constant within navigable. The spec also makes session history a property of the browsing context, which is similarly broken.


Note: To avoid multiple levels of reportaling, reportaling and implicit activation is skipped if the navigation spans across multiple documents

1. Asset: _documentChangesInDelta_ is not 0.
Copy link
Collaborator

Choose a reason for hiding this comment

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

sp: Assert

1. For each item in the navigable's session history, remove its document if the document is _documentToPortal_, and give it a weak reference to _documentToPortal_.
1. Otherwise, unload the current history item's document.

Note: This may include excluding it from bfcache.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't quite follow this but I assume there's a reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll improve the language here. During unloading, things can happen that exclude the document from bfcache, such as unload event handlers.

1. Let _document_ be the portal's session history item's document.
1. Let _targetHistoryItem_ be a copy of the portal's session history item.
1. Remove _targetHistoryItem_'s document.
1. Give _targetHistoryItem_ a weak reference to _document_.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this actually easier/clearer than having the history item has a strong/weak flag rather than two separate fields?

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 isn't as easy as I thought.

Good bits:

  • Avoids moving the document from property to property
  • Avoids cases where the weak document and main document are set at the same time (and are different)

Less good bits:

  • Maybe the moving solidifies the 'documents move around model' that we agreed on?
  • It doesn't work with portals. With portals the history item is removed upon activation, so the weak reference is on the portal itself. We could keep the history item and set the weak flag there, but that means any portal rendering/interaction code would need to treat the history entry as absent if the weak flag is set. Although, this would ensure the weak reference is gone when the portal is navigated.

There may be other places where we'd need to avoid doing things with the session history item if the document reference is weak.

I'm undecided.

@yoavweiss yoavweiss changed the base branch from master to main March 5, 2021 21:42
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.

4 participants