electron/shell/browser/osr/osr_web_contents_view.cc
electron-roller[bot] bccb7b572a
chore: bump chromium to 123.0.6272.0 (main) (#41130)
* chore: bump chromium in DEPS to 123.0.6265.0

* chore: bump chromium in DEPS to 123.0.6266.0

* chore: update feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5232280

reverts the revert *and* undoes the rewrites 😵

* chore: update chromium/disable_hidden.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

minor manual intervention

* chore: update patches

* chore: Rename mouse lock to pointer lock

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

* refactor: fix use of newly-removed QuitCurrentWhenIdleClosureDeprecated()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4710351

Xref: https://github.com/electron/electron/pull/26022

This usage was added in #26022 as part of Wayland support and some
simple fiddles WfM with this patch on Wayland, but I'm unsure what
to be testing for & would like a second opinion on this commit.

* chore: bump chromium in DEPS to 123.0.6268.0

* chore: update patches

* 5235021: WebUI: Migrate accessibility and bluetooth internals to WebUIConfig
https://chromium-review.googlesource.com/c/chromium/src/+/5235021

* address review comment for 5196547

See: https://chromium-review.googlesource.com/c/chromium/src/+/5196547
Review comment: https://github.com/electron/electron/pull/41130#discussion_r1468973786

* 5075962: Introduce URLLoaderFactoryBuilder
https://chromium-review.googlesource.com/c/chromium/src/+/5075962

* chore: bump chromium in DEPS to 123.0.6270.0

* the missing semicolon strikes again

* chore: update chromium patches

* chore: update v8 patches

* 5242326: Some followup cleanup to Fuchia files in chrome | https://chromium-review.googlesource.com/c/chromium/src/+/5242326

* chore: bump chromium in DEPS to 123.0.6272.0

* chore: update patches

* chore: update patch after rebase

* 5247339: [Clipboard] Remove ClipboardContentType enum.

https://chromium-review.googlesource.com/c/chromium/src/+/5247339

* Reland: "Allow content shell to enable the built-in DNS resolver"

https://chromium-review.googlesource.com/c/chromium/src/+/5232354

* 5018206: [accessibility] Migrate to ScopedAccessibilityMode

https://chromium-review.googlesource.com/c/chromium/src/+/5018206

* 5246669: [Default Nav Transition]Add GetBackForwardTransitionAnimationManager on WebContentsView | https://chromium-review.googlesource.com/c/chromium/src/+/5246669

* fix: move nut-js to optional spec deps (#41199)

* chore: bump chromium in DEPS to 123.0.6265.0

* chore: bump chromium in DEPS to 123.0.6266.0

* chore: update feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5232280

reverts the revert *and* undoes the rewrites 😵

* chore: update chromium/disable_hidden.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

minor manual intervention

* chore: update patches

* chore: Rename mouse lock to pointer lock

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5148491

* refactor: fix use of newly-removed QuitCurrentWhenIdleClosureDeprecated()

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4710351

Xref: https://github.com/electron/electron/pull/26022

This usage was added in #26022 as part of Wayland support and some
simple fiddles WfM with this patch on Wayland, but I'm unsure what
to be testing for & would like a second opinion on this commit.

* chore: bump chromium in DEPS to 123.0.6268.0

* chore: update patches

* 5235021: WebUI: Migrate accessibility and bluetooth internals to WebUIConfig
https://chromium-review.googlesource.com/c/chromium/src/+/5235021

* address review comment for 5196547

See: https://chromium-review.googlesource.com/c/chromium/src/+/5196547
Review comment: https://github.com/electron/electron/pull/41130#discussion_r1468973786

* 5075962: Introduce URLLoaderFactoryBuilder
https://chromium-review.googlesource.com/c/chromium/src/+/5075962

* chore: bump chromium in DEPS to 123.0.6270.0

* the missing semicolon strikes again

* chore: update chromium patches

* chore: update v8 patches

* 5242326: Some followup cleanup to Fuchia files in chrome | https://chromium-review.googlesource.com/c/chromium/src/+/5242326

* chore: bump chromium in DEPS to 123.0.6272.0

* chore: update patches

* chore: update patch after rebase

* 5247339: [Clipboard] Remove ClipboardContentType enum.

https://chromium-review.googlesource.com/c/chromium/src/+/5247339

* Reland: "Allow content shell to enable the built-in DNS resolver"

https://chromium-review.googlesource.com/c/chromium/src/+/5232354

* 5018206: [accessibility] Migrate to ScopedAccessibilityMode

https://chromium-review.googlesource.com/c/chromium/src/+/5018206

* 5246669: [Default Nav Transition]Add GetBackForwardTransitionAnimationManager on WebContentsView | https://chromium-review.googlesource.com/c/chromium/src/+/5246669

* fix: typescript error for optional dependency

(cherry picked from commit ea17105c8c01bd1f4c1df5e72190a687d92f93cc)

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: VerteDinde <vertedinde@electronjs.org>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Sam Maddock <smaddock@slack-corp.com>
2024-01-31 17:04:13 -06:00

231 lines
6.4 KiB
C++

// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/osr/osr_web_contents_view.h"
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
#include "content/public/browser/render_view_host.h"
#include "ui/display/screen.h"
#include "ui/display/screen_info.h"
namespace electron {
OffScreenWebContentsView::OffScreenWebContentsView(
bool transparent,
const OnPaintCallback& callback)
: transparent_(transparent), callback_(callback) {
#if BUILDFLAG(IS_MAC)
PlatformCreate();
#endif
}
OffScreenWebContentsView::~OffScreenWebContentsView() {
if (native_window_)
native_window_->RemoveObserver(this);
#if BUILDFLAG(IS_MAC)
PlatformDestroy();
#endif
}
void OffScreenWebContentsView::SetWebContents(
content::WebContents* web_contents) {
web_contents_ = web_contents;
if (GetView())
GetView()->InstallTransparency();
}
void OffScreenWebContentsView::SetNativeWindow(NativeWindow* window) {
if (native_window_)
native_window_->RemoveObserver(this);
native_window_ = window;
if (native_window_)
native_window_->AddObserver(this);
OnWindowResize();
}
void OffScreenWebContentsView::OnWindowResize() {
// In offscreen mode call RenderWidgetHostView's SetSize explicitly
if (GetView())
GetView()->SetSize(GetSize());
}
void OffScreenWebContentsView::OnWindowClosed() {
if (native_window_) {
native_window_->RemoveObserver(this);
native_window_ = nullptr;
}
}
gfx::Size OffScreenWebContentsView::GetSize() {
return native_window_ ? native_window_->GetSize() : gfx::Size();
}
#if !BUILDFLAG(IS_MAC)
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
if (!native_window_)
return gfx::NativeView();
return native_window_->GetNativeView();
}
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
if (!native_window_)
return gfx::NativeView();
return native_window_->GetNativeView();
}
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
if (!native_window_)
return gfx::NativeWindow();
return native_window_->GetNativeWindow();
}
#endif
gfx::Rect OffScreenWebContentsView::GetContainerBounds() const {
return GetViewBounds();
}
void OffScreenWebContentsView::Focus() {}
void OffScreenWebContentsView::SetInitialFocus() {}
void OffScreenWebContentsView::StoreFocus() {}
void OffScreenWebContentsView::RestoreFocus() {}
void OffScreenWebContentsView::FocusThroughTabTraversal(bool reverse) {}
content::DropData* OffScreenWebContentsView::GetDropData() const {
return nullptr;
}
void OffScreenWebContentsView::TransferDragSecurityInfo(WebContentsView* view) {
NOTREACHED();
}
gfx::Rect OffScreenWebContentsView::GetViewBounds() const {
return GetView() ? GetView()->GetViewBounds() : gfx::Rect();
}
void OffScreenWebContentsView::CreateView(gfx::NativeView context) {}
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host) {
if (render_widget_host->GetView()) {
return static_cast<content::RenderWidgetHostViewBase*>(
render_widget_host->GetView());
}
return new OffScreenRenderWidgetHostView(
transparent_, painting_, GetFrameRate(), callback_, render_widget_host,
nullptr, GetSize());
}
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForChildWidget(
content::RenderWidgetHost* render_widget_host) {
auto* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
auto* view = static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView());
return new OffScreenRenderWidgetHostView(transparent_, painting_,
view->frame_rate(), callback_,
render_widget_host, view, GetSize());
}
void OffScreenWebContentsView::SetPageTitle(const std::u16string& title) {}
void OffScreenWebContentsView::RenderViewReady() {
if (GetView())
GetView()->InstallTransparency();
}
void OffScreenWebContentsView::RenderViewHostChanged(
content::RenderViewHost* old_host,
content::RenderViewHost* new_host) {}
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {}
void OffScreenWebContentsView::OnCapturerCountChanged() {}
#if BUILDFLAG(IS_MAC)
bool OffScreenWebContentsView::CloseTabAfterEventTrackingIfNeeded() {
return false;
}
#endif // BUILDFLAG(IS_MAC)
void OffScreenWebContentsView::StartDragging(
const content::DropData& drop_data,
const url::Origin& source_origin,
blink::DragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& cursor_offset,
const gfx::Rect& drag_obj_rect,
const blink::mojom::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
if (web_contents_)
static_cast<content::WebContentsImpl*>(web_contents_)
->SystemDragEnded(source_rwh);
}
void OffScreenWebContentsView::UpdateDragOperation(
ui::mojom::DragOperation operation,
bool document_is_handling_drag) {}
void OffScreenWebContentsView::SetPainting(bool painting) {
auto* view = GetView();
painting_ = painting;
if (view != nullptr) {
view->SetPainting(painting);
}
}
bool OffScreenWebContentsView::IsPainting() const {
if (auto* view = GetView())
return view->is_painting();
return painting_;
}
void OffScreenWebContentsView::SetFrameRate(int frame_rate) {
auto* view = GetView();
frame_rate_ = frame_rate;
if (view != nullptr) {
view->SetFrameRate(frame_rate);
}
}
int OffScreenWebContentsView::GetFrameRate() const {
if (auto* view = GetView())
return view->frame_rate();
return frame_rate_;
}
OffScreenRenderWidgetHostView* OffScreenWebContentsView::GetView() const {
if (web_contents_) {
return static_cast<OffScreenRenderWidgetHostView*>(
web_contents_->GetRenderViewHost()->GetWidget()->GetView());
}
return nullptr;
}
void OffScreenWebContentsView::FullscreenStateChanged(bool is_fullscreen) {}
void OffScreenWebContentsView::UpdateWindowControlsOverlay(
const gfx::Rect& bounding_rect) {}
content::BackForwardTransitionAnimationManager*
OffScreenWebContentsView::GetBackForwardTransitionAnimationManager() {
return nullptr;
}
} // namespace electron