fix: BrowserWindow.setBackgroundColor
should work with transparency (#42928)
fix: BrowserWindow.setBackgroundColor should work with transparency Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
5029bce65c
commit
85cb6d9476
2 changed files with 35 additions and 12 deletions
|
@ -3724,14 +3724,17 @@ void WebContents::SetBackgroundColor(std::optional<SkColor> maybe_color) {
|
|||
type_ == Type::kBrowserView
|
||||
? SK_ColorTRANSPARENT
|
||||
: SK_ColorWHITE);
|
||||
bool is_opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
|
||||
web_contents()->SetPageBaseBackgroundColor(color);
|
||||
|
||||
content::RenderFrameHost* rfh = web_contents()->GetPrimaryMainFrame();
|
||||
if (!rfh)
|
||||
return;
|
||||
|
||||
content::RenderWidgetHostView* rwhv = rfh->GetView();
|
||||
if (rwhv) {
|
||||
rwhv->SetBackgroundColor(color);
|
||||
// RenderWidgetHostView doesn't allow setting an alpha that's not 0 or 255.
|
||||
rwhv->SetBackgroundColor(is_opaque ? color : SK_ColorTRANSPARENT);
|
||||
static_cast<content::RenderWidgetHostViewBase*>(rwhv)
|
||||
->SetContentBackgroundColor(color);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue