#include "third_party/blink/renderer/core/frame/find_in_page.h"
#include <utility>
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/public/web/web_document.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_document.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_document_state.h"
#include "third_party/blink/renderer/core/editing/finder/text_finder.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/page/page.h"
namespace blink {
FindInPage::FindInPage(WebLocalFrameImpl& frame,
InterfaceRegistry* interface_registry)
: … { … }
void FindInPage::Find(int request_id,
const String& search_text,
mojom::blink::FindOptionsPtr options) { … }
bool WebLocalFrameImpl::FindForTesting(int identifier,
const WebString& search_text,
bool match_case,
bool forward,
bool new_session,
bool force,
bool wrap_within_frame,
bool async) { … }
bool FindInPage::FindInternal(int identifier,
const WebString& search_text,
const mojom::blink::FindOptions& options,
bool wrap_within_frame,
bool* active_now) { … }
void FindInPage::StopFinding(mojom::StopFindAction action) { … }
int FindInPage::FindMatchMarkersVersion() const { … }
void FindInPage::SetClient(
mojo::PendingRemote<mojom::blink::FindInPageClient> remote) { … }
#if BUILDFLAG(IS_ANDROID)
gfx::RectF FindInPage::ActiveFindMatchRect() {
if (GetTextFinder())
return GetTextFinder()->ActiveFindMatchRect();
return gfx::RectF();
}
void FindInPage::ActivateNearestFindResult(int request_id,
const gfx::PointF& point) {
gfx::Rect active_match_rect;
const int ordinal =
EnsureTextFinder().SelectNearestFindMatch(point, &active_match_rect);
if (ordinal == -1) {
EnsureTextFinder().IncreaseMatchCount(request_id, 0);
return;
}
ReportFindInPageSelection(request_id, ordinal, active_match_rect,
true );
}
void FindInPage::GetNearestFindResult(const gfx::PointF& point,
GetNearestFindResultCallback callback) {
float distance;
EnsureTextFinder().NearestFindMatch(point, &distance);
std::move(callback).Run(distance);
}
void FindInPage::FindMatchRects(int current_version,
FindMatchRectsCallback callback) {
int rects_version = FindMatchMarkersVersion();
Vector<gfx::RectF> rects;
if (current_version != rects_version)
rects = EnsureTextFinder().FindMatchRects();
std::move(callback).Run(rects_version, rects, ActiveFindMatchRect());
}
#endif
void FindInPage::ClearActiveFindMatch() { … }
void WebLocalFrameImpl::SetTickmarks(const WebElement& target,
const WebVector<gfx::Rect>& tickmarks) { … }
void FindInPage::SetTickmarks(
const WebElement& target,
const WebVector<gfx::Rect>& tickmarks_in_layout_space) { … }
TextFinder* WebLocalFrameImpl::GetTextFinder() const { … }
TextFinder* FindInPage::GetTextFinder() const { … }
TextFinder& WebLocalFrameImpl::EnsureTextFinder() { … }
TextFinder& FindInPage::EnsureTextFinder() { … }
void FindInPage::SetPluginFindHandler(WebPluginContainer* plugin) { … }
WebPluginContainer* FindInPage::PluginFindHandler() const { … }
WebPlugin* FindInPage::GetWebPluginForFind() { … }
void FindInPage::BindToReceiver(
mojo::PendingAssociatedReceiver<mojom::blink::FindInPage> receiver) { … }
void FindInPage::Dispose() { … }
void FindInPage::ReportFindInPageMatchCount(int request_id,
int count,
bool final_update) { … }
void FindInPage::ReportFindInPageSelection(
int request_id,
int active_match_ordinal,
const gfx::Rect& local_selection_rect,
bool final_update) { … }
}