Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/contents_web_view.h" | 5 #include "chrome/browser/ui/views/frame/contents_web_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/themes/theme_properties.h" | 7 #include "chrome/browser/themes/theme_properties.h" |
| 8 #include "chrome/browser/ui/views/status_bubble_views.h" | 8 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 9 #include "content/public/browser/render_widget_host_view.h" | 9 #include "content/public/browser/render_widget_host_view.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 void ContentsWebView::OnThemeChanged() { | 51 void ContentsWebView::OnThemeChanged() { |
| 52 const ui::ThemeProvider* const theme = GetThemeProvider(); | 52 const ui::ThemeProvider* const theme = GetThemeProvider(); |
| 53 if (!theme) | 53 if (!theme) |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 // Set the background color to a dark tint of the new tab page's background | 56 // Set the background color to a dark tint of the new tab page's background |
| 57 // color. This is the color filled within the WebView's bounds when its child | 57 // color. This is the color filled within the WebView's bounds when its child |
| 58 // view is sized specially for fullscreen tab capture. See WebView header | 58 // view is sized specially for fullscreen tab capture. See WebView header |
| 59 // file comments for more details. | 59 // file comments for more details. |
| 60 const int kBackgroundBrightness = 0x33; // 20% | 60 const int kBackgroundBrightness = 0x33; // 20% |
| 61 const SkColor ntp_background = | 61 // Make sure the background is opaque. |
| 62 theme->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND); | 62 const SkColor ntp_background = color_utils::GetResultingPaintColor( |
| 63 theme->GetColor(ThemeProperties::COLOR_NTP_BACKGROUND), SK_ColorWHITE); | |
| 63 set_background(views::Background::CreateSolidBackground( | 64 set_background(views::Background::CreateSolidBackground( |
| 64 SkColorGetR(ntp_background) * kBackgroundBrightness / 0xFF, | 65 SkColorGetR(ntp_background) * kBackgroundBrightness / 0xFF, |
| 65 SkColorGetG(ntp_background) * kBackgroundBrightness / 0xFF, | 66 SkColorGetG(ntp_background) * kBackgroundBrightness / 0xFF, |
| 66 SkColorGetB(ntp_background) * kBackgroundBrightness / 0xFF, | 67 SkColorGetB(ntp_background) * kBackgroundBrightness / 0xFF, |
| 67 SkColorGetA(ntp_background))); | 68 SkColorGetA(ntp_background))); |
|
Peter Kasting
2017/05/08 23:11:14
Seems like this SkColorGetA can just become SK_Alp
Evan Stade
2017/05/09 14:14:31
It could. I considered it. Which is more correct/r
| |
| 68 | 69 |
| 69 | 70 |
| 70 if (web_contents()) { | 71 if (web_contents()) { |
| 71 content::RenderWidgetHostView* rwhv = | 72 content::RenderWidgetHostView* rwhv = |
| 72 web_contents()->GetRenderWidgetHostView(); | 73 web_contents()->GetRenderWidgetHostView(); |
| 73 if (rwhv) | 74 if (rwhv) |
| 74 rwhv->SetBackgroundColor(ntp_background); | 75 rwhv->SetBackgroundColor(ntp_background); |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 | 78 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 cloned_layer_tree_.reset(); | 123 cloned_layer_tree_.reset(); |
| 123 DestroyLayer(); | 124 DestroyLayer(); |
| 124 set_layer_owner_delegate(nullptr); | 125 set_layer_owner_delegate(nullptr); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void ContentsWebView::RenderViewReady() { | 128 void ContentsWebView::RenderViewReady() { |
| 128 // Apply the theme color to be the default background on startup. | 129 // Apply the theme color to be the default background on startup. |
| 129 OnThemeChanged(); | 130 OnThemeChanged(); |
| 130 WebView::RenderViewReady(); | 131 WebView::RenderViewReady(); |
| 131 } | 132 } |
| OLD | NEW |