2016-07-30 19:35:14 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
2016-07-05 19:33:22 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/osr/osr_render_widget_host_view.h"
|
2016-07-29 12:50:27 +00:00
|
|
|
|
2017-05-21 17:55:19 +00:00
|
|
|
#include <algorithm>
|
2017-06-29 23:50:55 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <utility>
|
2016-07-31 10:19:56 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2016-08-03 04:46:34 +00:00
|
|
|
#include "base/callback_helpers.h"
|
|
|
|
#include "base/location.h"
|
|
|
|
#include "base/memory/ptr_util.h"
|
|
|
|
#include "base/single_thread_task_runner.h"
|
2019-01-12 01:00:43 +00:00
|
|
|
#include "base/task/post_task.h"
|
2016-08-03 04:46:34 +00:00
|
|
|
#include "base/time/time.h"
|
2018-05-15 01:59:22 +00:00
|
|
|
#include "components/viz/common/features.h"
|
2020-02-27 19:00:07 +00:00
|
|
|
#include "components/viz/common/frame_sinks/begin_frame_args.h"
|
2017-12-18 10:07:27 +00:00
|
|
|
#include "components/viz/common/frame_sinks/copy_output_request.h"
|
2017-12-04 21:34:15 +00:00
|
|
|
#include "components/viz/common/frame_sinks/delay_based_time_source.h"
|
2020-09-21 08:00:36 +00:00
|
|
|
#include "components/viz/common/quads/compositor_render_pass.h"
|
2019-04-17 21:10:04 +00:00
|
|
|
#include "content/browser/renderer_host/cursor_manager.h" // nogncheck
|
|
|
|
#include "content/browser/renderer_host/input/synthetic_gesture_target.h" // nogncheck
|
|
|
|
#include "content/browser/renderer_host/render_widget_host_delegate.h" // nogncheck
|
|
|
|
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h" // nogncheck
|
2019-01-12 01:00:43 +00:00
|
|
|
#include "content/public/browser/browser_task_traits.h"
|
2016-08-03 04:46:34 +00:00
|
|
|
#include "content/public/browser/browser_thread.h"
|
2016-07-05 19:33:22 +00:00
|
|
|
#include "content/public/browser/context_factory.h"
|
2019-04-17 21:10:04 +00:00
|
|
|
#include "content/public/browser/gpu_data_manager.h"
|
2018-05-15 01:59:22 +00:00
|
|
|
#include "content/public/browser/render_process_host.h"
|
2020-03-03 21:35:05 +00:00
|
|
|
#include "gpu/command_buffer/client/gl_helper.h"
|
2017-04-05 08:31:22 +00:00
|
|
|
#include "media/base/video_frame.h"
|
2021-06-03 08:05:04 +00:00
|
|
|
#include "third_party/abseil-cpp/absl/types/optional.h"
|
2020-01-17 18:41:52 +00:00
|
|
|
#include "third_party/blink/public/common/input/web_input_event.h"
|
2018-10-05 15:38:27 +00:00
|
|
|
#include "third_party/skia/include/core/SkCanvas.h"
|
2017-01-26 07:10:28 +00:00
|
|
|
#include "ui/compositor/compositor.h"
|
2016-07-05 19:33:22 +00:00
|
|
|
#include "ui/compositor/layer.h"
|
|
|
|
#include "ui/compositor/layer_type.h"
|
2018-11-28 16:16:03 +00:00
|
|
|
#include "ui/display/screen.h"
|
2017-05-21 17:55:19 +00:00
|
|
|
#include "ui/events/base_event_utils.h"
|
|
|
|
#include "ui/events/event_constants.h"
|
2018-09-27 13:32:31 +00:00
|
|
|
#include "ui/gfx/canvas.h"
|
2016-08-03 04:46:34 +00:00
|
|
|
#include "ui/gfx/geometry/dip_util.h"
|
2020-10-16 01:30:41 +00:00
|
|
|
#include "ui/gfx/geometry/size_conversions.h"
|
2018-09-27 13:32:31 +00:00
|
|
|
#include "ui/gfx/image/image_skia.h"
|
2016-07-05 19:33:22 +00:00
|
|
|
#include "ui/gfx/native_widget_types.h"
|
2017-03-05 15:18:57 +00:00
|
|
|
#include "ui/gfx/skbitmap_operations.h"
|
2017-06-16 21:41:39 +00:00
|
|
|
#include "ui/latency/latency_info.h"
|
2016-07-29 22:51:19 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2016-08-03 05:09:38 +00:00
|
|
|
|
|
|
|
namespace {
|
2016-07-18 14:16:23 +00:00
|
|
|
|
2016-08-03 05:09:38 +00:00
|
|
|
const float kDefaultScaleFactor = 1.0;
|
2016-07-18 14:16:23 +00:00
|
|
|
|
2017-05-21 17:55:19 +00:00
|
|
|
ui::MouseEvent UiMouseEventFromWebMouseEvent(blink::WebMouseEvent event) {
|
|
|
|
ui::EventType type = ui::EventType::ET_UNKNOWN;
|
2017-06-16 20:42:33 +00:00
|
|
|
switch (event.GetType()) {
|
2020-05-26 20:06:26 +00:00
|
|
|
case blink::WebInputEvent::Type::kMouseDown:
|
2017-05-21 17:55:19 +00:00
|
|
|
type = ui::EventType::ET_MOUSE_PRESSED;
|
|
|
|
break;
|
2020-05-26 20:06:26 +00:00
|
|
|
case blink::WebInputEvent::Type::kMouseUp:
|
2017-05-21 17:55:19 +00:00
|
|
|
type = ui::EventType::ET_MOUSE_RELEASED;
|
|
|
|
break;
|
2020-05-26 20:06:26 +00:00
|
|
|
case blink::WebInputEvent::Type::kMouseMove:
|
2017-05-21 17:55:19 +00:00
|
|
|
type = ui::EventType::ET_MOUSE_MOVED;
|
|
|
|
break;
|
2020-05-26 20:06:26 +00:00
|
|
|
case blink::WebInputEvent::Type::kMouseEnter:
|
2017-05-21 17:55:19 +00:00
|
|
|
type = ui::EventType::ET_MOUSE_ENTERED;
|
|
|
|
break;
|
2020-05-26 20:06:26 +00:00
|
|
|
case blink::WebInputEvent::Type::kMouseLeave:
|
2017-05-21 17:55:19 +00:00
|
|
|
type = ui::EventType::ET_MOUSE_EXITED;
|
|
|
|
break;
|
2020-05-26 20:06:26 +00:00
|
|
|
case blink::WebInputEvent::Type::kMouseWheel:
|
2017-05-21 17:55:19 +00:00
|
|
|
type = ui::EventType::ET_MOUSEWHEEL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = ui::EventType::ET_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int button_flags = 0;
|
|
|
|
switch (event.button) {
|
2017-06-16 20:42:33 +00:00
|
|
|
case blink::WebMouseEvent::Button::kBack:
|
2017-05-21 17:55:19 +00:00
|
|
|
button_flags |= ui::EventFlags::EF_BACK_MOUSE_BUTTON;
|
|
|
|
break;
|
2017-06-16 20:42:33 +00:00
|
|
|
case blink::WebMouseEvent::Button::kForward:
|
2017-05-21 17:55:19 +00:00
|
|
|
button_flags |= ui::EventFlags::EF_FORWARD_MOUSE_BUTTON;
|
|
|
|
break;
|
2017-06-16 20:42:33 +00:00
|
|
|
case blink::WebMouseEvent::Button::kLeft:
|
2017-05-21 17:55:19 +00:00
|
|
|
button_flags |= ui::EventFlags::EF_LEFT_MOUSE_BUTTON;
|
|
|
|
break;
|
2017-06-16 20:42:33 +00:00
|
|
|
case blink::WebMouseEvent::Button::kMiddle:
|
2017-05-21 17:55:19 +00:00
|
|
|
button_flags |= ui::EventFlags::EF_MIDDLE_MOUSE_BUTTON;
|
|
|
|
break;
|
2017-06-16 20:42:33 +00:00
|
|
|
case blink::WebMouseEvent::Button::kRight:
|
2017-05-21 17:55:19 +00:00
|
|
|
button_flags |= ui::EventFlags::EF_RIGHT_MOUSE_BUTTON;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
button_flags = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui::MouseEvent ui_event(type,
|
2020-02-27 19:00:07 +00:00
|
|
|
gfx::Point(std::floor(event.PositionInWidget().x()),
|
|
|
|
std::floor(event.PositionInWidget().y())),
|
|
|
|
gfx::Point(std::floor(event.PositionInWidget().x()),
|
|
|
|
std::floor(event.PositionInWidget().y())),
|
2017-06-29 23:50:55 +00:00
|
|
|
ui::EventTimeForNow(), button_flags, button_flags);
|
2017-06-16 20:42:33 +00:00
|
|
|
ui_event.SetClickCount(event.click_count);
|
2017-05-21 17:55:19 +00:00
|
|
|
|
|
|
|
return ui_event;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui::MouseWheelEvent UiMouseWheelEventFromWebMouseEvent(
|
|
|
|
blink::WebMouseWheelEvent event) {
|
|
|
|
return ui::MouseWheelEvent(UiMouseEventFromWebMouseEvent(event),
|
2018-04-18 01:55:30 +00:00
|
|
|
std::floor(event.delta_x),
|
|
|
|
std::floor(event.delta_y));
|
2017-05-21 17:55:19 +00:00
|
|
|
}
|
|
|
|
|
2016-08-03 05:09:38 +00:00
|
|
|
} // namespace
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
class ElectronDelegatedFrameHostClient
|
|
|
|
: public content::DelegatedFrameHostClient {
|
2019-01-30 17:33:32 +00:00
|
|
|
public:
|
2020-02-04 20:19:40 +00:00
|
|
|
explicit ElectronDelegatedFrameHostClient(OffScreenRenderWidgetHostView* view)
|
2019-01-30 17:33:32 +00:00
|
|
|
: view_(view) {}
|
|
|
|
|
|
|
|
ui::Layer* DelegatedFrameHostGetLayer() const override {
|
|
|
|
return view_->GetRootLayer();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DelegatedFrameHostIsVisible() const override {
|
|
|
|
return view_->IsShowing();
|
|
|
|
}
|
|
|
|
|
|
|
|
SkColor DelegatedFrameHostGetGutterColor() const override {
|
|
|
|
if (view_->render_widget_host()->delegate() &&
|
2020-07-14 01:13:34 +00:00
|
|
|
view_->render_widget_host()->delegate()->IsFullscreen()) {
|
2019-01-30 17:33:32 +00:00
|
|
|
return SK_ColorWHITE;
|
|
|
|
}
|
|
|
|
return *view_->GetBackgroundColor();
|
|
|
|
}
|
|
|
|
|
2021-03-06 00:54:18 +00:00
|
|
|
void OnFrameTokenChanged(uint32_t frame_token,
|
|
|
|
base::TimeTicks activation_time) override {
|
2021-03-06 00:50:32 +00:00
|
|
|
view_->render_widget_host()->DidProcessFrame(frame_token, activation_time);
|
2019-01-30 17:33:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float GetDeviceScaleFactor() const override {
|
|
|
|
return view_->GetDeviceScaleFactor();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<viz::SurfaceId> CollectSurfaceIdsForEviction() override {
|
|
|
|
return view_->render_widget_host()->CollectSurfaceIdsForEviction();
|
|
|
|
}
|
|
|
|
|
2019-02-04 13:33:47 +00:00
|
|
|
bool ShouldShowStaleContentOnEviction() override { return false; }
|
|
|
|
|
2019-01-30 17:33:32 +00:00
|
|
|
void InvalidateLocalSurfaceIdOnEviction() override {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
OffScreenRenderWidgetHostView* const view_;
|
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(ElectronDelegatedFrameHostClient);
|
2019-01-30 17:33:32 +00:00
|
|
|
};
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
2016-08-03 04:46:34 +00:00
|
|
|
bool transparent,
|
2018-01-25 13:46:30 +00:00
|
|
|
bool painting,
|
|
|
|
int frame_rate,
|
2016-08-04 04:03:24 +00:00
|
|
|
const OnPaintCallback& callback,
|
2016-08-03 04:46:34 +00:00
|
|
|
content::RenderWidgetHost* host,
|
2017-03-04 02:09:16 +00:00
|
|
|
OffScreenRenderWidgetHostView* parent_host_view,
|
2018-11-30 05:25:02 +00:00
|
|
|
gfx::Size initial_size)
|
2018-08-30 22:44:35 +00:00
|
|
|
: content::RenderWidgetHostViewBase(host),
|
|
|
|
render_widget_host_(content::RenderWidgetHostImpl::From(host)),
|
2017-03-04 02:09:16 +00:00
|
|
|
parent_host_view_(parent_host_view),
|
2016-08-04 04:03:24 +00:00
|
|
|
transparent_(transparent),
|
|
|
|
callback_(callback),
|
2018-01-25 13:46:30 +00:00
|
|
|
frame_rate_(frame_rate),
|
2018-11-30 05:25:02 +00:00
|
|
|
size_(initial_size),
|
2018-01-25 13:46:30 +00:00
|
|
|
painting_(painting),
|
2021-06-08 02:00:05 +00:00
|
|
|
cursor_manager_(std::make_unique<content::CursorManager>(this)),
|
2018-08-30 22:44:35 +00:00
|
|
|
mouse_wheel_phase_handler_(this),
|
2021-06-08 02:00:05 +00:00
|
|
|
backing_(std::make_unique<SkBitmap>()) {
|
2016-07-13 15:43:00 +00:00
|
|
|
DCHECK(render_widget_host_);
|
2020-02-27 19:00:07 +00:00
|
|
|
DCHECK(!render_widget_host_->GetView());
|
2019-01-30 17:33:32 +00:00
|
|
|
|
2021-05-19 23:15:47 +00:00
|
|
|
// Initialize a display struct as needed, to cache the scale factor.
|
|
|
|
if (display_list_.displays().empty()) {
|
|
|
|
display_list_ = display::DisplayList(
|
|
|
|
{display::Display(display::kDefaultDisplayId)},
|
|
|
|
display::kDefaultDisplayId, display::kDefaultDisplayId);
|
|
|
|
}
|
2021-06-03 08:05:04 +00:00
|
|
|
display::Display current_display = display_list_.GetCurrentDisplay();
|
2021-05-19 23:15:47 +00:00
|
|
|
current_display.set_device_scale_factor(kDefaultScaleFactor);
|
|
|
|
display_list_.UpdateDisplay(current_display);
|
2019-01-30 17:33:32 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
delegated_frame_host_allocator_.GenerateId();
|
2020-10-16 01:30:41 +00:00
|
|
|
delegated_frame_host_surface_id_ =
|
|
|
|
delegated_frame_host_allocator_.GetCurrentLocalSurfaceId();
|
2019-04-17 21:10:04 +00:00
|
|
|
compositor_allocator_.GenerateId();
|
2020-10-16 01:30:41 +00:00
|
|
|
compositor_surface_id_ = compositor_allocator_.GetCurrentLocalSurfaceId();
|
2019-04-17 21:10:04 +00:00
|
|
|
|
2019-09-16 22:12:00 +00:00
|
|
|
delegated_frame_host_client_ =
|
2020-02-04 20:19:40 +00:00
|
|
|
std::make_unique<ElectronDelegatedFrameHostClient>(this);
|
2018-04-12 12:48:32 +00:00
|
|
|
delegated_frame_host_ = std::make_unique<content::DelegatedFrameHost>(
|
2020-02-27 19:00:07 +00:00
|
|
|
AllocateFrameSinkId(), delegated_frame_host_client_.get(),
|
2018-05-15 01:59:22 +00:00
|
|
|
true /* should_register_frame_sink_id */);
|
2017-01-26 07:10:28 +00:00
|
|
|
|
2019-09-16 22:12:00 +00:00
|
|
|
root_layer_ = std::make_unique<ui::Layer>(ui::LAYER_SOLID_COLOR);
|
2018-08-30 22:44:35 +00:00
|
|
|
|
2018-10-05 18:03:35 +00:00
|
|
|
bool opaque = SkColorGetA(background_color_) == SK_AlphaOPAQUE;
|
2018-08-30 22:44:35 +00:00
|
|
|
GetRootLayer()->SetFillsBoundsOpaquely(opaque);
|
2018-10-05 18:03:35 +00:00
|
|
|
GetRootLayer()->SetColor(background_color_);
|
2018-08-30 22:44:35 +00:00
|
|
|
|
2020-03-03 21:35:05 +00:00
|
|
|
ui::ContextFactory* context_factory = content::GetContextFactory();
|
2019-09-16 22:12:00 +00:00
|
|
|
compositor_ = std::make_unique<ui::Compositor>(
|
2020-03-03 21:35:05 +00:00
|
|
|
context_factory->AllocateFrameSinkId(), context_factory,
|
2019-09-16 22:12:00 +00:00
|
|
|
base::ThreadTaskRunnerHandle::Get(), false /* enable_pixel_canvas */,
|
2019-09-18 19:58:00 +00:00
|
|
|
false /* use_external_begin_frame_control */);
|
2018-01-25 13:40:37 +00:00
|
|
|
compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
|
2020-02-27 19:00:07 +00:00
|
|
|
compositor_->SetDelegate(this);
|
2016-07-13 15:43:00 +00:00
|
|
|
compositor_->SetRootLayer(root_layer_.get());
|
2019-04-17 21:10:04 +00:00
|
|
|
|
2018-08-20 16:54:31 +00:00
|
|
|
ResizeRootLayer(false);
|
2017-03-04 02:09:16 +00:00
|
|
|
render_widget_host_->SetView(this);
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) {
|
2019-09-16 22:12:00 +00:00
|
|
|
video_consumer_ = std::make_unique<OffScreenVideoConsumer>(
|
2019-05-29 20:02:15 +00:00
|
|
|
this, base::BindRepeating(&OffScreenRenderWidgetHostView::OnPaint,
|
2019-09-16 22:12:00 +00:00
|
|
|
weak_ptr_factory_.GetWeakPtr()));
|
2019-04-17 21:10:04 +00:00
|
|
|
video_consumer_->SetActive(IsPainting());
|
|
|
|
video_consumer_->SetFrameRate(GetFrameRate());
|
|
|
|
}
|
2016-07-22 11:55:58 +00:00
|
|
|
}
|
2016-07-18 14:16:23 +00:00
|
|
|
|
2016-07-29 22:51:19 +00:00
|
|
|
OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() {
|
2016-09-07 08:33:09 +00:00
|
|
|
// Marking the DelegatedFrameHost as removed from the window hierarchy is
|
|
|
|
// necessary to remove all connections to its old ui::Compositor.
|
2016-07-29 22:51:19 +00:00
|
|
|
if (is_showing_)
|
2019-08-15 20:50:58 +00:00
|
|
|
delegated_frame_host_->WasHidden(
|
|
|
|
content::DelegatedFrameHost::HiddenCause::kOther);
|
2018-11-07 19:17:53 +00:00
|
|
|
delegated_frame_host_->DetachFromCompositor();
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2019-09-16 22:12:00 +00:00
|
|
|
delegated_frame_host_.reset();
|
|
|
|
compositor_.reset();
|
|
|
|
root_layer_.reset();
|
2016-07-18 14:16:23 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::InitAsChild(gfx::NativeView) {
|
2017-03-04 02:09:16 +00:00
|
|
|
DCHECK(parent_host_view_);
|
|
|
|
|
|
|
|
if (parent_host_view_->child_host_view_) {
|
|
|
|
parent_host_view_->child_host_view_->CancelWidget();
|
|
|
|
}
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
parent_host_view_->set_child_host_view(this);
|
|
|
|
parent_host_view_->Hide();
|
|
|
|
|
2018-08-20 16:54:31 +00:00
|
|
|
ResizeRootLayer(false);
|
2019-04-17 21:10:04 +00:00
|
|
|
SetPainting(parent_host_view_->IsPainting());
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetSize(const gfx::Size& size) {
|
2016-07-13 15:43:00 +00:00
|
|
|
size_ = size;
|
2018-10-05 18:03:35 +00:00
|
|
|
SynchronizeVisualProperties();
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetBounds(const gfx::Rect& new_bounds) {
|
2017-03-04 02:09:16 +00:00
|
|
|
SetSize(new_bounds.size());
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
gfx::NativeView OffScreenRenderWidgetHostView::GetNativeView() {
|
2016-07-27 16:02:54 +00:00
|
|
|
return gfx::NativeView();
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 22:51:19 +00:00
|
|
|
gfx::NativeViewAccessible
|
2016-08-03 04:46:34 +00:00
|
|
|
OffScreenRenderWidgetHostView::GetNativeViewAccessible() {
|
2016-07-13 15:43:00 +00:00
|
|
|
return gfx::NativeViewAccessible();
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
ui::TextInputClient* OffScreenRenderWidgetHostView::GetTextInputClient() {
|
2016-07-05 19:33:22 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void OffScreenRenderWidgetHostView::Focus() {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
bool OffScreenRenderWidgetHostView::HasFocus() {
|
2016-07-31 23:01:55 +00:00
|
|
|
return false;
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
bool OffScreenRenderWidgetHostView::IsSurfaceAvailableForCopy() {
|
2017-04-05 08:31:22 +00:00
|
|
|
return GetDelegatedFrameHost()->CanCopyFromCompositingSurface();
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::Show() {
|
2016-07-13 15:43:00 +00:00
|
|
|
if (is_showing_)
|
|
|
|
return;
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2016-07-13 15:43:00 +00:00
|
|
|
is_showing_ = true;
|
2016-09-07 08:33:09 +00:00
|
|
|
|
2018-11-07 19:17:53 +00:00
|
|
|
delegated_frame_host_->AttachToCompositor(compositor_.get());
|
2020-10-16 01:30:41 +00:00
|
|
|
delegated_frame_host_->WasShown(GetLocalSurfaceId(),
|
|
|
|
GetRootLayer()->bounds().size(), {});
|
2016-09-07 08:33:09 +00:00
|
|
|
|
|
|
|
if (render_widget_host_)
|
2020-09-21 08:00:36 +00:00
|
|
|
render_widget_host_->WasShown({});
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::Hide() {
|
2016-07-13 15:43:00 +00:00
|
|
|
if (!is_showing_)
|
|
|
|
return;
|
|
|
|
|
2016-07-18 14:16:23 +00:00
|
|
|
if (render_widget_host_)
|
|
|
|
render_widget_host_->WasHidden();
|
2016-09-07 08:33:09 +00:00
|
|
|
|
2019-08-15 20:50:58 +00:00
|
|
|
// TODO(deermichel): correct or kOther?
|
|
|
|
GetDelegatedFrameHost()->WasHidden(
|
|
|
|
content::DelegatedFrameHost::HiddenCause::kOccluded);
|
2018-11-07 19:17:53 +00:00
|
|
|
GetDelegatedFrameHost()->DetachFromCompositor();
|
2016-09-07 08:33:09 +00:00
|
|
|
|
2016-07-13 15:43:00 +00:00
|
|
|
is_showing_ = false;
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
bool OffScreenRenderWidgetHostView::IsShowing() {
|
2016-07-13 15:43:00 +00:00
|
|
|
return is_showing_;
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 09:15:25 +00:00
|
|
|
void OffScreenRenderWidgetHostView::EnsureSurfaceSynchronizedForWebTest() {
|
2018-10-05 18:03:35 +00:00
|
|
|
++latest_capture_sequence_number_;
|
|
|
|
SynchronizeVisualProperties();
|
|
|
|
}
|
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
gfx::Rect OffScreenRenderWidgetHostView::GetViewBounds() {
|
2017-03-04 02:09:16 +00:00
|
|
|
if (IsPopupWidget())
|
|
|
|
return popup_position_;
|
|
|
|
|
2016-07-05 19:33:22 +00:00
|
|
|
return gfx::Rect(size_);
|
|
|
|
}
|
|
|
|
|
2016-08-01 11:27:39 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetBackgroundColor(SkColor color) {
|
2017-07-08 19:25:15 +00:00
|
|
|
// The renderer will feed its color back to us with the first CompositorFrame.
|
|
|
|
// We short-cut here to show a sensible color before that happens.
|
|
|
|
UpdateBackgroundColorFromRenderer(color);
|
2016-08-01 11:27:39 +00:00
|
|
|
|
2019-02-04 13:33:47 +00:00
|
|
|
if (render_widget_host_ && render_widget_host_->owner_delegate()) {
|
2019-01-21 20:43:17 +00:00
|
|
|
render_widget_host_->owner_delegate()->SetBackgroundOpaque(
|
|
|
|
SkColorGetA(color) == SK_AlphaOPAQUE);
|
2017-07-08 19:25:15 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-01 11:27:39 +00:00
|
|
|
|
2021-06-03 08:05:04 +00:00
|
|
|
absl::optional<SkColor> OffScreenRenderWidgetHostView::GetBackgroundColor() {
|
2017-07-08 19:25:15 +00:00
|
|
|
return background_color_;
|
2016-08-01 11:27:39 +00:00
|
|
|
}
|
|
|
|
|
2020-10-16 01:30:41 +00:00
|
|
|
void OffScreenRenderWidgetHostView::UpdateBackgroundColor() {}
|
2018-10-05 18:03:35 +00:00
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
gfx::Size OffScreenRenderWidgetHostView::GetVisibleViewportSize() {
|
2016-07-05 19:33:22 +00:00
|
|
|
return size_;
|
|
|
|
}
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetInsets(const gfx::Insets& insets) {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2020-03-14 20:54:14 +00:00
|
|
|
blink::mojom::PointerLockResult OffScreenRenderWidgetHostView::LockMouse(
|
2019-09-18 19:58:00 +00:00
|
|
|
bool request_unadjusted_movement) {
|
2020-03-14 20:54:14 +00:00
|
|
|
return blink::mojom::PointerLockResult::kUnsupportedOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
blink::mojom::PointerLockResult OffScreenRenderWidgetHostView::ChangeMouseLock(
|
|
|
|
bool request_unadjusted_movement) {
|
|
|
|
return blink::mojom::PointerLockResult::kUnsupportedOptions;
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void OffScreenRenderWidgetHostView::UnlockMouse() {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2018-08-30 22:44:35 +00:00
|
|
|
void OffScreenRenderWidgetHostView::TakeFallbackContentFrom(
|
|
|
|
content::RenderWidgetHostView* view) {
|
|
|
|
DCHECK(!static_cast<content::RenderWidgetHostViewBase*>(view)
|
|
|
|
->IsRenderWidgetHostViewChildFrame());
|
2020-10-26 18:56:31 +00:00
|
|
|
auto* view_osr = static_cast<OffScreenRenderWidgetHostView*>(view);
|
2018-10-05 18:03:35 +00:00
|
|
|
SetBackgroundColor(view_osr->background_color_);
|
2018-08-30 22:44:35 +00:00
|
|
|
if (GetDelegatedFrameHost() && view_osr->GetDelegatedFrameHost()) {
|
|
|
|
GetDelegatedFrameHost()->TakeFallbackContentFrom(
|
|
|
|
view_osr->GetDelegatedFrameHost());
|
|
|
|
}
|
|
|
|
host()->GetContentRenderingTimeoutFrom(view_osr->host());
|
|
|
|
}
|
|
|
|
|
2018-11-07 19:17:53 +00:00
|
|
|
void OffScreenRenderWidgetHostView::ResetFallbackToFirstNavigationSurface() {
|
|
|
|
GetDelegatedFrameHost()->ResetFallbackToFirstNavigationSurface();
|
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::InitAsPopup(
|
2018-04-18 01:55:30 +00:00
|
|
|
content::RenderWidgetHostView* parent_host_view,
|
2021-09-01 19:55:07 +00:00
|
|
|
const gfx::Rect& pos,
|
|
|
|
const gfx::Rect& anchor_rect) {
|
2017-03-04 02:09:16 +00:00
|
|
|
DCHECK_EQ(parent_host_view_, parent_host_view);
|
2019-04-17 21:10:04 +00:00
|
|
|
DCHECK_EQ(widget_type_, content::WidgetType::kPopup);
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
if (parent_host_view_->popup_host_view_) {
|
|
|
|
parent_host_view_->popup_host_view_->CancelWidget();
|
|
|
|
}
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
parent_host_view_->set_popup_host_view(this);
|
2018-04-18 01:55:30 +00:00
|
|
|
parent_callback_ =
|
2019-05-29 20:02:15 +00:00
|
|
|
base::BindRepeating(&OffScreenRenderWidgetHostView::OnPopupPaint,
|
|
|
|
parent_host_view_->weak_ptr_factory_.GetWeakPtr());
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
popup_position_ = pos;
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2018-08-20 16:54:31 +00:00
|
|
|
ResizeRootLayer(false);
|
2019-04-17 21:10:04 +00:00
|
|
|
SetPainting(parent_host_view_->IsPainting());
|
|
|
|
if (video_consumer_) {
|
|
|
|
video_consumer_->SizeChanged();
|
|
|
|
}
|
2017-03-04 02:09:16 +00:00
|
|
|
Show();
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void OffScreenRenderWidgetHostView::UpdateCursor(const content::WebCursor&) {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2018-10-11 13:14:01 +00:00
|
|
|
content::CursorManager* OffScreenRenderWidgetHostView::GetCursorManager() {
|
|
|
|
return cursor_manager_.get();
|
|
|
|
}
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetIsLoading(bool loading) {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::TextInputStateChanged(
|
2020-06-22 17:35:10 +00:00
|
|
|
const ui::mojom::TextInputState& params) {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void OffScreenRenderWidgetHostView::ImeCancelComposition() {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2019-05-01 00:18:22 +00:00
|
|
|
void OffScreenRenderWidgetHostView::RenderProcessGone() {
|
2016-07-05 19:33:22 +00:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::Destroy() {
|
2017-03-04 02:09:16 +00:00
|
|
|
if (!is_destroyed_) {
|
|
|
|
is_destroyed_ = true;
|
|
|
|
|
2019-09-16 22:12:00 +00:00
|
|
|
if (parent_host_view_ != nullptr) {
|
2017-03-04 02:09:16 +00:00
|
|
|
CancelWidget();
|
|
|
|
} else {
|
|
|
|
if (popup_host_view_)
|
|
|
|
popup_host_view_->CancelWidget();
|
|
|
|
if (child_host_view_)
|
|
|
|
child_host_view_->CancelWidget();
|
2017-07-08 19:25:15 +00:00
|
|
|
if (!guest_host_views_.empty()) {
|
|
|
|
// Guest RWHVs will be destroyed when the associated RWHVGuest is
|
|
|
|
// destroyed. This parent RWHV may be destroyed first, so disassociate
|
|
|
|
// the guest RWHVs here without destroying them.
|
2018-05-04 06:45:12 +00:00
|
|
|
for (auto* guest_host_view : guest_host_views_)
|
2017-07-08 19:25:15 +00:00
|
|
|
guest_host_view->parent_host_view_ = nullptr;
|
|
|
|
guest_host_views_.clear();
|
|
|
|
}
|
2018-05-04 06:45:12 +00:00
|
|
|
for (auto* proxy_view : proxy_views_)
|
2017-05-21 17:55:19 +00:00
|
|
|
proxy_view->RemoveObserver();
|
2017-03-04 02:09:16 +00:00
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
}
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2016-07-30 19:25:49 +00:00
|
|
|
delete this;
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2021-05-14 01:21:36 +00:00
|
|
|
void OffScreenRenderWidgetHostView::UpdateTooltipUnderCursor(
|
|
|
|
const std::u16string&) {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2018-10-05 18:03:35 +00:00
|
|
|
uint32_t OffScreenRenderWidgetHostView::GetCaptureSequenceNumber() const {
|
|
|
|
return latest_capture_sequence_number_;
|
|
|
|
}
|
|
|
|
|
2017-04-05 08:31:22 +00:00
|
|
|
void OffScreenRenderWidgetHostView::CopyFromSurface(
|
2018-05-15 01:59:22 +00:00
|
|
|
const gfx::Rect& src_rect,
|
|
|
|
const gfx::Size& output_size,
|
|
|
|
base::OnceCallback<void(const SkBitmap&)> callback) {
|
|
|
|
GetDelegatedFrameHost()->CopyFromCompositingSurface(src_rect, output_size,
|
|
|
|
std::move(callback));
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 01:59:22 +00:00
|
|
|
void OffScreenRenderWidgetHostView::GetScreenInfo(
|
2021-06-22 19:17:16 +00:00
|
|
|
display::ScreenInfo* screen_info) {
|
2018-05-15 01:59:22 +00:00
|
|
|
screen_info->depth = 24;
|
|
|
|
screen_info->depth_per_component = 8;
|
|
|
|
screen_info->orientation_angle = 0;
|
2021-05-19 23:15:47 +00:00
|
|
|
screen_info->device_scale_factor = GetCurrentDeviceScaleFactor();
|
2018-05-15 01:59:22 +00:00
|
|
|
screen_info->orientation_type =
|
2021-06-22 19:17:16 +00:00
|
|
|
display::mojom::ScreenOrientation::kLandscapePrimary;
|
2018-05-15 01:59:22 +00:00
|
|
|
screen_info->rect = gfx::Rect(size_);
|
|
|
|
screen_info->available_rect = gfx::Rect(size_);
|
2016-07-05 19:33:22 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 18:03:35 +00:00
|
|
|
void OffScreenRenderWidgetHostView::TransformPointToRootSurface(
|
|
|
|
gfx::PointF* point) {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() {
|
2016-07-05 19:33:22 +00:00
|
|
|
return gfx::Rect(size_);
|
|
|
|
}
|
|
|
|
|
2021-06-03 08:05:04 +00:00
|
|
|
absl::optional<content::DisplayFeature>
|
2020-11-14 00:16:56 +00:00
|
|
|
OffScreenRenderWidgetHostView::GetDisplayFeature() {
|
2021-06-03 08:05:04 +00:00
|
|
|
return absl::nullopt;
|
2020-11-14 00:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::SetDisplayFeatureForTesting(
|
|
|
|
const content::DisplayFeature* display_feature) {}
|
|
|
|
|
2018-05-15 01:59:22 +00:00
|
|
|
viz::SurfaceId OffScreenRenderWidgetHostView::GetCurrentSurfaceId() const {
|
|
|
|
return GetDelegatedFrameHost()
|
|
|
|
? GetDelegatedFrameHost()->GetCurrentSurfaceId()
|
|
|
|
: viz::SurfaceId();
|
|
|
|
}
|
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
std::unique_ptr<content::SyntheticGestureTarget>
|
|
|
|
OffScreenRenderWidgetHostView::CreateSyntheticGestureTarget() {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-07-29 12:50:27 +00:00
|
|
|
void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
|
2018-04-18 01:55:30 +00:00
|
|
|
const gfx::Range&,
|
|
|
|
const std::vector<gfx::Rect>&) {}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
gfx::Size OffScreenRenderWidgetHostView::GetCompositorViewportPixelSize() {
|
2018-11-28 16:16:03 +00:00
|
|
|
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(),
|
2021-05-19 23:15:47 +00:00
|
|
|
GetCurrentDeviceScaleFactor());
|
2016-07-13 15:43:00 +00:00
|
|
|
}
|
|
|
|
|
2021-06-16 22:43:51 +00:00
|
|
|
ui::Compositor* OffScreenRenderWidgetHostView::GetCompositor() {
|
|
|
|
return compositor_.get();
|
|
|
|
}
|
|
|
|
|
2017-03-14 11:56:24 +00:00
|
|
|
content::RenderWidgetHostViewBase*
|
2018-04-18 01:55:30 +00:00
|
|
|
OffScreenRenderWidgetHostView::CreateViewForWidget(
|
2017-03-14 11:56:24 +00:00
|
|
|
content::RenderWidgetHost* render_widget_host,
|
|
|
|
content::RenderWidgetHost* embedder_render_widget_host,
|
|
|
|
content::WebContentsView* web_contents_view) {
|
|
|
|
if (render_widget_host->GetView()) {
|
|
|
|
return static_cast<content::RenderWidgetHostViewBase*>(
|
|
|
|
render_widget_host->GetView());
|
|
|
|
}
|
|
|
|
|
|
|
|
OffScreenRenderWidgetHostView* embedder_host_view = nullptr;
|
|
|
|
if (embedder_render_widget_host) {
|
|
|
|
embedder_host_view = static_cast<OffScreenRenderWidgetHostView*>(
|
|
|
|
embedder_render_widget_host->GetView());
|
|
|
|
}
|
|
|
|
|
|
|
|
return new OffScreenRenderWidgetHostView(
|
2018-04-18 01:55:30 +00:00
|
|
|
transparent_, true, embedder_host_view->GetFrameRate(), callback_,
|
2018-11-30 05:25:02 +00:00
|
|
|
render_widget_host, embedder_host_view, size());
|
2017-03-14 11:56:24 +00:00
|
|
|
}
|
|
|
|
|
2018-10-11 13:14:01 +00:00
|
|
|
const viz::FrameSinkId& OffScreenRenderWidgetHostView::GetFrameSinkId() const {
|
2018-08-20 16:54:31 +00:00
|
|
|
return GetDelegatedFrameHost()->frame_sink_id();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::DidNavigate() {
|
|
|
|
ResizeRootLayer(true);
|
|
|
|
if (delegated_frame_host_)
|
|
|
|
delegated_frame_host_->DidNavigate();
|
|
|
|
}
|
|
|
|
|
2017-04-05 08:31:22 +00:00
|
|
|
bool OffScreenRenderWidgetHostView::TransformPointToCoordSpaceForView(
|
2018-05-15 01:59:22 +00:00
|
|
|
const gfx::PointF& point,
|
2017-04-05 08:31:22 +00:00
|
|
|
RenderWidgetHostViewBase* target_view,
|
2019-04-17 21:10:04 +00:00
|
|
|
gfx::PointF* transformed_point) {
|
2017-04-05 08:31:22 +00:00
|
|
|
if (target_view == this) {
|
|
|
|
*transformed_point = point;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-11-07 19:17:53 +00:00
|
|
|
return false;
|
2017-04-05 08:31:22 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
void OffScreenRenderWidgetHostView::CancelWidget() {
|
|
|
|
if (render_widget_host_)
|
2017-03-05 15:18:57 +00:00
|
|
|
render_widget_host_->LostCapture();
|
2017-03-04 02:09:16 +00:00
|
|
|
Hide();
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
if (parent_host_view_) {
|
|
|
|
if (parent_host_view_->popup_host_view_ == this) {
|
2019-09-16 22:12:00 +00:00
|
|
|
parent_host_view_->set_popup_host_view(nullptr);
|
2017-03-04 02:09:16 +00:00
|
|
|
} else if (parent_host_view_->child_host_view_ == this) {
|
2019-09-16 22:12:00 +00:00
|
|
|
parent_host_view_->set_child_host_view(nullptr);
|
2017-03-04 02:09:16 +00:00
|
|
|
parent_host_view_->Show();
|
|
|
|
} else {
|
|
|
|
parent_host_view_->RemoveGuestHostView(this);
|
|
|
|
}
|
2019-09-16 22:12:00 +00:00
|
|
|
parent_host_view_ = nullptr;
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
if (render_widget_host_ && !is_destroyed_) {
|
|
|
|
is_destroyed_ = true;
|
|
|
|
// Results in a call to Destroy().
|
|
|
|
render_widget_host_->ShutdownAndDestroyWidget(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::AddGuestHostView(
|
|
|
|
OffScreenRenderWidgetHostView* guest_host) {
|
|
|
|
guest_host_views_.insert(guest_host);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::RemoveGuestHostView(
|
|
|
|
OffScreenRenderWidgetHostView* guest_host) {
|
|
|
|
guest_host_views_.erase(guest_host);
|
|
|
|
}
|
|
|
|
|
2017-05-21 17:55:19 +00:00
|
|
|
void OffScreenRenderWidgetHostView::AddViewProxy(OffscreenViewProxy* proxy) {
|
|
|
|
proxy->SetObserver(this);
|
|
|
|
proxy_views_.insert(proxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::RemoveViewProxy(OffscreenViewProxy* proxy) {
|
|
|
|
proxy->RemoveObserver();
|
|
|
|
proxy_views_.erase(proxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::ProxyViewDestroyed(
|
|
|
|
OffscreenViewProxy* proxy) {
|
|
|
|
proxy_views_.erase(proxy);
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2021-02-19 23:28:48 +00:00
|
|
|
bool OffScreenRenderWidgetHostView::IsOffscreen() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
std::unique_ptr<viz::HostDisplayClient>
|
|
|
|
OffScreenRenderWidgetHostView::CreateHostDisplayClient(
|
2016-07-31 10:19:56 +00:00
|
|
|
ui::Compositor* compositor) {
|
2019-04-17 21:10:04 +00:00
|
|
|
host_display_client_ = new OffScreenHostDisplayClient(
|
|
|
|
gfx::kNullAcceleratedWidget,
|
2019-05-29 20:02:15 +00:00
|
|
|
base::BindRepeating(&OffScreenRenderWidgetHostView::OnPaint,
|
|
|
|
weak_ptr_factory_.GetWeakPtr()));
|
2019-04-17 21:10:04 +00:00
|
|
|
host_display_client_->SetActive(IsPainting());
|
|
|
|
return base::WrapUnique(host_display_client_);
|
2016-07-27 16:24:58 +00:00
|
|
|
}
|
2016-07-05 19:33:22 +00:00
|
|
|
|
2016-08-03 04:46:34 +00:00
|
|
|
bool OffScreenRenderWidgetHostView::InstallTransparency() {
|
|
|
|
if (transparent_) {
|
|
|
|
SetBackgroundColor(SkColor());
|
2018-03-13 06:38:55 +00:00
|
|
|
compositor_->SetBackgroundColor(SK_ColorTRANSPARENT);
|
2016-08-03 04:46:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-08-12 18:33:58 +00:00
|
|
|
#if defined(OS_MAC)
|
2019-04-17 21:10:04 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetActive(bool active) {}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::ShowDefinitionForSelection() {}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::SpeakSelection() {}
|
|
|
|
|
2020-08-12 18:33:58 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetWindowFrameInScreen(
|
|
|
|
const gfx::Rect& rect) {}
|
|
|
|
|
chore: bump chromium to 92.0.4475.0 (master) (#28462)
* chore: bump chromium in DEPS to 91.0.4464.0
* chore: rebuild chromium/dcheck.patch with import-patches -3
Mechanical only; no code changes
* chore: remove content_browser_main_loop.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
The function being patched (BrowserMainLoop::MainMessageLoopRun()) no
longer exists.
NB: if removing this introduces regressions the likely fix will be to
add a similar patch for ShellBrowserMainParts::WillRunMainMessageLoop()
which has similar code and was added at the same time this was removed.
* chore: rebuild chromium/put_back_deleted_colors_for_autofill.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/disable_color_correct_rendering.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/eat_allow_disabling_blink_scheduler_throttling_per_renderview.patch with patch
Mechanical only; no code changes
* chore: rebuild chromium/gpu_notify_when_dxdiag_request_fails.patch with import-patches -3
Mechanical only; no code changes
* chore: rebuild chromium/ui_gtk_public_header.patch manually
no code changes
* chore: rebuild chromium/web_contents.patch with import-patches -3
Mechanical only; no code changes
* chore: remove v8/skip_global_registration_of_shared_arraybuffer_backing_stores.patch
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2763874
This patch has been merged upstream
* chore: export patches
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785841
SkColorFromColorId() no longer takes theme, scheme args
* chore: sync chromium/put_back_deleted_colors_for_autofill.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2772143
Change new calls to GetDarkSchemeColor to fit our patched call signature
* chore: update add_trustedauthclient_to_urlloaderfactory.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2757969
Sync with removal of render_frame_id_ in our mojom
* chore: update chromium/frame_host_manager.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update chromium/revert_remove_contentrendererclient_shouldfork.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2755314
Upstream has removed `history_list_length_` which we were comparing to 0
to calculate our `is_initial_navigation` bool when calling ShouldFork().
ShouldFork() is ours and none of the code paths actually use that param,
so this commit removes it altogether.
* chore: update permissions_to_register
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2789074
Replace all uses of APIPermission::ID enum with Mojo type
* refactor: update return type of PreMainMessageLoopRun()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
Used to return void; now returns an int errorcode.
Note: 2725153 also has some nice doc updates about Browser's "stages"
* refactor: sync ElectronBrowserMainParts to MainParts changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
RunMainMessageLoopParts has been replaced with WillRunMainMessageLoop
so `BrowserMainLoop::result_code_` is no longer available to us for our
exit_code_ pointer.
This variable held a dual role: (1) of course, hold the exit code, but
also (2) was a nullptr before the message loop was ready, indicating to
anyone calling SetExitCode() that we were still in startup and could
just exit() without any extra steps. exit_code_ still fulfills these two
roles but is now a base::Optional.
* chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2725153
BrowserMainParts::BrowsePreDefaultMainMesssageLoopRun() has been
removed; move that work to the new WillRunMainMessageLoop().
* refactor: stop using CallbackList; it has been removed.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2785973
* refactor: update use of threadpools.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2773408
The upstream code is still in flux (e.g. reverts and re-lands) but the
tl;dr for this commit is (1) include thread_pool.h if you're using it
and (2) don't instantiate pools directly.
* refactor: remove routing_id from CreateLoaderAndStart
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
NB: One logic branch in ProxyingURLLoaderFactory::CreateLoaderAndStart
calls std::make_unique<InProgressRequest>, which needs a routing_id.
This PR uses the member field `routing_id_` since there's no longer one
being passed into CreateLoaderAndStart.
* refactor: sync to upstream ParittionOptions churn
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
PartitionOptions' enums have changed.
* refactor: update Manifest::Location usage
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
tldr: s/Manifest::FOO/ManifestLocation::kFoo/
* chore: bump chromium in DEPS to 91.0.4465.0
* update patches
* refactor: update extensions::Manifest to upstream
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771320
- extensions::Manifest::COMPONENT
+ extensions::mojom::ManifestLocation::kExternalComponent
* refactor: sync with upstream UrlInfo ctor changes
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2740008
UrlInfo ctor now takes UrlInfo::OriginIsolationRequest instead of a bool
* chore: update invocation of convert_protocol_to_json.py
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2792623
python3 is being used in parts of the upstream build, but the copy of
convert_protocol_to_json.py invoked in v8/third_party/inspector_protocol
is not python3-friendly. Node has a py2+3-friendly version of it in its
tools directory, so call it instead.
* chore: use extensions::mojom::APIPermissionID
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791122
tldr:
- extensions::APIPermission::kFoo
+ extensions::mojom::APIPermissionID::kFoo
* chore: Remove support for TLS1.0/1.1 in SSLVersionMin policy
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2765737
Remove TLS v1.0 & 1.1 from our SSLProtocolVersionFromString() function.
This is the same change made upstream at
https://chromium-review.googlesource.com/c/chromium/src/+/2765737/8/chrome/browser/ssl/ssl_config_service_manager_pref.cc
* fixup! chore: update ElectronBrowserMainParts::PreDefaultMainMessageLoopRun
* chore: Use IDType for permission change subscriptions.
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791431
tldr: {Subscribe,Unsubscribe}PermissionStatusChange's tag type used to
be an int; now it's the new SubscriptionId type (which is an IdType64).
* chore: sync PowerMonitor code to upstream refactor
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2752635
tldr: PowerMonitor has been split into PowerStateObserver,
PowerSuspendObserver, and PowerThermalObserver to reduce number of tasks
posted to consumers who only need notifications for one of those things
instead of all of them.
* chore: use PartitionOptions's new Cookies field
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2771318
* Revert "refactor: remove routing_id from CreateLoaderAndStart"
This reverts commit 8c9773b87a3c84f9073a47089eb2b6889d745245.
8c9773b was only a partial fix; reverting to start & try again.
* update patches
* chore: bump chromium in DEPS to 91.0.4466.0
* chore: update chromium/accelerator.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2795472
tldr: sync patch with upstream renamed variable & macro names.
* chore: update chromium/gtk_visibility.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796200
tldr: no code changes; just updating the diff to apply cleanly.
note: ooh upstream Wayland hacking!
* chore: update chromium/picture-in-picture.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2710023
tldr: no code changes; just updating the diff to apply cleanly.
* chore: update chromium/worker_feat_add_hook_to_notify_script_ready.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2775573
tldr: no code changes; just updating the diff to apply cleanly.
* chore: export_all_patches
* chore: update chromium/feat_add_set_theme_source_to_allow_apps_to.patch
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2796511
tldr: NotifyObservers has been renamed to NotifyOnNativeThemeUpdated,
so update the invocation in our patch.
* chore: update ElectronBrowserClient w/upstream API
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797454
tldr: GetDevToolsManagerDelegate() was returning an owned raw pointer.
Replaced it with CreateDevToolsManagerDelegate() which uses unique_ptr<>.
* chore: handle new content::PermissionType::FILE_HANDLING in toV8()
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762201
`file-handling` string confirmed in https://chromium-review.googlesource.com/c/chromium/src/+/2762201/18/chrome/browser/ui/webui/settings/site_settings_helper.cc
* refactor: remove routing_id from CreateLoaderAndStart pt 1
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2762858
Part 1: the easiest ones
* 2796724: Support Python3
https://chromium-review.googlesource.com/c/infra/luci/python-adb/+/2796724
* chore: bump chromium in DEPS to 91.0.4468.0
* 2668974: WebShare: Implement SharingServicePicker
https://chromium-review.googlesource.com/c/chromium/src/+/2668974
* 2802766: Apply modernize-make-unique to media/
https://chromium-review.googlesource.com/c/chromium/src/+/2802766
* 2802823: Apply modernize-make-unique to gpu/
https://chromium-review.googlesource.com/c/chromium/src/+/2802823
* 2803041: Apply modernize-make-unique to remaining files
https://chromium-review.googlesource.com/c/chromium/src/+/2803041
* 2798873: Convert GtkKeyBindingsHandler build checks to runtime checks
https://chromium-review.googlesource.com/c/chromium/src/+/2798873
* 2733595: [ch-r] Parse ACCEPT_CH H2/3 frame and restart with new headers if needed
https://chromium-review.googlesource.com/c/chromium/src/+/2733595
* chore: update patch indices
* 2795107: Remove unused PermissionRequest IDs.
https://chromium-review.googlesource.com/c/chromium/src/+/2795107
* chore: bump chromium in DEPS to 91.0.4469.0
* chore: fixup patch indices
* chore: bump chromium in DEPS to 91.0.4469.5
* PiP 1.5: Add microphone, camera, and hang up buttons to the PiP window
https://chromium-review.googlesource.com/c/chromium/src/+/2710023
* fixup! refactor: remove routing_id from CreateLoaderAndStart
* refactor: use URLLoaderNetworkServiceObserver for auth requests from SimpleURLLoader
* fixup! chore: fixup patch indices
* 2724817: Expand scope of wasm-eval to all URLs
https://chromium-review.googlesource.com/c/chromium/src/+/2724817
* Fixup patch after rebase
* chore: bump chromium in DEPS to 91.0.4472.0
* 2797341: [ozone/x11] Enabled the global shortcut listener.
https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* 2805553: Reland Add GTK ColorMixers to ColorPipeline P1
https://chromium-review.googlesource.com/c/chromium/src/+/2805553
* 2804366: PiP 1.5: Label back to tab button with origin and center it
https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* 2784730: Fix crash on AX mode change in NativeViewHost without a Widget
https://chromium-review.googlesource.com/c/chromium/src/+/2784730
* chore: update patch indices
* 2810174: Add PdfAnnotationsEnabled policy.
https://chromium-review.googlesource.com/c/chromium/src/+/2810174
* 2807829: Allow capturers to indicate if they want a WakeLock or not.
https://chromium-review.googlesource.com/c/chromium/src/+/2807829
* chore: bump chromium in DEPS to 92.0.4473.0
* chore: bump chromium in DEPS to 92.0.4474.0
* chore: bump chromium in DEPS to 92.0.4475.0
* chore: update patches
* chore: updates patches
* chore: update is_media_key patch to handle new ozone impl
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
* fix: ExecuteJavascript requests now need to be flagged as non-bf-aware
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2787195
* chore: icon_util_x11 is now icon_util_linux
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2791362
* build: update sysroots
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2628496
* build: fix missing symbols on linux build
* use_ozone and use_x11 are not exclusive
* new button view to build for pip
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2797341
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2804366
* chore: fix broken gtk_util color patch
* chore: remove patch conflict
* build: update linux manifests
* chore: build bttlb on all platforms for pip
* chore: add thread_pool include for views delegate win
* chore: fix lint
* chore: add node patches for V8 changes
* build: add missing base include on windows
* fix: update frame host manager patch for new state transitions
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2714464
* chore: update windows zip manifests
* chore: update mac zip manifests
* chore: fix patch linting
* refactor: implement missing URLLoaderNetworkServiceObserver methods
It is against The Mojo Rules to leave hanging callbacks. These always
have to be called.
Refs: https://github.com/electron/electron/commit/186528aab9f8e29d658f07d220bb7f627980edda
* spec: fix locale test on local linux
* fix: pass the exit code correctly in new PreMainMessageLoopRun
Refs: https://github.com/electron/electron/commit/2622e91c4493ceb032e2f80cb484885bb8f97475
* fix: ensure we early-exit when request_handler_ is not provided
Refs: https://github.com/electron/electron/commit/93077afbfb6db248a0c0cc447d7ad2c9ccfda1d5
* fix: strongly set result_code in the BrowserMainLoop
* fix: invalid usage of non-targetted PostTask
You must always either use a host threadpool or specify a target
thread. In this case we did neither after this refactor.
Refs: https://github.com/electron/electron/pull/28462/commits/4e33ee0ad35a710bd34641cb0376bdee6aea2d1f
* chore: fix gn check
* chore: remove stray .rej files in patch
* chore: add mojo error code to url loader failure
* build: ensure CI is truthy in arm test env
* fix: handle windowCaptureMacV2 being enabled when fetching media source id
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/2709931
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
Co-authored-by: Samuel Attard <sattard@slack-corp.com>
2021-04-15 17:44:35 +00:00
|
|
|
void OffScreenRenderWidgetHostView::ShowSharePicker(
|
|
|
|
const std::string& title,
|
|
|
|
const std::string& text,
|
|
|
|
const std::string& url,
|
|
|
|
const std::vector<std::string>& file_paths,
|
|
|
|
blink::mojom::ShareService::ShareCallback callback) {}
|
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
bool OffScreenRenderWidgetHostView::UpdateNSViewAndDisplay() {
|
|
|
|
return false;
|
2018-05-15 01:59:22 +00:00
|
|
|
}
|
2019-04-17 21:10:04 +00:00
|
|
|
#endif
|
2018-05-15 01:59:22 +00:00
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
void OffScreenRenderWidgetHostView::OnPaint(const gfx::Rect& damage_rect,
|
|
|
|
const SkBitmap& bitmap) {
|
2019-09-16 22:12:00 +00:00
|
|
|
backing_ = std::make_unique<SkBitmap>();
|
2019-04-17 21:10:04 +00:00
|
|
|
backing_->allocN32Pixels(bitmap.width(), bitmap.height(), !transparent_);
|
|
|
|
bitmap.readPixels(backing_->pixmap());
|
|
|
|
|
|
|
|
if (IsPopupWidget() && parent_callback_) {
|
|
|
|
parent_callback_.Run(this->popup_position_);
|
|
|
|
} else {
|
|
|
|
CompositeFrame(damage_rect);
|
|
|
|
}
|
|
|
|
}
|
2017-03-05 15:19:51 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
gfx::Size OffScreenRenderWidgetHostView::SizeInPixels() {
|
2021-05-19 23:15:47 +00:00
|
|
|
float sf = GetCurrentDeviceScaleFactor();
|
2019-04-17 21:10:04 +00:00
|
|
|
if (IsPopupWidget()) {
|
2021-05-19 23:15:47 +00:00
|
|
|
return gfx::ToFlooredSize(
|
|
|
|
gfx::ConvertSizeToPixels(popup_position_.size(), sf));
|
2017-05-21 17:55:19 +00:00
|
|
|
} else {
|
2021-05-19 23:15:47 +00:00
|
|
|
return gfx::ToFlooredSize(
|
|
|
|
gfx::ConvertSizeToPixels(GetViewBounds().size(), sf));
|
2019-04-17 21:10:04 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-12 18:54:03 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
void OffScreenRenderWidgetHostView::CompositeFrame(
|
|
|
|
const gfx::Rect& damage_rect) {
|
|
|
|
HoldResize();
|
2018-11-28 16:16:03 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
gfx::Size size_in_pixels = SizeInPixels();
|
2018-09-27 13:32:31 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
SkBitmap frame;
|
2017-05-21 17:55:19 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
// Optimize for the case when there is no popup
|
2020-10-22 20:24:59 +00:00
|
|
|
if (proxy_views_.empty() && !popup_host_view_) {
|
2019-04-17 21:10:04 +00:00
|
|
|
frame = GetBacking();
|
|
|
|
} else {
|
2021-05-19 23:15:47 +00:00
|
|
|
float sf = GetCurrentDeviceScaleFactor();
|
2019-04-17 21:10:04 +00:00
|
|
|
frame.allocN32Pixels(size_in_pixels.width(), size_in_pixels.height(),
|
|
|
|
false);
|
|
|
|
if (!GetBacking().drawsNothing()) {
|
|
|
|
SkCanvas canvas(frame);
|
|
|
|
canvas.writePixels(GetBacking(), 0, 0);
|
|
|
|
|
|
|
|
if (popup_host_view_ && !popup_host_view_->GetBacking().drawsNothing()) {
|
|
|
|
gfx::Rect rect = popup_host_view_->popup_position_;
|
2020-10-16 01:30:41 +00:00
|
|
|
gfx::Point origin_in_pixels =
|
2021-05-19 23:15:47 +00:00
|
|
|
gfx::ToFlooredPoint(gfx::ConvertPointToPixels(rect.origin(), sf));
|
2019-04-17 21:10:04 +00:00
|
|
|
canvas.writePixels(popup_host_view_->GetBacking(), origin_in_pixels.x(),
|
|
|
|
origin_in_pixels.y());
|
|
|
|
}
|
2017-04-12 18:54:03 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
for (auto* proxy_view : proxy_views_) {
|
|
|
|
gfx::Rect rect = proxy_view->GetBounds();
|
2020-10-16 01:30:41 +00:00
|
|
|
gfx::Point origin_in_pixels =
|
2021-05-19 23:15:47 +00:00
|
|
|
gfx::ToFlooredPoint(gfx::ConvertPointToPixels(rect.origin(), sf));
|
2019-04-17 21:10:04 +00:00
|
|
|
canvas.writePixels(*proxy_view->GetBitmap(), origin_in_pixels.x(),
|
|
|
|
origin_in_pixels.y());
|
|
|
|
}
|
2017-05-21 17:55:19 +00:00
|
|
|
}
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
paint_callback_running_ = true;
|
|
|
|
callback_.Run(gfx::IntersectRects(gfx::Rect(size_in_pixels), damage_rect),
|
|
|
|
frame);
|
|
|
|
paint_callback_running_ = false;
|
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
ReleaseResize();
|
|
|
|
}
|
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
void OffScreenRenderWidgetHostView::OnPopupPaint(const gfx::Rect& damage_rect) {
|
2020-10-16 01:30:41 +00:00
|
|
|
InvalidateBounds(gfx::ToEnclosingRect(
|
2021-05-19 23:15:47 +00:00
|
|
|
gfx::ConvertRectToPixels(damage_rect, GetCurrentDeviceScaleFactor())));
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
|
|
|
|
2017-05-21 17:55:19 +00:00
|
|
|
void OffScreenRenderWidgetHostView::OnProxyViewPaint(
|
|
|
|
const gfx::Rect& damage_rect) {
|
2020-10-16 01:30:41 +00:00
|
|
|
InvalidateBounds(gfx::ToEnclosingRect(
|
2021-05-19 23:15:47 +00:00
|
|
|
gfx::ConvertRectToPixels(damage_rect, GetCurrentDeviceScaleFactor())));
|
2017-05-21 17:55:19 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
void OffScreenRenderWidgetHostView::HoldResize() {
|
|
|
|
if (!hold_resize_)
|
|
|
|
hold_resize_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::ReleaseResize() {
|
|
|
|
if (!hold_resize_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hold_resize_ = false;
|
|
|
|
if (pending_resize_) {
|
|
|
|
pending_resize_ = false;
|
2019-09-18 19:58:00 +00:00
|
|
|
base::PostTask(
|
2019-01-12 01:00:43 +00:00
|
|
|
FROM_HERE, {content::BrowserThread::UI},
|
2018-10-05 18:03:35 +00:00
|
|
|
base::BindOnce(
|
|
|
|
&OffScreenRenderWidgetHostView::SynchronizeVisualProperties,
|
|
|
|
weak_ptr_factory_.GetWeakPtr()));
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 18:03:35 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SynchronizeVisualProperties() {
|
2017-03-04 02:09:16 +00:00
|
|
|
if (hold_resize_) {
|
|
|
|
if (!pending_resize_)
|
|
|
|
pending_resize_ = true;
|
|
|
|
return;
|
|
|
|
}
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
ResizeRootLayer(true);
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 01:59:22 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SendMouseEvent(
|
|
|
|
const blink::WebMouseEvent& event) {
|
2018-05-04 06:45:12 +00:00
|
|
|
for (auto* proxy_view : proxy_views_) {
|
2017-05-21 17:55:19 +00:00
|
|
|
gfx::Rect bounds = proxy_view->GetBounds();
|
2020-02-27 19:00:07 +00:00
|
|
|
if (bounds.Contains(event.PositionInWidget().x(),
|
|
|
|
event.PositionInWidget().y())) {
|
2017-05-21 17:55:19 +00:00
|
|
|
blink::WebMouseEvent proxy_event(event);
|
2017-06-16 21:13:28 +00:00
|
|
|
proxy_event.SetPositionInWidget(
|
2020-02-27 19:00:07 +00:00
|
|
|
proxy_event.PositionInWidget().x() - bounds.x(),
|
|
|
|
proxy_event.PositionInWidget().y() - bounds.y());
|
2017-05-21 17:55:19 +00:00
|
|
|
|
|
|
|
ui::MouseEvent ui_event = UiMouseEventFromWebMouseEvent(proxy_event);
|
|
|
|
proxy_view->OnEvent(&ui_event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
if (!IsPopupWidget()) {
|
2018-04-18 01:55:30 +00:00
|
|
|
if (popup_host_view_ &&
|
|
|
|
popup_host_view_->popup_position_.Contains(
|
2020-02-27 19:00:07 +00:00
|
|
|
event.PositionInWidget().x(), event.PositionInWidget().y())) {
|
2017-03-04 02:09:16 +00:00
|
|
|
blink::WebMouseEvent popup_event(event);
|
2017-06-16 21:13:28 +00:00
|
|
|
popup_event.SetPositionInWidget(
|
2020-02-27 19:00:07 +00:00
|
|
|
popup_event.PositionInWidget().x() -
|
2017-06-29 23:50:55 +00:00
|
|
|
popup_host_view_->popup_position_.x(),
|
2020-02-27 19:00:07 +00:00
|
|
|
popup_event.PositionInWidget().y() -
|
2017-06-29 23:50:55 +00:00
|
|
|
popup_host_view_->popup_position_.y());
|
2017-03-04 02:09:16 +00:00
|
|
|
|
2018-05-15 01:59:22 +00:00
|
|
|
popup_host_view_->ProcessMouseEvent(popup_event, ui::LatencyInfo());
|
2017-03-04 02:09:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-05-21 17:55:19 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
if (!render_widget_host_)
|
|
|
|
return;
|
|
|
|
render_widget_host_->ForwardMouseEvent(event);
|
|
|
|
}
|
|
|
|
|
2018-05-15 01:59:22 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SendMouseWheelEvent(
|
|
|
|
const blink::WebMouseWheelEvent& event) {
|
2018-05-04 06:45:12 +00:00
|
|
|
for (auto* proxy_view : proxy_views_) {
|
2017-05-21 17:55:19 +00:00
|
|
|
gfx::Rect bounds = proxy_view->GetBounds();
|
2020-02-27 19:00:07 +00:00
|
|
|
if (bounds.Contains(event.PositionInWidget().x(),
|
|
|
|
event.PositionInWidget().y())) {
|
2017-05-21 17:55:19 +00:00
|
|
|
blink::WebMouseWheelEvent proxy_event(event);
|
2017-06-16 21:13:28 +00:00
|
|
|
proxy_event.SetPositionInWidget(
|
2020-02-27 19:00:07 +00:00
|
|
|
proxy_event.PositionInWidget().x() - bounds.x(),
|
|
|
|
proxy_event.PositionInWidget().y() - bounds.y());
|
2017-05-21 17:55:19 +00:00
|
|
|
|
|
|
|
ui::MouseWheelEvent ui_event =
|
2018-04-18 01:55:30 +00:00
|
|
|
UiMouseWheelEventFromWebMouseEvent(proxy_event);
|
2017-05-21 17:55:19 +00:00
|
|
|
proxy_view->OnEvent(&ui_event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-08-20 16:54:31 +00:00
|
|
|
|
|
|
|
blink::WebMouseWheelEvent mouse_wheel_event(event);
|
|
|
|
|
2019-02-04 09:11:38 +00:00
|
|
|
bool should_route_event =
|
|
|
|
render_widget_host_->delegate() &&
|
|
|
|
render_widget_host_->delegate()->GetInputEventRouter();
|
|
|
|
mouse_wheel_phase_handler_.SendWheelEndForTouchpadScrollingIfNeeded(
|
|
|
|
should_route_event);
|
2018-08-20 16:54:31 +00:00
|
|
|
mouse_wheel_phase_handler_.AddPhaseIfNeededAndScheduleEndEvent(
|
|
|
|
mouse_wheel_event, false);
|
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
if (!IsPopupWidget()) {
|
|
|
|
if (popup_host_view_) {
|
2017-06-16 21:13:28 +00:00
|
|
|
if (popup_host_view_->popup_position_.Contains(
|
2020-02-27 19:00:07 +00:00
|
|
|
mouse_wheel_event.PositionInWidget().x(),
|
|
|
|
mouse_wheel_event.PositionInWidget().y())) {
|
2018-08-20 16:54:31 +00:00
|
|
|
blink::WebMouseWheelEvent popup_mouse_wheel_event(mouse_wheel_event);
|
|
|
|
popup_mouse_wheel_event.SetPositionInWidget(
|
2020-02-27 19:00:07 +00:00
|
|
|
mouse_wheel_event.PositionInWidget().x() -
|
2017-06-29 23:50:55 +00:00
|
|
|
popup_host_view_->popup_position_.x(),
|
2020-02-27 19:00:07 +00:00
|
|
|
mouse_wheel_event.PositionInWidget().y() -
|
2017-06-29 23:50:55 +00:00
|
|
|
popup_host_view_->popup_position_.y());
|
2018-08-20 16:54:31 +00:00
|
|
|
popup_mouse_wheel_event.SetPositionInScreen(
|
2020-02-27 19:00:07 +00:00
|
|
|
popup_mouse_wheel_event.PositionInWidget().x(),
|
|
|
|
popup_mouse_wheel_event.PositionInWidget().y());
|
2018-08-20 16:54:31 +00:00
|
|
|
|
|
|
|
popup_host_view_->SendMouseWheelEvent(popup_mouse_wheel_event);
|
2017-03-04 02:09:16 +00:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
// Scrolling outside of the popup widget so destroy it.
|
|
|
|
// Execute asynchronously to avoid deleting the widget from inside some
|
|
|
|
// other callback.
|
2019-09-18 19:58:00 +00:00
|
|
|
base::PostTask(
|
2019-01-12 01:00:43 +00:00
|
|
|
FROM_HERE, {content::BrowserThread::UI},
|
2018-04-20 10:55:05 +00:00
|
|
|
base::BindOnce(&OffScreenRenderWidgetHostView::CancelWidget,
|
|
|
|
popup_host_view_->weak_ptr_factory_.GetWeakPtr()));
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
2018-08-20 16:54:31 +00:00
|
|
|
} else if (!guest_host_views_.empty()) {
|
2018-08-28 13:30:44 +00:00
|
|
|
for (auto* guest_host_view : guest_host_views_) {
|
2018-08-20 16:54:31 +00:00
|
|
|
if (!guest_host_view->render_widget_host_ ||
|
|
|
|
!guest_host_view->render_widget_host_->GetView()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const gfx::Rect& guest_bounds =
|
|
|
|
guest_host_view->render_widget_host_->GetView()->GetViewBounds();
|
2020-02-27 19:00:07 +00:00
|
|
|
if (guest_bounds.Contains(mouse_wheel_event.PositionInWidget().x(),
|
|
|
|
mouse_wheel_event.PositionInWidget().y())) {
|
2018-08-20 16:54:31 +00:00
|
|
|
blink::WebMouseWheelEvent guest_mouse_wheel_event(mouse_wheel_event);
|
|
|
|
guest_mouse_wheel_event.SetPositionInWidget(
|
2020-02-27 19:00:07 +00:00
|
|
|
mouse_wheel_event.PositionInWidget().x() - guest_bounds.x(),
|
|
|
|
mouse_wheel_event.PositionInWidget().y() - guest_bounds.y());
|
2018-08-20 16:54:31 +00:00
|
|
|
guest_mouse_wheel_event.SetPositionInScreen(
|
2020-02-27 19:00:07 +00:00
|
|
|
guest_mouse_wheel_event.PositionInWidget().x(),
|
|
|
|
guest_mouse_wheel_event.PositionInWidget().y());
|
2018-08-20 16:54:31 +00:00
|
|
|
|
|
|
|
guest_host_view->SendMouseWheelEvent(guest_mouse_wheel_event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!render_widget_host_)
|
|
|
|
return;
|
|
|
|
render_widget_host_->ForwardWheelEvent(event);
|
2016-07-27 17:44:41 +00:00
|
|
|
}
|
|
|
|
|
2016-07-30 13:40:16 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetPainting(bool painting) {
|
|
|
|
painting_ = painting;
|
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
if (popup_host_view_) {
|
|
|
|
popup_host_view_->SetPainting(painting);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto* guest_host_view : guest_host_views_)
|
|
|
|
guest_host_view->SetPainting(painting);
|
|
|
|
|
|
|
|
if (video_consumer_) {
|
|
|
|
video_consumer_->SetActive(IsPainting());
|
|
|
|
} else if (host_display_client_) {
|
|
|
|
host_display_client_->SetActive(IsPainting());
|
2016-07-31 20:05:36 +00:00
|
|
|
}
|
2016-07-30 13:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OffScreenRenderWidgetHostView::IsPainting() const {
|
|
|
|
return painting_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenRenderWidgetHostView::SetFrameRate(int frame_rate) {
|
2017-03-04 02:09:16 +00:00
|
|
|
if (parent_host_view_) {
|
|
|
|
if (parent_host_view_->GetFrameRate() == GetFrameRate())
|
|
|
|
return;
|
2016-07-30 13:40:16 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
frame_rate_ = parent_host_view_->GetFrameRate();
|
|
|
|
} else {
|
|
|
|
if (frame_rate <= 0)
|
|
|
|
frame_rate = 1;
|
2018-01-25 13:44:19 +00:00
|
|
|
if (frame_rate > 240)
|
|
|
|
frame_rate = 240;
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
frame_rate_ = frame_rate;
|
|
|
|
}
|
2017-03-05 15:18:57 +00:00
|
|
|
|
2018-01-25 13:46:30 +00:00
|
|
|
SetupFrameRate(true);
|
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
if (video_consumer_) {
|
|
|
|
video_consumer_->SetFrameRate(GetFrameRate());
|
|
|
|
}
|
|
|
|
|
2018-05-04 06:45:12 +00:00
|
|
|
for (auto* guest_host_view : guest_host_views_)
|
2017-03-04 02:09:16 +00:00
|
|
|
guest_host_view->SetFrameRate(frame_rate);
|
2016-07-30 13:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int OffScreenRenderWidgetHostView::GetFrameRate() const {
|
|
|
|
return frame_rate_;
|
|
|
|
}
|
|
|
|
|
2016-09-07 08:33:09 +00:00
|
|
|
ui::Layer* OffScreenRenderWidgetHostView::GetRootLayer() const {
|
|
|
|
return root_layer_.get();
|
|
|
|
}
|
|
|
|
|
2020-10-16 01:30:41 +00:00
|
|
|
const viz::LocalSurfaceId& OffScreenRenderWidgetHostView::GetLocalSurfaceId()
|
|
|
|
const {
|
|
|
|
return delegated_frame_host_surface_id_;
|
2019-01-30 17:33:32 +00:00
|
|
|
}
|
|
|
|
|
2016-09-07 08:33:09 +00:00
|
|
|
content::DelegatedFrameHost*
|
|
|
|
OffScreenRenderWidgetHostView::GetDelegatedFrameHost() const {
|
|
|
|
return delegated_frame_host_.get();
|
|
|
|
}
|
|
|
|
|
2016-08-03 04:46:34 +00:00
|
|
|
void OffScreenRenderWidgetHostView::SetupFrameRate(bool force) {
|
2017-04-12 14:15:58 +00:00
|
|
|
if (!force && frame_rate_threshold_us_ != 0)
|
2016-08-03 04:46:34 +00:00
|
|
|
return;
|
|
|
|
|
2017-04-12 14:15:58 +00:00
|
|
|
frame_rate_threshold_us_ = 1000000 / frame_rate_;
|
2016-08-03 04:46:34 +00:00
|
|
|
|
2020-02-27 19:00:07 +00:00
|
|
|
if (compositor_) {
|
|
|
|
compositor_->SetDisplayVSyncParameters(
|
|
|
|
base::TimeTicks::Now(),
|
|
|
|
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us_));
|
2016-08-03 04:46:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-01 17:25:12 +00:00
|
|
|
void OffScreenRenderWidgetHostView::Invalidate() {
|
2019-04-17 21:10:04 +00:00
|
|
|
InvalidateBounds(gfx::Rect(GetRequestedRendererSize()));
|
2017-03-04 02:09:16 +00:00
|
|
|
}
|
2016-09-01 17:25:12 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
void OffScreenRenderWidgetHostView::InvalidateBounds(const gfx::Rect& bounds) {
|
2019-04-17 21:10:04 +00:00
|
|
|
CompositeFrame(bounds);
|
2016-09-01 17:25:12 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 16:54:31 +00:00
|
|
|
void OffScreenRenderWidgetHostView::ResizeRootLayer(bool force) {
|
2016-08-03 04:46:34 +00:00
|
|
|
SetupFrameRate(false);
|
|
|
|
|
2018-11-28 16:16:03 +00:00
|
|
|
display::Display display =
|
|
|
|
display::Screen::GetScreen()->GetDisplayNearestView(GetNativeView());
|
|
|
|
const float scaleFactor = display.device_scale_factor();
|
2021-05-19 23:15:47 +00:00
|
|
|
float sf = GetCurrentDeviceScaleFactor();
|
|
|
|
const bool scaleFactorDidChange = scaleFactor != sf;
|
|
|
|
|
|
|
|
// Initialize a display struct as needed, to cache the scale factor.
|
|
|
|
if (display_list_.displays().empty()) {
|
|
|
|
display_list_ = display::DisplayList(
|
|
|
|
{display::Display(display::kDefaultDisplayId)},
|
|
|
|
display::kDefaultDisplayId, display::kDefaultDisplayId);
|
|
|
|
}
|
2021-06-03 08:05:04 +00:00
|
|
|
display::Display current_display = display_list_.GetCurrentDisplay();
|
2021-05-19 23:15:47 +00:00
|
|
|
current_display.set_device_scale_factor(scaleFactor);
|
|
|
|
display_list_.UpdateDisplay(current_display);
|
2016-08-03 04:46:34 +00:00
|
|
|
|
2017-03-04 02:09:16 +00:00
|
|
|
gfx::Size size;
|
|
|
|
if (!IsPopupWidget())
|
|
|
|
size = GetViewBounds().size();
|
|
|
|
else
|
|
|
|
size = popup_position_.size();
|
2016-08-03 04:46:34 +00:00
|
|
|
|
2018-08-20 16:54:31 +00:00
|
|
|
if (!force && !scaleFactorDidChange &&
|
|
|
|
size == GetRootLayer()->bounds().size())
|
2016-08-03 04:46:34 +00:00
|
|
|
return;
|
|
|
|
|
2016-09-07 08:33:09 +00:00
|
|
|
GetRootLayer()->SetBounds(gfx::Rect(size));
|
2018-05-15 01:59:22 +00:00
|
|
|
|
2021-05-19 23:15:47 +00:00
|
|
|
const gfx::Size& size_in_pixels =
|
|
|
|
gfx::ToFlooredSize(gfx::ConvertSizeToPixels(size, sf));
|
2019-01-30 17:33:32 +00:00
|
|
|
|
2020-02-27 19:00:07 +00:00
|
|
|
if (compositor_) {
|
|
|
|
compositor_allocator_.GenerateId();
|
2020-10-16 01:30:41 +00:00
|
|
|
compositor_surface_id_ = compositor_allocator_.GetCurrentLocalSurfaceId();
|
2021-05-19 23:15:47 +00:00
|
|
|
compositor_->SetScaleAndSize(sf, size_in_pixels, compositor_surface_id_);
|
2020-02-27 19:00:07 +00:00
|
|
|
}
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
delegated_frame_host_allocator_.GenerateId();
|
2020-10-16 01:30:41 +00:00
|
|
|
delegated_frame_host_surface_id_ =
|
|
|
|
delegated_frame_host_allocator_.GetCurrentLocalSurfaceId();
|
2019-04-17 21:10:04 +00:00
|
|
|
|
2018-10-11 13:14:01 +00:00
|
|
|
GetDelegatedFrameHost()->EmbedSurface(
|
2020-10-16 01:30:41 +00:00
|
|
|
delegated_frame_host_surface_id_, size,
|
2019-01-30 17:33:32 +00:00
|
|
|
cc::DeadlinePolicy::UseDefaultDeadline());
|
2018-05-15 01:59:22 +00:00
|
|
|
|
|
|
|
// Note that |render_widget_host_| will retrieve resize parameters from the
|
2018-10-05 18:03:35 +00:00
|
|
|
// DelegatedFrameHost, so it must have SynchronizeVisualProperties called
|
|
|
|
// after.
|
2020-02-27 19:00:07 +00:00
|
|
|
if (render_widget_host_) {
|
2018-10-05 18:03:35 +00:00
|
|
|
render_widget_host_->SynchronizeVisualProperties();
|
2019-01-30 17:33:32 +00:00
|
|
|
}
|
2016-08-03 04:46:34 +00:00
|
|
|
}
|
|
|
|
|
2020-02-27 19:00:07 +00:00
|
|
|
viz::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId() {
|
|
|
|
return viz::FrameSinkId(
|
|
|
|
base::checked_cast<uint32_t>(render_widget_host_->GetProcess()->GetID()),
|
|
|
|
base::checked_cast<uint32_t>(render_widget_host_->GetRoutingID()));
|
2016-09-19 07:51:03 +00:00
|
|
|
}
|
|
|
|
|
2017-07-08 19:25:15 +00:00
|
|
|
void OffScreenRenderWidgetHostView::UpdateBackgroundColorFromRenderer(
|
|
|
|
SkColor color) {
|
2018-10-05 18:03:35 +00:00
|
|
|
if (color == background_color_)
|
2017-07-08 19:25:15 +00:00
|
|
|
return;
|
|
|
|
background_color_ = color;
|
|
|
|
|
|
|
|
bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;
|
|
|
|
GetRootLayer()->SetFillsBoundsOpaquely(opaque);
|
|
|
|
GetRootLayer()->SetColor(color);
|
|
|
|
}
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|