Skip to content

Commit 751867e

Browse files
committed
Add support for "userContexts" argument to "browsingContext.setViewport" command.
1 parent 198ddae commit 751867e

File tree

1 file changed

+131
-40
lines changed

1 file changed

+131
-40
lines changed

index.bs

Lines changed: 131 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,6 +2966,13 @@ between [=navigables=] and device pixel ratio overrides. It is initially empty.
29662966
Note: this map is not cleared when the final session ends i.e. device pixel
29672967
ratio overrides outlive any WebDriver session.
29682968

2969+
A [=remote end=] has a <dfn>viewport overrides map</dfn> which is a weak map
2970+
between [=user contexts=] and [=structs=], with an [=struct/item=] named <code>viewport</code>
2971+
and an [=struct/item=] named <code>devicePixelRatio</code>, which is a float or null.
2972+
An [=struct/item=] <code>viewport</code> is a [=struct=] or null, with an [=struct/item=]
2973+
named <code>height</code>, which is an integer, and an [=struct/item=] named <code>width</code>,
2974+
which is an integer.
2975+
29692976
### Types ### {#module-browsingcontext-types}
29702977

29712978
#### The browsingContext.BrowsingContext Type #### {#type-browsingContext-Browsingcontext}
@@ -4629,9 +4636,10 @@ The <dfn export for=commands>browsingContext.setViewport</dfn> command modifies
46294636
)
46304637

46314638
browsingContext.SetViewportParameters = {
4632-
context: browsingContext.BrowsingContext,
4639+
? context: browsingContext.BrowsingContext,
46334640
? viewport: browsingContext.Viewport / null,
46344641
? devicePixelRatio: (float .gt 0.0) / null,
4642+
? userContexts: [+browser.UserContext],
46354643
}
46364644

