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

Unified Diff: chrome/browser/ui/cocoa/tab_controller.mm

Issue 5703007: Mac: Correctly clip tab title... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/tab_controller.mm
===================================================================
--- chrome/browser/ui/cocoa/tab_controller.mm (revision 68959)
+++ chrome/browser/ui/cocoa/tab_controller.mm (working copy)
@@ -114,10 +114,11 @@
// When the icon is removed, the title expands to the left to fill the space
// left by the icon. When the close button is removed, the title expands to
// the right to fill its space. These are the amounts to expand and contract
- // titleView_ under those conditions.
+ // titleView_ under those conditions. We don't have to explicilty save the
+ // offset between the title and the close button since we can just get that
+ // value for the close button's frame.
NSRect titleFrame = [titleView_ frame];
iconTitleXOffset_ = NSMinX(titleFrame) - NSMinX(originalIconFrame_);
- titleCloseWidthOffset_ = NSMaxX([closeButton_ frame]) - NSMaxX(titleFrame);
[self internalSetSelected:selected_];
}
@@ -226,11 +227,18 @@
return ([self selected] || [self iconCapacity] >= 3);
}
+- (NSTextField*)titleView {
+ return titleView_;
+}
+
+- (HoverCloseButton*)closeButton {
+ return closeButton_;
+}
+
- (void)updateVisibility {
// iconView_ may have been replaced or it may be nil, so [iconView_ isHidden]
// won't work. Instead, the state of the icon is tracked separately in
// isIconShowing_.
- BOOL oldShowIcon = isIconShowing_ ? YES : NO;
BOOL newShowIcon = [self shouldShowIcon] ? YES : NO;
viettrungluu 2010/12/14 00:19:50 The |? YES : NO| here is just strange. Could you g
sail 2010/12/14 01:59:53 Done.
[iconView_ setHidden:newShowIcon ? NO : YES];
viettrungluu 2010/12/14 00:19:50 Ditto. Should just be |!newShowIcon|.
sail 2010/12/14 01:59:53 Done.
@@ -239,38 +247,32 @@
// If the tab is a mini-tab, hide the title.
[titleView_ setHidden:[self mini]];
- BOOL oldShowCloseButton = [closeButton_ isHidden] ? NO : YES;
BOOL newShowCloseButton = [self shouldShowCloseButton] ? YES : NO;
viettrungluu 2010/12/14 00:19:50 Etc.
sail 2010/12/14 01:59:53 Done.
[closeButton_ setHidden:newShowCloseButton ? NO : YES];
// Adjust the title view based on changes to the icon's and close button's
// visibility.
- NSRect titleFrame = [titleView_ frame];
+ NSRect oldTitleFrame = [titleView_ frame];
+ NSRect newTitleFrame;
+ newTitleFrame.size.height = oldTitleFrame.size.height;
viettrungluu 2010/12/14 00:19:50 NSMakeRect and a couple of uses of ?: would be mor
sail 2010/12/14 01:59:53 Unfortunately I need a temporary variable here sin
+ newTitleFrame.origin.y = oldTitleFrame.origin.y;
- if (oldShowIcon != newShowIcon) {
- // Adjust the left edge of the title view according to the presence or
- // absence of the icon view.
-
- if (newShowIcon) {
- titleFrame.origin.x += iconTitleXOffset_;
- titleFrame.size.width -= iconTitleXOffset_;
- } else {
- titleFrame.origin.x -= iconTitleXOffset_;
- titleFrame.size.width += iconTitleXOffset_;
- }
+ if (newShowIcon) {
+ newTitleFrame.origin.x = originalIconFrame_.origin.x + iconTitleXOffset_;
+ } else {
+ newTitleFrame.origin.x = originalIconFrame_.origin.x;
}
- if (oldShowCloseButton != newShowCloseButton) {
- // Adjust the right edge of the title view according to the presence or
- // absence of the close button.
- if (newShowCloseButton)
- titleFrame.size.width -= titleCloseWidthOffset_;
- else
- titleFrame.size.width += titleCloseWidthOffset_;
+ if (newShowCloseButton) {
+ newTitleFrame.size.width = NSMinX([closeButton_ frame]) -
+ NSMinX(newTitleFrame);
viettrungluu 2010/12/14 00:19:50 Presumably you may want to calculate the x-coordin
sail 2010/12/14 01:59:53 Done.
+ } else {
+ newTitleFrame.size.width = NSMaxX([closeButton_ frame]) -
+ NSMinX(newTitleFrame);
viettrungluu 2010/12/14 00:19:50 "
sail 2010/12/14 01:59:53 Done.
}
- [titleView_ setFrame:titleFrame];
+ [titleView_ setFrame:newTitleFrame];
}
- (void)updateTitleColor {

Powered by Google App Engine
This is Rietveld 408576698