Bug 143452 - [Mac] WebKit is not honoring operating system preferences for secondary click behavior
Summary: [Mac] WebKit is not honoring operating system preferences for secondary click...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac All
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-04-06 12:38 PDT by Brent Fulgham
Modified: 2015-04-08 22:55 PDT (History)
9 users (show)

See Also:


Attachments
Patch (3.56 KB, patch)
2015-04-06 12:42 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (Corrects WK1 and WK2 cases) (5.54 KB, patch)
2015-04-06 16:24 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (v3: iOS Fixes) (5.29 KB, patch)
2015-04-07 08:55 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (13.20 KB, patch)
2015-04-07 14:45 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (13.86 KB, patch)
2015-04-07 16:16 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (25.17 KB, patch)
2015-04-07 22:23 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (35.35 KB, patch)
2015-04-08 14:19 PDT, Brent Fulgham
thorton: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2015-04-06 12:38:18 PDT
Users can adjust their system preference for how secondary click is interpreted by the operating system. WebKit is improperly hard-coding the button number for these mouse events, resulting in improper behavior.
Comment 1 Brent Fulgham 2015-04-06 12:38:36 PDT
<rdar://problem/20437483>
Comment 2 Brent Fulgham 2015-04-06 12:42:04 PDT
Created attachment 250222 [details]
Patch
Comment 3 Brent Fulgham 2015-04-06 16:24:59 PDT
Created attachment 250240 [details]
Patch (Corrects WK1 and WK2 cases)
Comment 4 Brent Fulgham 2015-04-07 08:55:32 PDT
Created attachment 250267 [details]
Patch (v3: iOS Fixes)
Comment 5 Tim Horton 2015-04-07 11:13:17 PDT
Comment on attachment 250267 [details]
Patch (v3: iOS Fixes)

I don't think this is the right solution. You'll note that Ctrl-Click hands the DOM a "left mouse down", so clearly context menus do not require a "right mouse button" click. And, we should lie and re-map what AppKit says about which button went down. So, please find a solution that doesn't involve remapping the buttons.
Comment 6 Brent Fulgham 2015-04-07 14:45:21 PDT
Created attachment 250306 [details]
Patch
Comment 7 WebKit Commit Bot 2015-04-07 14:48:38 PDT
Attachment 250306 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/PlatformMouseEvent.h:75:  Wrong number of spaces before statement. (expected: 31)  [whitespace/indent] [4]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Tim Horton 2015-04-07 15:02:45 PDT
Comment on attachment 250306 [details]
Patch

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

> Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm:1268
> +bool WebPage::shouldBeHandledAsContextClick(const PlatformMouseEvent& event)

Can this be static and can it live in WebEventFactory, right near typeForEvent?

> Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm:1271
> +    if (event.button() == WebCore::LeftButton && event.ctrlKey())
> +        return true;

Can we make sure that event.menuTypeForEvent is NSMenuTypeContextMenu and get rid of this logic?
Comment 9 Brent Fulgham 2015-04-07 16:16:59 PDT
Created attachment 250313 [details]
Patch
Comment 10 WebKit Commit Bot 2015-04-07 16:19:13 PDT
Attachment 250313 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/PlatformMouseEvent.h:75:  Wrong number of spaces before statement. (expected: 31)  [whitespace/indent] [4]
Total errors found: 1 in 12 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Brent Fulgham 2015-04-07 22:23:22 PDT
Created attachment 250334 [details]
Patch
Comment 12 WebKit Commit Bot 2015-04-07 22:25:49 PDT
Attachment 250334 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/PlatformMouseEvent.h:75:  Wrong number of spaces before statement. (expected: 31)  [whitespace/indent] [4]
Total errors found: 1 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Brent Fulgham 2015-04-08 14:19:05 PDT
Created attachment 250385 [details]
Patch
Comment 14 WebKit Commit Bot 2015-04-08 14:22:30 PDT
Attachment 250385 [details] did not pass style-queue:


ERROR: Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:46:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:47:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:48:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:50:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:51:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:52:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/platform/PlatformMouseEvent.h:75:  Wrong number of spaces before statement. (expected: 31)  [whitespace/indent] [4]
ERROR: Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm:230:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm:231:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm:232:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm:234:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm:235:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm:236:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 13 in 19 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Tim Horton 2015-04-08 16:00:35 PDT
Comment on attachment 250385 [details]
Patch

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

> Tools/TestWebKitAPI/Tests/WebKit2/MenuTypesForMouseEvents.cpp:72
> +TEST(WebKit2, NormalLeftClick)

these should have better names. The concatenated name WebKit2.NormalLeftClick will show up as the name of the test in the test runner. Maybe add something like NormalLeftClickMenuType or something?

> Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:49
> +                                    windowNumber:[[webView.get() window] windowNumber]

No .get()
Comment 16 Brent Fulgham 2015-04-08 19:42:24 PDT
Committed r182581: <http://trac.webkit.org/changeset/182581>
Comment 17 Alexey Proskuryakov 2015-04-08 20:18:21 PDT
The new API tests fail everywhere: https://build.webkit.org/builders/Apple%20Yosemite%20Release%20WK1%20%28Tests%29/builds/4301/steps/run-api-tests/logs/stdio

/Volumes/Data/slave/yosemite-release/build/Tools/TestWebKitAPI/Tests/mac/MenuTypesForMouseEvents.mm:59
Value of: pme.menuTypeForEvent()
  Actual: 0
Expected: expectedMenu
Which is: 1

Should we roll out?
Comment 18 Brent Fulgham 2015-04-08 20:39:40 PDT
(In reply to comment #17)
> The new API tests fail everywhere:
> https://build.webkit.org/builders/
> Apple%20Yosemite%20Release%20WK1%20%28Tests%29/builds/4301/steps/run-api-
> tests/logs/stdio
> 
> /Volumes/Data/slave/yosemite-release/build/Tools/TestWebKitAPI/Tests/mac/
> MenuTypesForMouseEvents.mm:59
> Value of: pme.menuTypeForEvent()
>   Actual: 0
> Expected: expectedMenu
> Which is: 1
> 
> Should we roll out?

I'll check in a fix. This is apparently a system preference, which I didn't notice when I tested locally.
Comment 19 Brent Fulgham 2015-04-08 20:43:36 PDT
Attempted fix checked in as r182584:

Committed r182584: <http://trac.webkit.org/changeset/182584>
Comment 20 mitz 2015-04-08 20:44:58 PDT
(In reply to comment #19)
> Attempted fix checked in as r182584:
> 
> Committed r182584: <http://trac.webkit.org/changeset/182584>

Normally we set up consistent user defaults for testing so that the tests pass no matter what the global system preferences are. Can’t we do that here?
Comment 21 Alexey Proskuryakov 2015-04-08 21:33:47 PDT
We certainly can't expect one who sees a failing test to look for comments in the code. The tests should just pass unconditionally.
Comment 22 Brent Fulgham 2015-04-08 22:41:46 PDT
(In reply to comment #21)
> We certainly can't expect one who sees a failing test to look for comments
> in the code. The tests should just pass unconditionally.

It turns out that this was not related to system preferences; it was an improper bitwise comparison. Interesting that the EWS did not catch this.

Does EWS not run the API tests?

Fix committed in r182589 <https://trac.webkit.org/changeset/182589>.
Comment 23 Alexey Proskuryakov 2015-04-08 22:55:29 PDT
> Does EWS not run the API tests?

It does not.