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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 1861783002: Make sure to fill canvas opaquely when painting bookmark bar background. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: elaborate on comment Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // or page content according to |at_top| with |color|. 211 // or page content according to |at_top| with |color|.
212 void PaintHorizontalBorder(gfx::Canvas* canvas, 212 void PaintHorizontalBorder(gfx::Canvas* canvas,
213 BookmarkBarView* view, 213 BookmarkBarView* view,
214 bool at_top, 214 bool at_top,
215 SkColor color) { 215 SkColor color) {
216 int thickness = views::NonClientFrameView::kClientEdgeThickness; 216 int thickness = views::NonClientFrameView::kClientEdgeThickness;
217 int y = at_top ? 0 : (view->height() - thickness); 217 int y = at_top ? 0 : (view->height() - thickness);
218 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), color); 218 canvas->FillRect(gfx::Rect(0, y, view->width(), thickness), color);
219 } 219 }
220 220
221 // TODO(kuan): These functions are temporarily for the bookmark bar while its
222 // detached state is at the top of the page; it'll be moved to float on the
223 // content page in the very near future, at which time, these local functions
224 // will be removed.
225 void PaintDetachedBookmarkBar(gfx::Canvas* canvas, 221 void PaintDetachedBookmarkBar(gfx::Canvas* canvas,
226 BookmarkBarView* view, 222 BookmarkBarView* view) {
227 Profile* profile) {
228 // Paint background for detached state; if animating, this is fade in/out. 223 // Paint background for detached state; if animating, this is fade in/out.
229 const ui::ThemeProvider& tp = 224 const ui::ThemeProvider* tp = view->GetThemeProvider();
230 ThemeService::GetThemeProviderForProfile(profile); 225 // In detached mode, the bar is meant to overlap with |contents_container_|.
226 // Since the layer for |view| is opaque, we have to recreate that base color
227 // here. (The detached background color may be partially transparent.)
231 canvas->DrawColor( 228 canvas->DrawColor(
232 tp.GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND)); 229 tp->GetColor(ThemeProperties::COLOR_CONTROL_BACKGROUND));
230 canvas->DrawColor(
231 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND));
232
233 // Draw the separators above and below bookmark bar; 233 // Draw the separators above and below bookmark bar;
234 // if animating, these are fading in/out. 234 // if animating, these are fading in/out.
235 SkColor separator_color = 235 SkColor separator_color =
236 tp.GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR); 236 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR);
237 237
238 if (ui::MaterialDesignController::IsModeMaterial()) { 238 if (ui::MaterialDesignController::IsModeMaterial()) {
239 BrowserView::Paint1pxHorizontalLine( 239 BrowserView::Paint1pxHorizontalLine(
240 canvas, separator_color, 240 canvas, separator_color,
241 gfx::Rect(0, 0, view->width(), 241 gfx::Rect(0, 0, view->width(),
242 views::NonClientFrameView::kClientEdgeThickness), 242 views::NonClientFrameView::kClientEdgeThickness),
243 true); 243 true);
244 } else { 244 } else {
245 PaintHorizontalBorder(canvas, view, true, separator_color); 245 PaintHorizontalBorder(canvas, view, true, separator_color);
246 } 246 }
247 247
248 // For the bottom separator, increase the luminance. Either double it or halve 248 // For the bottom separator, increase the luminance. Either double it or halve
249 // the distance to 1.0, whichever is less of a difference. 249 // the distance to 1.0, whichever is less of a difference.
250 color_utils::HSL hsl; 250 color_utils::HSL hsl;
251 color_utils::SkColorToHSL(separator_color, &hsl); 251 color_utils::SkColorToHSL(separator_color, &hsl);
252 hsl.l = std::min((hsl.l + 1) / 2, hsl.l * 2); 252 hsl.l = std::min((hsl.l + 1) / 2, hsl.l * 2);
253 BrowserView::Paint1pxHorizontalLine( 253 BrowserView::Paint1pxHorizontalLine(
254 canvas, color_utils::HSLToSkColor(hsl, SK_AlphaOPAQUE), 254 canvas, color_utils::HSLToSkColor(hsl, SK_AlphaOPAQUE),
255 view->GetLocalBounds(), true); 255 view->GetLocalBounds(), true);
256 } 256 }
257 257
258 // Paints the background (including the theme image behind content area) for 258 // Paints the background (including the theme image behind content area) for
259 // the Bookmarks Bar when it is attached to the Toolbar into |bounds|. 259 // the Bookmarks Bar when it is attached to the Toolbar into |bounds|.
260 // |background_origin| is the origin to use for painting the theme image. 260 // |background_origin| is the origin to use for painting the theme image.
261 void PaintBackgroundAttachedMode(gfx::Canvas* canvas, 261 void PaintBackgroundAttachedMode(gfx::Canvas* canvas,
262 const ui::ThemeProvider* theme_provider, 262 const ui::ThemeProvider* theme_provider,
263 const gfx::Rect& bounds, 263 const gfx::Rect& bounds,
264 const gfx::Point& background_origin) { 264 const gfx::Point& background_origin) {
265 canvas->FillRect(bounds, 265 canvas->DrawColor(theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR));
266 theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR));
267 266
268 // Always tile the background image in pre-MD. In MD, only tile if there's a 267 // Always tile the background image in pre-MD. In MD, only tile if there's a
269 // non-default image. 268 // non-default image.
270 // TODO(estade): remove IDR_THEME_TOOLBAR when MD is default. 269 // TODO(estade): remove IDR_THEME_TOOLBAR when MD is default.
271 if (theme_provider->HasCustomImage(IDR_THEME_TOOLBAR) || 270 if (theme_provider->HasCustomImage(IDR_THEME_TOOLBAR) ||
272 !ui::MaterialDesignController::IsModeMaterial()) { 271 !ui::MaterialDesignController::IsModeMaterial()) {
273 canvas->TileImageInt(*theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR), 272 canvas->TileImageInt(*theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR),
274 background_origin.x(), 273 background_origin.x(),
275 background_origin.y(), 274 background_origin.y(),
276 bounds.x(), 275 bounds.x(),
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 PaintAttachedBookmarkBar(canvas, bookmark_bar_view_, browser_view_, 431 PaintAttachedBookmarkBar(canvas, bookmark_bar_view_, browser_view_,
433 toolbar_overlap); 432 toolbar_overlap);
434 } 433 }
435 434
436 if (!bookmark_bar_view_->IsDetached() || detached_alpha == 0) 435 if (!bookmark_bar_view_->IsDetached() || detached_alpha == 0)
437 return; 436 return;
438 437
439 // While animating, set opacity to cross-fade between attached and detached 438 // While animating, set opacity to cross-fade between attached and detached
440 // backgrounds including their respective separators. 439 // backgrounds including their respective separators.
441 canvas->SaveLayerAlpha(detached_alpha); 440 canvas->SaveLayerAlpha(detached_alpha);
442 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile()); 441 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_);
443 canvas->Restore(); 442 canvas->Restore();
444 } 443 }
445 444
446 /////////////////////////////////////////////////////////////////////////////// 445 ///////////////////////////////////////////////////////////////////////////////
447 // BrowserView, public: 446 // BrowserView, public:
448 447
449 // static 448 // static
450 const char BrowserView::kViewClassName[] = "BrowserView"; 449 const char BrowserView::kViewClassName[] = "BrowserView";
451 450
452 BrowserView::BrowserView() 451 BrowserView::BrowserView()
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 } 2666 }
2668 2667
2669 extensions::ActiveTabPermissionGranter* 2668 extensions::ActiveTabPermissionGranter*
2670 BrowserView::GetActiveTabPermissionGranter() { 2669 BrowserView::GetActiveTabPermissionGranter() {
2671 content::WebContents* web_contents = GetActiveWebContents(); 2670 content::WebContents* web_contents = GetActiveWebContents();
2672 if (!web_contents) 2671 if (!web_contents)
2673 return nullptr; 2672 return nullptr;
2674 return extensions::TabHelper::FromWebContents(web_contents) 2673 return extensions::TabHelper::FromWebContents(web_contents)
2675 ->active_tab_permission_granter(); 2674 ->active_tab_permission_granter();
2676 } 2675 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698