WebAPI/ScreenOrientation: Difference between revisions

Jump to navigation Jump to search
(Created page with "== Proposed API == partial interface Screen { readonly attribute DOMString orientation; attribute Function onorientationchange; boolean lockOrientation(DO...")
 
Line 13: Line 13:


Whenever the device orientation changes, an <code>"orientationchange"</code> event is fired on the Screen object *before* the rotation happens.
Whenever the device orientation changes, an <code>"orientationchange"</code> event is fired on the Screen object *before* the rotation happens.
The <code>lockOrientation</code> function takes any of the following values, or a comma-separated combination thereof: <code>"landscape"</code>, <code>"portrait"</code>, <code>"landscape-primary"</code>, <code>"landscape-secondary"</code>, <code>"portrait-primary"</code> or <code>"portrait-secondary"</code>. <code>"landscape"</code> and <code>"portrait"</code> refer to "any landscape orientation" and "any portrait orientation" respectively.
The function returns <code>false</code> if locking to the requested direction isn't allowed and <code>true</code> otherwise. If <code>false</code> is returned then the function takes no other actions.
== Security considerations ==
It could be annoying for a user if a page repeatedly sets the orientation using the lockOrientation function. It could even prevent the user from navigating away from the page since the location or the browser UI could be jumping around too fast.
We can either solve this by only allowing the orientation lock to be changed if we are in fullscreen mode, or in an app (which doesn't have navigation UI). Or we can add "spam" protection such that we only allow the orientation lock to be changed in response to a user action or if it hasn't been changed the last N seconds.
Confirmed users
716

edits

Navigation menu