Commit 54713b66 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert FrameMsg_IntrinsicSizingInfoOfChildChanged to use blink RemoteFrame

This CL changes FrameMsg_IntrinsicSizingInfoOfChildChanged so that it
is implemented in the RemoteFrame interface since it is only got
through RenderFrameProxy.

It introduces intrinsic_sizing_info.mojom to have the type used in
IntrinsicSizingInfoOfChildChanged().

Bug: 1044304
Change-Id: I7bb41d53a415f4bd8a4eb87c270d23c28c83b27b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015866
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736733}
parent 6564fed8
......@@ -24,6 +24,7 @@
#include "content/public/common/use_zoom_for_dsf_policy.h"
#include "gpu/ipc/common/gpu_messages.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/gfx/geometry/dip_util.h"
......@@ -158,9 +159,20 @@ void CrossProcessFrameConnector::RenderProcessGone() {
void CrossProcessFrameConnector::SendIntrinsicSizingInfoToParent(
const blink::WebIntrinsicSizingInfo& sizing_info) {
frame_proxy_in_parent_renderer_->Send(
new FrameMsg_IntrinsicSizingInfoOfChildChanged(
frame_proxy_in_parent_renderer_->GetRoutingID(), sizing_info));
// The width/height should not be negative since gfx::SizeF will clamp
// negative values to zero.
DCHECK((sizing_info.size.width >= 0.f) && (sizing_info.size.height >= 0.f));
DCHECK((sizing_info.aspect_ratio.width >= 0.f) &&
(sizing_info.aspect_ratio.height >= 0.f));
auto info = blink::mojom::IntrinsicSizingInfo::New(
gfx::SizeF(sizing_info.size.width, sizing_info.size.height),
gfx::SizeF(sizing_info.aspect_ratio.width,
sizing_info.aspect_ratio.height),
sizing_info.has_width, sizing_info.has_height);
frame_proxy_in_parent_renderer_->GetAssociatedRemoteFrame()
->IntrinsicSizingInfoOfChildChanged(std::move(info));
}
void CrossProcessFrameConnector::UpdateCursor(const WebCursor& cursor) {
......
......@@ -549,12 +549,6 @@ IPC_STRUCT_TRAITS_END()
// -----------------------------------------------------------------------------
// Messages sent from the browser to the renderer.
// Notifies the embedding frame that the intrinsic sizing info parameters
// of a child frame have changed. Generated when the browser receives a
// WidgetHostMsg_IntrinsicSizingInfoChanged.
IPC_MESSAGE_ROUTED1(FrameMsg_IntrinsicSizingInfoOfChildChanged,
blink::WebIntrinsicSizingInfo)
// Notifies the embedding frame that the process rendering the child frame's
// contents has terminated.
IPC_MESSAGE_ROUTED0(FrameMsg_ChildFrameProcessGone)
......
......@@ -216,7 +216,7 @@ IPC_MESSAGE_ROUTED0(WidgetHostMsg_UpdateScreenRects_ACK)
// browser can then notify a containing frame that the frame may need to
// trigger a new layout.
//
// Also see FrameMsg_IntrinsicSizingInfoOfChildChanged.
// Also see blink::mojom::RemoteFrame::IntrinsicSizingInfoOfChildChanged.
IPC_MESSAGE_ROUTED1(WidgetHostMsg_IntrinsicSizingInfoChanged,
blink::WebIntrinsicSizingInfo)
......
......@@ -71,6 +71,9 @@ void FakeRemoteFrame::DidStartLoading() {}
void FakeRemoteFrame::DidStopLoading() {}
void FakeRemoteFrame::IntrinsicSizingInfoOfChildChanged(
blink::mojom::IntrinsicSizingInfoPtr sizing_info) {}
void FakeRemoteFrame::FakeRemoteFrame::BindFrameHostReceiver(
mojo::ScopedInterfaceEndpointHandle handle) {
receiver_.Bind(mojo::PendingAssociatedReceiver<blink::mojom::RemoteFrame>(
......
......@@ -9,6 +9,7 @@
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/mojom/frame/frame.mojom.h"
#include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom.h"
#include "third_party/blink/public/mojom/frame/user_activation_update_types.mojom.h"
#include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom.h"
#include "ui/events/types/scroll_types.h"
......@@ -62,12 +63,16 @@ class FakeRemoteFrame : public blink::mojom::RemoteFrame {
void RenderFallbackContent() override;
void AddResourceTimingFromChild(
blink::mojom::ResourceTimingInfoPtr timing) override;
void ScrollRectToVisible(
const gfx::Rect& rect,
blink::mojom::ScrollIntoViewParamsPtr params) override;
void DidStartLoading() override;
void DidStopLoading() override;
void IntrinsicSizingInfoOfChildChanged(
blink::mojom::IntrinsicSizingInfoPtr sizing_info) override;
private:
void BindFrameHostReceiver(mojo::ScopedInterfaceEndpointHandle handle);
......
......@@ -411,8 +411,6 @@ bool RenderFrameProxy::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(RenderFrameProxy, msg)
IPC_MESSAGE_HANDLER(FrameMsg_ChildFrameProcessGone, OnChildFrameProcessGone)
IPC_MESSAGE_HANDLER(FrameMsg_IntrinsicSizingInfoOfChildChanged,
OnIntrinsicSizingInfoOfChildChanged)
IPC_MESSAGE_HANDLER(FrameMsg_UpdateOpener, OnUpdateOpener)
IPC_MESSAGE_HANDLER(FrameMsg_ViewChanged, OnViewChanged)
IPC_MESSAGE_HANDLER(FrameMsg_DidUpdateFramePolicy, OnDidUpdateFramePolicy)
......@@ -458,11 +456,6 @@ void RenderFrameProxy::OnChildFrameProcessGone() {
screen_info().device_scale_factor);
}
void RenderFrameProxy::OnIntrinsicSizingInfoOfChildChanged(
blink::WebIntrinsicSizingInfo sizing_info) {
web_frame()->IntrinsicSizingInfoChanged(sizing_info);
}
void RenderFrameProxy::OnUpdateOpener(int opener_routing_id) {
blink::WebFrame* opener = RenderFrameImpl::ResolveOpener(opener_routing_id);
web_frame_->SetOpener(opener);
......
......@@ -224,8 +224,6 @@ class CONTENT_EXPORT RenderFrameProxy : public IPC::Listener,
void OnDeleteProxy();
void OnChildFrameProcessGone();
void OnCompositorFrameSwapped(const IPC::Message& message);
void OnIntrinsicSizingInfoOfChildChanged(
blink::WebIntrinsicSizingInfo sizing_info);
void OnUpdateOpener(int opener_routing_id);
void OnViewChanged(const FrameMsg_ViewChanged_Params& params);
void OnDidUpdateFramePolicy(const blink::FramePolicy& frame_policy);
......
......@@ -52,6 +52,7 @@ mojom("mojom_platform") {
"frame/frame.mojom",
"frame/frame_policy.mojom",
"frame/fullscreen.mojom",
"frame/intrinsic_sizing_info.mojom",
"frame/lifecycle.mojom",
"frame/media_player_action.mojom",
"frame/navigation_initiator.mojom",
......
......@@ -14,6 +14,7 @@ import "third_party/blink/public/mojom/ad_tagging/ad_frame.mojom";
import "third_party/blink/public/mojom/devtools/console_message.mojom";
import "third_party/blink/public/mojom/frame/blocked_navigation_types.mojom";
import "third_party/blink/public/mojom/frame/fullscreen.mojom";
import "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom";
import "third_party/blink/public/mojom/frame/lifecycle.mojom";
import "third_party/blink/public/mojom/frame/media_player_action.mojom";
import "third_party/blink/public/mojom/frame/sudden_termination_disabler_type.mojom";
......@@ -454,4 +455,9 @@ interface RemoteFrame {
// Notifies this remote frame that its corresponding document has completed
// loading.
DidStopLoading();
// Sent to the remote frame placeholder in the parent process indicating the
// intrinsic sizing parameters of the content frame have changed. Generated
// when the browser receives a WidgetHostMsg_IntrinsicSizingInfoChanged.
IntrinsicSizingInfoOfChildChanged(IntrinsicSizingInfo sizing_info);
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "ui/gfx/geometry/mojom/geometry.mojom";
// The intrinsic dimensions of the embedded object.
struct IntrinsicSizingInfo {
// The specified width and height.
gfx.mojom.SizeF size;
// The ratio between the width and height.
// https://www.w3.org/TR/css-images-3/#intrinsic-aspect-ratio
gfx.mojom.SizeF aspect_ratio;
// True if it has a width.
bool has_width;
// True if it has a height.
bool has_height;
};
......@@ -30,7 +30,6 @@ class WebLocalFrameClient;
class WebRemoteFrameClient;
class WebString;
class WebView;
struct WebIntrinsicSizingInfo;
struct WebRect;
class WebRemoteFrame : public WebFrame {
......@@ -142,8 +141,6 @@ class WebRemoteFrame : public WebFrame {
virtual void SetHadStickyUserActivationBeforeNavigation(bool value) = 0;
virtual void IntrinsicSizingInfoChanged(const WebIntrinsicSizingInfo&) = 0;
virtual WebRect GetCompositingRect() = 0;
protected:
......
......@@ -317,24 +317,6 @@ void WebRemoteFrameImpl::TransferUserActivationFrom(
To<WebRemoteFrameImpl>(source_frame)->GetFrame());
}
void WebRemoteFrameImpl::IntrinsicSizingInfoChanged(
const WebIntrinsicSizingInfo& web_sizing_info) {
FrameOwner* owner = GetFrame()->Owner();
// Only communication from HTMLPluginElement-owned subframes is allowed
// at present. This includes <embed> and <object> tags.
if (!owner || !owner->IsPlugin())
return;
IntrinsicSizingInfo sizing_info;
sizing_info.size = web_sizing_info.size;
sizing_info.aspect_ratio = web_sizing_info.aspect_ratio;
sizing_info.has_width = web_sizing_info.has_width;
sizing_info.has_height = web_sizing_info.has_height;
frame_->View()->SetIntrinsicSizeInfo(sizing_info);
owner->IntrinsicSizingInfoChanged();
}
void WebRemoteFrameImpl::SetHadStickyUserActivationBeforeNavigation(
bool value) {
GetFrame()->SetHadStickyUserActivationBeforeNavigation(value);
......
......@@ -97,7 +97,6 @@ class CORE_EXPORT WebRemoteFrameImpl final
void UpdateUserActivationState(
mojom::blink::UserActivationUpdateType) override;
void TransferUserActivationFrom(blink::WebRemoteFrame* source_frame) override;
void IntrinsicSizingInfoChanged(const WebIntrinsicSizingInfo&) override;
void SetHadStickyUserActivationBeforeNavigation(bool value) override;
v8::Local<v8::Object> GlobalProxy() const override;
WebRect GetCompositingRect() override;
......
......@@ -7,6 +7,7 @@
#include "cc/layers/surface_layer.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom-blink.h"
#include "third_party/blink/public/platform/interface_registry.h"
#include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_view.h"
......@@ -23,6 +24,7 @@
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h"
#include "third_party/blink/renderer/core/layout/intrinsic_sizing_info.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/loader/frame_load_request.h"
......@@ -514,6 +516,28 @@ void RemoteFrame::ScrollRectToVisible(
element_bounds_in_document, caret_bounds_in_document, true);
}
void RemoteFrame::IntrinsicSizingInfoOfChildChanged(
mojom::blink::IntrinsicSizingInfoPtr info) {
FrameOwner* owner = Owner();
// Only communication from HTMLPluginElement-owned subframes is allowed
// at present. This includes <embed> and <object> tags.
if (!owner || !owner->IsPlugin())
return;
// TODO(https://crbug.com/1044304): Should either remove the native
// C++ Blink type and use the Mojo type everywhere or typemap the
// Mojo type to the pre-existing native C++ Blink type.
IntrinsicSizingInfo sizing_info;
sizing_info.size = FloatSize(info->size->width, info->size->height);
sizing_info.aspect_ratio =
FloatSize(info->aspect_ratio->width, info->aspect_ratio->height);
sizing_info.has_width = info->has_width;
sizing_info.has_height = info->has_height;
View()->SetIntrinsicSizeInfo(sizing_info);
owner->IntrinsicSizingInfoChanged();
}
bool RemoteFrame::IsIgnoredForHitTest() const {
HTMLFrameOwnerElement* owner = DeprecatedLocalOwner();
if (!owner || !owner->GetLayoutObject())
......
......@@ -123,6 +123,8 @@ class CORE_EXPORT RemoteFrame final : public Frame,
mojom::blink::ScrollIntoViewParamsPtr params) override;
void DidStartLoading() override;
void DidStopLoading() override;
void IntrinsicSizingInfoOfChildChanged(
mojom::blink::IntrinsicSizingInfoPtr sizing_info) override;
private:
// Frame protected overrides:
......
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