| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_content_view.h" | 5 #import "ui/views/cocoa/bridged_content_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "ui/views/view.h" | 28 #include "ui/views/view.h" |
| 29 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
| 30 | 30 |
| 31 using views::MenuController; | 31 using views::MenuController; |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 NSString* const kFullKeyboardAccessChangedNotification = | 35 NSString* const kFullKeyboardAccessChangedNotification = |
| 36 @"com.apple.KeyboardUIModeDidChange"; | 36 @"com.apple.KeyboardUIModeDidChange"; |
| 37 | 37 |
| 38 // We're sending simulated mouse events in CocoaWindowMoveLoop, and don't want |
| 39 // BridgedContentView to react when we're starting/ending the RunMoveLoop. |
| 40 // When reattaching the dragged tab we're sending the mouse down event to the |
| 41 // parent window we don't have the pointer to, so this flag is global for the |
| 42 // RunMoveLoop. |
| 43 bool g_ignore_mouse_events = false; |
| 44 |
| 38 // Returns true if all four corners of |rect| are contained inside |path|. | 45 // Returns true if all four corners of |rect| are contained inside |path|. |
| 39 bool IsRectInsidePath(NSRect rect, NSBezierPath* path) { | 46 bool IsRectInsidePath(NSRect rect, NSBezierPath* path) { |
| 40 return [path containsPoint:rect.origin] && | 47 return [path containsPoint:rect.origin] && |
| 41 [path containsPoint:NSMakePoint(rect.origin.x + rect.size.width, | 48 [path containsPoint:NSMakePoint(rect.origin.x + rect.size.width, |
| 42 rect.origin.y)] && | 49 rect.origin.y)] && |
| 43 [path containsPoint:NSMakePoint(rect.origin.x, | 50 [path containsPoint:NSMakePoint(rect.origin.x, |
| 44 rect.origin.y + rect.size.height)] && | 51 rect.origin.y + rect.size.height)] && |
| 45 [path containsPoint:NSMakePoint(rect.origin.x + rect.size.width, | 52 [path containsPoint:NSMakePoint(rect.origin.x + rect.size.width, |
| 46 rect.origin.y + rect.size.height)]; | 53 rect.origin.y + rect.size.height)]; |
| 47 } | 54 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 name:kFullKeyboardAccessChangedNotification | 276 name:kFullKeyboardAccessChangedNotification |
| 270 object:nil]; | 277 object:nil]; |
| 271 | 278 |
| 272 // Initialize the focus manager with the correct keyboard accessibility | 279 // Initialize the focus manager with the correct keyboard accessibility |
| 273 // setting. | 280 // setting. |
| 274 [self updateFullKeyboardAccess]; | 281 [self updateFullKeyboardAccess]; |
| 275 } | 282 } |
| 276 return self; | 283 return self; |
| 277 } | 284 } |
| 278 | 285 |
| 286 + (void)setIgnoreMouseEvents:(BOOL)flag { |
| 287 g_ignore_mouse_events = flag; |
| 288 } |
| 289 |
| 279 - (void)clearView { | 290 - (void)clearView { |
| 280 textInputClient_ = nullptr; | 291 textInputClient_ = nullptr; |
| 281 hostedView_ = nullptr; | 292 hostedView_ = nullptr; |
| 282 [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; | 293 [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; |
| 283 [cursorTrackingArea_.get() clearOwner]; | 294 [cursorTrackingArea_.get() clearOwner]; |
| 284 [self removeTrackingArea:cursorTrackingArea_.get()]; | 295 [self removeTrackingArea:cursorTrackingArea_.get()]; |
| 285 } | 296 } |
| 286 | 297 |
| 287 - (void)processCapturedMouseEvent:(NSEvent*)theEvent { | 298 - (void)processCapturedMouseEvent:(NSEvent*)theEvent { |
| 288 if (!hostedView_) | 299 if (!hostedView_) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // BaseView implementation. | 463 // BaseView implementation. |
| 453 | 464 |
| 454 // Don't use tracking areas from BaseView. BridgedContentView's tracks | 465 // Don't use tracking areas from BaseView. BridgedContentView's tracks |
| 455 // NSTrackingCursorUpdate and Apple's documentation suggests it's incompatible. | 466 // NSTrackingCursorUpdate and Apple's documentation suggests it's incompatible. |
| 456 - (void)enableTracking { | 467 - (void)enableTracking { |
| 457 } | 468 } |
| 458 | 469 |
| 459 // Translates the location of |theEvent| to toolkit-views coordinates and passes | 470 // Translates the location of |theEvent| to toolkit-views coordinates and passes |
| 460 // the event to NativeWidgetMac for handling. | 471 // the event to NativeWidgetMac for handling. |
| 461 - (void)mouseEvent:(NSEvent*)theEvent { | 472 - (void)mouseEvent:(NSEvent*)theEvent { |
| 462 if (!hostedView_) | 473 if (!hostedView_ || g_ignore_mouse_events) |
| 463 return; | 474 return; |
| 464 | 475 |
| 465 ui::MouseEvent event(theEvent); | 476 ui::MouseEvent event(theEvent); |
| 466 | 477 |
| 467 // Aura updates tooltips with the help of aura::Window::AddPreTargetHandler(). | 478 // Aura updates tooltips with the help of aura::Window::AddPreTargetHandler(). |
| 468 // Mac hooks in here. | 479 // Mac hooks in here. |
| 469 [self updateTooltipIfRequiredAt:event.location()]; | 480 [self updateTooltipIfRequiredAt:event.location()]; |
| 470 | 481 |
| 471 hostedView_->GetWidget()->OnMouseEvent(&event); | 482 hostedView_->GetWidget()->OnMouseEvent(&event); |
| 472 } | 483 } |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 } | 1034 } |
| 1024 | 1035 |
| 1025 return [super accessibilityAttributeValue:attribute]; | 1036 return [super accessibilityAttributeValue:attribute]; |
| 1026 } | 1037 } |
| 1027 | 1038 |
| 1028 - (id)accessibilityHitTest:(NSPoint)point { | 1039 - (id)accessibilityHitTest:(NSPoint)point { |
| 1029 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 1040 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
| 1030 } | 1041 } |
| 1031 | 1042 |
| 1032 @end | 1043 @end |
| OLD | NEW |