Commit 02a96bb5 authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Remove WebFindOptions & StopFindingForTesting

This CL removes WebFindOptions in favor of FindOptions defined
in find_in_page.mojom. This also removes WebLocalFrame::Find and
WebLocalFrame::StopFindingForTesting, combining both into just
one function WebLocalFrame::FindForTesting.

Bug: 819919
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: Ie904a02b3e197f1012c6d5b4c9f50fdb6ce8d14f
Reviewed-on: https://chromium-review.googlesource.com/1184808
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594614}
parent cce901d2
...@@ -67,8 +67,6 @@ include_rules = [ ...@@ -67,8 +67,6 @@ include_rules = [
# QuotaStatusCode required by AwQuotaManagerBridge. # QuotaStatusCode required by AwQuotaManagerBridge.
"+third_party/blink/public/mojom/quota", "+third_party/blink/public/mojom/quota",
# POD structure required by the find-in-page IPC messages.
"+third_party/blink/public/web/web_find_options.h",
# Interface required for in-process input event handling. # Interface required for in-process input event handling.
"+third_party/blink/public/web/WebCompositorInputHandler.h", "+third_party/blink/public/web/WebCompositorInputHandler.h",
# For find-in-page # For find-in-page
......
...@@ -165,7 +165,6 @@ include_rules = [ ...@@ -165,7 +165,6 @@ include_rules = [
"+third_party/blink/public/platform/modules/screen_orientation/web_screen_orientation_lock_type.h", "+third_party/blink/public/platform/modules/screen_orientation/web_screen_orientation_lock_type.h",
"+third_party/blink/public/public_buildflags.h", "+third_party/blink/public/public_buildflags.h",
"+third_party/blink/public/web/web_context_menu_data.h", "+third_party/blink/public/web/web_context_menu_data.h",
"+third_party/blink/public/web/web_find_options.h",
"+third_party/blink/public/web/web_fullscreen_options.h", "+third_party/blink/public/web/web_fullscreen_options.h",
"+third_party/blink/public/web/web_media_player_action.h", "+third_party/blink/public/web/web_media_player_action.h",
"+third_party/blink/public/web/web_plugin_action.h", "+third_party/blink/public/web/web_plugin_action.h",
......
...@@ -114,7 +114,6 @@ include_rules = [ ...@@ -114,7 +114,6 @@ include_rules = [
"+third_party/blink/public/web/web_context_menu_data.h", "+third_party/blink/public/web/web_context_menu_data.h",
"+third_party/blink/public/web/web_device_emulation_params.h", "+third_party/blink/public/web/web_device_emulation_params.h",
"+third_party/blink/public/web/web_drag_status.h", "+third_party/blink/public/web/web_drag_status.h",
"+third_party/blink/public/web/web_find_options.h",
"+third_party/blink/public/web/web_fullscreen_options.h", "+third_party/blink/public/web/web_fullscreen_options.h",
"+third_party/blink/public/web/web_frame_serializer_cache_control_policy.h", "+third_party/blink/public/web/web_frame_serializer_cache_control_policy.h",
"+third_party/blink/public/web/web_ime_text_span.h", "+third_party/blink/public/web/web_ime_text_span.h",
......
...@@ -67,7 +67,6 @@ include_rules = [ ...@@ -67,7 +67,6 @@ include_rules = [
"+third_party/blink/public/web/web_ax_enums.h", "+third_party/blink/public/web/web_ax_enums.h",
"+third_party/blink/public/web/web_device_emulation_params.h", "+third_party/blink/public/web/web_device_emulation_params.h",
"+third_party/blink/public/web/web_drag_status.h", "+third_party/blink/public/web/web_drag_status.h",
"+third_party/blink/public/web/web_find_options.h",
"+third_party/blink/public/web/web_frame_owner_properties.h", "+third_party/blink/public/web/web_frame_owner_properties.h",
"+third_party/blink/public/web/web_frame_serializer_cache_control_policy.h", "+third_party/blink/public/web/web_frame_serializer_cache_control_policy.h",
"+third_party/blink/public/web/web_fullscreen_options.h", "+third_party/blink/public/web/web_fullscreen_options.h",
......
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
#include "third_party/blink/public/platform/web_scroll_into_view_params.h" #include "third_party/blink/public/platform/web_scroll_into_view_params.h"
#include "third_party/blink/public/platform/web_scroll_types.h" #include "third_party/blink/public/platform/web_scroll_types.h"
#include "third_party/blink/public/platform/web_sudden_termination_disabler_type.h" #include "third_party/blink/public/platform/web_sudden_termination_disabler_type.h"
#include "third_party/blink/public/web/web_find_options.h"
#include "third_party/blink/public/web/web_frame_owner_properties.h" #include "third_party/blink/public/web/web_frame_owner_properties.h"
#include "third_party/blink/public/web/web_frame_serializer_cache_control_policy.h" #include "third_party/blink/public/web/web_frame_serializer_cache_control_policy.h"
#include "third_party/blink/public/web/web_fullscreen_options.h" #include "third_party/blink/public/web/web_fullscreen_options.h"
......
...@@ -476,9 +476,9 @@ TEST_F(RenderFrameImplTest, ZoomLimit) { ...@@ -476,9 +476,9 @@ TEST_F(RenderFrameImplTest, ZoomLimit) {
// text finding, and then delete the frame immediately before the text finding // text finding, and then delete the frame immediately before the text finding
// returns any text match. // returns any text match.
TEST_F(RenderFrameImplTest, NoCrashWhenDeletingFrameDuringFind) { TEST_F(RenderFrameImplTest, NoCrashWhenDeletingFrameDuringFind) {
blink::WebFindOptions options; frame()->GetWebFrame()->FindForTesting(
options.force = true; 1, "foo", true /* match_case */, true /* forward */,
frame()->GetWebFrame()->Find(1, "foo", options, false); false /* find_next */, true /* force */, false /* wrap_within_frame */);
FrameMsg_Delete delete_message(0); FrameMsg_Delete delete_message(0);
frame()->OnMessageReceived(delete_message); frame()->OnMessageReceived(delete_message);
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "third_party/blink/public/web/web_array_buffer_converter.h" #include "third_party/blink/public/web/web_array_buffer_converter.h"
#include "third_party/blink/public/web/web_document.h" #include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_document_loader.h" #include "third_party/blink/public/web/web_document_loader.h"
#include "third_party/blink/public/web/web_find_options.h"
#include "third_party/blink/public/web/web_frame.h" #include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_input_element.h" #include "third_party/blink/public/web/web_input_element.h"
#include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_local_frame.h"
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "third_party/blink/public/web/web_array_buffer.h" #include "third_party/blink/public/web/web_array_buffer.h"
#include "third_party/blink/public/web/web_array_buffer_converter.h" #include "third_party/blink/public/web/web_array_buffer_converter.h"
#include "third_party/blink/public/web/web_document.h" #include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_find_options.h"
#include "third_party/blink/public/web/web_frame.h" #include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_frame_widget.h" #include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_input_element.h" #include "third_party/blink/public/web/web_input_element.h"
...@@ -613,28 +612,25 @@ void TestRunner::InsertStyleSheet(const std::string& source_code) { ...@@ -613,28 +612,25 @@ void TestRunner::InsertStyleSheet(const std::string& source_code) {
bool TestRunnerForSpecificView::FindString( bool TestRunnerForSpecificView::FindString(
const std::string& search_text, const std::string& search_text,
const std::vector<std::string>& options_array) { const std::vector<std::string>& options_array) {
blink::WebFindOptions find_options; bool match_case = true;
bool forward = true;
bool find_next = true;
bool wrap_around = false; bool wrap_around = false;
find_options.match_case = true;
find_options.find_next = true;
for (const std::string& option : options_array) { for (const std::string& option : options_array) {
if (option == "CaseInsensitive") if (option == "CaseInsensitive")
find_options.match_case = false; match_case = false;
else if (option == "Backwards") else if (option == "Backwards")
find_options.forward = false; forward = false;
else if (option == "StartInSelection") else if (option == "StartInSelection")
find_options.find_next = false; find_next = false;
else if (option == "WrapAround") else if (option == "WrapAround")
wrap_around = true; wrap_around = true;
} }
blink::WebLocalFrame* frame = GetLocalMainFrame(); blink::WebLocalFrame* frame = GetLocalMainFrame();
const bool find_result = const bool find_result = frame->FindForTesting(
frame->Find(0, blink::WebString::FromUTF8(search_text), find_options, 0, blink::WebString::FromUTF8(search_text), match_case, forward,
wrap_around, nullptr); find_next, false /* force */, wrap_around);
frame->StopFindingForTesting(
blink::mojom::StopFindAction::kStopFindActionKeepSelection);
return find_result; return find_result;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/user_script.h" #include "extensions/common/user_script.h"
#include "third_party/blink/public/web/web_find_options.h"
using content::WebContents; using content::WebContents;
using extensions::ExtensionResource; using extensions::ExtensionResource;
......
...@@ -437,7 +437,6 @@ source_set("blink_headers") { ...@@ -437,7 +437,6 @@ source_set("blink_headers") {
"web/web_external_popup_menu_client.h", "web/web_external_popup_menu_client.h",
"web/web_file_chooser_completion.h", "web/web_file_chooser_completion.h",
"web/web_file_chooser_params.h", "web/web_file_chooser_params.h",
"web/web_find_options.h",
"web/web_form_control_element.h", "web/web_form_control_element.h",
"web/web_form_element.h", "web/web_form_element.h",
"web/web_frame.h", "web/web_frame.h",
......
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_FIND_OPTIONS_H_
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_FIND_OPTIONS_H_
#include "third_party/blink/public/platform/web_string.h"
namespace blink {
// Options used when performing a find-in-page query.
struct WebFindOptions {
// Whether to search forward or backward within the page.
bool forward;
// Whether search should be case-sensitive.
bool match_case;
// Whether this operation is the first request or a follow-up.
bool find_next;
// Force a re-search of the frame: typically used when forcing a re-search
// after the frame navigates.
bool force;
// Signifies whether we should force text scoping to happen immediately
// or not. Only used for testing purposes.
bool run_synchronously_for_testing;
WebFindOptions()
: forward(true),
match_case(false),
find_next(false),
force(false),
run_synchronously_for_testing(false) {}
};
} // namespace blink
#endif
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "third_party/blink/public/common/feature_policy/feature_policy.h" #include "third_party/blink/public/common/feature_policy/feature_policy.h"
#include "third_party/blink/public/common/frame/sandbox_flags.h" #include "third_party/blink/public/common/frame/sandbox_flags.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom-shared.h"
#include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h" #include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_focus_type.h" #include "third_party/blink/public/platform/web_focus_type.h"
...@@ -59,7 +58,6 @@ struct WebAssociatedURLLoaderOptions; ...@@ -59,7 +58,6 @@ struct WebAssociatedURLLoaderOptions;
struct WebConsoleMessage; struct WebConsoleMessage;
struct WebContentSecurityPolicyViolation; struct WebContentSecurityPolicyViolation;
struct WebNavigationParams; struct WebNavigationParams;
struct WebFindOptions;
struct WebMediaPlayerAction; struct WebMediaPlayerAction;
struct WebPrintParams; struct WebPrintParams;
struct WebPrintPresetOptions; struct WebPrintPresetOptions;
...@@ -683,7 +681,7 @@ class WebLocalFrame : public WebFrame { ...@@ -683,7 +681,7 @@ class WebLocalFrame : public WebFrame {
// Find-in-page ----------------------------------------------------------- // Find-in-page -----------------------------------------------------------
// Searches a frame for a given string. // Searches a frame for a given string. Only used for testing.
// //
// If a match is found, this function will select it (scrolling down to // If a match is found, this function will select it (scrolling down to
// make it visible if needed) and fill in selectionRect with the // make it visible if needed) and fill in selectionRect with the
...@@ -693,19 +691,13 @@ class WebLocalFrame : public WebFrame { ...@@ -693,19 +691,13 @@ class WebLocalFrame : public WebFrame {
// highlighting. // highlighting.
// //
// Returns true if the search string was found, false otherwise. // Returns true if the search string was found, false otherwise.
virtual bool Find(int identifier, virtual bool FindForTesting(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&, bool match_case,
bool wrap_within_frame, bool forward,
bool* active_now = nullptr) = 0; bool find_next,
bool force,
// Notifies the frame that we are no longer interested in searching. This bool wrap_within_frame) = 0;
// will abort any asynchronous scoping effort already under way (see the
// function TextFinder::scopeStringMatches for details) and erase all
// tick-marks and highlighting from the previous search. It will also
// follow the specified StopFindAction.
// TODO(rakina): Stop exposing this when possible.
virtual void StopFindingForTesting(mojom::StopFindAction) = 0;
// Set the tickmarks for the frame. This will override the default tickmarks // Set the tickmarks for the frame. This will override the default tickmarks
// generated by find results. If this is called with an empty array, the // generated by find results. If this is called with an empty array, the
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "third_party/blink/public/platform/web_float_rect.h" #include "third_party/blink/public/platform/web_float_rect.h"
#include "third_party/blink/public/platform/web_scroll_into_view_params.h" #include "third_party/blink/public/platform/web_scroll_into_view_params.h"
#include "third_party/blink/public/platform/web_vector.h" #include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_find_options.h"
#include "third_party/blink/public/web/web_local_frame_client.h" #include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_view_client.h" #include "third_party/blink/public/web/web_view_client.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache_base.h" #include "third_party/blink/renderer/core/accessibility/ax_object_cache_base.h"
...@@ -81,10 +80,11 @@ void TextFinder::FindMatch::Trace(blink::Visitor* visitor) { ...@@ -81,10 +80,11 @@ void TextFinder::FindMatch::Trace(blink::Visitor* visitor) {
class TextFinder::IdleScopeStringMatchesCallback class TextFinder::IdleScopeStringMatchesCallback
: public ScriptedIdleTaskController::IdleTask { : public ScriptedIdleTaskController::IdleTask {
public: public:
static IdleScopeStringMatchesCallback* Create(TextFinder* text_finder, static IdleScopeStringMatchesCallback* Create(
int identifier, TextFinder* text_finder,
const WebString& search_text, int identifier,
const WebFindOptions& options) { const WebString& search_text,
const mojom::blink::FindOptions& options) {
return new IdleScopeStringMatchesCallback(text_finder, identifier, return new IdleScopeStringMatchesCallback(text_finder, identifier,
search_text, options); search_text, options);
} }
...@@ -108,11 +108,11 @@ class TextFinder::IdleScopeStringMatchesCallback ...@@ -108,11 +108,11 @@ class TextFinder::IdleScopeStringMatchesCallback
IdleScopeStringMatchesCallback(TextFinder* text_finder, IdleScopeStringMatchesCallback(TextFinder* text_finder,
int identifier, int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions& options) const mojom::blink::FindOptions& options)
: text_finder_(text_finder), : text_finder_(text_finder),
identifier_(identifier), identifier_(identifier),
search_text_(search_text), search_text_(search_text),
options_(options) { options_(options.Clone()) {
callback_handle_ = callback_handle_ =
text_finder->GetFrame()->GetDocument()->RequestIdleCallback( text_finder->GetFrame()->GetDocument()->RequestIdleCallback(
this, IdleRequestOptions()); this, IdleRequestOptions());
...@@ -120,14 +120,14 @@ class TextFinder::IdleScopeStringMatchesCallback ...@@ -120,14 +120,14 @@ class TextFinder::IdleScopeStringMatchesCallback
void invoke(IdleDeadline* deadline) override { void invoke(IdleDeadline* deadline) override {
text_finder_->ResumeScopingStringMatches(deadline, identifier_, text_finder_->ResumeScopingStringMatches(deadline, identifier_,
search_text_, options_); search_text_, *options_);
} }
Member<TextFinder> text_finder_; Member<TextFinder> text_finder_;
int callback_handle_ = 0; int callback_handle_ = 0;
const int identifier_; const int identifier_;
const WebString search_text_; const WebString search_text_;
const WebFindOptions options_; mojom::blink::FindOptionsPtr options_;
}; };
static void ScrollToVisible(Range* match) { static void ScrollToVisible(Range* match) {
...@@ -150,7 +150,7 @@ static void ScrollToVisible(Range* match) { ...@@ -150,7 +150,7 @@ static void ScrollToVisible(Range* match) {
bool TextFinder::Find(int identifier, bool TextFinder::Find(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions& options, const mojom::blink::FindOptions& options,
bool wrap_within_frame, bool wrap_within_frame,
bool* active_now) { bool* active_now) {
if (!options.find_next) if (!options.find_next)
...@@ -388,9 +388,10 @@ void TextFinder::ReportFindInPageResultToAccessibility(int identifier) { ...@@ -388,9 +388,10 @@ void TextFinder::ReportFindInPageResultToAccessibility(int identifier) {
} }
} }
void TextFinder::StartScopingStringMatches(int identifier, void TextFinder::StartScopingStringMatches(
const WebString& search_text, int identifier,
const WebFindOptions& options) { const WebString& search_text,
const mojom::blink::FindOptions& options) {
CancelPendingScopingEffort(); CancelPendingScopingEffort();
// This is a brand new search, so we need to reset everything. // This is a brand new search, so we need to reset everything.
...@@ -426,7 +427,7 @@ void TextFinder::StartScopingStringMatches(int identifier, ...@@ -426,7 +427,7 @@ void TextFinder::StartScopingStringMatches(int identifier,
void TextFinder::ScopeStringMatches(IdleDeadline* deadline, void TextFinder::ScopeStringMatches(IdleDeadline* deadline,
int identifier, int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions& options) { const mojom::blink::FindOptions& options) {
if (!ShouldScopeMatches(search_text, options)) { if (!ShouldScopeMatches(search_text, options)) {
FinishCurrentScopingEffort(identifier); FinishCurrentScopingEffort(identifier);
return; return;
...@@ -847,7 +848,7 @@ void TextFinder::UnmarkAllTextMatches() { ...@@ -847,7 +848,7 @@ void TextFinder::UnmarkAllTextMatches() {
} }
bool TextFinder::ShouldScopeMatches(const String& search_text, bool TextFinder::ShouldScopeMatches(const String& search_text,
const WebFindOptions& options) { const mojom::blink::FindOptions& options) {
// Don't scope if we can't find a frame or a view. // Don't scope if we can't find a frame or a view.
// The user may have closed the tab/application, so abort. // The user may have closed the tab/application, so abort.
LocalFrame* frame = OwnerFrame().GetFrame(); LocalFrame* frame = OwnerFrame().GetFrame();
...@@ -879,9 +880,10 @@ bool TextFinder::ShouldScopeMatches(const String& search_text, ...@@ -879,9 +880,10 @@ bool TextFinder::ShouldScopeMatches(const String& search_text,
return true; return true;
} }
void TextFinder::ScopeStringMatchesSoon(int identifier, void TextFinder::ScopeStringMatchesSoon(
const WebString& search_text, int identifier,
const WebFindOptions& options) { const WebString& search_text,
const mojom::blink::FindOptions& options) {
DCHECK_EQ(idle_scoping_callback_, nullptr); DCHECK_EQ(idle_scoping_callback_, nullptr);
// If it's for testing, run the scoping immediately. // If it's for testing, run the scoping immediately.
// TODO(rakina): Change to use general solution when it's available. // TODO(rakina): Change to use general solution when it's available.
...@@ -897,10 +899,11 @@ void TextFinder::ScopeStringMatchesSoon(int identifier, ...@@ -897,10 +899,11 @@ void TextFinder::ScopeStringMatchesSoon(int identifier,
} }
} }
void TextFinder::ResumeScopingStringMatches(IdleDeadline* deadline, void TextFinder::ResumeScopingStringMatches(
int identifier, IdleDeadline* deadline,
const WebString& search_text, int identifier,
const WebFindOptions& options) { const WebString& search_text,
const mojom::blink::FindOptions& options) {
idle_scoping_callback_.Clear(); idle_scoping_callback_.Clear();
ScopeStringMatches(deadline, identifier, search_text, options); ScopeStringMatches(deadline, identifier, search_text, options);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_FINDER_TEXT_FINDER_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_FINDER_TEXT_FINDER_H_
#include "base/macros.h" #include "base/macros.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom-blink.h"
#include "third_party/blink/public/platform/web_float_point.h" #include "third_party/blink/public/platform/web_float_point.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/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h"
...@@ -46,7 +47,6 @@ class LocalFrame; ...@@ -46,7 +47,6 @@ class LocalFrame;
class Range; class Range;
class WebLocalFrameImpl; class WebLocalFrameImpl;
class WebString; class WebString;
struct WebFindOptions;
struct WebFloatPoint; struct WebFloatPoint;
struct WebFloatRect; struct WebFloatRect;
struct WebRect; struct WebRect;
...@@ -58,7 +58,7 @@ class CORE_EXPORT TextFinder final ...@@ -58,7 +58,7 @@ class CORE_EXPORT TextFinder final
bool Find(int identifier, bool Find(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&, const mojom::blink::FindOptions& options,
bool wrap_within_frame, bool wrap_within_frame,
bool* active_now = nullptr); bool* active_now = nullptr);
void ClearActiveFindMatch(); void ClearActiveFindMatch();
...@@ -74,7 +74,7 @@ class CORE_EXPORT TextFinder final ...@@ -74,7 +74,7 @@ class CORE_EXPORT TextFinder final
// asyncronously calls scopeStringMatches(). // asyncronously calls scopeStringMatches().
void StartScopingStringMatches(int identifier, void StartScopingStringMatches(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&); const mojom::blink::FindOptions& options);
// Cancels any outstanding requests for scoping string matches on the frame. // Cancels any outstanding requests for scoping string matches on the frame.
void CancelPendingScopingEffort(); void CancelPendingScopingEffort();
...@@ -166,7 +166,7 @@ class CORE_EXPORT TextFinder final ...@@ -166,7 +166,7 @@ class CORE_EXPORT TextFinder final
// is a repeat search that already returned nothing last time the same prefix // is a repeat search that already returned nothing last time the same prefix
// was searched. // was searched.
bool ShouldScopeMatches(const WTF::String& search_text, bool ShouldScopeMatches(const WTF::String& search_text,
const WebFindOptions&); const mojom::blink::FindOptions&);
// Removes the current frame from the global scoping effort and triggers any // Removes the current frame from the global scoping effort and triggers any
// updates if appropriate. This method does not mark the scoping operation // updates if appropriate. This method does not mark the scoping operation
...@@ -189,18 +189,18 @@ class CORE_EXPORT TextFinder final ...@@ -189,18 +189,18 @@ class CORE_EXPORT TextFinder final
void ScopeStringMatches(IdleDeadline* deadline, void ScopeStringMatches(IdleDeadline* deadline,
int identifier, int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&); const mojom::blink::FindOptions&);
// Queue up a deferred call to scopeStringMatches. // Queue up a deferred call to scopeStringMatches.
void ScopeStringMatchesSoon(int identifier, void ScopeStringMatchesSoon(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&); const mojom::blink::FindOptions&);
// Called by an IdleScopeStringMatchesCallback instance. // Called by an IdleScopeStringMatchesCallback instance.
void ResumeScopingStringMatches(IdleDeadline* deadline, void ResumeScopingStringMatches(IdleDeadline* deadline,
int identifier, int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&); const mojom::blink::FindOptions&);
// Determines whether to invalidate the content area and scrollbar. // Determines whether to invalidate the content area and scrollbar.
void InvalidateIfNecessary(); void InvalidateIfNecessary();
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "third_party/blink/renderer/core/frame/find_in_page.h" #include "third_party/blink/renderer/core/frame/find_in_page.h"
#include "third_party/blink/public/web/web_document.h" #include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_find_options.h"
#include "third_party/blink/public/web/web_local_frame_client.h" #include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_plugin.h" #include "third_party/blink/public/web/web_plugin.h"
#include "third_party/blink/public/web/web_plugin_document.h" #include "third_party/blink/public/web/web_plugin_document.h"
...@@ -89,18 +88,10 @@ void FindInPage::Find(int request_id, ...@@ -89,18 +88,10 @@ void FindInPage::Find(int request_id,
bool result = false; bool result = false;
bool active_now = false; bool active_now = false;
WebFindOptions web_options;
web_options.forward = options->forward;
web_options.match_case = options->match_case;
web_options.find_next = options->find_next;
web_options.force = options->force;
web_options.run_synchronously_for_testing =
options->run_synchronously_for_testing;
// Search for an active match only if this frame is focused or if this is a // Search for an active match only if this frame is focused or if this is a
// find next request. // find next
if (frame_->IsFocused() || options->find_next) { if (frame_->IsFocused() || options->find_next) {
result = FindInternal(request_id, search_text, web_options, result = FindInternal(request_id, search_text, *options,
false /* wrap_within_frame */, &active_now); false /* wrap_within_frame */, &active_now);
} }
...@@ -136,24 +127,35 @@ void FindInPage::Find(int request_id, ...@@ -136,24 +127,35 @@ void FindInPage::Find(int request_id,
return; return;
} }
// Start a new scoping request. If the scoping function determines that it // Start a new scoping If the scoping function determines that it
// needs to scope, it will defer until later. // needs to scope, it will defer until later.
EnsureTextFinder().StartScopingStringMatches(request_id, search_text, EnsureTextFinder().StartScopingStringMatches(request_id, search_text,
web_options); *options);
} }
bool WebLocalFrameImpl::Find(int identifier, bool WebLocalFrameImpl::FindForTesting(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions& options, bool match_case,
bool wrap_within_frame, bool forward,
bool* active_now) { bool find_next,
return find_in_page_->FindInternal(identifier, search_text, options, bool force,
wrap_within_frame, active_now); bool wrap_within_frame) {
auto options = mojom::blink::FindOptions::New();
options->match_case = match_case;
options->forward = forward;
options->find_next = find_next;
options->force = force;
options->run_synchronously_for_testing = true;
bool result = find_in_page_->FindInternal(identifier, search_text, *options,
wrap_within_frame, nullptr);
find_in_page_->StopFinding(
mojom::blink::StopFindAction::kStopFindActionKeepSelection);
return result;
} }
bool FindInPage::FindInternal(int identifier, bool FindInPage::FindInternal(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions& options, const mojom::blink::FindOptions& options,
bool wrap_within_frame, bool wrap_within_frame,
bool* active_now) { bool* active_now) {
if (!frame_->GetFrame()) if (!frame_->GetFrame())
...@@ -172,10 +174,6 @@ bool FindInPage::FindInternal(int identifier, ...@@ -172,10 +174,6 @@ bool FindInPage::FindInternal(int identifier,
wrap_within_frame, active_now); wrap_within_frame, active_now);
} }
void WebLocalFrameImpl::StopFindingForTesting(mojom::StopFindAction action) {
find_in_page_->StopFinding(action);
}
void FindInPage::StopFinding(mojom::StopFindAction action) { void FindInPage::StopFinding(mojom::StopFindAction action) {
WebPlugin* const plugin = GetWebPluginForFind(); WebPlugin* const plugin = GetWebPluginForFind();
if (plugin) { if (plugin) {
......
...@@ -21,7 +21,6 @@ namespace blink { ...@@ -21,7 +21,6 @@ namespace blink {
class WebLocalFrameImpl; class WebLocalFrameImpl;
class WebString; class WebString;
struct WebFindOptions;
struct WebFloatRect; struct WebFloatRect;
class CORE_EXPORT FindInPage final class CORE_EXPORT FindInPage final
...@@ -36,7 +35,7 @@ class CORE_EXPORT FindInPage final ...@@ -36,7 +35,7 @@ class CORE_EXPORT FindInPage final
bool FindInternal(int identifier, bool FindInternal(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&, const mojom::blink::FindOptions&,
bool wrap_within_frame, bool wrap_within_frame,
bool* active_now = nullptr); bool* active_now = nullptr);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom-blink.h" #include "third_party/blink/public/mojom/frame/find_in_page.mojom-blink.h"
#include "third_party/blink/public/web/web_find_options.h"
#include "third_party/blink/renderer/core/editing/finder/text_finder.h" #include "third_party/blink/renderer/core/editing/finder/text_finder.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h" #include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h"
...@@ -81,12 +80,13 @@ TEST_F(FindInPageTest, FindMatchRectsReturnsCorrectRects) { ...@@ -81,12 +80,13 @@ TEST_F(FindInPageTest, FindMatchRectsReturnsCorrectRects) {
int identifier = 0; int identifier = 0;
WebString search_text(String("aA")); WebString search_text(String("aA"));
WebFindOptions find_options; // Default + add testing flag. auto find_options =
find_options.run_synchronously_for_testing = true; mojom::blink::FindOptions::New(); // Default + add testing flag.
find_options->run_synchronously_for_testing = true;
GetTextFinder().ResetMatchCount(); GetTextFinder().ResetMatchCount();
GetTextFinder().StartScopingStringMatches(identifier, search_text, GetTextFinder().StartScopingStringMatches(identifier, search_text,
find_options); *find_options);
int rects_version = GetTextFinder().FindMatchMarkersVersion(); int rects_version = GetTextFinder().FindMatchMarkersVersion();
FindInPageCallbackReceiver callback_receiver; FindInPageCallbackReceiver callback_receiver;
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <set> #include <set>
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "third_party/blink/public/mojom/frame/find_in_page.mojom-blink.h"
#include "third_party/blink/public/platform/web_file_system_type.h" #include "third_party/blink/public/platform/web_file_system_type.h"
#include "third_party/blink/public/web/devtools_agent.mojom-blink.h" #include "third_party/blink/public/web/devtools_agent.mojom-blink.h"
#include "third_party/blink/public/web/web_history_commit_type.h" #include "third_party/blink/public/web/web_history_commit_type.h"
...@@ -320,12 +322,13 @@ class CORE_EXPORT WebLocalFrameImpl final ...@@ -320,12 +322,13 @@ class CORE_EXPORT WebLocalFrameImpl final
void DidCallAddSearchProvider() override; void DidCallAddSearchProvider() override;
void DidCallIsSearchProviderInstalled() override; void DidCallIsSearchProviderInstalled() override;
void ReplaceSelection(const WebString&) override; void ReplaceSelection(const WebString&) override;
bool Find(int identifier, bool FindForTesting(int identifier,
const WebString& search_text, const WebString& search_text,
const WebFindOptions&, bool match_case,
bool wrap_within_frame, bool forward,
bool* active_now = nullptr) override; bool force,
void StopFindingForTesting(mojom::StopFindAction) override; bool find_next,
bool wrap_within_frame) override;
void SetTickmarks(const WebVector<WebRect>&) override; void SetTickmarks(const WebVector<WebRect>&) override;
WebNode ContextMenuNode() const override; WebNode ContextMenuNode() const override;
WebFrameWidget* FrameWidget() const override; WebFrameWidget* FrameWidget() const override;
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/web/web_find_options.h" #include "third_party/blink/public/mojom/frame/find_in_page.mojom-blink.h"
#include "third_party/blink/public/web/web_script_source.h" #include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/renderer/bindings/core/v8/scroll_into_view_options_or_boolean.h" #include "third_party/blink/renderer/bindings/core/v8/scroll_into_view_options_or_boolean.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/frame/find_in_page.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/scroll_into_view_options.h" #include "third_party/blink/renderer/core/frame/scroll_into_view_options.h"
#include "third_party/blink/renderer/core/frame/scroll_to_options.h" #include "third_party/blink/renderer/core/frame/scroll_to_options.h"
...@@ -488,10 +489,10 @@ TEST_F(ScrollIntoViewTest, FindDoesNotScrollOverflowHidden) { ...@@ -488,10 +489,10 @@ TEST_F(ScrollIntoViewTest, FindDoesNotScrollOverflowHidden) {
Compositor().BeginFrame(); Compositor().BeginFrame();
ASSERT_EQ(container->scrollTop(), 0); ASSERT_EQ(container->scrollTop(), 0);
const int kFindIdentifier = 12345; const int kFindIdentifier = 12345;
WebFindOptions options; auto options = mojom::blink::FindOptions::New();
options.run_synchronously_for_testing = true; options->run_synchronously_for_testing = true;
MainFrame().Find(kFindIdentifier, WebString::FromUTF8("hello"), options, MainFrame().GetFindInPage()->FindInternal(
false); kFindIdentifier, WebString::FromUTF8("hello"), *options, false);
ASSERT_EQ(container->scrollTop(), 0); ASSERT_EQ(container->scrollTop(), 0);
} }
......
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