summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-05 22:03:47 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-05 22:03:47 +0000
commit54d3bb9ad25124af1949fb0eda1acf20bef9d38c (patch)
treebe8699ca71d0a44796af307074b4420014c8936b
parente91357ad8e2a260eebff4764945628c859fc7dee (diff)
downloadchromium_src-54d3bb9ad25124af1949fb0eda1acf20bef9d38c.zip
chromium_src-54d3bb9ad25124af1949fb0eda1acf20bef9d38c.tar.gz
chromium_src-54d3bb9ad25124af1949fb0eda1acf20bef9d38c.tar.bz2
Merge 264363 "CoreAnimation: Fix text anti-aliasing in download ..."
> CoreAnimation: Fix text anti-aliasing in download shelf > > Make the download shelf buttons opaque, and have them use the download > shelf's draw function to draw. > > Add a helper function to look up an ancestor view based on the view ID. > This is particularly useful because the download shelf is five views > above the download shelf button view. > > Update the bookmark button view function to refer to the toolbar view > as the download shelf toolbar view (which does not have a view ID > associated with it). > > BUG=363750 > > Review URL: https://codereview.chromium.org/240093006 TBR=ccameron@chromium.org Review URL: https://codereview.chromium.org/263093006 git-svn-id: svn://svn.chromium.org/chrome/branches/1916/src@268288 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm8
-rw-r--r--chrome/browser/ui/cocoa/download/download_item_button.mm14
-rw-r--r--chrome/browser/ui/cocoa/download/download_show_all_button.mm14
-rw-r--r--chrome/browser/ui/cocoa/view_id_util.h4
-rw-r--r--chrome/browser/ui/cocoa/view_id_util.mm7
5 files changed, 43 insertions, 4 deletions
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm
index cc3f93b..042d1a2 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button.mm
@@ -405,14 +405,14 @@ BookmarkButton* gDraggedButton = nil; // Weak
}
- (BOOL)isOpaque {
- // Make this control opaque so that sub pixel anti aliasing works when core
- // animation is enabled.
+ // Make this control opaque so that sub-pixel anti-aliasing works when
+ // CoreAnimation is enabled.
return YES;
}
- (void)drawRect:(NSRect)rect {
- NSView* toolbarView = [[self superview] superview];
- [self cr_drawUsingAncestor:toolbarView inRect:(NSRect)rect];
+ NSView* bookmarkBarToolbarView = [[self superview] superview];
+ [self cr_drawUsingAncestor:bookmarkBarToolbarView inRect:(NSRect)rect];
[super drawRect:rect];
}
diff --git a/chrome/browser/ui/cocoa/download/download_item_button.mm b/chrome/browser/ui/cocoa/download/download_item_button.mm
index 0a6a7a9..67726e8 100644
--- a/chrome/browser/ui/cocoa/download/download_item_button.mm
+++ b/chrome/browser/ui/cocoa/download/download_item_button.mm
@@ -9,6 +9,8 @@
#import "chrome/browser/ui/cocoa/download/download_item_cell.h"
#import "chrome/browser/ui/cocoa/download/download_item_controller.h"
#import "chrome/browser/ui/cocoa/download/download_shelf_context_menu_controller.h"
+#import "chrome/browser/ui/cocoa/nsview_additions.h"
+#import "chrome/browser/ui/cocoa/view_id_util.h"
@implementation DownloadItemButton
@@ -60,4 +62,16 @@
return YES;
}
+- (BOOL)isOpaque {
+ // Make this control opaque so that sub-pixel anti-aliasing works when
+ // CoreAnimation is enabled.
+ return YES;
+}
+
+- (void)drawRect:(NSRect)rect {
+ NSView* downloadShelfView = [self ancestorWithViewID:VIEW_ID_DOWNLOAD_SHELF];
+ [self cr_drawUsingAncestor:downloadShelfView inRect:rect];
+ [super drawRect:rect];
+}
+
@end
diff --git a/chrome/browser/ui/cocoa/download/download_show_all_button.mm b/chrome/browser/ui/cocoa/download/download_show_all_button.mm
index 81b6354..196a7ff 100644
--- a/chrome/browser/ui/cocoa/download/download_show_all_button.mm
+++ b/chrome/browser/ui/cocoa/download/download_show_all_button.mm
@@ -6,6 +6,8 @@
#include "base/logging.h"
#import "chrome/browser/ui/cocoa/download/download_show_all_cell.h"
+#import "chrome/browser/ui/cocoa/nsview_additions.h"
+#import "chrome/browser/ui/cocoa/view_id_util.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
@@ -35,4 +37,16 @@
[self setFrame:newRect];
}
+- (BOOL)isOpaque {
+ // Make this control opaque so that sub-pixel anti-aliasing works when
+ // CoreAnimation is enabled.
+ return YES;
+}
+
+- (void)drawRect:(NSRect)rect {
+ NSView* downloadShelfView = [self ancestorWithViewID:VIEW_ID_DOWNLOAD_SHELF];
+ [self cr_drawUsingAncestor:downloadShelfView inRect:rect];
+ [super drawRect:rect];
+}
+
@end
diff --git a/chrome/browser/ui/cocoa/view_id_util.h b/chrome/browser/ui/cocoa/view_id_util.h
index 2b16624..e104ad8 100644
--- a/chrome/browser/ui/cocoa/view_id_util.h
+++ b/chrome/browser/ui/cocoa/view_id_util.h
@@ -46,6 +46,10 @@ NSView* GetView(NSWindow* window, ViewID viewID);
// override this method to return its fixed ViewID.
- (ViewID)viewID;
+// Returns the ancestor view with a specific ViewID, or nil if no ancestor
+// view has that ViewID.
+- (NSView*)ancestorWithViewID:(ViewID)viewID;
+
@end
#endif // CHROME_BROWSER_UI_COCOA_VIEW_ID_UTIL_H_
diff --git a/chrome/browser/ui/cocoa/view_id_util.mm b/chrome/browser/ui/cocoa/view_id_util.mm
index 691c7f3..6dd19ad 100644
--- a/chrome/browser/ui/cocoa/view_id_util.mm
+++ b/chrome/browser/ui/cocoa/view_id_util.mm
@@ -86,4 +86,11 @@ NSView* GetView(NSWindow* window, ViewID viewID) {
return iter != map->end() ? iter->second : VIEW_ID_NONE;
}
+- (NSView*)ancestorWithViewID:(ViewID)viewID {
+ NSView* ancestor = self;
+ while (ancestor && [ancestor viewID] != viewID)
+ ancestor = [ancestor superview];
+ return ancestor;
+}
+
@end