зеркало из https://github.com/electron/electron.git
Show label for offscreen webview
This commit is contained in:
Родитель
e644e883ba
Коммит
1a80cb22b7
|
@ -224,11 +224,11 @@ InspectableWebContentsImpl::InspectableWebContentsImpl(
|
|||
gfx::Rect display;
|
||||
if (web_contents->GetNativeView()) {
|
||||
display = display::Screen::GetScreen()->
|
||||
GetDisplayNearestWindow(web_contents->GetNativeView()).bounds();
|
||||
GetDisplayNearestWindow(web_contents->GetNativeView()).bounds();
|
||||
} else {
|
||||
display = display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
|
||||
}
|
||||
|
||||
|
||||
devtools_bounds_.set_x(display.x() + (display.width() - devtools_bounds_.width()) / 2);
|
||||
devtools_bounds_.set_y(display.y() + (display.height() - devtools_bounds_.height()) / 2);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "browser/inspectable_web_contents_view_delegate.h"
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/controls/webview/webview.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views/widget/widget_delegate.h"
|
||||
|
@ -76,14 +77,21 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews(
|
|||
InspectableWebContentsImpl* inspectable_web_contents)
|
||||
: inspectable_web_contents_(inspectable_web_contents),
|
||||
devtools_window_web_view_(nullptr),
|
||||
contents_web_view_(new views::WebView(nullptr)),
|
||||
contents_web_view_(nullptr),
|
||||
devtools_web_view_(new views::WebView(nullptr)),
|
||||
devtools_visible_(false),
|
||||
devtools_window_delegate_(nullptr) {
|
||||
set_owned_by_client();
|
||||
|
||||
if (inspectable_web_contents_->GetWebContents()->GetNativeView()) {
|
||||
views::WebView* contents_web_view = new views::WebView(nullptr);
|
||||
contents_web_view->SetWebContents(inspectable_web_contents_->GetWebContents());
|
||||
contents_web_view_ = contents_web_view;
|
||||
} else {
|
||||
contents_web_view_ = new views::Label(L"No content under offscreen mode");
|
||||
}
|
||||
|
||||
devtools_web_view_->SetVisible(false);
|
||||
contents_web_view_->SetWebContents(inspectable_web_contents_->GetWebContents());
|
||||
AddChildView(devtools_web_view_);
|
||||
AddChildView(contents_web_view_);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView,
|
|||
|
||||
std::unique_ptr<views::Widget> devtools_window_;
|
||||
views::WebView* devtools_window_web_view_;
|
||||
views::WebView* contents_web_view_;
|
||||
views::View* contents_web_view_;
|
||||
views::WebView* devtools_web_view_;
|
||||
|
||||
DevToolsContentsResizingStrategy strategy_;
|
||||
|
|
Загрузка…
Ссылка в новой задаче