Skip to content

Commit f8595a0

Browse files
emulation.setScreenOrientationOverride (#925)
WPT tests: web-platform-tests/wpt#53327
1 parent 6120680 commit f8595a0

File tree

1 file changed

+144
-1
lines changed

1 file changed

+144
-1
lines changed

index.bs

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ spec: GEOLOCATION; urlPrefix: https://www.w3.org/TR/geolocation/
190190
text: GeolocationPositionError; url: #dom-geolocationpositionerror
191191
text: POSITION_UNAVAILABLE; url: #dom-geolocationpositionerror-position_unavailable
192192
text: set emulated position data; url: #dfn-set-emulated-position-data
193+
spec: SCREEN-ORIENTATION; urlPrefix: https://www.w3.org/TR/screen-orientation
194+
type: dfn
195+
text: current orientation angle; url: #dfn-current-orientation-angle
196+
text: current orientation type; url: #dfn-current-orientation-type
197+
text: screen orientation; url: #dom-screenorientation
198+
text: screen orientation change steps; url: #dfn-screen-orientation-change-steps
199+
text: screen orientation values lists; url: #dfn-screen-orientation-values-lists
193200
spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
194201
type: dfn
195202
text: 2D context creation algorithm; url: canvas.html#2d-context-creation-algorithm
@@ -4858,6 +4865,10 @@ TODO: Move it as a hook in the html spec instead.
48584865
1. If [=geolocation overrides map=] [=map/contains=] |user context|,
48594866
[=set emulated position data=] with |navigable| and [=geolocation overrides map=][|user context|].
48604867

4868+
1. If [=screen orientation overrides map=] [=map/contains=] |user context|,
4869+
[=set emulated screen orientation=] with |navigable| and
4870+
[=screen orientation overrides map=][|user context|].
4871+
48614872
1. If [=viewport overrides map=] [=map/contains=] |user context|:
48624873

48634874
1. If |navigable| is a [=/top-level traversable=] and the <code>viewport</code> field of
@@ -5756,7 +5767,8 @@ relating to emulation of browser APIs.
57565767

57575768
<pre class="cddl" data-cddl-module="remote-cddl">
57585769
EmulationCommand = (
5759-
emulation.SetGeolocationOverride
5770+
emulation.SetGeolocationOverride //
5771+
emulation.SetScreenOrientationOverride
57605772
)
57615773
</pre>
57625774

@@ -5771,6 +5783,13 @@ A <dfn>geolocation override</dfn> is a [=struct=] with:
57715783

57725784
A [=remote end=] has a <dfn>geolocation overrides map</dfn> which is a weak map between [=user contexts=] and [=geolocation override=].
57735785

5786+
A <dfn>screen orientation override</dfn> is a [=struct=] with:
5787+
5788+
* [=struct/item=] named <dfn attribute for="screen orientation override">natural</dfn> which is a string;
5789+
* [=struct/item=] named <dfn attribute for="screen orientation override">type</dfn> which is a string;
5790+
5791+
A [=remote end=] has a <dfn>screen orientation overrides map</dfn> which is a weak
5792+
map between [=user contexts=] and [=screen orientation override=].
57745793

57755794
### Commands ### {#module-emulation-commands}
57765795

@@ -5879,6 +5898,130 @@ The [=remote end steps=] with |command parameters| are:
58795898

58805899
</div>
58815900

5901+
#### The emulation.setScreenOrientationOverride Command #### {#command-emulation-setScreenOrientationOverride}
5902+
5903+
The <dfn export for=commands>emulation.setScreenOrientationOverride</dfn> command
5904+
emulates [=screen orientation=] of the given top-level traversables or user contexts.
5905+
5906+
<dl>
5907+
<dt>Command Type</dt>
5908+
<dd>
5909+
<pre class="cddl" data-cddl-module="remote-cddl">
5910+
emulation.SetScreenOrientationOverride = (
5911+
method: "emulation.setScreenOrientationOverride",
5912+
params: emulation.SetScreenOrientationOverrideParameters
5913+
)
5914+
5915+
emulation.ScreenOrientationNatural = "portrait" / "landscape"
5916+
emulation.ScreenOrientationType = "portrait-primary" / "portrait-secondary" / "landscape-primary" / "landscape-secondary"
5917+
5918+
emulation.ScreenOrientation = {
5919+
natural: emulation.ScreenOrientationNatural,
5920+
type: emulation.ScreenOrientationType
5921+
}
5922+
5923+
emulation.SetScreenOrientationOverrideParameters = {
5924+
screenOrientation: emulation.ScreenOrientation / null,
5925+
? contexts: [+browsingContext.BrowsingContext],
5926+
? userContexts: [+browser.UserContext],
5927+
}
5928+
</pre>
5929+
</dd>
5930+
<dt>Result Type</dt>
5931+
<dd>
5932+
<code>
5933+
EmptyResult
5934+
</code>
5935+
</dd>
5936+
</dl>
5937+
5938+
<div algorithm>
5939+
5940+
To <dfn>set emulated screen orientation</dfn> given |navigable| and
5941+
|emulated screen orientation|:
5942+
5943+
Issue: Move this algorithm to screen orientation specification.
5944+
5945+
1. If |emulated screen orientation| is null:
5946+
5947+
1. Set |navigable|'s [=current orientation angle=] to
5948+
implementation-defined default.
5949+
5950+
1. Set |navigable|'s [=current orientation type=] to
5951+
implementation-defined default.
5952+
5953+
1. Otherwise:
5954+
5955+
1. Let |emulated orientation type| be
5956+
|emulated screen orientation|["<code>type</code>"].
5957+
5958+
1. Let |emulated orientation angle| be the angle associated with
5959+
|emulated orientation type| for screens with
5960+
|emulated screen orientation|["<code>natural</code>"] orientations as defined
5961+
in [=screen orientation values lists=].
5962+
5963+
1. Set [=current orientation angle=] to |emulated orientation angle|.
5964+
5965+
1. Set [=current orientation type=] to |emulated orientation type|.
5966+
5967+
1. Run the [=screen orientation change steps=] with the |navigable|'s
5968+
[=active document=].
5969+
5970+
</div>
5971+
5972+
<div algorithm="remote end steps for emulation.setScreenOrientationOverride">
5973+
5974+
The [=remote end steps=] with |command parameters| are:
5975+
5976+
1. If the implementation is unable to adjust the [=screen orientations=]
5977+
parameters with the given |command parameters| for any reason, return
5978+
[=error=] with [=error code=] [=unsupported operation=].
5979+
5980+
1. If |command parameters| [=map/contains=] "<code>userContexts</code>"
5981+
and |command parameters| [=map/contains=] "<code>contexts</code>",
5982+
return [=error=] with [=error code=] [=invalid argument=].
5983+
5984+
1. If |command parameters| doesn't [=map/contain=] "<code>userContexts</code>"
5985+
and |command parameters| doesn't [=map/contain=] "<code>contexts</code>",
5986+
return [=error=] with [=error code=] [=invalid argument=].
5987+
5988+
1. Let |emulated screen orientation| be
5989+
|command parameters|["<code>screenOrientation</code>"].
5990+
5991+
1. Let |navigables| be a [=/set=].
5992+
5993+
1. If the <code>contexts</code> field of |command parameters| is present:
5994+
5995+
1. Let |navigables| be the result of [=trying=] to
5996+
[=get valid top-level traversables by ids=] with
5997+
|command parameters|["<code>contexts</code>"].
5998+
5999+
1. Otherwise, if the <code>userContexts</code> field of |command parameters| is
6000+
present:
6001+
6002+
1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=]
6003+
with |command parameters|["<code>userContexts</code>"].
6004+
6005+
1. For each |user context| of |user contexts|:
6006+
6007+
1. [=map/Set=] [=screen orientation overrides map=][|user context|] to
6008+
|emulated screen orientation|.
6009+
6010+
1. [=list/For each=] |top-level traversable| of the list of all
6011+
[=/top-level traversables=] whose [=associated user context=] is
6012+
|user context|:
6013+
6014+
1. [=list/Append=] |top-level traversable| to |navigables|.
6015+
6016+
1. For each |navigable| of |navigables|:
6017+
6018+
1. [=Set emulated screen orientation=] with |navigable| and
6019+
|emulated screen orientation|.
6020+
6021+
1. Return [=success=] with data null.
6022+
6023+
</div>
6024+
58826025
## The network Module ## {#module-network}
58836026

58846027
The <dfn export for=modules>network</dfn> module contains commands and events

0 commit comments

Comments
 (0)