OLD | NEW |
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 <QuartzCore/QuartzCore.h> | 8 #include <QuartzCore/QuartzCore.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return methodDescription.name != NULL || methodDescription.types != NULL; | 151 return methodDescription.name != NULL || methodDescription.types != NULL; |
152 } | 152 } |
153 | 153 |
154 // Private methods: | 154 // Private methods: |
155 @interface RenderWidgetHostViewCocoa () | 155 @interface RenderWidgetHostViewCocoa () |
156 @property(nonatomic, assign) NSRange selectedRange; | 156 @property(nonatomic, assign) NSRange selectedRange; |
157 @property(nonatomic, assign) NSRange markedRange; | 157 @property(nonatomic, assign) NSRange markedRange; |
158 | 158 |
159 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; | 159 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; |
160 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; | 160 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; |
161 - (void)gotUnhandledWheelEvent; | 161 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event |
| 162 consumed:(BOOL)consumed; |
| 163 |
162 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right; | 164 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right; |
163 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar; | 165 - (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar; |
164 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; | 166 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; |
165 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; | 167 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; |
166 - (void)windowChangedGlobalFrame:(NSNotification*)notification; | 168 - (void)windowChangedGlobalFrame:(NSNotification*)notification; |
167 - (void)drawWithDirtyRect:(CGRect)dirtyRect | 169 - (void)drawWithDirtyRect:(CGRect)dirtyRect |
168 inContext:(CGContextRef)context; | 170 inContext:(CGContextRef)context; |
169 - (void)checkForPluginImeCancellation; | 171 - (void)checkForPluginImeCancellation; |
170 - (void)updateScreenProperties; | 172 - (void)updateScreenProperties; |
171 - (void)setResponderDelegate: | 173 - (void)setResponderDelegate: |
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 CGAssociateMouseAndMouseCursorPosition(YES); | 2025 CGAssociateMouseAndMouseCursorPosition(YES); |
2024 [NSCursor unhide]; | 2026 [NSCursor unhide]; |
2025 | 2027 |
2026 if (render_widget_host_) | 2028 if (render_widget_host_) |
2027 render_widget_host_->LostMouseLock(); | 2029 render_widget_host_->LostMouseLock(); |
2028 } | 2030 } |
2029 | 2031 |
2030 void RenderWidgetHostViewMac::WheelEventAck( | 2032 void RenderWidgetHostViewMac::WheelEventAck( |
2031 const blink::WebMouseWheelEvent& event, | 2033 const blink::WebMouseWheelEvent& event, |
2032 InputEventAckState ack_result) { | 2034 InputEventAckState ack_result) { |
2033 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 2035 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; |
2034 return; | |
2035 | |
2036 // Only record a wheel event as unhandled if JavaScript handlers got a chance | 2036 // Only record a wheel event as unhandled if JavaScript handlers got a chance |
2037 // to see it (no-op wheel events are ignored by the event dispatcher) | 2037 // to see it (no-op wheel events are ignored by the event dispatcher) |
2038 if (event.deltaX || event.deltaY) | 2038 if (event.deltaX || event.deltaY) |
2039 [cocoa_view_ gotUnhandledWheelEvent]; | 2039 [cocoa_view_ processedWheelEvent:event consumed:consumed]; |
2040 } | 2040 } |
2041 | 2041 |
2042 bool RenderWidgetHostViewMac::Send(IPC::Message* message) { | 2042 bool RenderWidgetHostViewMac::Send(IPC::Message* message) { |
2043 if (render_widget_host_) | 2043 if (render_widget_host_) |
2044 return render_widget_host_->Send(message); | 2044 return render_widget_host_->Send(message); |
2045 delete message; | 2045 delete message; |
2046 return false; | 2046 return false; |
2047 } | 2047 } |
2048 | 2048 |
2049 void RenderWidgetHostViewMac::SoftwareFrameWasFreed( | 2049 void RenderWidgetHostViewMac::SoftwareFrameWasFreed( |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 responderDelegate_.reset([delegate retain]); | 2560 responderDelegate_.reset([delegate retain]); |
2561 } | 2561 } |
2562 | 2562 |
2563 - (void)resetCursorRects { | 2563 - (void)resetCursorRects { |
2564 if (currentCursor_) { | 2564 if (currentCursor_) { |
2565 [self addCursorRect:[self visibleRect] cursor:currentCursor_]; | 2565 [self addCursorRect:[self visibleRect] cursor:currentCursor_]; |
2566 [currentCursor_ setOnMouseEntered:YES]; | 2566 [currentCursor_ setOnMouseEntered:YES]; |
2567 } | 2567 } |
2568 } | 2568 } |
2569 | 2569 |
2570 - (void)gotUnhandledWheelEvent { | 2570 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event |
2571 if (responderDelegate_ && | 2571 consumed:(BOOL)consumed { |
2572 [responderDelegate_ | 2572 [responderDelegate_ rendererHandledWheelEvent:event consumed:consumed]; |
2573 respondsToSelector:@selector(gotUnhandledWheelEvent)]) { | |
2574 [responderDelegate_ gotUnhandledWheelEvent]; | |
2575 } | |
2576 } | 2573 } |
2577 | 2574 |
2578 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right { | 2575 - (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right { |
2579 if (responderDelegate_ && | 2576 if (responderDelegate_ && |
2580 [responderDelegate_ | 2577 [responderDelegate_ |
2581 respondsToSelector:@selector(scrollOffsetPinnedToLeft:toRight:)]) { | 2578 respondsToSelector:@selector(scrollOffsetPinnedToLeft:toRight:)]) { |
2582 [responderDelegate_ scrollOffsetPinnedToLeft:left toRight:right]; | 2579 [responderDelegate_ scrollOffsetPinnedToLeft:left toRight:right]; |
2583 } | 2580 } |
2584 } | 2581 } |
2585 | 2582 |
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4384 | 4381 |
4385 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 4382 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
4386 // regions that are not draggable. (See ControlRegionView in | 4383 // regions that are not draggable. (See ControlRegionView in |
4387 // native_app_window_cocoa.mm). This requires the render host view to be | 4384 // native_app_window_cocoa.mm). This requires the render host view to be |
4388 // draggable by default. | 4385 // draggable by default. |
4389 - (BOOL)mouseDownCanMoveWindow { | 4386 - (BOOL)mouseDownCanMoveWindow { |
4390 return YES; | 4387 return YES; |
4391 } | 4388 } |
4392 | 4389 |
4393 @end | 4390 @end |
OLD | NEW |