#include "third_party/blink/renderer/core/fragment_directive/text_fragment_selector_generator.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/default_tick_clock.h"
#include "components/shared_highlighting/core/common/shared_highlighting_features.h"
#include "third_party/abseil-cpp/absl/base/macros.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/interface_registry.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/finder/find_buffer.h"
#include "third_party/blink/renderer/core/editing/iterators/character_iterator.h"
#include "third_party/blink/renderer/core/editing/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/range_in_flat_tree.h"
#include "third_party/blink/renderer/core/fragment_directive/text_fragment_anchor_metrics.h"
#include "third_party/blink/renderer/core/fragment_directive/text_fragment_finder.h"
#include "third_party/blink/renderer/core/fragment_directive/text_fragment_selector.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/platform/text/text_boundaries.h"
#include "third_party/blink/renderer/platform/wtf/text/unicode.h"
LinkGenerationError;
LinkGenerationStatus;
namespace blink {
namespace {
bool IsFirstVisiblePosition(Node* node, unsigned pos_offset) { … }
bool IsLastVisiblePosition(Node* node, unsigned pos_offset) { … }
struct ForwardDirection { … };
struct BackwardDirection { … };
template <class Direction>
Node* NextNonEmptyVisibleTextNode(Node* start_node) { … }
Node* FirstNonEmptyVisibleTextNode(Node* start_node) { … }
Node* BackwardNonEmptyVisibleTextNode(Node* start_node) { … }
Node* ResolvePositionToNode(const PositionInFlatTree& position) { … }
}
constexpr int kExactTextMaxChars = …;
constexpr int kNoContextMinChars = …;
constexpr int kMaxContextWords = …;
constexpr int kMaxRangeWords = …;
constexpr int kMaxIterationCountToRecord = …;
constexpr int kMinWordCount = …;
std::optional<int> g_exactTextMaxCharsOverride;
TextFragmentSelectorGenerator::TextFragmentSelectorGenerator(
LocalFrame* main_frame)
: … { … }
void TextFragmentSelectorGenerator::Generate(const RangeInFlatTree& range,
GenerateCallback callback) { … }
void TextFragmentSelectorGenerator::Reset() { … }
void TextFragmentSelectorGenerator::Trace(Visitor* visitor) const { … }
void TextFragmentSelectorGenerator::RecordSelectorStateUma() const { … }
String TextFragmentSelectorGenerator::GetSelectorTargetText() const { … }
void TextFragmentSelectorGenerator::DidFindMatch(const RangeInFlatTree& match,
bool is_unique) { … }
void TextFragmentSelectorGenerator::NoMatchFound() { … }
void TextFragmentSelectorGenerator::AdjustSelection() { … }
void TextFragmentSelectorGenerator::StartGeneration() { … }
void TextFragmentSelectorGenerator::GenerateSelectorCandidate() { … }
void TextFragmentSelectorGenerator::ResolveSelectorState() { … }
void TextFragmentSelectorGenerator::RunTextFinder() { … }
PositionInFlatTree TextFragmentSelectorGenerator::GetPreviousTextEndPosition(
const PositionInFlatTree& position) { … }
PositionInFlatTree TextFragmentSelectorGenerator::GetNextTextStartPosition(
const PositionInFlatTree& position) { … }
void TextFragmentSelectorGenerator::GenerateExactSelector() { … }
void TextFragmentSelectorGenerator::ExtendRangeSelector() { … }
void TextFragmentSelectorGenerator::ExtendContext() { … }
void TextFragmentSelectorGenerator::RecordAllMetrics(
const TextFragmentSelector& selector) { … }
void TextFragmentSelectorGenerator::OnSelectorReady(
const TextFragmentSelector& selector) { … }
void TextFragmentSelectorGenerator::OverrideExactTextMaxCharsForTesting(
int value) { … }
unsigned TextFragmentSelectorGenerator::GetExactTextMaxChars() { … }
}