Bug 167716 - Dismiss HTML form validation popover when pressing Escape key
Summary: Dismiss HTML form validation popover when pressing Escape key
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-01 16:49 PST by Chris Dumez
Modified: 2017-02-03 14:19 PST (History)
7 users (show)

See Also:


Attachments
Patch (7.26 KB, patch)
2017-02-01 17:02 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-elcapitan (1.01 MB, application/zip)
2017-02-01 18:05 PST, Build Bot
no flags Details
Archive of layout-test-results from ews116 for mac-elcapitan (1.76 MB, application/zip)
2017-02-01 18:14 PST, Build Bot
no flags Details
Patch (7.27 KB, patch)
2017-02-01 19:10 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (7.31 KB, patch)
2017-02-02 09:34 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (12.05 KB, patch)
2017-02-02 18:43 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2017-02-01 16:49:02 PST
Dismiss HTML form validation popover when pressing Escape key.
Comment 1 Chris Dumez 2017-02-01 16:49:41 PST
<rdar://problem/29872943>
Comment 2 Chris Dumez 2017-02-01 17:02:16 PST
Created attachment 300372 [details]
Patch
Comment 3 Build Bot 2017-02-01 18:05:08 PST
Comment on attachment 300372 [details]
Patch

Attachment 300372 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/2988735

New failing tests:
fast/forms/validation-bubble-escape-key-dismiss.html
Comment 4 Build Bot 2017-02-01 18:05:12 PST
Created attachment 300381 [details]
Archive of layout-test-results from ews100 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 5 Build Bot 2017-02-01 18:14:33 PST
Comment on attachment 300372 [details]
Patch

Attachment 300372 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/2988736

New failing tests:
fast/forms/validation-bubble-escape-key-dismiss.html
Comment 6 Build Bot 2017-02-01 18:14:36 PST
Created attachment 300383 [details]
Archive of layout-test-results from ews116 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 7 Chris Dumez 2017-02-01 19:10:31 PST
Created attachment 300385 [details]
Patch
Comment 8 Chris Dumez 2017-02-02 09:34:38 PST
Created attachment 300416 [details]
Patch
Comment 9 Tim Horton 2017-02-02 12:48:56 PST
Comment on attachment 300416 [details]
Patch

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

> Source/WebKit/mac/WebView/WebFrameView.mm:1092
> +#if PLATFORM(MAC)

Why Mac specific? Did we not implement for UIWebView? Seems like we would want this to work with a hardware keyboard on iOS.

> Source/WebKit2/UIProcess/WebPageProxy.cpp:1989
> +    if (event.key() == "Escape")

Wonder if this should be plumbed the same way as escape-to-dismiss-spelling-suggestions or escape-to-exit-pointer-lock and whatnot. The fact that there aren't any other behaviors here makes me dubious that this is the right place for this.
Comment 10 Chris Dumez 2017-02-02 16:12:23 PST
Comment on attachment 300416 [details]
Patch

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

>> Source/WebKit/mac/WebView/WebFrameView.mm:1092
>> +#if PLATFORM(MAC)
> 
> Why Mac specific? Did we not implement for UIWebView? Seems like we would want this to work with a hardware keyboard on iOS.

1. This is not Form validation is not implemented on iOS / WK1.
2. kVK_Escape is only valid on Mac.

>> Source/WebKit2/UIProcess/WebPageProxy.cpp:1989
>> +    if (event.key() == "Escape")
> 
> Wonder if this should be plumbed the same way as escape-to-dismiss-spelling-suggestions or escape-to-exit-pointer-lock and whatnot. The fact that there aren't any other behaviors here makes me dubious that this is the right place for this.

I am not familiar with those. I'll take a look.
Comment 11 Chris Dumez 2017-02-02 18:43:51 PST
Created attachment 300483 [details]
Patch
Comment 12 Simon Fraser (smfr) 2017-02-03 12:09:53 PST
Comment on attachment 300483 [details]
Patch

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

> Source/WebCore/page/EventHandler.cpp:3063
> +    if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE) {
> +        if (auto* page = m_frame.page()) {
> +            if (auto* validationMessageClient = page->validationMessageClient())
> +                validationMessageClient->hideAnyValidationMessage();
> +        }
> +    }

Should Escape dismiss any bubble, or only the one on the field that's focused?

Also, does this work on iOS with a hardware keyboard?
Comment 13 Chris Dumez 2017-02-03 12:12:12 PST
(In reply to comment #12)
> Comment on attachment 300483 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=300483&action=review
> 
> > Source/WebCore/page/EventHandler.cpp:3063
> > +    if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE) {
> > +        if (auto* page = m_frame.page()) {
> > +            if (auto* validationMessageClient = page->validationMessageClient())
> > +                validationMessageClient->hideAnyValidationMessage();
> > +        }
> > +    }
> 
> Should Escape dismiss any bubble, or only the one on the field that's
> focused?

There is always only one bubble visible so I don't think it matters.

> 
> Also, does this work on iOS with a hardware keyboard?

The code does not have anything Mac specific so I don't think why not. That said, I do not have such configuration to test.
Comment 14 Chris Dumez 2017-02-03 12:15:41 PST
(In reply to comment #13)
> (In reply to comment #12)
> > Comment on attachment 300483 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=300483&action=review
> > 
> > > Source/WebCore/page/EventHandler.cpp:3063
> > > +    if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE) {
> > > +        if (auto* page = m_frame.page()) {
> > > +            if (auto* validationMessageClient = page->validationMessageClient())
> > > +                validationMessageClient->hideAnyValidationMessage();
> > > +        }
> > > +    }
> > 
> > Should Escape dismiss any bubble, or only the one on the field that's
> > focused?
> 
> There is always only one bubble visible so I don't think it matters.

Also, if a validation bubble is visible, then it means its associated field is focused. Doing anything (like focusing another field) would make the bubble go away.

> 
> > 
> > Also, does this work on iOS with a hardware keyboard?
> 
> The code does not have anything Mac specific so I don't think why not. That
> said, I do not have such configuration to test.
Comment 15 Chris Dumez 2017-02-03 12:42:37 PST
(In reply to comment #13)
> (In reply to comment #12)
> > Comment on attachment 300483 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=300483&action=review
> > 
> > > Source/WebCore/page/EventHandler.cpp:3063
> > > +    if (initialKeyEvent.type() == PlatformEvent::KeyDown && initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE) {
> > > +        if (auto* page = m_frame.page()) {
> > > +            if (auto* validationMessageClient = page->validationMessageClient())
> > > +                validationMessageClient->hideAnyValidationMessage();
> > > +        }
> > > +    }
> > 
> > Should Escape dismiss any bubble, or only the one on the field that's
> > focused?
> 
> There is always only one bubble visible so I don't think it matters.
> 
> > 
> > Also, does this work on iOS with a hardware keyboard?
> 
> The code does not have anything Mac specific so I don't think why not. That
> said, I do not have such configuration to test.

Oh, I have the right configuration now, I'll confirm it works on iOS shortly.
Comment 16 Chris Dumez 2017-02-03 14:19:48 PST
Comment on attachment 300483 [details]
Patch

Clearing flags on attachment: 300483

Committed r211653: <http://trac.webkit.org/changeset/211653>
Comment 17 Chris Dumez 2017-02-03 14:19:53 PST
All reviewed patches have been landed.  Closing bug.