Skip to content

Commit 986f461

Browse files
authored
Scope ModelContext to Document, and handle detached documents (#177)
1 parent a99ffd2 commit 986f461

1 file changed

Lines changed: 48 additions & 8 deletions

File tree

index.bs

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ spec:html; type:dfn;
8686
text:browsing context group set
8787
text:unique internal value
8888
</pre>
89+
<pre class="anchors">
90+
spec: html; type: dfn; urlPrefix: https://html.spec.whatwg.org/C
91+
text: create and initialize a Document object; url: initialise-the-document-object
92+
# Because `text` and `url` are the same (modulo slashes), we should be able to
93+
# exclude `url`. But the colon breaks the URL in `text`, forcing us to include
94+
# `url`.
95+
text:is initial about:blank; url: is-initial-about:blank
96+
text: associated Navigator
97+
</pre>
8998

9099
<h2 id="intro">Introduction</h2>
91100

@@ -113,6 +122,7 @@ A <dfn>model context</dfn> is a [=struct=] with the following [=struct/items=]:
113122
[=structs=].
114123
</dl>
115124

125+
116126
A <dfn>tool definition</dfn> is a [=struct=] with the following [=struct/items=]:
117127

118128
<dl dfn-for="tool definition">
@@ -183,19 +193,47 @@ https://dlaliberte.github.io/bikeshed-intro/#a-strategy-for-incremental-developm
183193

184194
<h3 id="navigator-extension">Extensions to the {{Navigator}} Interface</h3>
185195

186-
The {{Navigator}} interface is extended to provide access to the {{ModelContext}}.
196+
Each {{Navigator}} object has an <dfn for=Navigator>associated {{ModelContext}}</dfn>, which is a
197+
{{ModelContext}} object.
198+
199+
Upon creation of the {{Navigator}} object, its [=Navigator/associated ModelContext|associated
200+
<code>ModelContext</code>=] must be set to a [=new=] {{ModelContext}} object created in the
201+
{{Navigator}}'s [=relevant realm=]. It only ever changes from one `{{ModelContext}}` instance to
202+
another the first time the {{Navigator/modelContext}} getter is accessed after a navigation away
203+
from the [=is initial about:blank|initial <code>about:blank</code>=],
204+
205+
Note: The reason a {{Navigator}}'s [=Navigator/associated ModelContext|associated
206+
<code>ModelContext</code>=] changes is as follows: {{ModelContext}} is a {{Document}}-scoped
207+
registry of tools, but because it is accessed from an object that is shared between two {{Document}}
208+
objects, it gets updated when the {{Navigator}}'s [=relevant global object=]'s
209+
[=associated Document|associated <code>Document</code>=] gets updated, to ensure that tools registered within the [=is
210+
initial about:blank|initial <code>about:blank</code>=] {{Document}} do not mix with tools in the
211+
subsequent [=same origin=] {{Document}} See step 6.1 in [=create and initialize a Document
212+
object|create and initialize a <code>Document</code> object=].
213+
214+
Each {{ModelContext}} object has a <dfn for=ModelContext>creation {{Document}}</dfn>, which is its
215+
[=relevant global object=]s [=associated Document|associated <code>Document</code>=] at the time of creation.
216+
217+
<hr>
187218

188219
<xmp class="idl">
189220
partial interface Navigator {
190-
[SecureContext, SameObject] readonly attribute ModelContext modelContext;
221+
[SecureContext] readonly attribute ModelContext modelContext;
191222
};
192223
</xmp>
193224

194-
Each {{Navigator}} object has an associated <dfn for=Navigator>modelContext</dfn>, which is a
195-
{{ModelContext}} instance created alongside the {{Navigator}}.
196-
197225
<div algorithm>
198-
The <dfn attribute for=Navigator>modelContext</dfn> getter steps are to return [=this=]'s [=Navigator/modelContext=].
226+
The <dfn attribute for=Navigator>modelContext</dfn> getter steps are:
227+
228+
1. If [=this=]'s [=Navigator/associated ModelContext|associated <code>ModelContext</code>=]'s
229+
[=ModelContext/creation Document| creation <code>Document</code>=] does not equal [=this=]'s
230+
[=relevant global object=]'s [=associated Document|associated <code>Document</code>=], then set
231+
[=this=]'s [=Navigator/associated ModelContext|associated <code>ModelContext</code>=] to a
232+
[=new=] {{ModelContext}} object.
233+
234+
1. Return [=this=]'s [=Navigator/associated ModelContext|associated <code>ModelContext</code>=]
235+
object.
236+
199237
</div>
200238

201239
<h3 id="model-context-container">ModelContext Interface</h3>
@@ -516,8 +554,10 @@ steps:
516554
1. Let |id| be |document|'s [=Document/unique ID=].
517555

518556
1. Set |observation|'s [=observation/tool map=][|id|] = |document|'s [=relevant global
519-
object=]'s {{Navigator}}'s [=Navigator/modelContext=]'s [=ModelContext/internal context=]'s
520-
[=model context/tool map=]'s [=map/values=], which are [=tool definitions=].
557+
object=]'s [=associated Navigator|associated <code>Navigator</code>=]'s
558+
[=Navigator/associated ModelContext|associated <code>ModelContext</code>=]'s
559+
[=ModelContext/internal context=]'s [=model context/tool map=]'s [=map/values=], which are
560+
[=tool definitions=].
521561

522562
1. Perform any [=implementation-defined=] steps to add anything to |observation| that the [=user
523563
agent=] might deem useful or necessary, besides just populating the [=observation/tool map=].

0 commit comments

Comments
 (0)