Commit 1a55694b authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

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

This reverts commit 93120719.

Reason for revert: It's possible that this patch has caused the renderer
process to crash on Android, perhaps due to the last minute change to
make SurroundingTextImpl a Supplement<LocalFrame> (see [1]), so let's
revert it for now.

[1]https://chromium-review.googlesource.com/c/chromium/src/+/1698413/8..12

Original change's description:
> 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: Kentaro Hara <haraken@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#680346}

TBR=haraken@chromium.org,mario@igalia.com

Change-Id: Ic351b09b2c57a316f14473c8a1dfefd96b909386
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 980151, 987214
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715197Reviewed-by: default avatarMario Sanchez Prada <mario@igalia.com>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#680435}
parent 399a3aff
......@@ -45,7 +45,6 @@
#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/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/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
......@@ -184,9 +183,6 @@ void BlinkInitializer::InitLocalFrame(LocalFrame& frame) const {
}
frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating(
&DevToolsFrontendImpl::BindMojoRequest, WrapWeakPersistent(&frame)));
frame.GetInterfaceRegistry()->AddAssociatedInterface(WTF::BindRepeating(
&SurroundingTextImpl::BindToReceiver, WrapWeakPersistent(&frame)));
frame.GetInterfaceRegistry()->AddInterface(WTF::BindRepeating(
&LocalFrame::PauseSubresourceLoading, WrapWeakPersistent(&frame)));
if (!base::FeatureList::IsEnabled(
......
......@@ -9,45 +9,33 @@
#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"
namespace blink {
// static
const char SurroundingTextImpl::kSupplementName[] = "SurroundingTextImpl";
// static
void SurroundingTextImpl::BindToReceiver(
LocalFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver) {
if (!frame)
SurroundingTextImpl::SurroundingTextImpl(WebLocalFrameImpl& frame,
InterfaceRegistry* interface_registry)
: frame_(&frame) {
if (!interface_registry)
return;
frame->ProvideSupplement(
MakeGarbageCollected<SurroundingTextImpl>(*frame, std::move(receiver)));
// TODO(crbug.com/800641): Use InterfaceValidator when it works for associated
// interfaces.
interface_registry->AddAssociatedInterface(WTF::BindRepeating(
&SurroundingTextImpl::BindToReceiver, WrapWeakPersistent(this)));
}
// static
SurroundingTextImpl* SurroundingTextImpl::From(LocalFrame* frame) {
if (!frame)
return nullptr;
return frame->RequireSupplement<SurroundingTextImpl>();
void SurroundingTextImpl::BindToReceiver(
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver) {
receiver_.Bind(std::move(receiver),
frame_->GetTaskRunner(blink::TaskType::kInternalDefault));
}
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(
uint32_t max_length,
GetTextSurroundingSelectionCallback callback) {
blink::SurroundingText surrounding_text(GetSupplementable(), max_length);
blink::SurroundingText surrounding_text(frame_->GetFrame(), max_length);
if (surrounding_text.IsEmpty()) {
// |surrounding_text| might not be correctly initialized, for example if
......
......@@ -8,41 +8,35 @@
#include "mojo/public/cpp/bindings/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/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 LocalFrame;
class WebLocalFrameImpl;
// Implementation of mojom::blink::SurroundingText
class CORE_EXPORT SurroundingTextImpl final
: public GarbageCollectedFinalized<SurroundingTextImpl>,
public Supplement<LocalFrame>,
public mojom::blink::SurroundingText {
USING_GARBAGE_COLLECTED_MIXIN(SurroundingTextImpl);
public:
static const char kSupplementName[];
static void BindToReceiver(
LocalFrame* frame,
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver);
SurroundingTextImpl(WebLocalFrameImpl& frame,
InterfaceRegistry* interface_registry);
static SurroundingTextImpl* From(LocalFrame* frame);
explicit SurroundingTextImpl(
LocalFrame& frame,
void BindToReceiver(
mojo::PendingAssociatedReceiver<mojom::blink::SurroundingText> receiver);
~SurroundingTextImpl() 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::SurroundingText> receiver_{this};
DISALLOW_COPY_AND_ASSIGN(SurroundingTextImpl);
......
......@@ -192,6 +192,7 @@
#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/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/web_frame_widget_base.h"
#include "third_party/blink/renderer/core/html/forms/html_form_control_element.h"
......@@ -1714,6 +1715,8 @@ WebLocalFrameImpl::WebLocalFrameImpl(
autofill_client_(nullptr),
find_in_page_(
MakeGarbageCollected<FindInPage>(*this, interface_registry)),
surrounding_text_impl_(
MakeGarbageCollected<SurroundingTextImpl>(*this, interface_registry)),
interface_registry_(interface_registry),
input_method_controller_(*this),
spell_check_panel_host_client_(nullptr),
......@@ -1732,6 +1735,7 @@ WebLocalFrameImpl::~WebLocalFrameImpl() {
void WebLocalFrameImpl::Trace(blink::Visitor* visitor) {
visitor->Trace(local_frame_client_);
visitor->Trace(find_in_page_);
visitor->Trace(surrounding_text_impl_);
visitor->Trace(frame_);
visitor->Trace(dev_tools_agent_);
visitor->Trace(frame_widget_);
......
......@@ -65,6 +65,7 @@ class IntSize;
class LocalFrameClientImpl;
class ResourceError;
class ScrollableArea;
class SurroundingTextImpl;
class TextFinder;
class WebAssociatedURLLoader;
struct WebAssociatedURLLoaderOptions;
......@@ -505,6 +506,7 @@ class CORE_EXPORT WebLocalFrameImpl final
WebContentSettingsClient* content_settings_client_ = nullptr;
Member<FindInPage> find_in_page_;
Member<SurroundingTextImpl> surrounding_text_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