Commit 93120719 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate blink::SurroundingTextImpl from WebLocalFrame to LocalFrame

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: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680346}
parent 39cd68db
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "third_party/blink/renderer/core/dom/document.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/display_cutout_client_impl.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/surrounding_text_impl.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h" #include "third_party/blink/renderer/platform/bindings/microtask.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h" #include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
...@@ -183,6 +184,9 @@ void BlinkInitializer::InitLocalFrame(LocalFrame& frame) const { ...@@ -183,6 +184,9 @@ void BlinkInitializer::InitLocalFrame(LocalFrame& frame) const {
} }
frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating( frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating(
&DevToolsFrontendImpl::BindMojoRequest, WrapWeakPersistent(&frame))); &DevToolsFrontendImpl::BindMojoRequest, WrapWeakPersistent(&frame)));
frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating(
&SurroundingTextImpl::BindToReceiver, WrapWeakPersistent(&frame)));
frame.GetInterfaceRegistry()->AddInterface(WTF::BindRepeating( frame.GetInterfaceRegistry()->AddInterface(WTF::BindRepeating(
&LocalFrame::PauseSubresourceLoading, WrapWeakPersistent(&frame))); &LocalFrame::PauseSubresourceLoading, WrapWeakPersistent(&frame)));
if (!base::FeatureList::IsEnabled( if (!base::FeatureList::IsEnabled(
......
...@@ -9,33 +9,45 @@ ...@@ -9,33 +9,45 @@
#include "third_party/blink/public/platform/task_type.h" #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/editing/surrounding_text.h"
#include "third_party/blink/renderer/core/frame/local_frame.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/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink { namespace blink {
SurroundingTextImpl::SurroundingTextImpl(WebLocalFrameImpl& frame, // static
InterfaceRegistry* interface_registry) const char SurroundingTextImpl::kSupplementName[] = "SurroundingTextImpl";
: frame_(&frame) {
if (!interface_registry)
return;
// TODO(crbug.com/800641): Use InterfaceValidator when it works for associated
// interfaces.
interface_registry->AddAssociatedInterface(WTF::BindRepeating(
&SurroundingTextImpl::BindToReceiver, WrapWeakPersistent(this)));
}
// static
void SurroundingTextImpl::BindToReceiver( void SurroundingTextImpl::BindToReceiver(
LocalFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver) { mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver) {
receiver_.Bind(std::move(receiver), if (!frame)
frame_->GetTaskRunner(blink::TaskType::kInternalDefault)); return;
frame->ProvideSupplement(
MakeGarbageCollected<SurroundingTextImpl>(*frame, std::move(receiver)));
} }
// static
SurroundingTextImpl* SurroundingTextImpl::From(LocalFrame* frame) {
if (!frame)
return nullptr;
return frame->RequireSupplement<SurroundingTextImpl>();
}
SurroundingTextImpl::SurroundingTextImpl(
LocalFrame& frame,
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver)
: Supplement<LocalFrame>(frame),
receiver_(this,
std::move(receiver),
frame.GetTaskRunner(blink::TaskType::kInternalDefault)) {}
SurroundingTextImpl::~SurroundingTextImpl() = default;
void SurroundingTextImpl::GetTextSurroundingSelection( void SurroundingTextImpl::GetTextSurroundingSelection(
uint32_t max_length, uint32_t max_length,
GetTextSurroundingSelectionCallback callback) { GetTextSurroundingSelectionCallback callback) {
blink::SurroundingText surrounding_text(frame_->GetFrame(), max_length); blink::SurroundingText surrounding_text(GetSupplementable(), max_length);
if (surrounding_text.IsEmpty()) { if (surrounding_text.IsEmpty()) {
// |surrounding_text| might not be correctly initialized, for example if // |surrounding_text| might not be correctly initialized, for example if
......
...@@ -8,35 +8,41 @@ ...@@ -8,35 +8,41 @@
#include "mojo/public/cpp/bindings/associated_receiver.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "third_party/blink/public/mojom/frame/surrounding_text.mojom-blink.h" #include "third_party/blink/public/mojom/frame/surrounding_text.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/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.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 { namespace blink {
class WebLocalFrameImpl; class LocalFrame;
// Implementation of mojom::blink::SurroundingText // Implementation of mojom::blink::SurroundingText
class CORE_EXPORT SurroundingTextImpl final class CORE_EXPORT SurroundingTextImpl final
: public GarbageCollectedFinalized<SurroundingTextImpl>, : public GarbageCollectedFinalized<SurroundingTextImpl>,
public Supplement<LocalFrame>,
public mojom::blink::SurroundingText { public mojom::blink::SurroundingText {
USING_GARBAGE_COLLECTED_MIXIN(SurroundingTextImpl);
public: public:
SurroundingTextImpl(WebLocalFrameImpl& frame, static const char kSupplementName[];
InterfaceRegistry* interface_registry);
static void BindToReceiver(
LocalFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver);
void BindToReceiver( static SurroundingTextImpl* From(LocalFrame* frame);
explicit SurroundingTextImpl(
LocalFrame& frame,
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver); mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver);
~SurroundingTextImpl() override;
void GetTextSurroundingSelection( void GetTextSurroundingSelection(
uint32_t max_length, uint32_t max_length,
GetTextSurroundingSelectionCallback callback) final; GetTextSurroundingSelectionCallback callback) final;
void Trace(blink::Visitor* visitor) { visitor->Trace(frame_); }
private: private:
const Member<WebLocalFrameImpl> frame_;
mojo::AssociatedReceiver<mojom::blink::SurroundingText> receiver_{this}; mojo::AssociatedReceiver<mojom::blink::SurroundingText> receiver_{this};
DISALLOW_COPY_AND_ASSIGN(SurroundingTextImpl); DISALLOW_COPY_AND_ASSIGN(SurroundingTextImpl);
......
...@@ -192,7 +192,6 @@ ...@@ -192,7 +192,6 @@
#include "third_party/blink/renderer/core/frame/screen_orientation_controller.h" #include "third_party/blink/renderer/core/frame/screen_orientation_controller.h"
#include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/smart_clip.h" #include "third_party/blink/renderer/core/frame/smart_clip.h"
#include "third_party/blink/renderer/core/frame/surrounding_text_impl.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h" #include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_base.h" #include "third_party/blink/renderer/core/frame/web_frame_widget_base.h"
#include "third_party/blink/renderer/core/html/forms/html_form_control_element.h" #include "third_party/blink/renderer/core/html/forms/html_form_control_element.h"
...@@ -1715,8 +1714,6 @@ WebLocalFrameImpl::WebLocalFrameImpl( ...@@ -1715,8 +1714,6 @@ WebLocalFrameImpl::WebLocalFrameImpl(
autofill_client_(nullptr), autofill_client_(nullptr),
find_in_page_( find_in_page_(
MakeGarbageCollected<FindInPage>(*this, interface_registry)), MakeGarbageCollected<FindInPage>(*this, interface_registry)),
surrounding_text_impl_(
MakeGarbageCollected<SurroundingTextImpl>(*this, interface_registry)),
interface_registry_(interface_registry), interface_registry_(interface_registry),
input_method_controller_(*this), input_method_controller_(*this),
spell_check_panel_host_client_(nullptr), spell_check_panel_host_client_(nullptr),
...@@ -1735,7 +1732,6 @@ WebLocalFrameImpl::~WebLocalFrameImpl() { ...@@ -1735,7 +1732,6 @@ WebLocalFrameImpl::~WebLocalFrameImpl() {
void WebLocalFrameImpl::Trace(blink::Visitor* visitor) { void WebLocalFrameImpl::Trace(blink::Visitor* visitor) {
visitor->Trace(local_frame_client_); visitor->Trace(local_frame_client_);
visitor->Trace(find_in_page_); visitor->Trace(find_in_page_);
visitor->Trace(surrounding_text_impl_);
visitor->Trace(frame_); visitor->Trace(frame_);
visitor->Trace(dev_tools_agent_); visitor->Trace(dev_tools_agent_);
visitor->Trace(frame_widget_); visitor->Trace(frame_widget_);
......
...@@ -65,7 +65,6 @@ class IntSize; ...@@ -65,7 +65,6 @@ class IntSize;
class LocalFrameClientImpl; class LocalFrameClientImpl;
class ResourceError; class ResourceError;
class ScrollableArea; class ScrollableArea;
class SurroundingTextImpl;
class TextFinder; class TextFinder;
class WebAssociatedURLLoader; class WebAssociatedURLLoader;
struct WebAssociatedURLLoaderOptions; struct WebAssociatedURLLoaderOptions;
...@@ -506,7 +505,6 @@ class CORE_EXPORT WebLocalFrameImpl final ...@@ -506,7 +505,6 @@ class CORE_EXPORT WebLocalFrameImpl final
WebContentSettingsClient* content_settings_client_ = nullptr; WebContentSettingsClient* content_settings_client_ = nullptr;
Member<FindInPage> find_in_page_; Member<FindInPage> find_in_page_;
Member<SurroundingTextImpl> surrounding_text_impl_;
// Valid between calls to BeginPrint() and EndPrint(). Containts the print // Valid between calls to BeginPrint() and EndPrint(). Containts the print
// information. Is used by PrintPage(). // 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