fix: transparency on child windows being lost (#31003)
* fix: transparency on child windows being lost * fix crash * fix a different crash * fix more crash
This commit is contained in:
		
					parent
					
						
							
								6dd33b75b2
							
						
					
				
			
			
				commit
				
					
						82da4b0090
					
				
			
		
					 2 changed files with 14 additions and 3 deletions
				
			
		| 
						 | 
					@ -362,7 +362,11 @@ void BrowserWindow::Blur() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
 | 
					void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
 | 
				
			||||||
  BaseWindow::SetBackgroundColor(color_name);
 | 
					  BaseWindow::SetBackgroundColor(color_name);
 | 
				
			||||||
  web_contents()->SetPageBaseBackgroundColor(ParseHexColor(color_name));
 | 
					  SkColor color = ParseHexColor(color_name);
 | 
				
			||||||
 | 
					  web_contents()->SetPageBaseBackgroundColor(color);
 | 
				
			||||||
 | 
					  auto* rwhv = web_contents()->GetRenderWidgetHostView();
 | 
				
			||||||
 | 
					  if (rwhv)
 | 
				
			||||||
 | 
					    rwhv->SetBackgroundColor(color);
 | 
				
			||||||
  // Also update the web preferences object otherwise the view will be reset on
 | 
					  // Also update the web preferences object otherwise the view will be reset on
 | 
				
			||||||
  // the next load URL call
 | 
					  // the next load URL call
 | 
				
			||||||
  if (api_web_contents_) {
 | 
					  if (api_web_contents_) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1373,8 +1373,9 @@ void WebContents::HandleNewRenderFrame(
 | 
				
			||||||
  // Set the background color of RenderWidgetHostView.
 | 
					  // Set the background color of RenderWidgetHostView.
 | 
				
			||||||
  auto* web_preferences = WebContentsPreferences::From(web_contents());
 | 
					  auto* web_preferences = WebContentsPreferences::From(web_contents());
 | 
				
			||||||
  if (web_preferences) {
 | 
					  if (web_preferences) {
 | 
				
			||||||
    web_contents()->SetPageBaseBackgroundColor(
 | 
					    absl::optional<SkColor> color = web_preferences->GetBackgroundColor();
 | 
				
			||||||
        web_preferences->GetBackgroundColor());
 | 
					    web_contents()->SetPageBaseBackgroundColor(color);
 | 
				
			||||||
 | 
					    rwhv->SetBackgroundColor(color.value_or(SK_ColorWHITE));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!background_throttling_)
 | 
					  if (!background_throttling_)
 | 
				
			||||||
| 
						 | 
					@ -3866,6 +3867,12 @@ gin::Handle<WebContents> WebContents::CreateFromWebPreferences(
 | 
				
			||||||
    if (gin::ConvertFromV8(isolate, web_preferences.GetHandle(),
 | 
					    if (gin::ConvertFromV8(isolate, web_preferences.GetHandle(),
 | 
				
			||||||
                           &web_preferences_dict)) {
 | 
					                           &web_preferences_dict)) {
 | 
				
			||||||
      existing_preferences->SetFromDictionary(web_preferences_dict);
 | 
					      existing_preferences->SetFromDictionary(web_preferences_dict);
 | 
				
			||||||
 | 
					      absl::optional<SkColor> color =
 | 
				
			||||||
 | 
					          existing_preferences->GetBackgroundColor();
 | 
				
			||||||
 | 
					      web_contents->web_contents()->SetPageBaseBackgroundColor(color);
 | 
				
			||||||
 | 
					      auto* rwhv = web_contents->web_contents()->GetRenderWidgetHostView();
 | 
				
			||||||
 | 
					      if (rwhv)
 | 
				
			||||||
 | 
					        rwhv->SetBackgroundColor(color.value_or(SK_ColorWHITE));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    // Create one if not.
 | 
					    // Create one if not.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue