Commit 826f1ef9 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Move SetWindowRect[Synchronously] into base.

Move the implementations into base and protect with a
DCHECK(ForMainFrame() as we don't expect setting the window rect to
be an operation on a child local root.

BUG=1097816

Change-Id: Ia2f6d3f735ad9cd91bbd507a26a54ff44e0a6133
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2543833
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829012}
parent 407179a5
......@@ -2827,16 +2827,11 @@ void WebViewImpl::DidShowCreatedWindow() {
web_widget_->AckPendingWindowRect();
}
void WebViewImpl::SetWindowRect(const gfx::Rect& bounds) {
void WebViewImpl::SendWindowRectToMainFrameHost(
const gfx::Rect& bounds,
base::OnceClosure ack_callback) {
DCHECK(local_main_frame_host_remote_);
DCHECK(web_widget_);
web_widget_->SetPendingWindowRect(bounds);
local_main_frame_host_remote_->SetWindowRect(
bounds, WTF::Bind(&WebViewImpl::DidSetWindowRect, WTF::Unretained(this)));
}
void WebViewImpl::DidSetWindowRect() {
web_widget_->AckPendingWindowRect();
local_main_frame_host_remote_->SetWindowRect(bounds, std::move(ack_callback));
}
void WebViewImpl::UpdateTargetURL(const WebURL& url,
......
......@@ -492,7 +492,10 @@ class CORE_EXPORT WebViewImpl final : public WebView,
const gfx::Rect& rect,
bool opened_by_user_gesture);
void SetWindowRect(const gfx::Rect& bounds);
// Send the window rect to the browser and call `ack_callback` when the
// browser has processed it.
void SendWindowRectToMainFrameHost(const gfx::Rect& bounds,
base::OnceClosure ack_callback);
// TODO(crbug.com/1149992): This is called from the associated widget and this
// code should eventually move out of WebView into somewhere else.
......@@ -629,10 +632,6 @@ class CORE_EXPORT WebViewImpl final : public WebView,
// Corresponds to a Show method call.
void DidShowCreatedWindow();
// Callback when the window rect has been adjusted by the browser.
// Corresponds to a SetWindowRect method call.
void DidSetWindowRect();
// Can be null (e.g. unittests, shared workers, etc).
WebViewClient* web_view_client_;
Persistent<ChromeClient> chrome_client_;
......
......@@ -3492,4 +3492,50 @@ void WebFrameWidgetBase::ImeFinishComposingTextForPlugin(bool keep_selection) {
plugin->ImeFinishComposingTextForPlugin(keep_selection);
}
void WebFrameWidgetBase::SetWindowRect(const gfx::Rect& window_rect) {
DCHECK(ForMainFrame());
if (SynchronousResizeModeForTestingEnabled()) {
// This is a web-test-only path. At one point, it was planned to be
// removed. See https://crbug.com/309760.
SetWindowRectSynchronously(window_rect);
return;
}
SetPendingWindowRect(window_rect);
View()->SendWindowRectToMainFrameHost(
window_rect, WTF::Bind(&WebFrameWidgetBase::AckPendingWindowRect,
WrapWeakPersistent(this)));
}
void WebFrameWidgetBase::SetWindowRectSynchronouslyForTesting(
const gfx::Rect& new_window_rect) {
DCHECK(ForMainFrame());
SetWindowRectSynchronously(new_window_rect);
}
void WebFrameWidgetBase::SetWindowRectSynchronously(
const gfx::Rect& new_window_rect) {
// This method is only call in tests, and it applies the |new_window_rect| to
// all three of:
// a) widget size (in |size_|)
// b) blink viewport (in |visible_viewport_size_|)
// c) compositor viewport (in cc::LayerTreeHost)
// Normally the browser controls these three things independently, but this is
// used in tests to control the size from the renderer.
// We are resizing the window from the renderer, so allocate a new
// viz::LocalSurfaceId to avoid surface invariants violations in tests.
widget_base_->LayerTreeHost()->RequestNewLocalSurfaceId();
gfx::Rect compositor_viewport_pixel_rect(gfx::ScaleToCeiledSize(
new_window_rect.size(),
widget_base_->GetScreenInfo().device_scale_factor));
widget_base_->UpdateSurfaceAndScreenInfo(
widget_base_->local_surface_id_from_parent(),
compositor_viewport_pixel_rect, widget_base_->GetScreenInfo());
Resize(new_window_rect.size());
widget_base_->SetScreenRects(new_window_rect, new_window_rect);
}
} // namespace blink
......@@ -588,6 +588,9 @@ class CORE_EXPORT WebFrameWidgetBase
// pixels).
gfx::Size DIPsToCeiledBlinkSpace(const gfx::Size& size);
void SetWindowRect(const gfx::Rect& window_rect);
void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
void SetToolTipText(const String& tooltip_text, TextDirection dir);
void ShowVirtualKeyboardOnElementFocus();
......@@ -788,6 +791,8 @@ class CORE_EXPORT WebFrameWidgetBase
void ForEachRemoteFrameControlledByWidget(
const base::RepeatingCallback<void(RemoteFrame*)>& callback);
void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
static bool ignore_input_events_;
WebWidgetClient* client_;
......
......@@ -100,16 +100,6 @@ bool WebViewFrameWidget::ShouldHandleImeEvents() {
return HasFocus();
}
void WebViewFrameWidget::SetWindowRect(const gfx::Rect& window_rect) {
if (SynchronousResizeModeForTestingEnabled()) {
// This is a web-test-only path. At one point, it was planned to be
// removed. See https://crbug.com/309760.
SetWindowRectSynchronously(window_rect);
return;
}
View()->SetWindowRect(window_rect);
}
bool WebViewFrameWidget::ScrollFocusedEditableElementIntoView() {
return web_view_->ScrollFocusedEditableElementIntoView();
}
......@@ -298,36 +288,6 @@ WebInputEventResult WebViewFrameWidget::HandleGestureEvent(
return event_result;
}
void WebViewFrameWidget::SetWindowRectSynchronouslyForTesting(
const gfx::Rect& new_window_rect) {
SetWindowRectSynchronously(new_window_rect);
}
void WebViewFrameWidget::SetWindowRectSynchronously(
const gfx::Rect& new_window_rect) {
// This method is only call in tests, and it applies the |new_window_rect| to
// all three of:
// a) widget size (in |size_|)
// b) blink viewport (in |visible_viewport_size_|)
// c) compositor viewport (in cc::LayerTreeHost)
// Normally the browser controls these three things independently, but this is
// used in tests to control the size from the renderer.
// We are resizing the window from the renderer, so allocate a new
// viz::LocalSurfaceId to avoid surface invariants violations in tests.
widget_base_->LayerTreeHost()->RequestNewLocalSurfaceId();
gfx::Rect compositor_viewport_pixel_rect(gfx::ScaleToCeiledSize(
new_window_rect.size(),
widget_base_->GetScreenInfo().device_scale_factor));
widget_base_->UpdateSurfaceAndScreenInfo(
widget_base_->local_surface_id_from_parent(),
compositor_viewport_pixel_rect, widget_base_->GetScreenInfo());
Resize(new_window_rect.size());
widget_base_->SetScreenRects(new_window_rect, new_window_rect);
}
void WebViewFrameWidget::ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) {
if (size_ !=
......
......@@ -78,15 +78,10 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
// WidgetBaseClient overrides:
void FocusChanged(bool enabled) override;
void SetWindowRect(const gfx::Rect& window_rect);
void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
private:
// PageWidgetEventHandler overrides:
WebInputEventResult HandleGestureEvent(const WebGestureEvent&) override;
void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
scoped_refptr<WebViewImpl> web_view_;
// This stores the last hidden page popup. If a GestureTap attempts to open
......
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