Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include "chrome/browser/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 // The number of milliseconds between loading animation frames. | 193 // The number of milliseconds between loading animation frames. |
| 194 const int kLoadingAnimationFrameTimeMs = 30; | 194 const int kLoadingAnimationFrameTimeMs = 30; |
| 195 | 195 |
| 196 // Paints the horizontal border separating the Bookmarks Bar from the Toolbar | 196 // Paints the horizontal border separating the Bookmarks Bar from the Toolbar |
| 197 // or page content according to |at_top| with |color|. | 197 // or page content according to |at_top| with |color|. |
| 198 void PaintDetachedBookmarkBar(gfx::Canvas* canvas, | 198 void PaintDetachedBookmarkBar(gfx::Canvas* canvas, |
| 199 BookmarkBarView* view) { | 199 BookmarkBarView* view) { |
| 200 // Paint background for detached state; if animating, this is fade in/out. | 200 // Paint background for detached state; if animating, this is fade in/out. |
| 201 const ui::ThemeProvider* tp = view->GetThemeProvider(); | 201 const ui::ThemeProvider* tp = view->GetThemeProvider(); |
| 202 gfx::Rect fill_rect = view->GetLocalBounds(); | 202 gfx::Rect fill_rect = view->GetLocalBounds(); |
| 203 // We have to not color the top 1dp, because that should be painted by the | |
| 204 // toolbar. We will, however, paint the 1px separator at the bottom of the | |
| 205 // first dp. See crbug.com/610359 | |
| 206 fill_rect.Inset(0, 1, 0, 0); | |
| 207 | 203 |
| 208 // In detached mode, the bar is meant to overlap with |contents_container_|. | 204 // In detached mode, the bar is meant to overlap with |contents_container_|. |
| 209 // The detached background color may be partially transparent, but the layer | 205 // The detached background color may be partially transparent, but the layer |
| 210 // for |view| must be painted opaquely to avoid subpixel anti-aliasing | 206 // for |view| must be painted opaquely to avoid subpixel anti-aliasing |
| 211 // artifacts, so we recreate the contents container base color here. | 207 // artifacts, so we recreate the contents container base color here. |
| 212 canvas->FillRect(fill_rect, | 208 canvas->FillRect(fill_rect, |
| 213 tp->GetColor(ThemeProperties::COLOR_CONTROL_BACKGROUND)); | 209 tp->GetColor(ThemeProperties::COLOR_CONTROL_BACKGROUND)); |
| 214 canvas->FillRect( | 210 canvas->FillRect( |
| 215 fill_rect, | 211 fill_rect, |
| 216 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND)); | 212 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND)); |
| 217 | 213 |
| 218 // Draw the separators above and below bookmark bar; | 214 // Draw the separators above and below bookmark bar; |
| 219 // if animating, these are fading in/out. | 215 // if animating, these are fading in/out. |
| 220 SkColor separator_color = | 216 SkColor separator_color = |
| 221 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR); | 217 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR); |
| 222 | 218 |
| 223 // For the bottom separator, increase the luminance. Either double it or halve | 219 // For the bottom separator, increase the luminance. Either double it or halve |
| 224 // the distance to 1.0, whichever is less of a difference. | 220 // the distance to 1.0, whichever is less of a difference. |
| 225 color_utils::HSL hsl; | 221 color_utils::HSL hsl; |
| 226 color_utils::SkColorToHSL(separator_color, &hsl); | 222 color_utils::SkColorToHSL(separator_color, &hsl); |
| 227 hsl.l = std::min((hsl.l + 1) / 2, hsl.l * 2); | 223 hsl.l = std::min((hsl.l + 1) / 2, hsl.l * 2); |
| 228 BrowserView::Paint1pxHorizontalLine( | 224 BrowserView::Paint1pxHorizontalLine( |
| 225 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR), | |
| 226 view->GetLocalBounds(), false); | |
|
Evan Stade
2017/05/26 15:03:41
Isn't this separator already being drawn by Opaque
| |
| 227 BrowserView::Paint1pxHorizontalLine( | |
| 229 canvas, color_utils::HSLToSkColor(hsl, SK_AlphaOPAQUE), | 228 canvas, color_utils::HSLToSkColor(hsl, SK_AlphaOPAQUE), |
| 230 view->GetLocalBounds(), true); | 229 view->GetLocalBounds(), true); |
| 231 } | 230 } |
| 232 | 231 |
| 233 // Paints the background (including the theme image behind content area) for | 232 // Paints the background (including the theme image behind content area) for |
| 234 // the Bookmarks Bar when it is attached to the Toolbar into |bounds|. | 233 // the Bookmarks Bar when it is attached to the Toolbar into |bounds|. |
| 235 // |background_origin| is the origin to use for painting the theme image. | 234 // |background_origin| is the origin to use for painting the theme image. |
| 236 void PaintBackgroundAttachedMode(gfx::Canvas* canvas, | 235 void PaintBackgroundAttachedMode(gfx::Canvas* canvas, |
| 237 const ui::ThemeProvider* theme_provider, | 236 const ui::ThemeProvider* theme_provider, |
| 238 const gfx::Rect& bounds, | 237 const gfx::Rect& bounds, |
| (...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2692 } | 2691 } |
| 2693 | 2692 |
| 2694 extensions::ActiveTabPermissionGranter* | 2693 extensions::ActiveTabPermissionGranter* |
| 2695 BrowserView::GetActiveTabPermissionGranter() { | 2694 BrowserView::GetActiveTabPermissionGranter() { |
| 2696 content::WebContents* web_contents = GetActiveWebContents(); | 2695 content::WebContents* web_contents = GetActiveWebContents(); |
| 2697 if (!web_contents) | 2696 if (!web_contents) |
| 2698 return nullptr; | 2697 return nullptr; |
| 2699 return extensions::TabHelper::FromWebContents(web_contents) | 2698 return extensions::TabHelper::FromWebContents(web_contents) |
| 2700 ->active_tab_permission_granter(); | 2699 ->active_tab_permission_granter(); |
| 2701 } | 2700 } |
| OLD | NEW |