Skip to content

Commit d8194fc

Browse files
committed
Refactor fullscreen rejection handling to use WebIDL react pattern
This commit modernizes how the Screen Orientation specification responds to fullscreen request rejections by using the WebIDL 'react' concept instead of the previous flag-based approach. Changes: - Replace flag-based 'pending fullscreen request flag unset due to rejection' pattern - Use WebIDL 'react' pattern with 'pending fullscreen request promise' - Update reference to use proper 'pending fullscreen request flag' terminology - Extract duplicated descendant document logic into helper algorithm 'reject descendant document orientation promises' - Maintain all existing algorithm behavior while modernizing the specification architecture This enables cleaner, more maintainable specification text that follows modern WebIDL patterns for promise-based APIs and eliminates code duplication. The change complements the fullscreen spec changes in whatwg/fullscreen that add both the exported flag and promise definitions needed for this integration. Fixes #254 Fixes #255
1 parent 245ed44 commit d8194fc

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

index.html

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,19 +859,72 @@ <h2>
859859
<li>[=Apply orientation lock=] `null` to |topDocument|.
860860
</li>
861861
</ol>
862+
<h2>
863+
Rejecting descendant document orientation promises
864+
</h2>
865+
<p>
866+
To <dfn>reject descendant document orientation promises</dfn> for a {{Document}} |document|, the [=user agent=] MUST:
867+
</p>
868+
<ol class="algorithm">
869+
<li>If |document| is not a [=top-level browsing context=]'s [=navigable/active document=], abort these steps.</li>
870+
<li>Let |descendantDocs| be an [=ordered set=] consisting of |document|'s
871+
[=Document/descendant navigables=]'s [=navigable/active documents=], if any, in tree order.</li>
872+
<li>[=Set/For each=] |descendantDoc:Document| in |descendantDocs|:
873+
<ol>
874+
<li>If |descendantDoc| is not [=same origin=] with |document|, continue.</li>
875+
<li>If |descendantDoc|'s {{Document/[[orientationPendingPromise]]}} is not `null`,
876+
[=reject and nullify the current lock promise=] of |descendantDoc| with an {{"AbortError"}}.</li>
877+
</ol>
878+
</li>
879+
</ol>
862880
</section>
863881
<section id="fullscreen-interaction">
864882
<h2>
865883
Interaction with Fullscreen API
866884
</h2>
867885
<p>
868886
A user agent SHOULD restrict the use of {{ScreenOrientation/lock()}} to
869-
simple fullscreen documents as a [=pre-lock condition=]. [[fullscreen]]
887+
documents that meet the <dfn>fullscreen pre-lock condition</dfn> as a
888+
[=pre-lock condition=]. [[fullscreen]]
889+
</p>
890+
<p>
891+
A {{Document}} |document| meets the [=fullscreen pre-lock condition=]
892+
if any of the following are true:
893+
</p>
894+
<ol>
895+
<li>|document| has a [=fullscreen element=].
896+
</li>
897+
<li>|document| has its [=pending fullscreen request flag=] set.
898+
</li>
899+
<li>|document| is [=same origin=] with its [=top-level browsing
900+
context=]'s [=navigable/active document=], and that [=top-level
901+
browsing context=]'s [=navigable/active document=] meets one of the
902+
above conditions.
903+
</li>
904+
</ol>
905+
<p class="note">
906+
The third condition allows same-origin iframes to lock the screen
907+
orientation when their parent document is in fullscreen or has
908+
requested fullscreen. This prevents cross-origin documents from
909+
detecting the fullscreen state of their embedding document.
910+
</p>
911+
<p>
912+
When a [=document=] |doc| exits fullscreen, the user agent MUST:
870913
</p>
914+
<ol class="algorithm">
915+
<li>Run the [=fully unlock the screen orientation steps=] with |doc|.</li>
916+
<li>[=Reject descendant document orientation promises=] for |doc|.</li>
917+
</ol>
871918
<p>
872-
When a [=document=] exits fullscreen, it also runs the [=fully unlock
873-
the screen orientation steps=]. [[fullscreen]]
919+
[=React=] to a [=document=] |doc|'s [=pending fullscreen request
920+
promise=]. When the promise is [=reject|rejected=], run the following
921+
steps:
874922
</p>
923+
<ol class="algorithm">
924+
<li>If |doc|'s {{Document/[[orientationPendingPromise]]}} is not `null`,
925+
[=reject and nullify the current lock promise=] of |doc| with an {{"AbortError"}}.</li>
926+
<li>[=Reject descendant document orientation promises=] for |doc|.</li>
927+
</ol>
875928
</section>
876929
<section id="appmanifest-interaction">
877930
<h2>

0 commit comments

Comments
 (0)