Commit 297ebbfa authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Move ApplyVisualProperties into WebFrameWidgetBase

Move the two implementations into one common one in the base.

BUG=1097816

Change-Id: Ia4187c07676256e62e8d019e90f79b4acc24f97a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542596
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829284}
parent c1ec388a
......@@ -1203,6 +1203,68 @@ void WebFrameWidgetBase::UpdateVisualProperties(
ScrollFocusedEditableElementIntoView();
}
void WebFrameWidgetBase::ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) {
gfx::Rect new_compositor_viewport_pixel_rect =
visual_properties.compositor_viewport_pixel_rect;
if (ForMainFrame()) {
if (size_ !=
widget_base_->DIPsToCeiledBlinkSpace(visual_properties.new_size)) {
// Only hide popups when the size changes. Eg https://crbug.com/761908.
View()->CancelPagePopup();
}
if (auto* device_emulator = DeviceEmulator()) {
device_emulator->UpdateVisualProperties(visual_properties);
return;
}
if (AutoResizeMode()) {
new_compositor_viewport_pixel_rect = gfx::Rect(gfx::ScaleToCeiledSize(
widget_base_->BlinkSpaceToFlooredDIPs(size_.value_or(gfx::Size())),
visual_properties.screen_info.device_scale_factor));
}
}
SetWindowSegments(visual_properties.root_widget_window_segments);
widget_base_->UpdateSurfaceAndScreenInfo(
visual_properties.local_surface_id.value_or(viz::LocalSurfaceId()),
new_compositor_viewport_pixel_rect, visual_properties.screen_info);
// Store this even when auto-resizing, it is the size of the full viewport
// used for clipping, and this value is propagated down the Widget
// hierarchy via the VisualProperties waterfall.
widget_base_->SetVisibleViewportSizeInDIPs(
visual_properties.visible_viewport_size);
if (ForMainFrame()) {
if (!AutoResizeMode()) {
size_ = widget_base_->DIPsToCeiledBlinkSpace(visual_properties.new_size);
View()->ResizeWithBrowserControls(
size_.value(),
widget_base_->DIPsToCeiledBlinkSpace(
widget_base_->VisibleViewportSizeInDIPs()),
visual_properties.browser_controls_params);
}
} else {
// Widgets in a WebView's frame tree without a local main frame
// set the size of the WebView to be the |visible_viewport_size|, in order
// to limit compositing in (out of process) child frames to what is visible.
//
// Note that child frames in the same process/WebView frame tree as the
// main frame do not do this in order to not clobber the source of truth in
// the main frame.
if (!View()->MainFrameImpl()) {
View()->Resize(widget_base_->DIPsToCeiledBlinkSpace(
widget_base_->VisibleViewportSizeInDIPs()));
}
Resize(widget_base_->DIPsToCeiledBlinkSpace(visual_properties.new_size));
}
}
void WebFrameWidgetBase::ScheduleAnimationForWebTests() {
Client()->ScheduleAnimationForWebTests();
}
......
......@@ -637,10 +637,6 @@ class CORE_EXPORT WebFrameWidgetBase
ScreenMetricsEmulator* DeviceEmulator();
// Called during |UpdateVisualProperties| to apply the new size to the widget.
virtual void ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) = 0;
// Calculates the selection bounds in the root frame. Returns bounds unchanged
// when there is no focused frame or no selection.
void CalculateSelectionBounds(gfx::Rect& anchor_in_root_frame,
......@@ -732,6 +728,9 @@ class CORE_EXPORT WebFrameWidgetBase
HitTestResult HitTestResultForRootFramePos(
const FloatPoint& pos_in_root_frame);
// Called during |UpdateVisualProperties| to apply the new size to the widget.
void ApplyVisualPropertiesSizing(const VisualProperties& visual_properties);
// Returns the current state of synchronous resize mode for testing.
bool SynchronousResizeModeForTestingEnabled();
......
......@@ -466,33 +466,4 @@ void WebFrameWidgetImpl::GetScrollParamsForFocusedEditableElement(
rect_to_scroll = PhysicalRect(maximal_rect);
}
void WebFrameWidgetImpl::ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) {
SetWindowSegments(visual_properties.root_widget_window_segments);
widget_base_->UpdateSurfaceAndScreenInfo(
visual_properties.local_surface_id.value_or(viz::LocalSurfaceId()),
visual_properties.compositor_viewport_pixel_rect,
visual_properties.screen_info);
// Store this even when auto-resizing, it is the size of the full viewport
// used for clipping, and this value is propagated down the Widget
// hierarchy via the VisualProperties waterfall.
widget_base_->SetVisibleViewportSizeInDIPs(
visual_properties.visible_viewport_size);
// Widgets in a WebView's frame tree without a local main frame
// set the size of the WebView to be the |visible_viewport_size|, in order
// to limit compositing in (out of process) child frames to what is visible.
//
// Note that child frames in the same process/WebView frame tree as the
// main frame do not do this in order to not clobber the source of truth in
// the main frame.
if (!View()->MainFrameImpl()) {
View()->Resize(widget_base_->DIPsToCeiledBlinkSpace(
widget_base_->VisibleViewportSizeInDIPs()));
}
Resize(widget_base_->DIPsToCeiledBlinkSpace(visual_properties.new_size));
}
} // namespace blink
......@@ -93,8 +93,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase {
// WebFrameWidgetBase overrides:
void DidCreateLocalRootView() override;
void ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) override;
// FrameWidget overrides:
bool ShouldHandleImeEvents() override;
......
......@@ -284,69 +284,4 @@ WebInputEventResult WebViewFrameWidget::HandleGestureEvent(
return event_result;
}
void WebViewFrameWidget::ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) {
if (size_ !=
widget_base_->DIPsToCeiledBlinkSpace(visual_properties.new_size)) {
// Only hide popups when the size changes. Eg https://crbug.com/761908.
web_view_->CancelPagePopup();
}
if (auto* device_emulator = DeviceEmulator()) {
device_emulator->UpdateVisualProperties(visual_properties);
return;
}
SetWindowSegments(visual_properties.root_widget_window_segments);
// We can ignore browser-initialized resizing during synchronous
// (renderer-controlled) mode, unless it is switching us to/from
// fullsreen mode or changing the device scale factor.
bool ignore_resize = SynchronousResizeModeForTestingEnabled();
if (ignore_resize) {
// TODO(danakj): Does the browser actually change DSF inside a web test??
// TODO(danakj): Isn't the display mode check redundant with the
// fullscreen one?
if (visual_properties.is_fullscreen_granted != IsFullscreenGranted() ||
visual_properties.screen_info.device_scale_factor !=
widget_base_->GetScreenInfo().device_scale_factor)
ignore_resize = false;
}
// When controlling the size in the renderer, we should ignore sizes given
// by the browser IPC here.
// TODO(danakj): There are many things also being ignored that aren't the
// widget's size params. It works because tests that use this mode don't
// change those parameters, I guess. But it's more complicated then because
// it looks like they are related to sync resize mode. Let's move them out
// of this block.
gfx::Rect new_compositor_viewport_pixel_rect =
visual_properties.compositor_viewport_pixel_rect;
if (AutoResizeMode()) {
new_compositor_viewport_pixel_rect = gfx::Rect(gfx::ScaleToCeiledSize(
widget_base_->BlinkSpaceToFlooredDIPs(size_.value_or(gfx::Size())),
visual_properties.screen_info.device_scale_factor));
}
widget_base_->UpdateSurfaceAndScreenInfo(
visual_properties.local_surface_id.value_or(viz::LocalSurfaceId()),
new_compositor_viewport_pixel_rect, visual_properties.screen_info);
// Store this even when auto-resizing, it is the size of the full viewport
// used for clipping, and this value is propagated down the Widget
// hierarchy via the VisualProperties waterfall.
widget_base_->SetVisibleViewportSizeInDIPs(
visual_properties.visible_viewport_size);
if (!AutoResizeMode()) {
size_ = widget_base_->DIPsToCeiledBlinkSpace(visual_properties.new_size);
View()->ResizeWithBrowserControls(
size_.value(),
widget_base_->DIPsToCeiledBlinkSpace(
widget_base_->VisibleViewportSizeInDIPs()),
visual_properties.browser_controls_params);
}
}
} // namespace blink
......@@ -68,10 +68,6 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
// WebFrameWidget overrides:
bool ScrollFocusedEditableElementIntoView() override;
// WebFrameWidgetBase overrides:
void ApplyVisualPropertiesSizing(
const VisualProperties& visual_properties) override;
// FrameWidget overrides:
bool ShouldHandleImeEvents() override;
......
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