-
Notifications
You must be signed in to change notification settings - Fork 142
Scope ModelContext to Document, and handle detached documents
#177
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
Open
domfarolino
wants to merge
1
commit into
main
Choose a base branch
from
fix-modelcontext-lifetime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+38
−8
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,14 @@ spec:html; type:dfn; | |
| text:browsing context group set | ||
| text:unique internal value | ||
| </pre> | ||
| <pre class="anchors"> | ||
| spec: html; type: dfn; urlPrefix: https://html.spec.whatwg.org/C | ||
| text: create and initialize a Document object; url: initialise-the-document-object | ||
| # Because `text` and `url` are the same (modulo slashes), we should be able to | ||
| # exclude `url`. But the colon breaks the URL in `text`, forcing us to include | ||
| # `url`. | ||
| text:is initial about:blank; url: is-initial-about:blank | ||
| </pre> | ||
|
|
||
| <h2 id="intro">Introduction</h2> | ||
|
|
||
|
|
@@ -113,6 +121,7 @@ A <dfn>model context</dfn> is a [=struct=] with the following [=struct/items=]: | |
| [=structs=]. | ||
| </dl> | ||
|
|
||
|
|
||
| A <dfn>tool definition</dfn> is a [=struct=] with the following [=struct/items=]: | ||
|
|
||
| <dl dfn-for="tool definition"> | ||
|
|
@@ -183,19 +192,40 @@ https://dlaliberte.github.io/bikeshed-intro/#a-strategy-for-incremental-developm | |
|
|
||
| <h3 id="navigator-extension">Extensions to the {{Navigator}} Interface</h3> | ||
|
|
||
| The {{Navigator}} interface is extended to provide access to the {{ModelContext}}. | ||
| Each {{Document}} object has an <dfn for=Document>associated {{ModelContext}}</dfn>, which is a | ||
| {{ModelContext}} object. | ||
|
|
||
| Upon creation of the {{Document}} object, its [=Document/associated ModelContext|associated | ||
| <code>ModelContext</code>=] must be set to a [=new=] {{ModelContext}} object created in the | ||
| {{Document}}'s [=relevant realm=]. | ||
|
|
||
| The {{Navigator}} interface provides access to a {{Document}}'s [=Document/associated | ||
| ModelContext|associated <code>ModelContext</code>=] through its {{Navigator/modelContext}} | ||
| attribute. | ||
|
|
||
| Note: The reason {{ModelContext}} is owned by {{Document}} instead of {{Navigator}} is to ensure | ||
| that tools registered within an [=is initial about:blank|initial <code>about:blank</code>=] | ||
| {{Document}} are not available to the subsequent [=same origin=] {{Document}} that results from | ||
| navigating away from the initial {{Document}}. This is crucial, since these two {{Document}}s share | ||
| the same {{Window}} and {{Navigator}} objects. See step 6.1 in [=create and initialize a Document | ||
| object|create and initialize a <code>Document</code> object=]. | ||
|
|
||
| <hr> | ||
|
|
||
| <xmp class="idl"> | ||
| partial interface Navigator { | ||
| [SecureContext, SameObject] readonly attribute ModelContext modelContext; | ||
| [SecureContext] readonly attribute ModelContext? modelContext; | ||
| }; | ||
| </xmp> | ||
|
|
||
| Each {{Navigator}} object has an associated <dfn for=Navigator>modelContext</dfn>, which is a | ||
| {{ModelContext}} instance created alongside the {{Navigator}}. | ||
|
|
||
| <div algorithm> | ||
| The <dfn attribute for=Navigator>modelContext</dfn> getter steps are to return [=this=]'s [=Navigator/modelContext=]. | ||
| The <dfn attribute for=Navigator>modelContext</dfn> getter steps are: | ||
|
|
||
| 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is null, then return null. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a developer perspective, I'd love if this wouldn't become |
||
|
|
||
| 1. Return [=this=]'s [=relevant global object=]'s [=associated Document=]'s [=Document/associated | ||
| ModelContext|associated <code>ModelContext</code>=] object. | ||
|
|
||
| </div> | ||
|
|
||
| <h3 id="model-context-container">ModelContext Interface</h3> | ||
|
|
@@ -515,8 +545,8 @@ steps: | |
|
|
||
| 1. Let |id| be |document|'s [=Document/unique ID=]. | ||
|
|
||
| 1. Set |observation|'s [=observation/tool map=][|id|] = |document|'s [=relevant global | ||
| object=]'s {{Navigator}}'s [=Navigator/modelContext=]'s [=ModelContext/internal context=]'s | ||
| 1. Set |observation|'s [=observation/tool map=][|id|] = |document|'s [=Document/associated | ||
| ModelContext|associated <code>ModelContext</code>=]'s [=ModelContext/internal context=]'s | ||
| [=model context/tool map=]'s [=map/values=], which are [=tool definitions=]. | ||
|
|
||
| 1. Perform any [=implementation-defined=] steps to add anything to |observation| that the [=user | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hey @tabatkins, I could not for the life of me figure out how to add
{{ModelContext}}or<code>ModelContext</code>to the actual linking text, so I had to settle on this super verbose[=foo|<code>foo</code>=]which is really redundant and I can't figure out if there's a way around it, so I can tighten these up. It's not blocking, so if there's no solution, that's fine.Uh oh!
There was an error while loading. Please reload this page.
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.
There's no "proper" way around it - linking text is text, not markup.
There is a workaround, tho - use an internal macro:
(You could also scope it to just use the macro for the visible text part, but if you're doing this link a lot you might as well macro the whole thing.)