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() { ...@@ -2827,16 +2827,11 @@ void WebViewImpl::DidShowCreatedWindow() {
web_widget_->AckPendingWindowRect(); 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(local_main_frame_host_remote_);
DCHECK(web_widget_); local_main_frame_host_remote_->SetWindowRect(bounds, std::move(ack_callback));
web_widget_->SetPendingWindowRect(bounds);
local_main_frame_host_remote_->SetWindowRect(
bounds, WTF::Bind(&WebViewImpl::DidSetWindowRect, WTF::Unretained(this)));
}
void WebViewImpl::DidSetWindowRect() {
web_widget_->AckPendingWindowRect();
} }
void WebViewImpl::UpdateTargetURL(const WebURL& url, void WebViewImpl::UpdateTargetURL(const WebURL& url,
......
...@@ -492,7 +492,10 @@ class CORE_EXPORT WebViewImpl final : public WebView, ...@@ -492,7 +492,10 @@ class CORE_EXPORT WebViewImpl final : public WebView,
const gfx::Rect& rect, const gfx::Rect& rect,
bool opened_by_user_gesture); 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 // TODO(crbug.com/1149992): This is called from the associated widget and this
// code should eventually move out of WebView into somewhere else. // code should eventually move out of WebView into somewhere else.
...@@ -629,10 +632,6 @@ class CORE_EXPORT WebViewImpl final : public WebView, ...@@ -629,10 +632,6 @@ class CORE_EXPORT WebViewImpl final : public WebView,
// Corresponds to a Show method call. // Corresponds to a Show method call.
void DidShowCreatedWindow(); 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). // Can be null (e.g. unittests, shared workers, etc).
WebViewClient* web_view_client_; WebViewClient* web_view_client_;
Persistent<ChromeClient> chrome_client_; Persistent<ChromeClient> chrome_client_;
......
...@@ -3492,4 +3492,50 @@ void WebFrameWidgetBase::ImeFinishComposingTextForPlugin(bool keep_selection) { ...@@ -3492,4 +3492,50 @@ void WebFrameWidgetBase::ImeFinishComposingTextForPlugin(bool keep_selection) {
plugin->ImeFinishComposingTextForPlugin(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 } // namespace blink
...@@ -588,6 +588,9 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -588,6 +588,9 @@ class CORE_EXPORT WebFrameWidgetBase
// pixels). // pixels).
gfx::Size DIPsToCeiledBlinkSpace(const gfx::Size& size); 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 SetToolTipText(const String& tooltip_text, TextDirection dir);
void ShowVirtualKeyboardOnElementFocus(); void ShowVirtualKeyboardOnElementFocus();
...@@ -788,6 +791,8 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -788,6 +791,8 @@ class CORE_EXPORT WebFrameWidgetBase
void ForEachRemoteFrameControlledByWidget( void ForEachRemoteFrameControlledByWidget(
const base::RepeatingCallback<void(RemoteFrame*)>& callback); const base::RepeatingCallback<void(RemoteFrame*)>& callback);
void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
static bool ignore_input_events_; static bool ignore_input_events_;
WebWidgetClient* client_; WebWidgetClient* client_;
......
...@@ -100,16 +100,6 @@ bool WebViewFrameWidget::ShouldHandleImeEvents() { ...@@ -100,16 +100,6 @@ bool WebViewFrameWidget::ShouldHandleImeEvents() {
return HasFocus(); 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() { bool WebViewFrameWidget::ScrollFocusedEditableElementIntoView() {
return web_view_->ScrollFocusedEditableElementIntoView(); return web_view_->ScrollFocusedEditableElementIntoView();
} }
...@@ -298,36 +288,6 @@ WebInputEventResult WebViewFrameWidget::HandleGestureEvent( ...@@ -298,36 +288,6 @@ WebInputEventResult WebViewFrameWidget::HandleGestureEvent(
return event_result; 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( void WebViewFrameWidget::ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) { const VisualProperties& visual_properties) {
if (size_ != if (size_ !=
......
...@@ -78,15 +78,10 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase { ...@@ -78,15 +78,10 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
// WidgetBaseClient overrides: // WidgetBaseClient overrides:
void FocusChanged(bool enabled) override; void FocusChanged(bool enabled) override;
void SetWindowRect(const gfx::Rect& window_rect);
void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
private: private:
// PageWidgetEventHandler overrides: // PageWidgetEventHandler overrides:
WebInputEventResult HandleGestureEvent(const WebGestureEvent&) override; WebInputEventResult HandleGestureEvent(const WebGestureEvent&) override;
void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
scoped_refptr<WebViewImpl> web_view_; scoped_refptr<WebViewImpl> web_view_;
// This stores the last hidden page popup. If a GestureTap attempts to open // 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