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

Side by Side Diff: chrome/browser/cocoa/tab_view.mm

Issue 2762014: Mac: clang build (Closed)
Patch Set: more Created 10 years, 6 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
« no previous file with comments | « chrome/browser/cocoa/status_bubble_mac.mm ('k') | chrome/browser/cocoa/url_drop_target.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/tab_view.h" 5 #import "chrome/browser/cocoa/tab_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/nsimage_cache_mac.h" 8 #include "base/nsimage_cache_mac.h"
9 #include "chrome/browser/browser_theme_provider.h" 9 #include "chrome/browser/browser_theme_provider.h"
10 #import "chrome/browser/cocoa/tab_controller.h" 10 #import "chrome/browser/cocoa/tab_controller.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // controller. 277 // controller.
278 scoped_nsobject<TabController> controller([controller_ retain]); 278 scoped_nsobject<TabController> controller([controller_ retain]);
279 279
280 // Because we move views between windows, we need to handle the event loop 280 // Because we move views between windows, we need to handle the event loop
281 // ourselves. Ideally we should use the standard event loop. 281 // ourselves. Ideally we should use the standard event loop.
282 while (1) { 282 while (1) {
283 theEvent = 283 theEvent =
284 [NSApp nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask 284 [NSApp nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask
285 untilDate:[NSDate distantFuture] 285 untilDate:[NSDate distantFuture]
286 inMode:NSDefaultRunLoopMode dequeue:YES]; 286 inMode:NSDefaultRunLoopMode dequeue:YES];
287 NSPoint thisPoint = [NSEvent mouseLocation];
288
289 NSEventType type = [theEvent type]; 287 NSEventType type = [theEvent type];
290 if (type == NSLeftMouseDragged) { 288 if (type == NSLeftMouseDragged) {
291 [self mouseDragged:theEvent]; 289 [self mouseDragged:theEvent];
292 } else if (type == NSLeftMouseUp) { 290 } else if (type == NSLeftMouseUp) {
293 NSPoint upLocation = [theEvent locationInWindow]; 291 NSPoint upLocation = [theEvent locationInWindow];
294 CGFloat dx = upLocation.x - downLocation.x; 292 CGFloat dx = upLocation.x - downLocation.x;
295 CGFloat dy = upLocation.y - downLocation.y; 293 CGFloat dy = upLocation.y - downLocation.y;
296 294
297 // During rapid tab closure (mashing tab close buttons), we may get hit 295 // During rapid tab closure (mashing tab close buttons), we may get hit
298 // with a mouse down. As long as the mouse up is over the close button, 296 // with a mouse down. As long as the mouse up is over the close button,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 [sourceWindow_ setFrameOrigin:NSMakePoint(origin.x, origin.y)]; 330 [sourceWindow_ setFrameOrigin:NSMakePoint(origin.x, origin.y)];
333 } // else do nothing. 331 } // else do nothing.
334 return; 332 return;
335 } 333 }
336 334
337 // First, go through the magnetic drag cycle. We break out of this if 335 // First, go through the magnetic drag cycle. We break out of this if
338 // "stretchiness" ever exceeds a set amount. 336 // "stretchiness" ever exceeds a set amount.
339 tabWasDragged_ = YES; 337 tabWasDragged_ = YES;
340 338
341 if (draggingWithinTabStrip_) { 339 if (draggingWithinTabStrip_) {
342 NSRect frame = [self frame];
343 NSPoint thisPoint = [NSEvent mouseLocation]; 340 NSPoint thisPoint = [NSEvent mouseLocation];
344 CGFloat stretchiness = thisPoint.y - dragOrigin_.y; 341 CGFloat stretchiness = thisPoint.y - dragOrigin_.y;
345 stretchiness = copysign(sqrtf(fabs(stretchiness))/sqrtf(kTearDistance), 342 stretchiness = copysign(sqrtf(fabs(stretchiness))/sqrtf(kTearDistance),
346 stretchiness) / 2.0; 343 stretchiness) / 2.0;
347 CGFloat offset = thisPoint.x - dragOrigin_.x; 344 CGFloat offset = thisPoint.x - dragOrigin_.x;
348 if (fabsf(offset) > 100) stretchiness = 0; 345 if (fabsf(offset) > 100) stretchiness = 0;
349 [sourceController_ insertPlaceholderForTab:self 346 [sourceController_ insertPlaceholderForTab:self
350 frame:NSOffsetRect(sourceTabFrame_, 347 frame:NSOffsetRect(sourceTabFrame_,
351 offset, 0) 348 offset, 0)
352 yStretchiness:stretchiness]; 349 yStretchiness:stretchiness];
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // a placeholder so it appears like it's part of that window. 492 // a placeholder so it appears like it's part of that window.
496 if (targetController_) { 493 if (targetController_) {
497 if (![[targetController_ window] isKeyWindow]) { 494 if (![[targetController_ window] isKeyWindow]) {
498 // && ([targetDwellDate timeIntervalSinceNow] < -REQUIRED_DWELL)) { 495 // && ([targetDwellDate timeIntervalSinceNow] < -REQUIRED_DWELL)) {
499 [[targetController_ window] orderFront:nil]; 496 [[targetController_ window] orderFront:nil];
500 targetDwellDate = nil; 497 targetDwellDate = nil;
501 } 498 }
502 499
503 // Compute where placeholder should go and insert it into the 500 // Compute where placeholder should go and insert it into the
504 // destination tab strip. 501 // destination tab strip.
505 NSRect dropTabFrame = [[targetController_ tabStripView] frame];
506 TabView* draggedTabView = (TabView*)[draggedController_ selectedTabView]; 502 TabView* draggedTabView = (TabView*)[draggedController_ selectedTabView];
507 NSRect tabFrame = [draggedTabView frame]; 503 NSRect tabFrame = [draggedTabView frame];
508 tabFrame.origin = [dragWindow_ convertBaseToScreen:tabFrame.origin]; 504 tabFrame.origin = [dragWindow_ convertBaseToScreen:tabFrame.origin];
509 tabFrame.origin = [[targetController_ window] 505 tabFrame.origin = [[targetController_ window]
510 convertScreenToBase:tabFrame.origin]; 506 convertScreenToBase:tabFrame.origin];
511 tabFrame = [[targetController_ tabStripView] 507 tabFrame = [[targetController_ tabStripView]
512 convertRect:tabFrame fromView:nil]; 508 convertRect:tabFrame fromView:nil];
513 NSPoint point = 509 NSPoint point =
514 [sourceWindow_ convertBaseToScreen: 510 [sourceWindow_ convertBaseToScreen:
515 [draggedTabView convertPoint:NSZeroPoint toView:nil]]; 511 [draggedTabView convertPoint:NSZeroPoint toView:nil]];
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 } 956 }
961 957
962 if (nextUpdate < kNoUpdate) 958 if (nextUpdate < kNoUpdate)
963 [self performSelector:_cmd withObject:nil afterDelay:nextUpdate]; 959 [self performSelector:_cmd withObject:nil afterDelay:nextUpdate];
964 960
965 [self resetLastGlowUpdateTime]; 961 [self resetLastGlowUpdateTime];
966 [self setNeedsDisplay:YES]; 962 [self setNeedsDisplay:YES];
967 } 963 }
968 964
969 @end // @implementation TabView(Private) 965 @end // @implementation TabView(Private)
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/status_bubble_mac.mm ('k') | chrome/browser/cocoa/url_drop_target.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698