| OLD | NEW |
| 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/bookmark_bar_toolbar_view.h" | 5 #import "chrome/browser/cocoa/bookmark_bar_toolbar_view.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas_paint.h" | 7 #include "app/gfx/canvas_paint.h" |
| 8 #include "app/theme_provider.h" | 8 #include "app/theme_provider.h" |
| 9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
| 10 #include "chrome/browser/browser_theme_provider.h" | 10 #include "chrome/browser/browser_theme_provider.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 if (!themeProvider) | 43 if (!themeProvider) |
| 44 return; | 44 return; |
| 45 | 45 |
| 46 NSGraphicsContext* theContext = [NSGraphicsContext currentContext]; | 46 NSGraphicsContext* theContext = [NSGraphicsContext currentContext]; |
| 47 [theContext saveGraphicsState]; | 47 [theContext saveGraphicsState]; |
| 48 | 48 |
| 49 // Draw the background | 49 // Draw the background |
| 50 { | 50 { |
| 51 // CanvasPaint draws to the NSGraphicsContext during its destructor, so | 51 // CanvasPaint draws to the NSGraphicsContext during its destructor, so |
| 52 // explicitly scope this. | 52 // explicitly scope this. |
| 53 gfx::CanvasPaint canvas(rect, true); | 53 // |
| 54 gfx::Rect area(0, 0, NSWidth(rect), NSHeight(rect)); | 54 // Paint the entire bookmark bar, even if the damage rect is much smaller |
| 55 // because PaintBackgroundDetachedMode() assumes that area's origin is |
| 56 // (0, 0) and that its size is the size of the bookmark bar. |
| 57 // |
| 58 // In practice, this sounds worse than it is because redraw time is still |
| 59 // minimal compared to the pause between frames of animations. We were |
| 60 // already repainting the rest of the bookmark bar below without setting a |
| 61 // clip area, anyway. Also, the only time we weren't asked to redraw the |
| 62 // whole bookmark bar is when the find bar is drawn over it. |
| 63 gfx::CanvasPaint canvas(bounds, true); |
| 64 gfx::Rect area(0, 0, NSWidth(bounds), NSHeight(bounds)); |
| 55 | 65 |
| 56 NtpBackgroundUtil::PaintBackgroundDetachedMode(themeProvider, &canvas, | 66 NtpBackgroundUtil::PaintBackgroundDetachedMode(themeProvider, &canvas, |
| 57 area, [controller_ currentTabContentsHeight]); | 67 area, [controller_ currentTabContentsHeight]); |
| 58 } | 68 } |
| 59 | 69 |
| 60 // Draw our bookmark bar border on top of the background. | 70 // Draw our bookmark bar border on top of the background. |
| 61 NSRect frameRect = | 71 NSRect frameRect = |
| 62 NSMakeRect(bookmarks::kNTPBookmarkBarPadding, | 72 NSMakeRect(bookmarks::kNTPBookmarkBarPadding, |
| 63 bookmarks::kNTPBookmarkBarPadding, | 73 bookmarks::kNTPBookmarkBarPadding, |
| 64 NSWidth(bounds) - 2 * bookmarks::kNTPBookmarkBarPadding, | 74 NSWidth(bounds) - 2 * bookmarks::kNTPBookmarkBarPadding, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 85 NSColor* borderColor = | 95 NSColor* borderColor = |
| 86 [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBarButton | 96 [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBarButton |
| 87 state:GTMThemeStateActiveWindow]; | 97 state:GTMThemeStateActiveWindow]; |
| 88 [borderColor set]; | 98 [borderColor set]; |
| 89 [border stroke]; | 99 [border stroke]; |
| 90 | 100 |
| 91 [theContext restoreGraphicsState]; | 101 [theContext restoreGraphicsState]; |
| 92 } | 102 } |
| 93 | 103 |
| 94 @end // @implementation BookmarkBarToolbarView | 104 @end // @implementation BookmarkBarToolbarView |
| OLD | NEW |