diff --git a/index.html b/index.html
index 236ae10..d497abe 100644
--- a/index.html
+++ b/index.html
@@ -286,17 +286,16 @@
Launching a Web App with Handling
- This specification amends the existing algorithm to
- launch a web
- application to include the behavior of [=manifest/launch_handler=]
+ This specification replaces the existing algorithm to [=launch a web
+ application=] to include the behavior of [=manifest/launch_handler=]
by replacing it with the steps to [=launch a web app with handling=].
- The steps to launch a web app with handling are given by
- the following algorithm. The algorithm takes a
- processed manifest
- |manifest:processed manifest|, an optional [=URL=] or
- {{LaunchParams}} |params| and an optional POST resource |POST resource|.
+ The steps to launch a web app with handling
+ are given by the following algorithm. The algorithm takes a
+ [=Document/processed manifest=] |manifest:processed manifest|, an
+ optional [=URL=] or {{LaunchParams}} |params|, an optional [=POST
+ resource=] |POST resource| and returns an [=application context=].
- If |params| is null, set |params| to
@@ -305,18 +304,22 @@
- If |params| is a [=URL=], set |params| to a new {{LaunchParams}}
with {{LaunchParams/targetURL}} set to |params|.
- - Set |client| to the result of running the steps to
- [=prepare a web app launch client=] passing |manifest|, |params|
+
- Assert: |params|.{{LaunchParams/targetURL}} is [=manifest/within
+ scope=] of |manifest|.
+
+ - Set |application context| to the result of running the steps to
+ [=prepare an application context=] passing |manifest|, |params|
and |POST resource|.
- Append |params| to the [=unconsumed launch params=] of the
- |client|'s document's {{Window/launchQueue}}.
+ |application context|'s document's {{Window/launchQueue}}.
- Run the steps to [=process unconsumed launch params=] on the
- |client|'s document's {{Window/launchQueue}}.
+ |application context|'s [=navigable/active document=]'s
+ {{Window/launchQueue}}.
- |client| may be an existing [=web app launch client=] with
- an [=assigned launch consumer=] hence it is necessary to process
+ |application context| may be an existing instance with an
+ [=assigned launch consumer=] hence it is necessary to process
the newly appended {{LaunchParams}}.
@@ -324,24 +327,14 @@
- Preparing a [=Web App Launch Client=]
+ Preparing an [=application context=]
- A web app launch client is a
- [=top-level browsing context=] associated with the web app.
-
-
- The exact form of this association is up to the user agent e.g. a
- dedicated app window separate UI presentation from general hyperlink
- browsing.
-
-
- To prepare a web app launch client given a
- processed
- manifest |manifest|, a {{LaunchParams}}
- |launch params:LaunchParams| and an optional
- POST resource |POST resource|,
- run the following steps:
+ The steps to prepare an application context are given by
+ the following algorithm. The algorithm takes a
+ [=Document/processed manifest=] |manifest:processed manifest|, a
+ {{LaunchParams}} |launch params|, an optional [=POST
+ resource=] |POST resource| and returns an [=application context=].
- Let [=client mode target=] |client_mode| be
@@ -358,63 +351,43 @@
- [=client mode/navigate-new=]
-
- - Return the result of running the steps to [=prepare a new
- web app launch client=] passing |manifest|,
- |launch params| and |POST resource|.
+
- Return the result of running the steps to [=create a new
+ application context=] passing |manifest|, |launch
+ params|.{{LaunchParams/targetURL}} and |POST resource|.
- [=client mode/navigate-existing=] or
[=client mode/focus-existing=]
-
- - If there is no [=top-level browsing context=] for
- the web app, return the result of running the steps to
- [=prepare a new web app launch client=] passing |manifest|
- |target URL|.
+
- If there is no [=application context=] that has |manifest|
+ [=applied=], return the result of running the steps to
+ [=create a new application context=] passing |manifest|,
+ |launch params|.{{LaunchParams/targetURL}} and |POST
+ resource|.
+
+ - Let |application context| be an [=application context=]
+ that has |manifest| [=applied=], the user agent selects
+ the most appropriate one if there are multiple.
+
+ An appropriate selection strategy would be to pick the
+ one that was most recently in focus.
+
- - Let |client| be a [=top-level browsing context=]
- for the web app, the exact selection algorithm is decided
- by the user agent.
+
- Bring |application context|'s viewport into focus.
- If |client mode| is [=client mode/navigate-existing=],
- run the steps to navigate
- |client| to |launch params|.{{LaunchParams/targetURL}}
- passing |POST resource|.
+ [=navigate=] |application context| to |launch
+ params|.{{LaunchParams/targetURL}} passing |POST
+ resource|.
- - Return |client|.
+
- Return |application context|.
-
-
- Preparing a new [=Web App Launch Client=]
-
-
- To prepare a new web app launch client given a
- processed
- manifest |manifest:processed manifest|, {{LaunchParams}}
- |launch params:LaunchParams| and optional
- POST resource |POST resource|,
- run the following steps:
-
-
- - Let |traversable| be the result of
-
- creating a fresh top-level traversable passing
- |launch params|.{{LaunchParams/targetURL}} and |POST resource|.
-
- - Let |browsing context| be the |traversable|'s
- active browsing context.
-
- - [=Apply=] |manifest| to |browsing context|.
-
- - Return |browsing context|.
-
-
-
Processing [=unconsumed launch params=]