| 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.
|
|
|