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

Revert "Move blink::WebSurroundingText out of the public API"

This reverts commit 81209323.

Reason for revert: It's possible that the first patch of this chain of
three
patches has caused the renderer process to crash on Android, so we need to
revert this CL now in order to revert that first patch afterwards, so check
whether the crashes go away after that.

Original change's description:
> Move blink::WebSurroundingText out of the public API
> 
> This class is now only used from blink::SurroundingTextImpl, so we can
> move it down into renderer/core/editing and remove it from the public API.
> 
> Also, make the most of this move to make the new blink::SurroundingText
> class use internal Blink types (i.e. WTF::String, LocalFrame) instead of
> the public Web* types (i.e. WebString, WebLocalFrame), which will allow
> migrating blink::EditingImpl away from WebLocalFrame on a follow-up CL.
> 
> Bug: 980151, 919392
> Change-Id: I2a6ba1aa9e00603d40b4ccb9acb69f46baf5931b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1699608
> Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#680007}

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

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 980151, 919392
Change-Id: I978b040d7d9ee68d515cb7226f39edef942e61d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719349Reviewed-by: default avatarMario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#681226}
parent 2cfebb87
...@@ -498,6 +498,7 @@ source_set("blink_headers") { ...@@ -498,6 +498,7 @@ source_set("blink_headers") {
"web/web_settings.h", "web/web_settings.h",
"web/web_shared_worker.h", "web/web_shared_worker.h",
"web/web_shared_worker_client.h", "web/web_shared_worker_client.h",
"web/web_surrounding_text.h",
"web/web_testing_support.h", "web/web_testing_support.h",
"web/web_text_check_client.h", "web/web_text_check_client.h",
"web/web_text_checking_completion.h", "web/web_text_checking_completion.h",
......
...@@ -22,50 +22,48 @@ ...@@ -22,50 +22,48 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SURROUNDING_TEXT_H_ #ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SURROUNDING_TEXT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SURROUNDING_TEXT_H_ #define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SURROUNDING_TEXT_H_
#include "third_party/blink/renderer/core/core_export.h"
#if INSIDE_BLINK #if INSIDE_BLINK
#include "third_party/blink/renderer/core/editing/forward.h" // nogncheck #include "third_party/blink/renderer/core/editing/forward.h" // nogncheck
#endif #endif
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/public/platform/web_string.h"
namespace blink { namespace blink {
class LocalFrame; class WebLocalFrame;
// SurroundingText is a Blink API that gives access to the SurroundingText // WebSurroundingText is a Blink API that gives access to the SurroundingText
// API. It allows caller to know the text surrounding a point or a range. // API. It allows caller to know the text surrounding a point or a range.
class CORE_EXPORT SurroundingText { class WebSurroundingText {
public: public:
// Initializes the object with the current selection in a given frame. // Initializes the object with the current selection in a given frame.
// The maximum length of the contents retrieved is defined by max_length. // The maximum length of the contents retrieved is defined by max_length.
// It does not include the text inside the range. // It does not include the text inside the range.
SurroundingText(LocalFrame*, size_t max_length); BLINK_EXPORT WebSurroundingText(WebLocalFrame*, size_t max_length);
#if INSIDE_BLINK #if INSIDE_BLINK
SurroundingText(const EphemeralRange&, size_t max_length); BLINK_EXPORT WebSurroundingText(const EphemeralRange&, size_t max_length);
#endif #endif
bool IsEmpty() const; BLINK_EXPORT bool IsEmpty() const;
// Surrounding text content retrieved. // Surrounding text content retrieved.
String TextContent() const; BLINK_EXPORT WebString TextContent() const;
// Start offset of the initial text in the text content. // Start offset of the initial text in the text content.
size_t StartOffsetInTextContent() const; BLINK_EXPORT size_t StartOffsetInTextContent() const;
// End offset of the initial text in the text content. // End offset of the initial text in the text content.
size_t EndOffsetInTextContent() const; BLINK_EXPORT size_t EndOffsetInTextContent() const;
private: private:
String text_content_; WebString text_content_;
size_t start_offset_in_text_content_; size_t start_offset_in_text_content_;
size_t end_offset_in_text_content_; size_t end_offset_in_text_content_;
}; };
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SURROUNDING_TEXT_H_ #endif
...@@ -1165,6 +1165,7 @@ jumbo_source_set("unit_tests") { ...@@ -1165,6 +1165,7 @@ jumbo_source_set("unit_tests") {
"exported/web_scoped_window_focus_allowed_indicator_test.cc", "exported/web_scoped_window_focus_allowed_indicator_test.cc",
"exported/web_searchable_form_data_test.cc", "exported/web_searchable_form_data_test.cc",
"exported/web_selector_test.cc", "exported/web_selector_test.cc",
"exported/web_surrounding_text_test.cc",
"exported/web_user_gesture_token_test.cc", "exported/web_user_gesture_token_test.cc",
"exported/web_view_test.cc", "exported/web_view_test.cc",
"feature_policy/feature_policy_test.cc", "feature_policy/feature_policy_test.cc",
......
...@@ -299,8 +299,6 @@ blink_core_sources("editing") { ...@@ -299,8 +299,6 @@ blink_core_sources("editing") {
"suggestion/text_suggestion_controller.cc", "suggestion/text_suggestion_controller.cc",
"suggestion/text_suggestion_controller.h", "suggestion/text_suggestion_controller.h",
"suggestion/text_suggestion_info.h", "suggestion/text_suggestion_info.h",
"surrounding_text.cc",
"surrounding_text.h",
"text_affinity.cc", "text_affinity.cc",
"text_affinity.h", "text_affinity.h",
"text_granularity.h", "text_granularity.h",
...@@ -412,7 +410,6 @@ jumbo_source_set("unit_tests") { ...@@ -412,7 +410,6 @@ jumbo_source_set("unit_tests") {
"state_machines/state_machine_test_util.h", "state_machines/state_machine_test_util.h",
"state_machines/state_machine_util_test.cc", "state_machines/state_machine_util_test.cc",
"suggestion/text_suggestion_controller_test.cc", "suggestion/text_suggestion_controller_test.cc",
"surrounding_text_test.cc",
"testing/editing_test_base.cc", "testing/editing_test_base.cc",
"testing/editing_test_base.h", "testing/editing_test_base.h",
"testing/editing_test_base_test.cc", "testing/editing_test_base_test.cc",
......
...@@ -73,6 +73,7 @@ blink_core_sources("exported") { ...@@ -73,6 +73,7 @@ blink_core_sources("exported") {
"web_settings_impl.h", "web_settings_impl.h",
"web_shared_worker_impl.cc", "web_shared_worker_impl.cc",
"web_shared_worker_impl.h", "web_shared_worker_impl.h",
"web_surrounding_text.cc",
"web_text_checking_result.cc", "web_text_checking_result.cc",
"web_user_gesture_indicator.cc", "web_user_gesture_indicator.cc",
"web_user_gesture_token.cc", "web_user_gesture_token.cc",
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* DAMAGE. * DAMAGE.
*/ */
#include "third_party/blink/renderer/core/editing/surrounding_text.h" #include "third_party/blink/public/web/web_surrounding_text.h"
#include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h" #include "third_party/blink/renderer/core/editing/editing_utilities.h"
...@@ -33,28 +33,32 @@ ...@@ -33,28 +33,32 @@
#include "third_party/blink/renderer/core/editing/iterators/character_iterator.h" #include "third_party/blink/renderer/core/editing/iterators/character_iterator.h"
#include "third_party/blink/renderer/core/editing/visible_selection.h" #include "third_party/blink/renderer/core/editing/visible_selection.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/core/html/forms/html_form_control_element.h" #include "third_party/blink/renderer/core/html/forms/html_form_control_element.h"
namespace blink { namespace blink {
namespace { namespace {
EphemeralRange ComputeRangeFromFrameSelection(LocalFrame* frame) { EphemeralRange ComputeRangeFromFrameSelection(WebLocalFrame* frame) {
LocalFrame* web_frame = To<WebLocalFrameImpl>(frame)->GetFrame();
// TODO(editing-dev): The use of UpdateStyleAndLayout // TODO(editing-dev): The use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
frame->GetDocument()->UpdateStyleAndLayout(); web_frame->GetDocument()->UpdateStyleAndLayout();
return frame->Selection() return web_frame->Selection()
.ComputeVisibleSelectionInDOMTree() .ComputeVisibleSelectionInDOMTree()
.ToNormalizedEphemeralRange(); .ToNormalizedEphemeralRange();
} }
} // namespace } // namespace
SurroundingText::SurroundingText(LocalFrame* frame, size_t max_length) WebSurroundingText::WebSurroundingText(WebLocalFrame* frame, size_t max_length)
: SurroundingText(ComputeRangeFromFrameSelection(frame), max_length) {} : WebSurroundingText(ComputeRangeFromFrameSelection(frame), max_length) {}
SurroundingText::SurroundingText(const EphemeralRange& range, size_t max_length) WebSurroundingText::WebSurroundingText(const EphemeralRange& range,
size_t max_length)
: start_offset_in_text_content_(0), end_offset_in_text_content_(0) { : start_offset_in_text_content_(0), end_offset_in_text_content_(0) {
const Position start_position = range.StartPosition(); const Position start_position = range.StartPosition();
const Position end_position = range.EndPosition(); const Position end_position = range.EndPosition();
...@@ -122,19 +126,19 @@ SurroundingText::SurroundingText(const EphemeralRange& range, size_t max_length) ...@@ -122,19 +126,19 @@ SurroundingText::SurroundingText(const EphemeralRange& range, size_t max_length)
TextIteratorBehavior::EmitsObjectReplacementCharacterBehavior()); TextIteratorBehavior::EmitsObjectReplacementCharacterBehavior());
} }
String SurroundingText::TextContent() const { WebString WebSurroundingText::TextContent() const {
return text_content_; return text_content_;
} }
size_t SurroundingText::StartOffsetInTextContent() const { size_t WebSurroundingText::StartOffsetInTextContent() const {
return start_offset_in_text_content_; return start_offset_in_text_content_;
} }
size_t SurroundingText::EndOffsetInTextContent() const { size_t WebSurroundingText::EndOffsetInTextContent() const {
return end_offset_in_text_content_; return end_offset_in_text_content_;
} }
bool SurroundingText::IsEmpty() const { bool WebSurroundingText::IsEmpty() const {
return text_content_.IsEmpty(); return text_content_.IsEmpty();
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <utility> #include <utility>
#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/public/web/web_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/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"
...@@ -35,7 +35,7 @@ void SurroundingTextImpl::BindToReceiver( ...@@ -35,7 +35,7 @@ void SurroundingTextImpl::BindToReceiver(
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::WebSurroundingText surrounding_text(frame_, 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
......
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