mac: Call SetBackgroundOpaque in BrowserWindow

This commit is contained in:
Cheng Zhao 2018-03-06 13:47:21 +09:00
Родитель 8a1884c407
Коммит 7d4ff3b061
3 изменённых файлов: 10 добавлений и 24 удалений

Просмотреть файл

@ -1116,8 +1116,17 @@ void BrowserWindow::AddTabbedWindow(NativeWindow* window,
void BrowserWindow::SetVibrancy(mate::Arguments* args) { void BrowserWindow::SetVibrancy(mate::Arguments* args) {
std::string type; std::string type;
args->GetNext(&type); args->GetNext(&type);
auto* render_view_host = web_contents()->GetRenderViewHost();
if (render_view_host) {
auto* impl = content::RenderWidgetHostImpl::FromID(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (impl)
impl->SetBackgroundOpaque(type.empty() ? !window_->transparent() : false);
}
window_->SetVibrancy(type); window_->SetVibrancy(type);
} }

Просмотреть файл

@ -154,8 +154,6 @@ class NativeWindowMac : public NativeWindow {
void InstallView(); void InstallView();
void UninstallView(); void UninstallView();
void SetRenderWidgetHostOpaque(bool opaque);
base::scoped_nsobject<AtomNSWindow> window_; base::scoped_nsobject<AtomNSWindow> window_;
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_; base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;

Просмотреть файл

@ -20,12 +20,7 @@
#include "brightray/browser/inspectable_web_contents.h" #include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h" #include "brightray/browser/inspectable_web_contents_view.h"
#include "brightray/browser/mac/event_dispatching_window.h" #include "brightray/browser/mac/event_dispatching_window.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "native_mate/dictionary.h" #include "native_mate/dictionary.h"
#include "skia/ext/skia_utils_mac.h" #include "skia/ext/skia_utils_mac.h"
#include "third_party/skia/include/core/SkRegion.h" #include "third_party/skia/include/core/SkRegion.h"
@ -1652,20 +1647,6 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) {
return true; return true;
} }
void NativeWindowMac::SetRenderWidgetHostOpaque(bool opaque) {
if (!web_contents()) return;
auto render_view_host = web_contents()->GetRenderViewHost();
if (!render_view_host) return;
content::RenderWidgetHostImpl* impl = content::RenderWidgetHostImpl::FromID(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (!impl) return;
impl->SetBackgroundOpaque(opaque);
}
void NativeWindowMac::SetVibrancy(const std::string& type) { void NativeWindowMac::SetVibrancy(const std::string& type) {
if (!base::mac::IsAtLeastOS10_10()) return; if (!base::mac::IsAtLeastOS10_10()) return;
@ -1676,7 +1657,6 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
[window_ setBackgroundColor:background_color_before_vibrancy_]; [window_ setBackgroundColor:background_color_before_vibrancy_];
[window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_]; [window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_];
} }
SetRenderWidgetHostOpaque(!transparent());
if (vibrant_view == nil) return; if (vibrant_view == nil) return;
[vibrant_view removeFromSuperview]; [vibrant_view removeFromSuperview];
@ -1685,7 +1665,6 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
return; return;
} }
SetRenderWidgetHostOpaque(false);
background_color_before_vibrancy_.reset([window_ backgroundColor]); background_color_before_vibrancy_.reset([window_ backgroundColor]);
transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent]; transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent];