@@ -2966,6 +2966,13 @@ between [=navigables=] and device pixel ratio overrides. It is initially empty.
2966
2966
Note: this map is not cleared when the final session ends i.e. device pixel
2967
2967
ratio overrides outlive any WebDriver session.
2968
2968
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
+
2969
2976
### Types ### {#module-browsingcontext-types}
2970
2977
2971
2978
#### The browsingContext.BrowsingContext Type #### {#type-browsingContext-Browsingcontext}
@@ -4629,9 +4636,10 @@ The <dfn export for=commands>browsingContext.setViewport</dfn> command modifies
4629
4636
)
4630
4637
4631
4638
browsingContext.SetViewportParameters = {
4632
- context: browsingContext.BrowsingContext,
4639
+ ? context: browsingContext.BrowsingContext,
4633
4640
? viewport: browsingContext.Viewport / null,
4634
4641
? devicePixelRatio: (float .gt 0.0) / null,
4642
+ ? userContexts: [+browser.UserContext] ,
4635
4643
}
4636
4644
4637
4645
browsingContext.Viewport = {
@@ -4648,71 +4656,154 @@ The <dfn export for=commands>browsingContext.setViewport</dfn> command modifies
4648
4656
</dd>
4649
4657
</dl>
4650
4658
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
+
4651
4735
<div algorithm="remote end steps for browsingContext.setViewport">
4652
4736
4653
4737
The [=remote end steps=] with |command parameters| are:
4654
4738
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=] .
4657
4742
4658
- 1. Let |navigable| be the result of [=trying=] to [=get a navigable=] with
4659
- |navigable id|.
4743
+ 1. Let |navigables| be a [=/set=] .
4660
4744
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:
4663
4746
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|.
4667
4749
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|.
4669
4752
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=] .
4671
4755
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=] .
4676
4759
4677
- 1. Otherwise, set the |navigable|'s [=layout viewport=] to the
4678
- implementation-defined default.
4760
+ 1. [=set/Append=] |navigable| to |navigables|.
4679
4761
4680
- 1. Run the [[cssom-view-1#resizing-viewports]] steps.
4762
+ 1. Otherwise, if the <code> userContexts </code> field of |command parameters| is present:
4681
4763
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>"] :
4683
4765
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|.
4686
4767
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=] .
4688
4769
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=] .
4691
4771
4692
- 1. If |device pixel ratio| is not null :
4772
+ 1. If |command parameters| [=map/contains=] the <code> viewport </code> field :
4693
4773
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>"] .
4696
4776
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:
4699
4778
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>"] .
4701
4781
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|:
4703
4784
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>"] .
4705
4790
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>"] .
4708
4801
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|:
4711
4803
4712
- 1. [=map/Remove=] |navigable| from [=device pixel ratio overrides=] .
4804
+ 1. For the |navigable| and all [=descendant navigables=] :
4713
4805
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|.
4716
4807
4717
4808
1. Return [=success=] with data null.
4718
4809
0 commit comments