#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include <algorithm>
#include "base/debug/dump_without_crashing.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_traversal.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/markers/active_suggestion_marker.h"
#include "third_party/blink/renderer/core/editing/markers/active_suggestion_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/markers/composition_marker.h"
#include "third_party/blink/renderer/core/editing/markers/composition_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/markers/custom_highlight_marker.h"
#include "third_party/blink/renderer/core/editing/markers/custom_highlight_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/markers/grammar_marker.h"
#include "third_party/blink/renderer/core/editing/markers/grammar_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/markers/sorted_document_marker_list_editor.h"
#include "third_party/blink/renderer/core/editing/markers/spelling_marker.h"
#include "third_party/blink/renderer/core/editing/markers/spelling_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/markers/suggestion_marker.h"
#include "third_party/blink/renderer/core/editing/markers/suggestion_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/markers/text_fragment_marker.h"
#include "third_party/blink/renderer/core/editing/markers/text_fragment_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/markers/text_match_marker.h"
#include "third_party/blink/renderer/core/editing/markers/text_match_marker_list_impl.h"
#include "third_party/blink/renderer/core/editing/position.h"
#include "third_party/blink/renderer/core/editing/visible_position.h"
#include "third_party/blink/renderer/core/editing/visible_units.h"
#include "third_party/blink/renderer/core/highlight/highlight_style_utils.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_text_fragment.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h"
namespace blink {
namespace {
DocumentMarker::MarkerTypeIndex MarkerTypeToMarkerIndex(
DocumentMarker::MarkerType type) { … }
DocumentMarkerList* CreateListForType(DocumentMarker::MarkerType type) { … }
void InvalidateVisualOverflowForNode(const Node& node,
DocumentMarker::MarkerType type) { … }
void InvalidatePaintForNode(const Node& node) { … }
PositionInFlatTree SearchAroundPositionStart(
const PositionInFlatTree& position) { … }
PositionInFlatTree SearchAroundPositionEnd(const PositionInFlatTree& position) { … }
}
bool DocumentMarkerController::PossiblyHasMarkers(
DocumentMarker::MarkerType type) const { … }
inline bool DocumentMarkerController::PossiblyHasMarkers(
DocumentMarker::MarkerTypes types) const { … }
bool DocumentMarkerController::HasAnyMarkersForText(const Text& text) const { … }
DocumentMarkerController::DocumentMarkerController(Document& document)
: … { … }
void DocumentMarkerController::AddSpellingMarker(const EphemeralRange& range,
const String& description) { … }
void DocumentMarkerController::AddGrammarMarker(const EphemeralRange& range,
const String& description) { … }
void DocumentMarkerController::AddTextMatchMarker(
const EphemeralRange& range,
TextMatchMarker::MatchStatus match_status) { … }
void DocumentMarkerController::AddCompositionMarker(
const EphemeralRange& range,
Color underline_color,
ui::mojom::ImeTextSpanThickness thickness,
ui::mojom::ImeTextSpanUnderlineStyle underline_style,
Color text_color,
Color background_color) { … }
void DocumentMarkerController::AddActiveSuggestionMarker(
const EphemeralRange& range,
Color underline_color,
ui::mojom::ImeTextSpanThickness thickness,
ui::mojom::ImeTextSpanUnderlineStyle underline_style,
Color text_color,
Color background_color) { … }
void DocumentMarkerController::AddSuggestionMarker(
const EphemeralRange& range,
const SuggestionMarkerProperties& properties) { … }
void DocumentMarkerController::AddTextFragmentMarker(
const EphemeralRange& range) { … }
void DocumentMarkerController::AddCustomHighlightMarker(
const EphemeralRange& range,
const String& highlight_name,
const Member<Highlight> highlight) { … }
void DocumentMarkerController::PrepareForDestruction() { … }
void DocumentMarkerController::RemoveMarkers(
TextIterator& marked_text,
DocumentMarker::MarkerTypes marker_types) { … }
void DocumentMarkerController::RemoveMarkersInRange(
const EphemeralRange& range,
DocumentMarker::MarkerTypes marker_types) { … }
void DocumentMarkerController::AddMarkerInternal(
const EphemeralRange& range,
base::FunctionRef<DocumentMarker*(int, int)> create_marker_from_offsets,
const TextIteratorBehavior& iterator_behavior) { … }
void DocumentMarkerController::AddMarkerToNode(const Text& text,
DocumentMarker* new_marker) { … }
void DocumentMarkerController::MoveMarkers(const Text& src_node,
int length,
const Text& dst_node) { … }
void DocumentMarkerController::DidRemoveNodeFromMap(
DocumentMarker::MarkerType type,
bool clear_document_allowed) { … }
void DocumentMarkerController::RemoveMarkersInternal(
const Text& text,
unsigned start_offset,
int length,
DocumentMarker::MarkerType marker_type) { … }
DocumentMarkerList* DocumentMarkerController::FindMarkers(
const MarkerMap* marker_map,
const Text* key) const { … }
DocumentMarkerList* DocumentMarkerController::FindMarkersForType(
DocumentMarker::MarkerType type,
const Text* key) const { … }
DocumentMarker* DocumentMarkerController::FirstMarkerAroundPosition(
const PositionInFlatTree& position,
DocumentMarker::MarkerTypes types) { … }
DocumentMarker* DocumentMarkerController::FirstMarkerIntersectingEphemeralRange(
const EphemeralRange& range,
DocumentMarker::MarkerTypes types) { … }
DocumentMarker* DocumentMarkerController::FirstMarkerIntersectingOffsetRange(
const Text& node,
unsigned start_offset,
unsigned end_offset,
DocumentMarker::MarkerTypes types) { … }
DocumentMarkerGroup* DocumentMarkerController::FirstMarkerGroupAroundPosition(
const PositionInFlatTree& position,
DocumentMarker::MarkerTypes types) { … }
DocumentMarkerGroup*
DocumentMarkerController::FirstMarkerGroupIntersectingEphemeralRange(
const EphemeralRange& range,
DocumentMarker::MarkerTypes types) { … }
DocumentMarkerGroup* DocumentMarkerController::GetMarkerGroupForMarker(
const DocumentMarker* marker) { … }
HeapVector<std::pair<Member<const Text>, Member<DocumentMarker>>>
DocumentMarkerController::MarkersAroundPosition(
const PositionInFlatTree& position,
DocumentMarker::MarkerTypes types) { … }
HeapVector<std::pair<Member<const Text>, Member<DocumentMarker>>>
DocumentMarkerController::MarkersIntersectingRange(
const EphemeralRangeInFlatTree& range,
DocumentMarker::MarkerTypes types) { … }
DocumentMarkerVector DocumentMarkerController::MarkersFor(
const Text& text,
DocumentMarker::MarkerTypes marker_types) const { … }
DocumentMarkerVector DocumentMarkerController::MarkersFor(
const Text& text,
DocumentMarker::MarkerType marker_type,
unsigned start_offset,
unsigned end_offset) const { … }
DocumentMarkerVector DocumentMarkerController::Markers() const { … }
void DocumentMarkerController::ApplyToMarkersOfType(
base::FunctionRef<void(const Text&, DocumentMarker*)> func,
DocumentMarker::MarkerType type) { … }
void DocumentMarkerController::MergeOverlappingMarkers(
DocumentMarker::MarkerType type) { … }
DocumentMarkerVector DocumentMarkerController::ComputeMarkersToPaint(
const Text& text) const { … }
bool DocumentMarkerController::PossiblyHasTextMatchMarkers() const { … }
Vector<gfx::Rect> DocumentMarkerController::LayoutRectsForTextMatchMarkers() { … }
static void InvalidatePaintForTickmarks(const Node& node) { … }
void DocumentMarkerController::InvalidateRectsForTextMatchMarkersInNode(
const Text& node) { … }
void DocumentMarkerController::InvalidateRectsForAllTextMatchMarkers() { … }
void DocumentMarkerController::Trace(Visitor* visitor) const { … }
void DocumentMarkerController::RemoveMarkersForNode(
const Text& text,
DocumentMarker::MarkerTypes marker_types) { … }
void DocumentMarkerController::RemoveSpellingMarkersUnderWords(
const Vector<String>& words) { … }
void DocumentMarkerController::RemoveSuggestionMarkerInRangeOnFinish(
const EphemeralRangeInFlatTree& range) { … }
void DocumentMarkerController::RemoveSuggestionMarkerByType(
const EphemeralRangeInFlatTree& range,
const SuggestionMarker::SuggestionType& type) { … }
void DocumentMarkerController::RemoveSuggestionMarkerByType(
const SuggestionMarker::SuggestionType& type) { … }
void DocumentMarkerController::RemoveSuggestionMarkerByTag(const Text& text,
int32_t marker_tag) { … }
void DocumentMarkerController::RemoveMarkersOfTypes(
DocumentMarker::MarkerTypes marker_types) { … }
void DocumentMarkerController::RemoveMarkersFromList(
MarkerMap::iterator iterator,
DocumentMarker::MarkerType marker_type) { … }
void DocumentMarkerController::RepaintMarkers(
DocumentMarker::MarkerTypes marker_types) { … }
bool DocumentMarkerController::SetTextMatchMarkersActive(
const EphemeralRange& range,
bool active) { … }
bool DocumentMarkerController::SetTextMatchMarkersActive(const Text& text,
unsigned start_offset,
unsigned end_offset,
bool active) { … }
#if DCHECK_IS_ON()
void DocumentMarkerController::ShowMarkers() const { … }
#endif
void DocumentMarkerController::DidUpdateCharacterData(CharacterData* node,
unsigned offset,
unsigned old_length,
unsigned new_length) { … }
}
#if DCHECK_IS_ON()
void ShowDocumentMarkers(const blink::DocumentMarkerController* controller) { … }
#endif