2011-05-16 Jeremy Noble <jer.noble@apple.com>
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 May 2011 07:38:30 +0000 (07:38 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 May 2011 07:38:30 +0000 (07:38 +0000)
        Reviewed by Darin Adler.

        Disable keyboard input (with exceptions) in full-screen mode.
        https://bugs.webkit.org/show_bug.cgi?id=60943

        * fullscreen/full-screen-keyboard-disabled-expected.txt: Added.
        * fullscreen/full-screen-keyboard-disabled.html: Added.
        * fullscreen/full-screen-keyboard-enabled-expected.txt: Added.
        * fullscreen/full-screen-keyboard-enabled.html: Added.
2011-05-16  Jeremy Noble  <jer.noble@apple.com>

        Reviewed by Darin Adler.

        Disable keyboard input (with exceptions) in full-screen mode.
        https://bugs.webkit.org/show_bug.cgi?id=60943

        Tests: fullscreen/full-screen-keyboard-disabled.html
               fullscreen/full-screen-keyboard-enabled.html

        * page/EventHandler.cpp:
        (WebCore::EventHandler::isKeyEventAllowedInFullScreen): Added.  Implements the
            list of allowed keyboard events in the proposed API.
        (WebCore::EventHandler::keyEvent): Discard events which are not allowed in
            full-screen mode.
        * page/EventHandler.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86741 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fullscreen/full-screen-keyboard-disabled-expected.txt [new file with mode: 0644]
LayoutTests/fullscreen/full-screen-keyboard-disabled.html [new file with mode: 0644]
LayoutTests/fullscreen/full-screen-keyboard-enabled-expected.txt [new file with mode: 0644]
LayoutTests/fullscreen/full-screen-keyboard-enabled.html [new file with mode: 0644]
LayoutTests/platform/mac-wk2/Skipped
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h

index 1f7fd33..5d63178 100644 (file)
@@ -1,3 +1,15 @@
+2011-05-16  Jeremy Noble  <jer.noble@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Disable keyboard input (with exceptions) in full-screen mode.
+        https://bugs.webkit.org/show_bug.cgi?id=60943
+
+        * fullscreen/full-screen-keyboard-disabled-expected.txt: Added.
+        * fullscreen/full-screen-keyboard-disabled.html: Added.
+        * fullscreen/full-screen-keyboard-enabled-expected.txt: Added.
+        * fullscreen/full-screen-keyboard-enabled.html: Added.
+
 2011-05-17  Jeremy Noble  <jer.noble@apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fullscreen/full-screen-keyboard-disabled-expected.txt b/LayoutTests/fullscreen/full-screen-keyboard-disabled-expected.txt
new file mode 100644 (file)
index 0000000..18fb026
--- /dev/null
@@ -0,0 +1,6 @@
+EVENT(webkitfullscreenchange)
+EXPECTED (document.webkitIsFullScreen == 'true') OK
+EVENT(keypress)
+EXPECTED (event.keyCode == '32') OK
+END OF TEST
+This tests that full screen mode does not allow alphanumeric key events. Press space to continue, then press an alphanumeric key, followed by space.
diff --git a/LayoutTests/fullscreen/full-screen-keyboard-disabled.html b/LayoutTests/fullscreen/full-screen-keyboard-disabled.html
new file mode 100644 (file)
index 0000000..b835f9a
--- /dev/null
@@ -0,0 +1,40 @@
+<body>
+<script src="full-screen-test.js"></script>
+<p>This tests that full screen mode does not allow alphanumeric key events.  Press space to continue, then press an alphanumeric key, followed by space.
+<span></span>
+<script>
+    // Bail out early if the full screen API is not enabled or is missing:
+    if (Element.prototype.webkitRequestFullScreen == undefined) {
+        logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
+        endTest();
+    } else {
+        var callback;
+        var fullscreenChanged = function(event)
+        {
+            if (callback)
+                callback(event)
+        };
+        waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
+
+        var spanEnteredFullScreen = function() {
+            callback = null;
+            testExpected("document.webkitIsFullScreen", true);
+            if (window.layoutTestController && eventSender.keyDown) {
+                waitForEvent(document, 'keypress', keyPressed);
+                eventSender.keyDown('a', []);
+                eventSender.keyDown(' ', []);
+            }
+        };
+
+        var keyPressed = function(event) {
+            testExpected('event.keyCode', 32); // Space
+            endTest();
+            document.webkitCancelFullScreen();
+        }
+        waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
+
+        var span = document.getElementsByTagName('span')[0];
+        callback = spanEnteredFullScreen;
+        runWithKeyDown(function(){span.webkitRequestFullScreen()});
+    }
+</script>
diff --git a/LayoutTests/fullscreen/full-screen-keyboard-enabled-expected.txt b/LayoutTests/fullscreen/full-screen-keyboard-enabled-expected.txt
new file mode 100644 (file)
index 0000000..da4b736
--- /dev/null
@@ -0,0 +1,6 @@
+EVENT(webkitfullscreenchange)
+EXPECTED (document.webkitIsFullScreen == 'true') OK
+EVENT(keypress)
+EXPECTED (event.keyCode == '97') OK
+END OF TEST
+This tests that full screen mode does not allow alphanumeric key events. Press space to continue, then press the 'a' key.
diff --git a/LayoutTests/fullscreen/full-screen-keyboard-enabled.html b/LayoutTests/fullscreen/full-screen-keyboard-enabled.html
new file mode 100644 (file)
index 0000000..e1726cb
--- /dev/null
@@ -0,0 +1,37 @@
+<body>
+<script src="full-screen-test.js"></script>
+<p>This tests that full screen mode does not allow alphanumeric key events.  Press space to continue, then press the 'a' key.
+<span></span>
+<script>
+    // Bail out early if the full screen API is not enabled or is missing:
+    if (Element.prototype.webkitRequestFullScreen == undefined) {
+        logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
+        endTest();
+    } else {
+        var callback;
+        var fullscreenChanged = function(event)
+        {
+            if (callback)
+                callback(event)
+        };
+        waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
+
+        var spanEnteredFullScreen = function() {
+            callback = null;
+            testExpected("document.webkitIsFullScreen", true);
+            if (window.layoutTestController && eventSender.keyDown) {
+                waitForEvent(document, 'keypress', keyPressed);
+                eventSender.keyDown('a', []);
+            }
+        };
+        
+        var keyPressed = function(event) {
+            testExpected('event.keyCode', 97); // 'A'
+            endTest();
+        }
+        
+        var span = document.getElementsByTagName('span')[0];
+        callback = spanEnteredFullScreen;
+        runWithKeyDown(function(){span.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)});
+    }
+</script>
index fc61545..211155d 100644 (file)
@@ -1679,16 +1679,7 @@ inspector/console/console-long-eval-crash.html
 
 # WebKit2 needs fullscreen support
 # https://bugs.webkit.org/show_bug.cgi?id=56318
