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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm

Issue 244043002: CoreAnimation: Reduce VA usage by extra layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add disabler Created 6 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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
6 6
7 #import "base/mac/mac_util.h" 7 #import "base/mac/mac_util.h"
8 #include "base/mac/scoped_cftyperef.h" 8 #include "base/mac/scoped_cftyperef.h"
9 #import "base/mac/sdk_forward_declarations.h" 9 #import "base/mac/sdk_forward_declarations.h"
10 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 10 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
11 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" 11 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h"
12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 12 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
13 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 13 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
14 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" 14 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
16 #include "ui/gfx/mac/scoped_ns_disable_screen_updates.h"
16 17
17 const CGFloat kTearDistance = 36.0; 18 const CGFloat kTearDistance = 36.0;
18 const NSTimeInterval kTearDuration = 0.333; 19 const NSTimeInterval kTearDuration = 0.333;
19 20
20 // Returns whether |screenPoint| is inside the bounds of |view|. 21 // Returns whether |screenPoint| is inside the bounds of |view|.
21 static BOOL PointIsInsideView(NSPoint screenPoint, NSView* view) { 22 static BOOL PointIsInsideView(NSPoint screenPoint, NSView* view) {
22 if ([view window] == nil) 23 if ([view window] == nil)
23 return NO; 24 return NO;
24 NSPoint windowPoint = [[view window] convertScreenToBase:screenPoint]; 25 NSPoint windowPoint = [[view window] convertScreenToBase:screenPoint];
25 NSPoint viewPoint = [view convertPoint:windowPoint fromView:nil]; 26 NSPoint viewPoint = [view convertPoint:windowPoint fromView:nil];
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Because we move views between windows, we need to handle the event loop 107 // Because we move views between windows, we need to handle the event loop
107 // ourselves. Ideally we should use the standard event loop. 108 // ourselves. Ideally we should use the standard event loop.
108 while (1) { 109 while (1) {
109 const NSUInteger mask = 110 const NSUInteger mask =
110 NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSKeyUpMask; 111 NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSKeyUpMask;
111 theEvent = 112 theEvent =
112 [NSApp nextEventMatchingMask:mask 113 [NSApp nextEventMatchingMask:mask
113 untilDate:[NSDate distantFuture] 114 untilDate:[NSDate distantFuture]
114 inMode:NSDefaultRunLoopMode 115 inMode:NSDefaultRunLoopMode
115 dequeue:YES]; 116 dequeue:YES];
117
ccameron 2014/04/19 02:45:29 The dark background was popping through without th
118 // Ensure that any window changes that happen while handling this event
119 // appear atomically.
120 gfx::ScopedNSDisableScreenUpdates disabler;
121
116 NSEventType type = [theEvent type]; 122 NSEventType type = [theEvent type];
117 if (type == NSKeyUp) { 123 if (type == NSKeyUp) {
118 if ([theEvent keyCode] == kVK_Escape) { 124 if ([theEvent keyCode] == kVK_Escape) {
119 // Cancel the drag and restore the previous state. 125 // Cancel the drag and restore the previous state.
120 if (draggingWithinTabStrip_) { 126 if (draggingWithinTabStrip_) {
121 // Simply pretend the tab wasn't dragged (far enough). 127 // Simply pretend the tab wasn't dragged (far enough).
122 tabWasDragged_ = NO; 128 tabWasDragged_ = NO;
123 } else { 129 } else {
124 [targetController_ removePlaceholder]; 130 [targetController_ removePlaceholder];
125 if ([sourceController_ numberOfTabs] < 2) { 131 if ([sourceController_ numberOfTabs] < 2) {
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 [[targetController_ window] makeMainWindow]; 496 [[targetController_ window] makeMainWindow];
491 } else { 497 } else {
492 [dragWindow_ setAlphaValue:0.5]; 498 [dragWindow_ setAlphaValue:0.5];
493 [[draggedController_ overlayWindow] setHasShadow:NO]; 499 [[draggedController_ overlayWindow] setHasShadow:NO];
494 [[draggedController_ window] makeMainWindow]; 500 [[draggedController_ window] makeMainWindow];
495 } 501 }
496 chromeIsVisible_ = shouldBeVisible; 502 chromeIsVisible_ = shouldBeVisible;
497 } 503 }
498 504
499 @end 505 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698