From 6860bf543858bb56509f5b36903396552140144d Mon Sep 17 00:00:00 2001 From: alancutter Date: Wed, 9 Nov 2022 10:39:01 +1100 Subject: [PATCH] Replace appmanifest's launch algorithm with one that has launch_handler behaviors (#79) This builds on top of w3c/manifest#1056 which adds a launch web application algorithm to the manifest spec. This updates the launch handler spec to replace that algorithm with its own. This enables other webapp specs (not in WICG) to gain the launch_handler behaviour without directly referencing this WICG spec. Additionally this replaces the concept of "web app launch client" with the existing "application context" concept from the manifest spec which is effectively the same thing. #67 #69 #84 https://github.com/WICG/web-app-launch/pull/79 --- index.html | 153 ++++++++++++++++++++--------------------------------- 1 file changed, 58 insertions(+), 95 deletions(-) diff --git a/index.html b/index.html index 07e1fb6..6bee8db 100644 --- a/index.html +++ b/index.html @@ -283,87 +283,64 @@

- Launching a Web App + Launching a Web App with Handling

- When launching a web app via any means the trigger of the launch - should run the steps to [=launch a web app=] with a {{LaunchParams}} - containing relevant launch information (e.g. share data in the event - of a share target launch). + 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 application with + handling=].

-

- Examples of different web app launch triggers: -

-

- The steps to launch a web app are given by the following - algorithm and takes an optional {{LaunchParams}} - |params:LaunchParams|. + The steps to + launch a web application 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=].

    -
  1. If |params| is null, set |params| to a new {{LaunchParams}} with - {{LaunchParams/targetURL}} set to [=manifest/start_url=]. +
  2. If |params| is not given, set |params| to + |manifest|.[=manifest/start_url=].
  3. -
  4. Set |client| to the result of running the steps to - [=prepare a web app launch client=] passing the web app's - processed - manifest and |params|.{{LaunchParams/targetURL}}. +
  5. If |params| is a [=URL=], set |params| to a new {{LaunchParams}} + with {{LaunchParams/targetURL}} set to |params|. +
  6. +
  7. Assert: |params|.{{LaunchParams/targetURL}} is [=manifest/within + scope=] of |manifest|. +
  8. +
  9. Set |application context| to the result of running the steps to + [=prepare an application context=] passing |manifest|, |params| + and |POST resource|.
  10. Append |params| to the [=unconsumed launch params=] of the - |client|'s document's {{Window/launchQueue}}. + |application context|'s document's {{Window/launchQueue}}.
  11. 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 window client with an + |application context| may be an existing instance with an [=assigned launch consumer=] hence it is necessary to process - the newly appended |params|. + the newly appended {{LaunchParams}}.

-
-
-

- Preparing a [=Web App Launch Client=] -

- 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| and |target URL: URL|, 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=].

  1. Let [=client mode target=] |client_mode| be - |manifest|["launch_handler"]["client_mode"]. + |manifest|.[=manifest/launch_handler=].[=manifest/client_mode=].
  2. -
  3. If |client_mode| is [=client mode/auto=], set |client_mode| to either - [=client mode/navigate-new=] or [=client mode/navigate-existing=] - according to the user agent's decision for which is most - appropriate. +
  4. If |client_mode| is [=client mode/auto=], set |client_mode| to + either [=client mode/navigate-new=] or + [=client mode/navigate-existing=] according to the user agent's + decision for which is most appropriate.
  5. Switching on |client mode|, run the following substeps:

    @@ -371,57 +348,43 @@

    [=client mode/navigate-new=]
      -
    1. Return the result of running the steps to [=prepare a new - web app launch client=] passing |manifest| and - |target URL|. +
    2. 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=]
      -
    1. If there is no [=top-level browsing context=] for - the web app, return the result of the result of - [=prepare a new web app launch client=] passing |manifest| - and |target URL|. +
    2. 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|.
    3. -
    4. Let |client| be a [=top-level browsing context=] - for the web app, the exact selection algorithm is decided - by the user agent. +
    5. 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. +

      +
    6. +
    7. Bring |application context|'s viewport into focus.
    8. If |client mode| is [=client mode/navigate-existing=], - run the steps to [=navigate=] |client| to |target URL|. + [=navigate=] |application context| to |launch + params|.{{LaunchParams/targetURL}} passing |POST + resource|.
    9. -
    10. Return |client|. +
    11. Return |application context|.

-
-

- Preparing a new [=Web App Launch Client=] -

-

- To prepare a new web app launch client given a - processed - manifest |manifest| and |target URL:URL|, run the following steps: -

-
    -
  1. Let |client| be the result of - - creating a new top-level browsing context. -
  2. -
  3. Apply |manifest| to - |client|. -
  4. -
  5. Run the steps to [=navigate=] |client| passing |target URL|. -
  6. -
  7. Return |client|. -
  8. -
-

Processing [=unconsumed launch params=]