4 Copyright (c) 2012 The Chromium Authors. All rights reserved.
5 Use of this source code is governed by a BSD-style license that can be
6 found in the LICENSE file.
9 <title>Mouse Lock Example
</title>
10 <style type=
"text/css">
11 :-webkit-full-screen
{
17 <body title=
"This tooltip should not be shown if the mouse is locked.">
22 <li>left click in either of the two boxes; or
</li>
23 <li>right click in either of the boxes to ensure that it is focused and
24 then press Enter key. (You could verify that the tooltip window is
25 dismissed properly by this second approach.)
</li>
28 <li>Unlock mouse voluntarily:
33 <li>Unlock mouse involuntarily:
35 <li>lose focus; or
</li>
36 <li>press Esc key; or
</li>
37 <li>exit from
"tab fullscreen"/
"browser fullscreen"/
"Flash fullscreen".
39 <li>"tab fullscreen" refers to when a tab enters fullscreen mode via
40 the JS or Pepper fullscreen API;
</li>
41 <li>"browser fullscreen" refers to the user putting the browser
42 itself into fullscreen mode from the UI (e.g., pressing F11).
44 <li>"Flash fullscreen" refers to the fullscreen mode used by Pepper
45 Flash. You could enter Flash fullscreen by pressing 'f' key
46 when either of the boxes is focused, and exit by pressing Esc
54 <button onclick=
"ToggleFullscreen();">
57 <button onclick=
"AddAPlugin();">
60 <button onclick=
"RemoveAPlugin();">
61 Remove A Plugin (press 'x')
64 <div id=
"plugins_container">
69 plugins_container
= document
.getElementById("plugins_container");
73 function ToggleFullscreen() {
74 if (document
.webkitIsFullScreen
) {
75 document
.webkitCancelFullScreen();
77 document
.getElementById('container').webkitRequestFullScreen(
78 Element
.ALLOW_KEYBOARD_INPUT
);
81 function AddAPlugin() {
82 plugins_container
.insertAdjacentHTML("BeforeEnd",
83 '<object type="application/x-ppapi-example-mouse-lock" ' +
84 'width="300" height="300" border="2px"></object>');
86 function RemoveAPlugin() {
87 if (plugins_container
.firstElementChild
)
88 plugins_container
.removeChild(plugins_container
.firstElementChild
);
90 document
.body
.onkeydown = function (e
) {
91 if (String
.fromCharCode(e
.keyCode
) == "X")