-fullscreen/full-screen-css.html
-fullscreen/full-screen-iframe-allowed.html
-fullscreen/full-screen-iframe-not-allowed.html
-fullscreen/full-screen-frameset.html
-fullscreen/full-screen-remove-ancestor.html
-fullscreen/full-screen-remove.html
-fullscreen/full-screen-request.html
-fullscreen/full-screen-twice.html
-fullscreen/full-screen-zIndex.html
-fullscreen/video-specified-size.html
+fullscreen/
 
 # WebKit2 needs to support synchronous creation of about:blank/data:url frames
 fast/dom/HTMLDocument/hasFocus.html
index 2e7aae1..90f48f3 100644 (file)
@@ -1,3 +1,20 @@
+2011-05-16  Jeremy Noble  <jer.noble@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Disable keyboard input (with exceptions) in full-screen mode.
+        https://bugs.webkit.org/show_bug.cgi?id=60943
+
+        Tests: fullscreen/full-screen-keyboard-disabled.html
+               fullscreen/full-screen-keyboard-enabled.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::isKeyEventAllowedInFullScreen): Added.  Implements the 
+            list of allowed keyboard events in the proposed API.
+        (WebCore::EventHandler::keyEvent): Discard events which are not allowed in
+            full-screen mode.
+        * page/EventHandler.h:
+
 2011-05-17  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Reviewed by Dirk Schulze.
index 393d7cb..071796b 100644 (file)
@@ -2425,10 +2425,30 @@ bool EventHandler::needsKeyboardEventDisambiguationQuirks() const
 }
 #endif
 
+#if ENABLE(FULLSCREEN_API)
+bool EventHandler::isKeyEventAllowedInFullScreen(const PlatformKeyboardEvent& keyEvent) const
+{
+    Document* document = m_frame->document();
+    if (document->webkitFullScreenKeyboardInputAllowed())
+        return true;
+
+    int keyCode = keyEvent.windowsVirtualKeyCode();
+    return (keyCode >= VK_BACK && keyCode <= VK_CAPITAL)
+        || (keyCode >= VK_SPACE && keyCode <= VK_DELETE)
+        || (keyCode >= VK_OEM_1 && keyCode <= VK_OEM_PLUS)
+        || (keyCode >= VK_MULTIPLY && keyCode <= VK_OEM_8);
+}
+#endif
+
 bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
 {
     RefPtr<FrameView> protector(m_frame->view()); 
 
+#if ENABLE(FULLSCREEN_API)
+    if (m_frame->document()->webkitIsFullScreen() && !isKeyEventAllowedInFullScreen(initialKeyEvent))
+        return false;
+#endif
+
     if (initialKeyEvent.windowsVirtualKeyCode() == VK_CAPITAL)
         capsLockStateMayHaveChanged();
 
index 26e8874..107f1bb 100644 (file)
@@ -351,6 +351,10 @@ private:
     PlatformMouseEvent currentPlatformMouseEvent() const;
 #endif
 
+#if ENABLE(FULLSCREEN_API)
+    bool isKeyEventAllowedInFullScreen(const PlatformKeyboardEvent&) const;
+#endif
+
     Frame* m_frame;
 
     bool m_mousePressed;