Commit d6c6c6a1 authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Fix functions in web_test_support to handle proxy main frames.

If a RenderViewImpl is for a proxy main frame, then don't bother forwarding test
commands to its render widget [since it will no longer exist in the future].

Bug: 912193
Change-Id: I8f5dc4d41415d7bf0cbb921ef6c9fa225c5e159a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841658
Auto-Submit: Erik Chen <erikchen@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703071}
parent af17b71d
...@@ -206,7 +206,9 @@ void SetFocusAndActivate(RenderView* render_view, bool enable) { ...@@ -206,7 +206,9 @@ void SetFocusAndActivate(RenderView* render_view, bool enable) {
} }
void ForceResizeRenderView(RenderView* render_view, const WebSize& new_size) { void ForceResizeRenderView(RenderView* render_view, const WebSize& new_size) {
auto* render_view_impl = static_cast<RenderViewImpl*>(render_view); RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
if (!render_view_impl->GetMainRenderFrame())
return;
RenderWidget* render_widget = render_view_impl->GetWidget(); RenderWidget* render_widget = render_view_impl->GetWidget();
gfx::Rect window_rect(render_widget->WindowRect().x, gfx::Rect window_rect(render_widget->WindowRect().x,
render_widget->WindowRect().y, new_size.width, render_widget->WindowRect().y, new_size.width,
...@@ -215,14 +217,17 @@ void ForceResizeRenderView(RenderView* render_view, const WebSize& new_size) { ...@@ -215,14 +217,17 @@ void ForceResizeRenderView(RenderView* render_view, const WebSize& new_size) {
} }
void SetDeviceScaleFactor(RenderView* render_view, float factor) { void SetDeviceScaleFactor(RenderView* render_view, float factor) {
RenderWidget* render_widget = RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
static_cast<RenderViewImpl*>(render_view)->GetWidget(); if (!render_view_impl->GetMainRenderFrame())
render_widget->SetDeviceScaleFactorForTesting(factor); return;
render_view_impl->GetWidget()->SetDeviceScaleFactorForTesting(factor);
} }
float GetWindowToViewportScale(RenderView* render_view) { float GetWindowToViewportScale(RenderView* render_view) {
return GetWindowToViewportScale( RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
static_cast<RenderViewImpl*>(render_view)->GetWidget()); blink::WebFloatRect rect(0, 0, 1.0f, 0.0);
render_view_impl->page_properties()->ConvertWindowToViewport(&rect);
return rect.width;
} }
std::unique_ptr<blink::WebInputEvent> TransformScreenToWidgetCoordinates( std::unique_ptr<blink::WebInputEvent> TransformScreenToWidgetCoordinates(
...@@ -256,9 +261,10 @@ gfx::ColorSpace GetTestingColorSpace(const std::string& name) { ...@@ -256,9 +261,10 @@ gfx::ColorSpace GetTestingColorSpace(const std::string& name) {
void SetDeviceColorSpace(RenderView* render_view, void SetDeviceColorSpace(RenderView* render_view,
const gfx::ColorSpace& color_space) { const gfx::ColorSpace& color_space) {
RenderWidget* render_widget = RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
static_cast<RenderViewImpl*>(render_view)->GetWidget(); if (!render_view_impl->GetMainRenderFrame())
render_widget->SetDeviceColorSpaceForTesting(color_space); return;
render_view_impl->GetWidget()->SetDeviceColorSpaceForTesting(color_space);
} }
void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting) { void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting) {
...@@ -277,23 +283,26 @@ void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting) { ...@@ -277,23 +283,26 @@ void SetTestBluetoothScanDuration(BluetoothTestScanDurationSetting setting) {
} }
void UseSynchronousResizeMode(RenderView* render_view, bool enable) { void UseSynchronousResizeMode(RenderView* render_view, bool enable) {
RenderWidget* render_widget = RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
static_cast<RenderViewImpl*>(render_view)->GetWidget(); if (!render_view_impl->GetMainRenderFrame())
render_widget->UseSynchronousResizeModeForTesting(enable); return;
render_view_impl->GetWidget()->UseSynchronousResizeModeForTesting(enable);
} }
void EnableAutoResizeMode(RenderView* render_view, void EnableAutoResizeMode(RenderView* render_view,
const WebSize& min_size, const WebSize& min_size,
const WebSize& max_size) { const WebSize& max_size) {
RenderWidget* render_widget = RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
static_cast<RenderViewImpl*>(render_view)->GetWidget(); if (!render_view_impl->GetMainRenderFrame())
render_widget->EnableAutoResizeForTesting(min_size, max_size); return;
render_view_impl->GetWidget()->EnableAutoResizeForTesting(min_size, max_size);
} }
void DisableAutoResizeMode(RenderView* render_view, const WebSize& new_size) { void DisableAutoResizeMode(RenderView* render_view, const WebSize& new_size) {
RenderWidget* render_widget = RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
static_cast<RenderViewImpl*>(render_view)->GetWidget(); if (!render_view_impl->GetMainRenderFrame())
render_widget->DisableAutoResizeForTesting(new_size); return;
render_view_impl->GetWidget()->DisableAutoResizeForTesting(new_size);
} }
void SchedulerRunIdleTasks(base::OnceClosure callback) { void SchedulerRunIdleTasks(base::OnceClosure callback) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment