Commit 6d60d94c authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Reland "Migrate blink::SurroundingTextImpl from WebLocalFrame to LocalFrame"

Adapted the original CL to the change done in the precursor CL
to rename the new blink::mojom::SurroundingText Mojo interface
into blink::mojom::Frame instead.

Original change's description:
> Now that we have blink::SurroundingText inside Blink and implemented
> using internal Blink types like WTF::String and LocalFrame, we can
> finally migrate blink::SurroundingTextImpl away from WebLocalFrame
> and remove the DEPS exception rule we previously introduced during
> this process of Onion Soup'ing the SurroundingText API.
>
> Additionally, we move the instantiation of blink::SurroundingTextImpl
> from WebLocalFrame to LocalFrame as well and, with that, we remove any
> reference to public Blink classes from SurroundingText-related code.
>
> Bug: 980151
> Change-Id: I1a1014dbf6671b9327a068ceca4f62d873cb5fb3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1698413
> Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#680346}

Bug: 980151
Change-Id: Ifbec56f9391ff5b450ebeb6532d5089a53f94350
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1738454
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686388}
parent 2c0c1809
......@@ -44,6 +44,7 @@
#include "third_party/blink/renderer/controller/dev_tools_frontend_impl.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/display_cutout_client_impl.h"
#include "third_party/blink/renderer/core/frame/frame_impl.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
......@@ -183,6 +184,9 @@ void BlinkInitializer::InitLocalFrame(LocalFrame& frame) const {
}
frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating(
&DevToolsFrontendImpl::BindMojoRequest, WrapWeakPersistent(&frame)));
frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating(
&FrameImpl::BindToReceiver, WrapWeakPersistent(&frame)));
frame.GetInterfaceRegistry()->AddInterface(WTF::BindRepeating(
&LocalFrame::PauseSubresourceLoading, WrapWeakPersistent(&frame)));
if (!base::FeatureList::IsEnabled(
......
......@@ -119,10 +119,5 @@ specific_include_rules = {
],
"element_test.cc": [
"+third_party/blink/renderer/core/exported/web_plugin_container_impl.h"
],
# TODO(crbug.com/980151): Include this while WebSurroundingText is not
# removed from the public API and implemented in renderer/core.
"frame_impl.cc" : [
"+third_party/blink/renderer/core/frame/web_local_frame_impl.h",
]
}
......@@ -9,34 +9,46 @@
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/editing/surrounding_text.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
FrameImpl::FrameImpl(WebLocalFrameImpl& frame,
InterfaceRegistry* interface_registry)
: frame_(&frame) {
if (!interface_registry)
return;
// TODO(crbug.com/800641): Use InterfaceValidator when it works for associated
// interfaces.
interface_registry->AddAssociatedInterface(
WTF::BindRepeating(&FrameImpl::BindToReceiver, WrapWeakPersistent(this)));
}
// static
const char FrameImpl::kSupplementName[] = "FrameImpl";
// static
void FrameImpl::BindToReceiver(
LocalFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::Frame> receiver) {
receiver_.Bind(std::move(receiver),
frame_->GetTaskRunner(blink::TaskType::kInternalDefault));
if (!frame)
return;
frame->ProvideSupplement(
MakeGarbageCollected<FrameImpl>(*frame, std::move(receiver)));
}
// static
FrameImpl* FrameImpl::From(LocalFrame* frame) {
if (!frame)
return nullptr;
return frame->RequireSupplement<FrameImpl>();
}
FrameImpl::FrameImpl(
LocalFrame& frame,
mojo::PendingAssociatedReceiver<mojom::blink::Frame> receiver)
: Supplement<LocalFrame>(frame),
receiver_(this,
std::move(receiver),
frame.GetTaskRunner(blink::TaskType::kInternalDefault)) {}
FrameImpl::~FrameImpl() = default;
void FrameImpl::GetTextSurroundingSelection(
uint32_t max_length,
GetTextSurroundingSelectionCallback callback) {
blink::SurroundingText surrounding_text(frame_->GetFrame(), max_length);
blink::SurroundingText surrounding_text(GetSupplementable(), max_length);
// |surrounding_text| might not be correctly initialized, for example if
// |frame_->SelectionRange().IsNull()|, in other words, if there was no
......
......@@ -8,36 +8,40 @@
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
#include "third_party/blink/public/platform/interface_registry.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/supplementable.h"
namespace blink {
class WebLocalFrameImpl;
class LocalFrame;
// Implementation of blink::mojom::Frame
// Implementation of mojom::blink::Frame
class CORE_EXPORT FrameImpl final : public GarbageCollectedFinalized<FrameImpl>,
public Supplement<LocalFrame>,
public mojom::blink::Frame {
USING_GARBAGE_COLLECTED_MIXIN(FrameImpl);
public:
// TODO(crbug.com/980151): Construct FrameImpl this way only while we need to
// rely in blink::WebSurroundingText to implement GetTextSurroundingSelection,
// and remove the dependency once WebSurroundingText is out of the public API.
FrameImpl(WebLocalFrameImpl& frame, InterfaceRegistry* interface_registry);
static const char kSupplementName[];
static void BindToReceiver(
LocalFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::Frame> receiver);
void BindToReceiver(
static FrameImpl* From(LocalFrame* frame);
explicit FrameImpl(
LocalFrame& frame,
mojo::PendingAssociatedReceiver<mojom::blink::Frame> receiver);
~FrameImpl() override;
void GetTextSurroundingSelection(
uint32_t max_length,
GetTextSurroundingSelectionCallback callback) final;
void Trace(blink::Visitor* visitor) { visitor->Trace(frame_); }
private:
const Member<WebLocalFrameImpl> frame_;
mojo::AssociatedReceiver<mojom::blink::Frame> receiver_{this};
DISALLOW_COPY_AND_ASSIGN(FrameImpl);
......
......@@ -1712,7 +1712,6 @@ WebLocalFrameImpl::WebLocalFrameImpl(
autofill_client_(nullptr),
find_in_page_(
MakeGarbageCollected<FindInPage>(*this, interface_registry)),
frame_impl_(MakeGarbageCollected<FrameImpl>(*this, interface_registry)),
interface_registry_(interface_registry),
input_method_controller_(*this),
spell_check_panel_host_client_(nullptr),
......@@ -1731,7 +1730,6 @@ WebLocalFrameImpl::~WebLocalFrameImpl() {
void WebLocalFrameImpl::Trace(blink::Visitor* visitor) {
visitor->Trace(local_frame_client_);
visitor->Trace(find_in_page_);
visitor->Trace(frame_impl_);
visitor->Trace(frame_);
visitor->Trace(dev_tools_agent_);
visitor->Trace(frame_widget_);
......
......@@ -66,7 +66,6 @@ class IntSize;
class LocalFrameClientImpl;
class ResourceError;
class ScrollableArea;
class FrameImpl;
class TextFinder;
class WebAssociatedURLLoader;
struct WebAssociatedURLLoaderOptions;
......@@ -510,7 +509,6 @@ class CORE_EXPORT WebLocalFrameImpl final
WebContentSettingsClient* content_settings_client_ = nullptr;
Member<FindInPage> find_in_page_;
Member<FrameImpl> frame_impl_;
// Valid between calls to BeginPrint() and EndPrint(). Containts the print
// information. Is used by PrintPage().
......
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