| 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 <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 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 BOOL handled = [responderDelegate_ handleEvent:theEvent]; | 1779 BOOL handled = [responderDelegate_ handleEvent:theEvent]; |
| 1780 if (handled) | 1780 if (handled) |
| 1781 return; | 1781 return; |
| 1782 } | 1782 } |
| 1783 | 1783 |
| 1784 if ([self shouldIgnoreMouseEvent:theEvent]) { | 1784 if ([self shouldIgnoreMouseEvent:theEvent]) { |
| 1785 // If this is the first such event, send a mouse exit to the host view. | 1785 // If this is the first such event, send a mouse exit to the host view. |
| 1786 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { | 1786 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { |
| 1787 WebMouseEvent exitEvent = WebMouseEventBuilder::Build(theEvent, self); | 1787 WebMouseEvent exitEvent = WebMouseEventBuilder::Build(theEvent, self); |
| 1788 exitEvent.type = WebInputEvent::MouseLeave; | 1788 exitEvent.type = WebInputEvent::MouseLeave; |
| 1789 exitEvent.button = WebMouseEvent::ButtonNone; | 1789 exitEvent.button = WebMouseEvent::Button::NoButton; |
| 1790 renderWidgetHostView_->ForwardMouseEvent(exitEvent); | 1790 renderWidgetHostView_->ForwardMouseEvent(exitEvent); |
| 1791 } | 1791 } |
| 1792 mouseEventWasIgnored_ = YES; | 1792 mouseEventWasIgnored_ = YES; |
| 1793 return; | 1793 return; |
| 1794 } | 1794 } |
| 1795 | 1795 |
| 1796 if (mouseEventWasIgnored_) { | 1796 if (mouseEventWasIgnored_) { |
| 1797 // If this is the first mouse event after a previous event that was ignored | 1797 // If this is the first mouse event after a previous event that was ignored |
| 1798 // due to the hitTest, send a mouse enter event to the host view. | 1798 // due to the hitTest, send a mouse enter event to the host view. |
| 1799 if (renderWidgetHostView_->render_widget_host_) { | 1799 if (renderWidgetHostView_->render_widget_host_) { |
| 1800 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); | 1800 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); |
| 1801 enterEvent.type = WebInputEvent::MouseMove; | 1801 enterEvent.type = WebInputEvent::MouseMove; |
| 1802 enterEvent.button = WebMouseEvent::ButtonNone; | 1802 enterEvent.button = WebMouseEvent::Button::NoButton; |
| 1803 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { | 1803 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { |
| 1804 renderWidgetHostView_->render_widget_host_->delegate() | 1804 renderWidgetHostView_->render_widget_host_->delegate() |
| 1805 ->GetInputEventRouter() | 1805 ->GetInputEventRouter() |
| 1806 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); | 1806 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent); |
| 1807 } else { | 1807 } else { |
| 1808 ui::LatencyInfo latency_info; | 1808 ui::LatencyInfo latency_info; |
| 1809 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, | 1809 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, |
| 1810 0, 0); | 1810 0, 0); |
| 1811 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); | 1811 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); |
| 1812 } | 1812 } |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3063 if ([self window]) | 3063 if ([self window]) |
| 3064 [self updateScreenProperties]; | 3064 [self updateScreenProperties]; |
| 3065 renderWidgetHostView_->browser_compositor_->SetNSViewAttachedToWindow( | 3065 renderWidgetHostView_->browser_compositor_->SetNSViewAttachedToWindow( |
| 3066 [self window]); | 3066 [self window]); |
| 3067 | 3067 |
| 3068 // If we switch windows (or are removed from the view hierarchy), cancel any | 3068 // If we switch windows (or are removed from the view hierarchy), cancel any |
| 3069 // open mouse-downs. | 3069 // open mouse-downs. |
| 3070 if (hasOpenMouseDown_) { | 3070 if (hasOpenMouseDown_) { |
| 3071 WebMouseEvent event; | 3071 WebMouseEvent event; |
| 3072 event.type = WebInputEvent::MouseUp; | 3072 event.type = WebInputEvent::MouseUp; |
| 3073 event.button = WebMouseEvent::ButtonLeft; | 3073 event.button = WebMouseEvent::Button::Left; |
| 3074 renderWidgetHostView_->ForwardMouseEvent(event); | 3074 renderWidgetHostView_->ForwardMouseEvent(event); |
| 3075 | 3075 |
| 3076 hasOpenMouseDown_ = NO; | 3076 hasOpenMouseDown_ = NO; |
| 3077 } | 3077 } |
| 3078 } | 3078 } |
| 3079 | 3079 |
| 3080 - (void)viewDidChangeBackingProperties { | 3080 - (void)viewDidChangeBackingProperties { |
| 3081 NSScreen* screen = [[self window] screen]; | 3081 NSScreen* screen = [[self window] screen]; |
| 3082 if (screen) { | 3082 if (screen) { |
| 3083 gfx::ICCProfile icc_profile = | 3083 gfx::ICCProfile icc_profile = |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 | 3259 |
| 3260 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3260 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3261 // regions that are not draggable. (See ControlRegionView in | 3261 // regions that are not draggable. (See ControlRegionView in |
| 3262 // native_app_window_cocoa.mm). This requires the render host view to be | 3262 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3263 // draggable by default. | 3263 // draggable by default. |
| 3264 - (BOOL)mouseDownCanMoveWindow { | 3264 - (BOOL)mouseDownCanMoveWindow { |
| 3265 return YES; | 3265 return YES; |
| 3266 } | 3266 } |
| 3267 | 3267 |
| 3268 @end | 3268 @end |
| OLD | NEW |