Skip to content

Commit 6097876

Browse files
REGRESSION(206450): WebKit2PlatformMouseEvent m_modifierFlags not set
https://bugs.webkit.org/show_bug.cgi?id=171297 <rdar://problem/31530719> Reviewed by Geoffrey Garen. Source/WebKit2: * Shared/WebEventConversion.cpp: (WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent): Tools: * TestWebKitAPI/PlatformWebView.h: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2/EventModifiers.cpp: Added. (TestWebKitAPI::didFinishLoadForFrame): (TestWebKitAPI::mouseDidMoveOverElement): (TestWebKitAPI::setClients): (TestWebKitAPI::TEST): * TestWebKitAPI/mac/PlatformWebViewMac.mm: (TestWebKitAPI::PlatformWebView::simulateRightClick): (TestWebKitAPI::PlatformWebView::simulateMouseMove): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@215790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 3008cf4 commit 6097876

File tree

8 files changed

+134
-19
lines changed

8 files changed

+134
-19
lines changed

Source/WebKit2/ChangeLog

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2017-04-25 Alex Christensen <[email protected]>
2+
3+
REGRESSION(206450): WebKit2PlatformMouseEvent m_modifierFlags not set
4+
https://bugs.webkit.org/show_bug.cgi?id=171297
5+
<rdar://problem/31530719>
6+
7+
Reviewed by Geoffrey Garen.
8+
9+
* Shared/WebEventConversion.cpp:
10+
(WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent):
11+
112
2017-04-25 Wenson Hsieh <[email protected]>
213

314
Unreviewed, speculative build fix

Source/WebKit2/Shared/WebEventConversion.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ class WebKit2PlatformMouseEvent : public WebCore::PlatformMouseEvent {
109109
m_eventNumber = webEvent.eventNumber();
110110
m_menuTypeForEvent = webEvent.menuTypeForEvent();
111111
#endif
112+
m_modifierFlags = 0;
113+
if (webEvent.shiftKey())
114+
m_modifierFlags |= WebEvent::ShiftKey;
115+
if (webEvent.controlKey())
116+
m_modifierFlags |= WebEvent::ControlKey;
117+
if (webEvent.altKey())
118+
m_modifierFlags |= WebEvent::AltKey;
119+
if (webEvent.metaKey())
120+
m_modifierFlags |= WebEvent::MetaKey;
112121
}
113122
};
114123

Tools/ChangeLog

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2017-04-25 Alex Christensen <[email protected]>
2+
3+
REGRESSION(206450): WebKit2PlatformMouseEvent m_modifierFlags not set
4+
https://bugs.webkit.org/show_bug.cgi?id=171297
5+
<rdar://problem/31530719>
6+
7+
Reviewed by Geoffrey Garen.
8+
9+
* TestWebKitAPI/PlatformWebView.h:
10+
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
11+
* TestWebKitAPI/Tests/WebKit2/EventModifiers.cpp: Added.
12+
(TestWebKitAPI::didFinishLoadForFrame):
13+
(TestWebKitAPI::mouseDidMoveOverElement):
14+
(TestWebKitAPI::setClients):
15+
(TestWebKitAPI::TEST):
16+
* TestWebKitAPI/mac/PlatformWebViewMac.mm:
17+
(TestWebKitAPI::PlatformWebView::simulateRightClick):
18+
(TestWebKitAPI::PlatformWebView::simulateMouseMove):
19+
120
2017-04-25 Wenson Hsieh <[email protected]>
221

322
Unreviewed, temporarily disable the data interaction unit tests.

