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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1848063002: Fix page navigation being incorrectly fired on Mac OSX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename variable, add comments and remove ack in unittest Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "content/browser/renderer_host/render_widget_helper.h" 46 #include "content/browser/renderer_host/render_widget_helper.h"
47 #include "content/browser/renderer_host/render_widget_host_delegate.h" 47 #include "content/browser/renderer_host/render_widget_host_delegate.h"
48 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 48 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
49 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 49 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h"
50 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 50 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
51 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h" 51 #include "content/browser/renderer_host/render_widget_resize_helper_mac.h"
52 #include "content/browser/renderer_host/resize_lock.h" 52 #include "content/browser/renderer_host/resize_lock.h"
53 #import "content/browser/renderer_host/text_input_client_mac.h" 53 #import "content/browser/renderer_host/text_input_client_mac.h"
54 #include "content/common/accessibility_messages.h" 54 #include "content/common/accessibility_messages.h"
55 #include "content/common/edit_command.h" 55 #include "content/common/edit_command.h"
56 #include "content/common/input/input_event_utils.h"
56 #include "content/common/input_messages.h" 57 #include "content/common/input_messages.h"
57 #include "content/common/site_isolation_policy.h" 58 #include "content/common/site_isolation_policy.h"
58 #include "content/common/view_messages.h" 59 #include "content/common/view_messages.h"
59 #include "content/common/webplugin_geometry.h" 60 #include "content/common/webplugin_geometry.h"
60 #include "content/public/browser/browser_context.h" 61 #include "content/public/browser/browser_context.h"
61 #include "content/public/browser/browser_plugin_guest_manager.h" 62 #include "content/public/browser/browser_plugin_guest_manager.h"
62 #include "content/public/browser/browser_thread.h" 63 #include "content/public/browser/browser_thread.h"
63 #include "content/public/browser/native_web_keyboard_event.h" 64 #include "content/public/browser/native_web_keyboard_event.h"
64 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 65 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
65 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 66 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 170
170 // Private methods: 171 // Private methods:
171 @interface RenderWidgetHostViewCocoa () 172 @interface RenderWidgetHostViewCocoa ()
172 @property(nonatomic, assign) NSRange selectedRange; 173 @property(nonatomic, assign) NSRange selectedRange;
173 @property(nonatomic, assign) NSRange markedRange; 174 @property(nonatomic, assign) NSRange markedRange;
174 175
175 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; 176 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event;
176 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; 177 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r;
177 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event 178 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event
178 consumed:(BOOL)consumed; 179 consumed:(BOOL)consumed;
180 - (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event
181 consumed:(BOOL)consumed;
179 182
180 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; 183 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv;
181 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; 184 - (void)windowDidChangeBackingProperties:(NSNotification*)notification;
182 - (void)windowChangedGlobalFrame:(NSNotification*)notification; 185 - (void)windowChangedGlobalFrame:(NSNotification*)notification;
183 - (void)windowDidBecomeKey:(NSNotification*)notification; 186 - (void)windowDidBecomeKey:(NSNotification*)notification;
184 - (void)windowDidResignKey:(NSNotification*)notification; 187 - (void)windowDidResignKey:(NSNotification*)notification;
185 - (void)checkForPluginImeCancellation; 188 - (void)checkForPluginImeCancellation;
186 - (void)updateScreenProperties; 189 - (void)updateScreenProperties;
187 - (void)setResponderDelegate: 190 - (void)setResponderDelegate:
188 (NSObject<RenderWidgetHostViewMacDelegate>*)delegate; 191 (NSObject<RenderWidgetHostViewMacDelegate>*)delegate;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 bool is_guest_view_hack) 519 bool is_guest_view_hack)
517 : render_widget_host_(RenderWidgetHostImpl::From(widget)), 520 : render_widget_host_(RenderWidgetHostImpl::From(widget)),
518 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 521 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
519 can_compose_inline_(true), 522 can_compose_inline_(true),
520 browser_compositor_state_(BrowserCompositorDestroyed), 523 browser_compositor_state_(BrowserCompositorDestroyed),
521 browser_compositor_placeholder_(new BrowserCompositorMacPlaceholder), 524 browser_compositor_placeholder_(new BrowserCompositorMacPlaceholder),
522 page_at_minimum_scale_(true), 525 page_at_minimum_scale_(true),
523 is_loading_(false), 526 is_loading_(false),
524 allow_pause_for_resize_or_repaint_(true), 527 allow_pause_for_resize_or_repaint_(true),
525 is_guest_view_hack_(is_guest_view_hack), 528 is_guest_view_hack_(is_guest_view_hack),
529 wheel_gestures_enabled_(UseGestureBasedWheelScrolling()),
526 fullscreen_parent_host_view_(NULL), 530 fullscreen_parent_host_view_(NULL),
527 weak_factory_(this) { 531 weak_factory_(this) {
528 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| 532 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_|
529 // goes away. Since we autorelease it, our caller must put 533 // goes away. Since we autorelease it, our caller must put
530 // |GetNativeView()| into the view hierarchy right after calling us. 534 // |GetNativeView()| into the view hierarchy right after calling us.
531 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] 535 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc]
532 initWithRenderWidgetHostViewMac:this] autorelease]; 536 initWithRenderWidgetHostViewMac:this] autorelease];
533 537
534 // Paint this view host with |background_color_| when there is no content 538 // Paint this view host with |background_color_| when there is no content
535 // ready to draw. 539 // ready to draw.
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 CGAssociateMouseAndMouseCursorPosition(YES); 1538 CGAssociateMouseAndMouseCursorPosition(YES);
1535 [NSCursor unhide]; 1539 [NSCursor unhide];
1536 1540
1537 if (render_widget_host_) 1541 if (render_widget_host_)
1538 render_widget_host_->LostMouseLock(); 1542 render_widget_host_->LostMouseLock();
1539 } 1543 }
1540 1544
1541 void RenderWidgetHostViewMac::WheelEventAck( 1545 void RenderWidgetHostViewMac::WheelEventAck(
1542 const blink::WebMouseWheelEvent& event, 1546 const blink::WebMouseWheelEvent& event,
1543 InputEventAckState ack_result) { 1547 InputEventAckState ack_result) {
1548 // TODO(dtapuska): Remove this handling of the wheel event ack
1549 // once wheel gestures is enabled for a full release; see crbug.com/598798.
1550 if (wheel_gestures_enabled_)
1551 return;
1544 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; 1552 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED;
1545 // Only record a wheel event as unhandled if JavaScript handlers got a chance 1553 // Only record a wheel event as unhandled if JavaScript handlers got a chance
1546 // to see it (no-op wheel events are ignored by the event dispatcher) 1554 // to see it (no-op wheel events are ignored by the event dispatcher)
1547 if (event.deltaX || event.deltaY) 1555 if (event.deltaX || event.deltaY)
1548 [cocoa_view_ processedWheelEvent:event consumed:consumed]; 1556 [cocoa_view_ processedWheelEvent:event consumed:consumed];
1549 } 1557 }
1550 1558
1559 void RenderWidgetHostViewMac::GestureEventAck(
1560 const blink::WebGestureEvent& event,
1561 InputEventAckState ack_result) {
1562 if (!wheel_gestures_enabled_)
1563 return;
1564 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED;
1565 switch (event.type) {
1566 case blink::WebInputEvent::GestureScrollBegin:
1567 case blink::WebInputEvent::GestureScrollUpdate:
1568 case blink::WebInputEvent::GestureScrollEnd:
1569 [cocoa_view_ processedGestureScrollEvent:event consumed:consumed];
1570 return;
1571 default:
1572 break;
1573 }
1574 }
1575
1551 scoped_ptr<SyntheticGestureTarget> 1576 scoped_ptr<SyntheticGestureTarget>
1552 RenderWidgetHostViewMac::CreateSyntheticGestureTarget() { 1577 RenderWidgetHostViewMac::CreateSyntheticGestureTarget() {
1553 RenderWidgetHostImpl* host = 1578 RenderWidgetHostImpl* host =
1554 RenderWidgetHostImpl::From(GetRenderWidgetHost()); 1579 RenderWidgetHostImpl::From(GetRenderWidgetHost());
1555 return scoped_ptr<SyntheticGestureTarget>( 1580 return scoped_ptr<SyntheticGestureTarget>(
1556 new SyntheticGestureTargetMac(host, cocoa_view_)); 1581 new SyntheticGestureTargetMac(host, cocoa_view_));
1557 } 1582 }
1558 1583
1559 uint32_t RenderWidgetHostViewMac::GetSurfaceIdNamespace() { 1584 uint32_t RenderWidgetHostViewMac::GetSurfaceIdNamespace() {
1560 DCHECK(delegated_frame_host_); 1585 DCHECK(delegated_frame_host_);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 [self addCursorRect:[self visibleRect] cursor:currentCursor_]; 1873 [self addCursorRect:[self visibleRect] cursor:currentCursor_];
1849 [currentCursor_ setOnMouseEntered:YES]; 1874 [currentCursor_ setOnMouseEntered:YES];
1850 } 1875 }
1851 } 1876 }
1852 1877
1853 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event 1878 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event
1854 consumed:(BOOL)consumed { 1879 consumed:(BOOL)consumed {
1855 [responderDelegate_ rendererHandledWheelEvent:event consumed:consumed]; 1880 [responderDelegate_ rendererHandledWheelEvent:event consumed:consumed];
1856 } 1881 }
1857 1882
1883 - (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event
1884 consumed:(BOOL)consumed {
1885 [responderDelegate_ rendererHandledGestureScrollEvent:event
1886 consumed:consumed];
1887 }
1888
1858 - (BOOL)respondsToSelector:(SEL)selector { 1889 - (BOOL)respondsToSelector:(SEL)selector {
1859 // Trickiness: this doesn't mean "does this object's superclass respond to 1890 // Trickiness: this doesn't mean "does this object's superclass respond to
1860 // this selector" but rather "does the -respondsToSelector impl from the 1891 // this selector" but rather "does the -respondsToSelector impl from the
1861 // superclass say that this class responds to the selector". 1892 // superclass say that this class responds to the selector".
1862 if ([super respondsToSelector:selector]) 1893 if ([super respondsToSelector:selector])
1863 return YES; 1894 return YES;
1864 1895
1865 if (responderDelegate_) 1896 if (responderDelegate_)
1866 return [responderDelegate_ respondsToSelector:selector]; 1897 return [responderDelegate_ respondsToSelector:selector];
1867 1898
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
3491 3522
3492 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3523 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3493 // regions that are not draggable. (See ControlRegionView in 3524 // regions that are not draggable. (See ControlRegionView in
3494 // native_app_window_cocoa.mm). This requires the render host view to be 3525 // native_app_window_cocoa.mm). This requires the render host view to be
3495 // draggable by default. 3526 // draggable by default.
3496 - (BOOL)mouseDownCanMoveWindow { 3527 - (BOOL)mouseDownCanMoveWindow {
3497 return YES; 3528 return YES;
3498 } 3529 }
3499 3530
3500 @end 3531 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698