#include "third_party/blink/renderer/core/editing/layout_selection.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/selection_template.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/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/html/html_wbr_element.h"
#include "third_party/blink/renderer/core/layout/block_node.h"
#include "third_party/blink/renderer/core/layout/inline/fragment_item.h"
#include "third_party/blink/renderer/core/layout/inline/inline_cursor.h"
#include "third_party/blink/renderer/core/layout/inline/offset_mapping.h"
#include "third_party/blink/renderer/core/layout/inline/physical_line_box_fragment.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/core/paint/paint_layer.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h"
namespace blink {
namespace {
bool ShouldUseLayoutNGTextContent(const Node& node) { … }
}
class SelectionPaintRange : public GarbageCollected<SelectionPaintRange> { … };
LayoutSelection::LayoutSelection(FrameSelection& frame_selection)
: … { … }
enum class SelectionMode { … };
void LayoutSelection::AssertIsValid() const { … }
static SelectionMode ComputeSelectionMode(
const FrameSelection& frame_selection) { … }
static EphemeralRangeInFlatTree CalcSelectionInFlatTree(
const FrameSelection& frame_selection) { … }
struct OldSelectedNodes { … };
std::ostream& operator<<(std::ostream&, const OldSelectedNodes&);
struct NewPaintRangeAndSelectedNodes { … };
std::ostream& operator<<(std::ostream&, const NewPaintRangeAndSelectedNodes&);
static void SetShouldInvalidateIfNeeded(LayoutObject* layout_object) { … }
static LayoutTextFragment* FirstLetterPartFor(
const LayoutObject* layout_object) { … }
static void SetShouldInvalidateIfNeeded(const Node& node) { … }
static void SetSelectionStateIfNeeded(const Node& node, SelectionState state) { … }
static void SetShouldInvalidateSelection(
const NewPaintRangeAndSelectedNodes& new_range,
const OldSelectedNodes& old_selected_objects) { … }
static bool IsDisplayContentElement(const Node& node) { … }
template <typename Visitor>
static void VisitSelectedInclusiveDescendantsOfInternal(Node& node,
Visitor* visitor) { … }
static inline bool IsFlatTreeClean(const Node& node) { … }
template <typename Visitor>
static void VisitSelectedInclusiveDescendantsOf(Node& node, Visitor* visitor) { … }
static OldSelectedNodes ResetOldSelectedNodes(
Node& root,
std::optional<unsigned> old_start_offset,
std::optional<unsigned> old_end_offset) { … }
static std::optional<unsigned> ComputeStartOffset(
const Node& node,
const PositionInFlatTree& selection_start) { … }
static std::optional<unsigned> ComputeEndOffset(
const Node& node,
const PositionInFlatTree& selection_end) { … }
#if DCHECK_IS_ON()
static bool IsPositionValidText(const Position& position) { … }
#endif
static std::optional<unsigned> GetTextContentOffset(const Position& position) { … }
static std::optional<unsigned> GetTextContentOffsetStart(
const Node& node,
std::optional<unsigned> node_offset) { … }
static std::optional<unsigned> GetTextContentOffsetEnd(
const Node& node,
std::optional<unsigned> node_offset) { … }
static SelectionPaintRange* ComputeNewPaintRange(
const SelectionPaintRange& paint_range) { … }
static unsigned ClampOffset(unsigned offset,
unsigned start_offset,
unsigned end_offset) { … }
static Text* AssociatedTextNode(const LayoutText& text) { … }
static SelectionState GetSelectionStateFor(const LayoutText& layout_text) { … }
static SelectionState GetSelectionStateFor(
const InlineCursorPosition& position) { … }
static SelectionState GetPaintingSelectionStateFor(
const LayoutText& layout_text) { … }
bool LayoutSelection::IsSelected(const LayoutObject& layout_object) { … }
static inline unsigned ClampOffset(unsigned node_offset,
const LayoutTextFragment& fragment) { … }
static LayoutTextSelectionStatus ComputeSelectionStatusForNode(
const Text& text,
SelectionState selection_state,
std::optional<unsigned> start_offset,
std::optional<unsigned> end_offset) { … }
LayoutTextSelectionStatus LayoutSelection::ComputeSelectionStatus(
const LayoutText& layout_text) const { … }
LayoutTextSelectionStatus FrameSelection::ComputeLayoutSelectionStatus(
const LayoutText& text) const { … }
LayoutSelectionStatus LayoutSelection::ComputeSelectionStatus(
const InlineCursor& cursor) const { … }
LayoutSelectionStatus LayoutSelection::ComputeSelectionStatus(
const InlineCursor& cursor,
const TextOffsetRange& offset) const { … }
SelectionState LayoutSelection::ComputeSelectionStateFromOffsets(
SelectionState state,
unsigned start_offset,
unsigned end_offset) const { … }
SelectionState LayoutSelection::ComputePaintingSelectionStateForCursor(
const InlineCursorPosition& position) const { … }
static void SetSelectionStateForPaint(
const EphemeralRangeInFlatTree& selection) { … }
static NewPaintRangeAndSelectedNodes CalcSelectionRangeAndSetSelectionState(
const FrameSelection& frame_selection) { … }
void LayoutSelection::SetHasPendingSelection() { … }
void LayoutSelection::Commit() { … }
void LayoutSelection::ContextDestroyed() { … }
static PhysicalRect SelectionRectForLayoutObject(const LayoutObject* object) { … }
template <typename Visitor>
static void VisitLayoutObjectsOf(const Node& node, Visitor* visitor) { … }
gfx::Rect LayoutSelection::AbsoluteSelectionBounds() { … }
void LayoutSelection::InvalidateStyleAndPaintForSelection() { … }
void LayoutSelection::Trace(Visitor* visitor) const { … }
void PrintSelectionStatus(std::ostream& ostream, const Node& node) { … }
#if DCHECK_IS_ON()
std::ostream& operator<<(std::ostream& ostream,
const std::optional<unsigned>& offset) { … }
std::ostream& operator<<(std::ostream& ostream,
const SelectionPaintRange& range) { … }
std::ostream& operator<<(
std::ostream& ostream,
const HeapHashMap<Member<const Node>, SelectionState>& map) { … }
std::ostream& operator<<(std::ostream& ostream,
const OldSelectedNodes& old_node) { … }
void PrintOldSelectedNodes(const OldSelectedNodes& old_node) { … }
std::ostream& operator<<(
std::ostream& ostream,
const HeapHashSet<Member<const Node>>& selected_objects) { … }
std::ostream& operator<<(std::ostream& ostream,
const NewPaintRangeAndSelectedNodes& new_range) { … }
void PrintSelectedNodes(const NewPaintRangeAndSelectedNodes& new_range) { … }
void PrintSelectionStateInDocument(const FrameSelection& selection) { … }
#endif
}