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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm

Issue 7326043: The text color for BookmarkButton sometimes doesn't get updated. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added comment. Moved applyTextColor to Private protocol. Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
index 2add75208da79b5be1e97a6c158bf9512c2874d9..33cf9f3d675ca1468a996ab4431448bd5d9e9901 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
@@ -18,6 +18,7 @@
@interface BookmarkButtonCell(Private)
- (void)configureBookmarkButtonCell;
+- (void)applyTextColor;
@end
@@ -46,6 +47,8 @@
if ((self = [super initTextCell:cellText])) {
[self configureBookmarkButtonCell];
John Grabowski 2011/07/12 02:15:38 Minor nit: we now have 3 method calls with blank l
+ [self setTextColor:[NSColor redColor]];
+
[self setBookmarkNode:node];
if (node) {
@@ -160,20 +163,25 @@
return menu;
}
-// Unfortunately, NSCell doesn't already have something like this.
-// TODO(jrg): consider placing in GTM.
-- (void)setTextColor:(NSColor*)color {
+- (void)setTitle:(NSString*)title {
+ if ([[self title] isEqualTo:title])
+ return;
+ [super setTitle:title];
+ [self applyTextColor];
+}
- // We can't properly set the cell's text color without a control.
- // In theory we could just save the next for later and wait until
- // the cell is moved to a control, but there is no obvious way to
- // accomplish that (e.g. no "cellDidMoveToControl" notification.)
- DCHECK([self controlView]);
+- (void)setTextColor:(NSColor*)color {
+ if ([textColor_ isEqualTo:color])
+ return;
+ textColor_.reset([color copy]);
+ [self applyTextColor];
+}
+- (void)applyTextColor {
John Grabowski 2011/07/12 02:15:38 Add comment in code explaining why this is here.
scoped_nsobject<NSMutableParagraphStyle> style([NSMutableParagraphStyle new]);
[style setAlignment:NSLeftTextAlignment];
NSDictionary* dict = [NSDictionary
- dictionaryWithObjectsAndKeys:color,
+ dictionaryWithObjectsAndKeys:textColor_,
NSForegroundColorAttributeName,
[self font], NSFontAttributeName,
style.get(), NSParagraphStyleAttributeName,
@@ -181,11 +189,7 @@
scoped_nsobject<NSAttributedString> ats([[NSAttributedString alloc]
initWithString:[self title]
attributes:dict]);
- NSButton* button = static_cast<NSButton*>([self controlView]);
- if (button) {
- DCHECK([button isKindOfClass:[NSButton class]]);
- [button setAttributedTitle:ats.get()];
- }
+ [self setAttributedTitle:ats.get()];
}
// To implement "hover open a bookmark button to open the folder"
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698