46374645
browsingContext.Viewport = {
@@ -4648,71 +4656,154 @@ The <dfn export for=commands>browsingContext.setViewport</dfn> command modifies
46484656
</dd>
46494657
</dl>
46504658

4659+
<div algorithm>
4660+
To <dfn>set device pixel ratio override</dfn> given |navigable| and |device pixel ratio|:
4661+
4662+
1. Let |navigable| be the [=/navigable=] whose [=navigable/active document=] is
4663+
|navigable|'s [=navigable/active document=].
4664+
4665+
1. If |device pixel ratio| is not null:
4666+
4667+
1. When the [=select an image source from a source set=] are run, act as if
4668+
the implementation's pixel density was set to |device pixel ratio| when selecting an image.
4669+
4670+
1. For the purposes of the [=resolution media feature=], act as if
4671+
the implementation's resolution is |device pixel ratio| dppx scaled by the page zoom.
4672+
4673+
1. [=map/Set=] [=device pixel ratio overrides=][|navigable|] to |device pixel ratio|.
4674+
4675+
Note: This will take an effect because of the patch of [[#patchs-determine-the-device-pixel-ratio]].
4676+
4677+
1. Otherwise:
4678+
4679+
1. When the [=select an image source from a source set=] steps are run, use the implementation's default behavior,
4680+
without any changes made by previous invocations of these steps.
4681+
4682+
1. For the purposes of the [=resolution media feature=], use the implementation's default behavior,
4683+
without any changes made by previous invocations of these steps.
4684+
4685+
1. [=map/Remove=] |navigable| from [=device pixel ratio overrides=].
4686+
4687+
1. Run [=evaluate media queries and report changes=] for [=/document=] currently loaded
4688+
in a specified |navigable|.
4689+
4690+
</div>
4691+
4692+
4693+
<div algorithm>
4694+
To <dfn>set viewport</dfn> given |navigable| and |viewport|:
4695+
4696+
1. If |viewport| is not null, set the width of |navigable|'s [=layout
4697+
viewport=] to be the <code>width</code> of |viewport| in CSS pixels and
4698+
set the height of the |navigable|'s [=layout viewport=] to be the
4699+
<code>height</code> of |viewport| in CSS pixels.
4700+
4701+
1. Otherwise, set the |navigable|'s [=layout viewport=] to the
4702+
implementation-defined default.
4703+
4704+
</div>
4705+
4706+
<div algorithm="set viewport when a top-level traversable is created">
4707+
4708+
When the [=set up a window environment settings object=]
4709+
algorithm is invoked, immediately prior to returning the settings
4710+
object:
4711+
4712+
1. Let |environment settings| be the newly created [=environment settings
4713+
object=].
4714+
4715+
1. Let |related navigables| be the result of [=get related navigables=] given |environment settings|.
4716+
4717+
1. For each |navigable| of |related navigables|:
4718+
4719+
1. If |navigable| is not a [=/top-level traversable=], continue.
4720+
4721+
1. Let |user context| be |navigable|'s [=associated user context=].
4722+
4723+
1. If [=viewport overrides map=] [=map/contains=] |user context|:
4724+
4725+
1. If |viewport overrides map|[|user context|] [=map/contains=] the <code>viewport</code> field:
4726+
4727+
1. [=Set viewport=] with |navigable| and |viewport overrides map|[|user context|]["<code>viewport</code>"].
4728+
4729+
1. If |viewport overrides map|[|user context|] [=map/contains=] the <code>devicePixelRatio</code> field:
4730+
4731+
1. For the |navigable| and all [=descendant navigables=]:
4732+
4733+
1. [=Set device pixel ratio override=] with |navigable| and |viewport overrides map|[|user context|]["<code>devicePixelRatio</code>""].
4734+
46514735
<div algorithm="remote end steps for browsingContext.setViewport">
46524736

46534737
The [=remote end steps=] with |command parameters| are:
46544738

4655-
1. Let |navigable id| be the value of the <code>context</code> field of |command
4656-
parameters|.
4739+
1. If |command parameters| [=map/contains=] "<code>userContexts</code>"
4740+
and |command parameters| [=map/contains=] "<code>context</code>",
4741+
return [=error=] with [=error code=] [=invalid argument=].
46574742

4658-
1. Let |navigable| be the result of [=trying=] to [=get a navigable=] with
4659-
|navigable id|.
4743+
1. Let |navigables| be a [=/set=].
46604744

4661-
1. If |navigable| is not a [=/top-level traversable=], return [=error=] with
4662-
[=error code=] [=invalid argument=].
4745+
1. If the <code>context</code> field of |command parameters| is present:
46634746

4664-
1. If the implementation is unable to adjust the |navigable|'s [=layout viewport=]
4665-
parameters with the given |command parameters| for any reason, return
4666-
[=error=] with [=error code=] [=unsupported operation=].
4747+
1. Let |navigable id| be the value of the <code>context</code> field of |command
4748+
parameters|.
46674749

4668-
1. If |command parameters| [=map/contains=] the <code>viewport</code> field:
4750+
1. Let |navigable| be the result of [=trying=] to [=get a navigable=] with
4751+
|navigable id|.
46694752

4670-
1. Let |viewport| be the |command parameters|["<code>viewport</code>"].
4753+
1. If |navigable| is not a [=/top-level traversable=], return [=error=] with
4754+
[=error code=] [=invalid argument=].
46714755

4672-
1. If |viewport| is not null, set the width of |navigable|'s [=layout
4673-
viewport=] to be the <code>width</code> of |viewport| in CSS pixels and
4674-
set the height of the |navigable|'s [=layout viewport=] to be the
4675-
<code>height</code> of |viewport| in CSS pixels.
4756+
1. If the implementation is unable to adjust the |navigable|'s [=layout viewport=]
4757+
parameters with the given |command parameters| for any reason, return
4758+
[=error=] with [=error code=] [=unsupported operation=].
46764759

4677-
1. Otherwise, set the |navigable|'s [=layout viewport=] to the
4678-
implementation-defined default.
4760+
1. [=set/Append=] |navigable| to |navigables|.
46794761

4680-
1. Run the [[cssom-view-1#resizing-viewports]] steps.
4762+
1. Otherwise, if the <code>userContexts</code> field of |command parameters| is present:
46814763

4682-
1. If |command parameters| [=map/contains=] the <code>devicePixelRatio</code> field:
4764+
1. For each |user context id| of |command parameters|["<code>userContexts</code>"]:
46834765

4684-
1. Let |device pixel ratio| be the |command
4685-
parameters|["<code>devicePixelRatio</code>"].
4766+
1. Set |user context| to [=get user context=] with |user context id|.
46864767

4687-
1. For the |navigable| and all [=descendant navigables=]:
4768+
1. If |user context| is null, return [=error=] with [=error code=] [=no such user context=].
46884769

4689-
1. Let |navigable| be the [=/navigable=] whose [=navigable/active document=] is
4690-
|navigable|'s [=navigable/active document=].
4770+
1. [=map/Set=] [=viewport overrides map=][|user context|] to a new [=/map=].
46914771

4692-
1. If |device pixel ratio| is not null:
4772+
1. If |command parameters| [=map/contains=] the <code>viewport</code> field:
46934773

4694-
1. When the [=select an image source from a source set=] are run, act as if
4695-
the implementation's pixel density was set to |device pixel ratio| when selecting an image.
4774+
1. Set |viewport overrides map|[|user context|]["<code>viewport</code>"]
4775+
to |command parameters|["<code>viewport</code>"].
46964776

4697-
1. For the purposes of the [=resolution media feature=], act as if
4698-
the implementation's resolution is |device pixel ratio| dppx scaled by the page zoom.
4777+
1. If |command parameters| [=map/contains=] the <code>devicePixelRatio</code> field:
46994778

4700-
1. [=map/Set=] [=device pixel ratio overrides=][|navigable|] to |device pixel ratio|.
4779+
1. Set |viewport overrides map|[|user context|]["<code>devicePixelRatio</code>"]
4780+
to |command parameters|["<code>devicePixelRatio</code>"].
47014781

4702-
Note: This will take an effect because of the patch of [[#patchs-determine-the-device-pixel-ratio]].
4782+
1. [=list/For each=] |top-level traversable| in the list of all [=/top-level traversables=]
4783+
whose [=associated user context=] is |user context|:
47034784

4704-
1. Otherwise:
4785+
1. [=list/Append=] |top-level traversable| to |navigables|.
4786+
4787+
1. If |command parameters| [=map/contains=] the <code>viewport</code> field:
4788+
4789+
1. Let |viewport| be the |command parameters|["<code>viewport</code>"].
47054790

4706-
1. When the [=select an image source from a source set=] steps are run, use the implementation's default behavior,
4707-
without any changes made by previous invocations of these steps.
4791+
1. For each |navigable| of |navigables|:
4792+
4793+
1. [=Set viewport=] with |navigable| and |viewport|.
4794+
4795+
1. Run the [[cssom-view-1#resizing-viewports]] steps.
4796+
4797+
1. If |command parameters| [=map/contains=] the <code>devicePixelRatio</code> field:
4798+
4799+
1. Let |device pixel ratio| be the |command
4800+
parameters|["<code>devicePixelRatio</code>"].
47084801

4709-
1. For the purposes of the [=resolution media feature=], use the implementation's default behavior,
4710-
without any changes made by previous invocations of these steps.
4802+
1. For each |navigable| of |navigables|:
47114803

4712-
1. [=map/Remove=] |navigable| from [=device pixel ratio overrides=].
4804+
1. For the |navigable| and all [=descendant navigables=]:
47134805

4714-
1. Run [=evaluate media queries and report changes=] for [=/document=] currently loaded
4715-
in a specified |navigable|.
4806+
1. [=Set device pixel ratio override=] with |navigable| and |device pixel ratio|.
47164807

47174808
1. Return [=success=] with data null.
47184809

0 commit comments

Comments
 (0)