Bug 83330 - Allow certain Char events in fullscreen
Summary: Allow certain Char events in fullscreen
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 83014
  Show dependency treegraph
 
Reported: 2012-04-05 16:55 PDT by Cem Kocagil
Modified: 2012-04-12 13:23 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.27 KB, patch)
2012-04-05 16:59 PDT, Cem Kocagil
ap: review-
Details | Formatted Diff | Diff
Patch (1.34 KB, patch)
2012-04-08 17:06 PDT, Cem Kocagil
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cem Kocagil 2012-04-05 16:55:41 PDT
Currently only KeyDown/KeyUp/RawKeyDown are allowed. Char events should be allowed for processing space key events of type Char.
Comment 1 Cem Kocagil 2012-04-05 16:59:23 PDT
Created attachment 135938 [details]
Patch
Comment 2 Ryosuke Niwa 2012-04-06 10:17:46 PDT
What is the rationale for this change? Is there any spec for this?
Comment 3 Cem Kocagil 2012-04-06 10:32:36 PDT
(In reply to comment #2)
> What is the rationale for this change? Is there any spec for this?

According to PlatformKeyboardEvent.h, PlatformKeyboardEvent::windowsVirtualKeyCode() returns zero for Char events. Therefore, space events of type Char are currently not allowed in fullscreen mode. They should be allowed, because there are tests that expect this and Firefox also does this.

However, these tests that seem to check space key events currently pass on Chromium because Chromium doesn't implement windowsVirtualKeyCode as specified in PlatformKeyboardEvent.h. I have not investigated how it works in other ports. Perhaps the windowsVirtualKeyCode() specification in the header is incorrect?
Comment 4 Alexey Proskuryakov 2012-04-06 11:16:49 PDT
Comment on attachment 135938 [details]
Patch

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

It is expected behavior that keypress events (corresponding to Char) have a character code, but no virtual key code.

It's quite unfortunate that information about key bindings is hardcoded here. In fact, existing code below makes me quite suspicious (why VK_BACK? why VK_OEM_1?)

> Source/WebCore/page/EventHandler.cpp:2728
> +        char character = keyEvent.text()[0];

This character is Unicode, so converting to char loses high bits. Also, this should check that length of text is 1.
Comment 5 Cem Kocagil 2012-04-06 13:25:18 PDT
(In reply to comment #4)
> (From update of attachment 135938 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=135938&action=review
> 
> It is expected behavior that keypress events (corresponding to Char) have a character code, but no virtual key code.

In that case, is PlatformKeyboardEvent.h inaccurate? Or by "no virtual key code" do you mean a windowsVirtualKeyCode value of zero?

> It's quite unfortunate that information about key bindings is hardcoded here. In fact, existing code below makes me quite suspicious (why VK_BACK? why VK_OEM_1?)

Without VK_BACK, backspace on textboxes do not work and takes us back to the previous page. Without VK_OEM_1, I think the semicolon key wouldn't work.

> > Source/WebCore/page/EventHandler.cpp:2728
> > +        char character = keyEvent.text()[0];
> 
> This character is Unicode, so converting to char loses high bits. Also, this should check that length of text is 1.

Can we not assume that the string always has a null character?
If windowsVirtualKeyCode is supposed to give us the char code, should we use it instead of ".text()[0]"?

I'll fix these and character type and resubmit a new patch, if these are the reasons for the r-. Please let me know if there's any particular refactoring that you think should be done.
Comment 6 Alexey Proskuryakov 2012-04-06 16:58:26 PDT
> Or by "no virtual key code" do you mean a windowsVirtualKeyCode value of zero?

I mean that text events such as keypress don't have a virtual key code conceptually - they may not even be initiated by a keyboard. At code level, that corresponds to a zero value.

> Without VK_BACK, backspace on textboxes do not work and takes us back to the previous page. Without VK_OEM_1, I think the semicolon key wouldn't work.

Why is the semicolon expected to work, in the first place?

Backspace is an example of why this is a very poor place to hardcode key behaviors - it may or may not cause a navigation, but that's decided elsewhere.

> Can we not assume that the string always has a null character?

I'm not sure about that, but I know that it can be longer than 1 character.
Comment 7 Cem Kocagil 2012-04-08 17:06:09 PDT
Created attachment 136163 [details]
Patch
Comment 8 Cem Kocagil 2012-04-08 17:28:49 PDT
(In reply to comment #6)
> Why is the semicolon expected to work, in the first place?

You're right, I can't see a reason for that either.

> > Can we not assume that the string always has a null character?
> 
> I'm not sure about that, but I know that it can be longer than 1 character.

I changed the type to UChar and it checks the length now. Could you review this patch so we can fix the current implementation?
Comment 9 Alexey Proskuryakov 2012-04-08 18:54:46 PDT
Jer Noble is our fullscreen expert, I'd like him to do review.

Please mark the patch as r? to make sure it doesn't get overlooked.
Comment 10 Jer Noble 2012-04-09 09:11:00 PDT
(In reply to comment #9)
> Jer Noble is our fullscreen expert, I'd like him to do review.
> 
> Please mark the patch as r? to make sure it doesn't get overlooked.

This looks fine, though the next revision of the W3C Full Screen spec does not include any keyboard limitations (all key press events will be supported in full screen).  So it's likely this code will eventually be obsoleted.  In the meantime, this patch should be fine.
Comment 11 WebKit Review Bot 2012-04-12 13:23:45 PDT
Comment on attachment 136163 [details]
Patch

Clearing flags on attachment: 136163

Committed r114024: <http://trac.webkit.org/changeset/114024>
Comment 12 WebKit Review Bot 2012-04-12 13:23:50 PDT
All reviewed patches have been landed.  Closing bug.