Tools/TestWebKitAPI/PlatformWebView.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class PlatformWebView {
6969
void simulateSpacebarKeyPress();
7070
void simulateAltKeyPress();
7171
void simulateRightClick(unsigned x, unsigned y);
72-
void simulateMouseMove(unsigned x, unsigned y);
72+
void simulateMouseMove(unsigned x, unsigned y, WKEventModifiers = 0);
7373
#if PLATFORM(MAC)
7474
void simulateButtonClick(WKEventMouseButton, unsigned x, unsigned y, WKEventModifiers);
7575
#endif

Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */; };
197197
5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C6E65411D5CEF8500F7862E /* URLParser.cpp */; };
198198
5C726D6F1D3EE06E00C5E1A1 /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */; };
199+
5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C79640F1EB0269B0075D74C /* EventModifiers.cpp */; };
199200
5C838F7F1DB04F900082858F /* LoadInvalidURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */; };
200201
5C9E56851DF9145400C9EE33 /* WebsitePolicies.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */; };
201202
5C9E56871DF914AE00C9EE33 /* contentBlockerCheck.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */; };
@@ -1145,6 +1146,7 @@
11451146
5C6E65411D5CEF8500F7862E /* URLParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLParser.cpp; sourceTree = "<group>"; };
11461147
5C726D6D1D3EE06800C5E1A1 /* InstanceMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstanceMethodSwizzler.h; path = cocoa/InstanceMethodSwizzler.h; sourceTree = "<group>"; };
11471148
5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = InstanceMethodSwizzler.mm; path = cocoa/InstanceMethodSwizzler.mm; sourceTree = "<group>"; };
1149+
5C79640F1EB0269B0075D74C /* EventModifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventModifiers.cpp; sourceTree = "<group>"; };
11481150
5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebsitePolicies.mm; sourceTree = "<group>"; };
11491151
5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = contentBlockerCheck.html; sourceTree = "<group>"; };
11501152
5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */ = {isa = PBXFileReference; lastKnownFileType = file; path = ApplicationCache.db; sourceTree = "<group>"; };
@@ -2043,6 +2045,7 @@
20432045
448D7E451EA6C55500ECC756 /* EnvironmentUtilitiesTest.cpp */,
20442046
75F3133F18C171B70041CAEC /* EphemeralSessionPushStateNoHistoryCallback.cpp */,
20452047
1A5FEFDC1270E2A3000E2921 /* EvaluateJavaScript.cpp */,
2048+
5C79640F1EB0269B0075D74C /* EventModifiers.cpp */,
20462049
BCC8B95A12611F4700DE46A4 /* FailedLoad.cpp */,
20472050
1A02C84E125D4A8400E3F4BD /* Find.cpp */,
20482051
C51AFB98169F49FF009CCF66 /* FindMatches.mm */,
@@ -3048,6 +3051,7 @@
30483051
5E4B1D2E1D404C6100053621 /* WKScrollViewDelegateCrash.mm in Sources */,
30493052
7CCE7F221A411AE600447C4C /* WKString.cpp in Sources */,
30503053
7CCE7F1E1A411AE600447C4C /* WKStringJSString.cpp in Sources */,
3054+
5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */,
30513055
2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */,
30523056
5CE354D91E70DA5C00BEFE3B /* WKUserContentExtensionStore.mm in Sources */,
30533057
2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (C) 2017 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
28+
#if WK_HAVE_C_SPI
29+
30+
#include "JavaScriptTest.h"
31+
#include "PlatformUtilities.h"
32+
#include "PlatformWebView.h"
33+
34+
namespace TestWebKitAPI {
35+
36+
static bool didFinishLoad { false };
37+
static bool mouseMoveCallbackFinished { false };
38+
39+
static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
40+
{
41+
didFinishLoad = true;
42+
}
43+
44+
static void mouseDidMoveOverElement(WKPageRef, WKHitTestResultRef, WKEventModifiers modifiers, WKTypeRef, const void*)
45+
{
46+
EXPECT_EQ(modifiers, kWKEventModifiersControlKey);
47+
mouseMoveCallbackFinished = true;
48+
}
49+
50+
static void setClients(WKPageRef page)
51+
{
52+
WKPageLoaderClientV0 loaderClient;
53+
memset(&loaderClient, 0, sizeof(loaderClient));
54+
loaderClient.base.version = 0;
55+
loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
56+
WKPageSetPageLoaderClient(page, &loaderClient.base);
57+
58+
WKPageUIClientV1 uiClient;
59+
memset(&uiClient, 0, sizeof(uiClient));
60+
uiClient.base.version = 1;
61+
uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement;
62+
WKPageSetPageUIClient(page, &uiClient.base);
63+
}
64+
65+
TEST(WebKit2, EventModifiers)
66+
{
67+
WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate());
68+
69+
PlatformWebView webView(context.get());
70+
setClients(webView.page());
71+
72+
WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
73+
WKPageLoadURL(webView.page(), url.get());
74+
Util::run(&didFinishLoad);
75+
76+
webView.simulateMouseMove(10, 10, kWKEventModifiersControlKey);
77+
Util::run(&mouseMoveCallbackFinished);
78+
}
79+
80+
} // namespace TestWebKitAPI
81+
82+
#endif

Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void PlatformWebView::simulateRightClick(unsigned x, unsigned y)
148148
doMouseButtonEvent(viewWidget, GDK_BUTTON_RELEASE, x, y, 3);
149149
}
150150

151-
void PlatformWebView::simulateMouseMove(unsigned x, unsigned y)
151+
void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers)
152152
{
153153
GUniquePtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY));
154154
event->motion.x = x;

Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm

+7-17
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,6 @@ - (BOOL)isVisible
177177
[m_view rightMouseUp:event];
178178

179179
}
180-
181-
void PlatformWebView::simulateMouseMove(unsigned x, unsigned y)
182-
{
183-
NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved
184-
location:NSMakePoint(x, y)
185-
modifierFlags:0
186-
timestamp:GetCurrentEventTime()
187-
windowNumber:[m_window windowNumber]
188-
context:[NSGraphicsContext currentContext]
189-
eventNumber:0
190-
clickCount:0
191-
pressure:0];
192-
193-
[m_view mouseMoved:event];
194-
195-
}
196180

197181
static NSEventType eventTypeForButton(WKEventMouseButton button)
198182
{
@@ -226,7 +210,13 @@ static NSEventModifierFlags modifierFlagsForWKModifiers(WKEventModifiers modifie
226210

227211
return returnVal;
228212
}
229-
213+
214+
void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers modifiers)
215+
{
216+
NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeMouseMoved location:NSMakePoint(x, y) modifierFlags:modifierFlagsForWKModifiers(modifiers) timestamp:GetCurrentEventTime() windowNumber:[m_window windowNumber] context:[NSGraphicsContext currentContext] eventNumber:0 clickCount:0 pressure:0];
217+
[m_view mouseMoved:event];
218+
}
219+
230220
void PlatformWebView::simulateButtonClick(WKEventMouseButton button, unsigned x, unsigned y, WKEventModifiers modifiers)
231221
{
232222
NSEvent *event = [NSEvent mouseEventWithType:eventTypeForButton(button)

0 commit comments

Comments
 (0)