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

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: color_frame 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 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 223 // content page in the very near future, at which time, these local functions
224 // will be removed. 224 // will be removed.
225 void PaintDetachedBookmarkBar(gfx::Canvas* canvas, 225 void PaintDetachedBookmarkBar(gfx::Canvas* canvas,
226 BookmarkBarView* view, 226 BookmarkBarView* view) {
227 Profile* profile) {
228 // Paint background for detached state; if animating, this is fade in/out. 227 // Paint background for detached state; if animating, this is fade in/out.
229 const ui::ThemeProvider& tp = 228 const ui::ThemeProvider* tp = view->GetThemeProvider();
230 ThemeService::GetThemeProviderForProfile(profile);
231 canvas->DrawColor( 229 canvas->DrawColor(
232 tp.GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND)); 230 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND));
231
233 // Draw the separators above and below bookmark bar; 232 // Draw the separators above and below bookmark bar;
234 // if animating, these are fading in/out. 233 // if animating, these are fading in/out.
235 SkColor separator_color = 234 SkColor separator_color =
236 tp.GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR); 235 tp->GetColor(ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR);
237 236
238 if (ui::MaterialDesignController::IsModeMaterial()) { 237 if (ui::MaterialDesignController::IsModeMaterial()) {
239 BrowserView::Paint1pxHorizontalLine( 238 BrowserView::Paint1pxHorizontalLine(
240 canvas, separator_color, 239 canvas, separator_color,
241 gfx::Rect(0, 0, view->width(), 240 gfx::Rect(0, 0, view->width(),
242 views::NonClientFrameView::kClientEdgeThickness), 241 views::NonClientFrameView::kClientEdgeThickness),
243 true); 242 true);
244 } else { 243 } else {
245 PaintHorizontalBorder(canvas, view, true, separator_color); 244 PaintHorizontalBorder(canvas, view, true, separator_color);
246 } 245 }
247 246
248 // For the bottom separator, increase the luminance. Either double it or halve 247 // For the bottom separator, increase the luminance. Either double it or halve
249 // the distance to 1.0, whichever is less of a difference. 248 // the distance to 1.0, whichever is less of a difference.
250 color_utils::HSL hsl; 249 color_utils::HSL hsl;
251 color_utils::SkColorToHSL(separator_color, &hsl); 250 color_utils::SkColorToHSL(separator_color, &hsl);
252 hsl.l = std::min((hsl.l + 1) / 2, hsl.l * 2); 251 hsl.l = std::min((hsl.l + 1) / 2, hsl.l * 2);
253 BrowserView::Paint1pxHorizontalLine( 252 BrowserView::Paint1pxHorizontalLine(
254 canvas, color_utils::HSLToSkColor(hsl, SK_AlphaOPAQUE), 253 canvas, color_utils::HSLToSkColor(hsl, SK_AlphaOPAQUE),
255 view->GetLocalBounds(), true); 254 view->GetLocalBounds(), true);
256 } 255 }
257 256
258 // Paints the background (including the theme image behind content area) for 257 // Paints the background (including the theme image behind content area) for
259 // the Bookmarks Bar when it is attached to the Toolbar into |bounds|. 258 // 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. 259 // |background_origin| is the origin to use for painting the theme image.
261 void PaintBackgroundAttachedMode(gfx::Canvas* canvas, 260 void PaintBackgroundAttachedMode(gfx::Canvas* canvas,
262 const ui::ThemeProvider* theme_provider, 261 const ui::ThemeProvider* theme_provider,
263 const gfx::Rect& bounds, 262 const gfx::Rect& bounds,
264 const gfx::Point& background_origin) { 263 const gfx::Point& background_origin) {
265 canvas->FillRect(bounds, 264 canvas->DrawColor(theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR));
266 theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR));
267 265
268 // Always tile the background image in pre-MD. In MD, only tile if there's a 266 // Always tile the background image in pre-MD. In MD, only tile if there's a
269 // non-default image. 267 // non-default image.
270 // TODO(estade): remove IDR_THEME_TOOLBAR when MD is default. 268 // TODO(estade): remove IDR_THEME_TOOLBAR when MD is default.
271 if (theme_provider->HasCustomImage(IDR_THEME_TOOLBAR) || 269 if (theme_provider->HasCustomImage(IDR_THEME_TOOLBAR) ||
272 !ui::MaterialDesignController::IsModeMaterial()) { 270 !ui::MaterialDesignController::IsModeMaterial()) {
273 canvas->TileImageInt(*theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR), 271 canvas->TileImageInt(*theme_provider->GetImageSkiaNamed(IDR_THEME_TOOLBAR),
274 background_origin.x(), 272 background_origin.x(),
275 background_origin.y(), 273 background_origin.y(),
276 bounds.x(), 274 bounds.x(),
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 BrowserView* browser_view, 415 BrowserView* browser_view,
418 BookmarkBarView* bookmark_bar_view, 416 BookmarkBarView* bookmark_bar_view,
419 Browser* browser) 417 Browser* browser)
420 : browser_view_(browser_view), 418 : browser_view_(browser_view),
421 bookmark_bar_view_(bookmark_bar_view), 419 bookmark_bar_view_(bookmark_bar_view),
422 browser_(browser) { 420 browser_(browser) {
423 } 421 }
424 422
425 void BookmarkBarViewBackground::Paint(gfx::Canvas* canvas, 423 void BookmarkBarViewBackground::Paint(gfx::Canvas* canvas,
426 views::View* view) const { 424 views::View* view) const {
425 // Start with a frame-colored canvas in case the attached/detached colors
426 // aren't opaque.
427 canvas->DrawColor(SK_ColorBLACK);
428 canvas->DrawColor(
429 view->GetThemeProvider()->GetColor(ThemeProperties::COLOR_FRAME));
sky 2016/04/07 18:23:45 Shouldn't this route through BrowserNonClientFrame
Evan Stade 2016/04/07 19:30:24 This comment led me to realize I was wrong about t
430
427 int toolbar_overlap = bookmark_bar_view_->GetToolbarOverlap(); 431 int toolbar_overlap = bookmark_bar_view_->GetToolbarOverlap();
428 432
429 SkAlpha detached_alpha = static_cast<SkAlpha>( 433 SkAlpha detached_alpha = static_cast<SkAlpha>(
430 bookmark_bar_view_->size_animation().CurrentValueBetween(0xff, 0)); 434 bookmark_bar_view_->size_animation().CurrentValueBetween(0xff, 0));
431 if (detached_alpha != 0xff) { 435 if (detached_alpha != 0xff) {
432 PaintAttachedBookmarkBar(canvas, bookmark_bar_view_, browser_view_, 436 PaintAttachedBookmarkBar(canvas, bookmark_bar_view_, browser_view_,
433 toolbar_overlap); 437 toolbar_overlap);
434 } 438 }
435 439
436 if (!bookmark_bar_view_->IsDetached() || detached_alpha == 0) 440 if (!bookmark_bar_view_->IsDetached() || detached_alpha == 0)
437 return; 441 return;
438 442
439 // While animating, set opacity to cross-fade between attached and detached 443 // While animating, set opacity to cross-fade between attached and detached
440 // backgrounds including their respective separators. 444 // backgrounds including their respective separators.
441 canvas->SaveLayerAlpha(detached_alpha); 445 canvas->SaveLayerAlpha(detached_alpha);
442 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_, browser_->profile()); 446 PaintDetachedBookmarkBar(canvas, bookmark_bar_view_);
443 canvas->Restore(); 447 canvas->Restore();
444 } 448 }
445 449
446 /////////////////////////////////////////////////////////////////////////////// 450 ///////////////////////////////////////////////////////////////////////////////
447 // BrowserView, public: 451 // BrowserView, public:
448 452
449 // static 453 // static
450 const char BrowserView::kViewClassName[] = "BrowserView"; 454 const char BrowserView::kViewClassName[] = "BrowserView";
451 455
452 BrowserView::BrowserView() 456 BrowserView::BrowserView()
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 } 2671 }
2668 2672
2669 extensions::ActiveTabPermissionGranter* 2673 extensions::ActiveTabPermissionGranter*
2670 BrowserView::GetActiveTabPermissionGranter() { 2674 BrowserView::GetActiveTabPermissionGranter() {
2671 content::WebContents* web_contents = GetActiveWebContents(); 2675 content::WebContents* web_contents = GetActiveWebContents();
2672 if (!web_contents) 2676 if (!web_contents)
2673 return nullptr; 2677 return nullptr;
2674 return extensions::TabHelper::FromWebContents(web_contents) 2678 return extensions::TabHelper::FromWebContents(web_contents)
2675 ->active_tab_permission_granter(); 2679 ->active_tab_permission_granter();
2676 } 2680 }
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