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

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

Issue 194008: Restore r25049 (back out r25295) to isolate it as the cause of bug 20872 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_strip_controller.h" 5 #import "chrome/browser/cocoa/tab_strip_controller.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } else { 412 } else {
413 // If our left edge is to the left of the placeholder's left, but our mid 413 // If our left edge is to the left of the placeholder's left, but our mid
414 // is to the right of it we should slide over to make space for it. 414 // is to the right of it we should slide over to make space for it.
415 if (placeholderTab_ && gap < 0 && NSMidX(tabFrame) > minX) { 415 if (placeholderTab_ && gap < 0 && NSMidX(tabFrame) > minX) {
416 gap = i; 416 gap = i;
417 offset += NSWidth(tabFrame); 417 offset += NSWidth(tabFrame);
418 offset -= kTabOverlap; 418 offset -= kTabOverlap;
419 tabFrame.origin.x = offset; 419 tabFrame.origin.x = offset;
420 } 420 }
421 421
422 // Animate the tab in by putting it below the horizon. 422 // Animate the tab in by putting it below the horizon, but don't bother
423 if (newTab && visible && animate) { 423 // if we only have 1 tab.
424 BOOL shouldAnimate = animate && [tabContentsArray_ count] > 1;
425 if (newTab && visible && shouldAnimate) {
424 [[tab view] setFrame:NSOffsetRect(tabFrame, 0, -NSHeight(tabFrame))]; 426 [[tab view] setFrame:NSOffsetRect(tabFrame, 0, -NSHeight(tabFrame))];
425 } 427 }
426 428
427 // Set the width. Selected tabs are slightly wider when things get 429 // Set the width. Selected tabs are slightly wider when things get
428 // really small and thus we enforce a different minimum width. 430 // really small and thus we enforce a different minimum width.
429 tabFrame.size.width = 431 tabFrame.size.width =
430 [tab selected] ? MAX(baseTabWidth, kMinSelectedTabWidth) : 432 [tab selected] ? MAX(baseTabWidth, kMinSelectedTabWidth) :
431 baseTabWidth; 433 baseTabWidth;
432 434
433 // Check the frame by identifier to avoid redundant calls to animator. 435 // Check the frame by identifier to avoid redundant calls to animator.
434 id frameTarget = visible && animate ? [[tab view] animator] : [tab view]; 436 id frameTarget = visible && animate ? [[tab view] animator] : [tab view];
435 NSValue *identifier = [NSValue valueWithPointer:[tab view]]; 437 NSValue *identifier = [NSValue valueWithPointer:[tab view]];
436 NSValue *oldTargetValue = [targetFrames_ objectForKey:identifier]; 438 NSValue *oldTargetValue = [targetFrames_ objectForKey:identifier];
437 if (!oldTargetValue || 439 if (!oldTargetValue ||
438 !NSEqualRects([oldTargetValue rectValue], tabFrame)) { 440 !NSEqualRects([oldTargetValue rectValue], tabFrame)) {
439 [frameTarget setFrame:tabFrame]; 441 [frameTarget setFrame:tabFrame];
440 [targetFrames_ setObject:[NSValue valueWithRect:tabFrame] 442 [targetFrames_ setObject:[NSValue valueWithRect:tabFrame]
441 forKey:identifier]; 443 forKey:identifier];
442 } 444 }
443 enclosingRect = NSUnionRect(tabFrame, enclosingRect); 445 enclosingRect = NSUnionRect(tabFrame, enclosingRect);
444 } 446 }
445 447
446 offset += NSWidth(tabFrame); 448 offset += NSWidth(tabFrame);
447 offset -= kTabOverlap; 449 offset -= kTabOverlap;
448 i++; 450 i++;
449 } 451 }
450 452
451 // Hide the new tab button if we're explicitly told to. It may already 453 // Hide the new tab button if we're explicitly told to. It may already
452 // be hidden, doing it again doesn't hurt. 454 // be hidden, doing it again doesn't hurt. Otherwise position it
455 // appropriately, showing it if necessary.
453 if (forceNewTabButtonHidden_) { 456 if (forceNewTabButtonHidden_) {
454 [newTabButton_ setHidden:YES]; 457 [newTabButton_ setHidden:YES];
455 } else { 458 } else {
456 NSRect newTabNewFrame = [newTabButton_ frame]; 459 NSRect newTabNewFrame = [newTabButton_ frame];
457 // We've already ensured there's enough space for the new tab button 460 // We've already ensured there's enough space for the new tab button
458 // so we don't have to check it against the available width. We do need 461 // so we don't have to check it against the available width. We do need
459 // to make sure we put it after any placeholder. 462 // to make sure we put it after any placeholder.
460 newTabNewFrame.origin = NSMakePoint(offset, 0); 463 newTabNewFrame.origin = NSMakePoint(offset, 0);
461 newTabNewFrame.origin.x = MAX(newTabNewFrame.origin.x, 464 newTabNewFrame.origin.x = MAX(newTabNewFrame.origin.x,
462 NSMaxX(placeholderFrame_)) + 465 NSMaxX(placeholderFrame_)) +
463 kNewTabButtonOffset; 466 kNewTabButtonOffset;
464 if (i > 0 && [newTabButton_ isHidden]) { 467 if ([tabContentsArray_ count])
465 id target = animate ? [newTabButton_ animator] : newTabButton_; 468 [newTabButton_ setHidden:NO];
466 [target setHidden:NO];
467 }
468 469
469 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) { 470 if (!NSEqualRects(newTabTargetFrame_, newTabNewFrame)) {
470 [newTabButton_ setFrame:newTabNewFrame]; 471 [newTabButton_ setFrame:newTabNewFrame];
471 newTabTargetFrame_ = newTabNewFrame; 472 newTabTargetFrame_ = newTabNewFrame;
472 // Move the new tab button into place. 473 // Move the new tab button into place.
473 } 474 }
474 } 475 }
475 476
476 [NSAnimationContext endGrouping]; 477 [NSAnimationContext endGrouping];
477 [dragBlockingView_ setFrame:enclosingRect]; 478 [dragBlockingView_ setFrame:enclosingRect];
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 BrowserWindowController* controller = 955 BrowserWindowController* controller =
955 (BrowserWindowController*)[[switchView_ window] windowController]; 956 (BrowserWindowController*)[[switchView_ window] windowController];
956 DCHECK(index >= 0); 957 DCHECK(index >= 0);
957 if (index >= 0) { 958 if (index >= 0) {
958 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; 959 [controller setTab:[self viewAtIndex:index] isDraggable:YES];
959 } 960 }
960 } 961 }
961 962
962 963
963 @end 964 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698