Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2682593005: Fixes pinch-to-zoom when linking against the 10.11 SDK or newer.
Patch Set: Test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 98d344535040c84c37473567d953ab94dec8a512..3b0efc11303a4859cf6cd371d2d7b6933c685dff 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -150,7 +150,8 @@ RenderWidgetHostView* GetRenderWidgetHostViewToUse(
consumed:(BOOL)consumed;
- (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event
consumed:(BOOL)consumed;
-
+- (void)handleBeginGestureWithEvent:(NSEvent*)event;
+- (void)handleEndGestureWithEvent:(NSEvent*)event;
- (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv;
- (void)windowDidChangeBackingProperties:(NSNotification*)notification;
- (void)windowChangedGlobalFrame:(NSNotification*)notification;
@@ -2278,7 +2279,13 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
}
}
-- (void)beginGestureWithEvent:(NSEvent*)event {
+// Internal implementation for handling begin gesture events. This helper
+// method is called via different codepaths based on OS version and SDK:
+// - On 10.11 and later, when linking with the 10.11 SDK, it is called from
+// |magnifyWithEvent:| when the given event's phase is NSEventPhaseBegin.
+// - On 10.10 and earlier, or when linking with an earlier SDK, it is called
+// by |beginGestureWithEvent:| when a gesture begins.
+- (void)handleBeginGestureWithEvent:(NSEvent*)event {
[responderDelegate_ beginGestureWithEvent:event];
gestureBeginEvent_.reset(
new WebGestureEvent(WebGestureEventBuilder::Build(event, self)));
@@ -2291,7 +2298,13 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
}
}
-- (void)endGestureWithEvent:(NSEvent*)event {
+// Internal implementation for handling end gesture events. This helper
+// method is called via different codepaths based on OS version and SDK:
+// - On 10.11 and later, when linking with the 10.11 SDK, it is called from
+// |magnifyWithEvent:| when the given event's phase is NSEventPhaseEnded.
+// - On 10.10 and earlier, or when linking with an earlier SDK, it is called
+// by |endGestureWithEvent:| when a gesture ends.
+- (void)handleEndGestureWithEvent:(NSEvent*)event {
[responderDelegate_ endGestureWithEvent:event];
gestureBeginEvent_.reset();
@@ -2306,6 +2319,38 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
}
}
+- (void)beginGestureWithEvent:(NSEvent*)event {
+ // This method must be handled when linking with the 10.10 SDK or earlier, or
+ // when the app is running on 10.10 or earlier. In other circumstances, the
+ // event will be handled by |magnifyWithEvent:|, so this method should do
+ // nothing.
+ bool shouldHandle = true;
+#if defined(MAC_OS_X_VERSION_10_11) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11
+ shouldHandle = base::mac::IsAtMostOS10_10();
+#endif
+
+ if (shouldHandle) {
+ [self handleBeginGestureWithEvent:event];
+ }
+}
+
+- (void)endGestureWithEvent:(NSEvent*)event {
+ // This method must be handled when linking with the 10.10 SDK or earlier, or
+ // when the app is running on 10.10 or earlier. In other circumstances, the
+ // event will be handled by |magnifyWithEvent:|, so this method should do
+ // nothing.
+ bool shouldHandle = true;
+#if defined(MAC_OS_X_VERSION_10_11) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11
+ shouldHandle = base::mac::IsAtMostOS10_10();
+#endif
+
+ if (shouldHandle) {
+ [self handleEndGestureWithEvent:event];
+ }
+}
+
- (void)touchesMovedWithEvent:(NSEvent*)event {
[responderDelegate_ touchesMovedWithEvent:event];
}
@@ -2503,6 +2548,23 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
if (!renderWidgetHostView_->render_widget_host_)
return;
+// When linking against the 10.11 (or later) SDK and running on 10.11 or later,
+// check the phase of the event and specially handle the "begin" and "end"
+// phases.
+#if defined(MAC_OS_X_VERSION_10_11) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11
+ if (event.phase == NSEventPhaseBegan) {
+ [self handleBeginGestureWithEvent:event];
+ return;
+ }
+
+ if (event.phase == NSEventPhaseEnded ||
+ event.phase == NSEventPhaseCancelled) {
+ [self handleEndGestureWithEvent:event];
+ return;
+ }
+#endif
+
// If, due to nesting of multiple gestures (e.g, from multiple touch
// devices), the beginning of the gesture has been lost, skip the remainder
// of the gesture.
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698