Bug 60943

Summary: Disable keyboard input (with exceptions) in full-screen mode.
Product: WebKit Reporter: Jer Noble <jer.noble>
Component: New BugsAssignee: Jer Noble <jer.noble>
Status: RESOLVED FIXED    
Severity: Normal Keywords: InRadar
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch darin: review+

Description Jer Noble 2011-05-16 23:06:01 PDT
Disable keyboard input (with exceptions) in full-screen mode.
Comment 1 Jer Noble 2011-05-16 23:06:19 PDT
<rdar://problem/9450785>
Comment 2 Jer Noble 2011-05-16 23:14:15 PDT
Created attachment 93740 [details]
Patch
Comment 3 Darin Adler 2011-05-17 18:11:11 PDT
Comment on attachment 93740 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=93740&action=review

> Source/WebCore/page/EventHandler.cpp:2442
> +    if ((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))
> +        return true;
> +
> +    return false;

This seems quite unclear. Is this specific set of key code ranges straight out of some specification? If not, what is the rationale for what keys are listed here and what keys are not?

Also, if (x) return true; return false; is an anti-pattern. Just use a return.
Comment 4 Jer Noble 2011-05-17 21:19:38 PDT
(In reply to comment #3)
> (From update of attachment 93740 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=93740&action=review
> 
> > Source/WebCore/page/EventHandler.cpp:2442
> > +    if ((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))
> > +        return true;
> > +
> > +    return false;
> 
> This seems quite unclear. Is this specific set of key code ranges straight out of some specification? If not, what is the rationale for what keys are listed here and what keys are not?

Yes, it's specifically from the proposed Full Screen API:

"Toplevel browsing contexts can be in a "keys disabled" state. In this state, the user agent must suppress all keyup, keydown and keypress events whose keyCode is not in one of the following ranges:

DOM_VK_CANCEL to DOM_VK_CAPS_LOCK, inclusive
DOM_VK_SPACE to DOM_VK_DELETE, inclusive
DOM_VK_SEMICOLON to DOM_VK_EQUALS, inclusive
DOM_VK_MULTIPLY to DOM_VK_META, inclusive"

The key codes listed in the patch are the equivalents to the Mozilla-specific enums in the spec.

> Also, if (x) return true; return false; is an anti-pattern. Just use a return.

Sure thing.  Thanks!
Comment 5 Jer Noble 2011-05-18 00:38:41 PDT
Committed r86741: <http://trac.webkit.org/changeset/86741>