#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/layout/inline/inline_cursor.h"
#include "base/containers/adapters.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/position_with_affinity.h"
#include "third_party/blink/renderer/core/html/html_br_element.h"
#include "third_party/blink/renderer/core/layout/block_break_token.h"
#include "third_party/blink/renderer/core/layout/geometry/writing_mode_converter.h"
#include "third_party/blink/renderer/core/layout/inline/fragment_items.h"
#include "third_party/blink/renderer/core/layout/inline/inline_item_span.h"
#include "third_party/blink/renderer/core/layout/inline/physical_line_box_fragment.h"
#include "third_party/blink/renderer/core/layout/layout_block_flow.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_text_combine.h"
#include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
#include "third_party/blink/renderer/core/paint/inline_paint_context.h"
namespace blink {
class HTMLBRElement;
namespace {
bool IsBidiControl(StringView string) { … }
LogicalRect ExpandedSelectionRectForSoftLineBreakIfNeeded(
const LogicalRect& rect,
const InlineCursor& cursor,
const LayoutSelectionStatus& selection_status) { … }
LogicalRect ExpandSelectionRectToLineHeight(
const LogicalRect& rect,
const LogicalRect& line_logical_rect) { … }
LogicalRect ExpandSelectionRectToLineHeight(const LogicalRect& rect,
const InlineCursor& cursor) { … }
bool IsLastBRInPage(const LayoutObject& layout_object) { … }
bool ShouldIgnoreForPositionForPoint(const FragmentItem& item) { … }
bool ShouldIgnoreForPositionForPoint(const InlineCursor& line) { … }
}
inline void InlineCursor::MoveToItem(const ItemsSpan::iterator& iter) { … }
void InlineCursor::SetRoot(const PhysicalBoxFragment& box_fragment,
const FragmentItems& fragment_items,
ItemsSpan items) { … }
void InlineCursor::SetRoot(const PhysicalBoxFragment& box_fragment,
const FragmentItems& items) { … }
bool InlineCursor::TrySetRootFragmentItems() { … }
void InlineCursor::SetRoot(const LayoutBlockFlow& block_flow) { … }
InlineCursor::InlineCursor(const LayoutBlockFlow& block_flow) { … }
InlineCursor::InlineCursor(const PhysicalBoxFragment& box_fragment,
const FragmentItems& fragment_items,
ItemsSpan items) { … }
InlineCursor::InlineCursor(const PhysicalBoxFragment& box_fragment,
const FragmentItems& items) { … }
InlineCursor::InlineCursor(const PhysicalBoxFragment& box_fragment) { … }
InlineCursor::InlineCursor(const InlineBackwardCursor& backward_cursor)
: … { … }
bool InlineCursor::operator==(const InlineCursor& other) const { … }
const LayoutBlockFlow* InlineCursor::GetLayoutBlockFlow() const { … }
bool InlineCursorPosition::HasChildren() const { … }
InlineCursor InlineCursor::CursorForDescendants() const { … }
InlineCursor InlineCursor::CursorForMovingAcrossFragmentainer() const { … }
void InlineCursor::ExpandRootToContainingBlock() { … }
bool InlineCursorPosition::HasSoftWrapToNextLine() const { … }
bool InlineCursorPosition::IsInlineLeaf() const { … }
bool InlineCursorPosition::IsPartOfCulledInlineBox(
const LayoutInline& layout_inline) const { … }
bool InlineCursor::IsLastLineInInlineBlock() const { … }
bool InlineCursor::IsBeforeSoftLineBreak() const { … }
bool InlineCursorPosition::CanHaveChildren() const { … }
TextDirection InlineCursorPosition::BaseDirection() const { … }
UBiDiLevel InlineCursorPosition::BidiLevel() const { … }
const DisplayItemClient* InlineCursorPosition::GetSelectionDisplayItemClient()
const { … }
const Node* InlineCursorPosition::GetNode() const { … }
gfx::RectF InlineCursorPosition::ObjectBoundingBox(
const InlineCursor& cursor) const { … }
void InlineCursorPosition::RecalcInkOverflow(
const InlineCursor& cursor,
InlinePaintContext* inline_context) const { … }
StringView InlineCursorPosition::Text(const InlineCursor& cursor) const { … }
PhysicalRect InlineCursor::CurrentLocalRect(unsigned start_offset,
unsigned end_offset) const { … }
PhysicalRect InlineCursor::CurrentLocalSelectionRectForText(
const LayoutSelectionStatus& selection_status) const { … }
PhysicalRect InlineCursor::CurrentLocalSelectionRectForReplaced() const { … }
PhysicalRect InlineCursor::CurrentRectInBlockFlow() const { … }
LayoutUnit InlineCursor::CaretInlinePositionForOffset(unsigned offset) const { … }
LogicalRect InlineCursorPosition::ConvertChildToLogical(
const PhysicalRect& physical_rect) const { … }
PhysicalRect InlineCursorPosition::ConvertChildToPhysical(
const LogicalRect& logical_rect) const { … }
PositionWithAffinity InlineCursor::PositionForPointInInlineFormattingContext(
const PhysicalOffset& point,
const PhysicalBoxFragment& container) { … }
PositionWithAffinity InlineCursor::PositionForPointInInlineBox(
const PhysicalOffset& point_in) const { … }
PositionWithAffinity InlineCursor::PositionForPointInChild(
const PhysicalOffset& point_in_container) const { … }
PositionWithAffinity InlineCursor::PositionForPointInText(
unsigned text_offset) const { … }
PositionWithAffinity InlineCursor::PositionForStartOfLine() const { … }
PositionWithAffinity InlineCursor::PositionForEndOfLine() const { … }
inline wtf_size_t InlineCursor::GetTextOffsetForEndOfLine(
InlineCursor& last_leaf) const { … }
void InlineCursor::MoveTo(const InlineCursorPosition& position) { … }
inline wtf_size_t InlineCursor::SpanBeginItemIndex() const { … }
inline wtf_size_t InlineCursor::SpanIndexFromItemIndex(unsigned index) const { … }
void InlineCursor::MoveTo(const FragmentItem& fragment_item) { … }
bool InlineCursor::TryMoveTo(const FragmentItem& fragment_item) { … }
void InlineCursor::MoveTo(const InlineCursor& cursor) { … }
void InlineCursor::MoveToParent() { … }
void InlineCursor::MoveToContainingLine() { … }
bool InlineCursor::IsAtFirst() const { … }
void InlineCursor::MoveToFirst() { … }
void InlineCursor::MoveToFirstChild() { … }
void InlineCursor::MoveToFirstLine() { … }
void InlineCursor::MoveToFirstLogicalLeaf() { … }
void InlineCursor::MoveToFirstNonPseudoLeaf() { … }
void InlineCursor::MoveToLastChild() { … }
void InlineCursor::MoveToLastLine() { … }
void InlineCursor::MoveToLastLogicalLeaf() { … }
void InlineCursor::MoveToLastNonPseudoLeaf() { … }
void InlineCursor::MoveToNextInlineLeaf() { … }
void InlineCursor::MoveToNextInlineLeafIgnoringLineBreak() { … }
void InlineCursor::MoveToNextInlineLeafOnLine() { … }
void InlineCursor::MoveToNextLine() { … }
void InlineCursor::MoveToNextLineIncludingFragmentainer() { … }
void InlineCursor::MoveToPreviousInlineLeaf() { … }
void InlineCursor::MoveToPreviousInlineLeafIgnoringLineBreak() { … }
void InlineCursor::MoveToPreviousInlineLeafOnLine() { … }
void InlineCursor::MoveToPreviousLine() { … }
bool InlineCursor::TryMoveToFirstChild() { … }
bool InlineCursor::TryMoveToFirstInlineLeafChild() { … }
bool InlineCursor::TryMoveToLastChild() { … }
void InlineCursor::MoveToNext() { … }
void InlineCursor::MoveToNextSkippingChildren() { … }
void InlineCursor::MoveToPrevious() { … }
void InlineCursor::MoveToPreviousFragmentainer() { … }
void InlineCursor::MoveToPreviousIncludingFragmentainer() { … }
void InlineCursor::MoveToFirstIncludingFragmentainer() { … }
void InlineCursor::MoveToNextFragmentainer() { … }
void InlineCursor::MoveToNextIncludingFragmentainer() { … }
void InlineCursor::SlowMoveToForIfNeeded(const LayoutObject& layout_object) { … }
void InlineCursor::SlowMoveToFirstFor(const LayoutObject& layout_object) { … }
void InlineCursor::SlowMoveToNextForSameLayoutObject(
const LayoutObject& layout_object) { … }
void InlineCursor::MoveTo(const LayoutObject& layout_object) { … }
void InlineCursor::MoveToNextForSameLayoutObjectExceptCulledInline() { … }
void InlineCursor::MoveToLastForSameLayoutObject() { … }
const LayoutObject* InlineCursor::CulledInlineTraversal::Find(
const LayoutObject* child) const { … }
void InlineCursor::CulledInlineTraversal::SetUseFragmentTree(
const LayoutInline& layout_inline) { … }
const LayoutObject* InlineCursor::CulledInlineTraversal::MoveToFirstFor(
const LayoutInline& layout_inline) { … }
const LayoutObject* InlineCursor::CulledInlineTraversal::MoveToNext() { … }
void InlineCursor::MoveToFirstForCulledInline(
const LayoutInline& layout_inline) { … }
void InlineCursor::MoveToNextForCulledInline() { … }
void InlineCursor::MoveToNextCulledInlineDescendantIfNeeded() { … }
void InlineCursor::ResetFragmentIndex() { … }
void InlineCursor::DecrementFragmentIndex() { … }
void InlineCursor::IncrementFragmentIndex() { … }
void InlineCursor::MoveToIncludingCulledInline(
const LayoutObject& layout_object) { … }
void InlineCursor::MoveToNextForSameLayoutObject() { … }
void InlineCursor::MoveToVisualLastForSameLayoutObject() { … }
void InlineCursor::MoveToVisualFirstForSameLayoutObject() { … }
void InlineCursor::MoveToVisualFirstOrLastForCulledInline(bool last) { … }
InlineBackwardCursor::InlineBackwardCursor(const InlineCursor& cursor)
: … { … }
InlineCursor InlineBackwardCursor::CursorForDescendants() const { … }
void InlineBackwardCursor::MoveToPreviousSibling() { … }
std::ostream& operator<<(std::ostream& ostream, const InlineCursor& cursor) { … }
std::ostream& operator<<(std::ostream& ostream, const InlineCursor* cursor) { … }
#if DCHECK_IS_ON()
void InlineCursor::CheckValid(const InlineCursorPosition& position) const { … }
#endif
}