#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/layout/inline/offset_mapping.h"
#include <algorithm>
#include "base/ranges/algorithm.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/text.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/position.h"
#include "third_party/blink/renderer/core/layout/block_node.h"
#include "third_party/blink/renderer/core/layout/inline/inline_node.h"
#include "third_party/blink/renderer/core/layout/layout_text_fragment.h"
#include "third_party/blink/renderer/platform/text/character.h"
namespace blink {
namespace {
bool CanUseOffsetMapping(const LayoutObject& object) { … }
Position CreatePositionForOffsetMapping(const Node& node, unsigned dom_offset) { … }
std::pair<const Node&, unsigned> ToNodeOffsetPair(const Position& position) { … }
}
LayoutBlockFlow* NGInlineFormattingContextOf(const Position& position) { … }
LayoutBlockFlow* OffsetMapping::GetInlineFormattingContextOf(
const Position& position) { … }
OffsetMappingUnit::OffsetMappingUnit(OffsetMappingUnitType type,
const LayoutObject& layout_object,
unsigned dom_start,
unsigned dom_end,
unsigned text_content_start,
unsigned text_content_end)
: … { … }
void OffsetMappingUnit::AssertValid() const { … }
const Node* OffsetMappingUnit::AssociatedNode() const { … }
const Node& OffsetMappingUnit::GetOwner() const { … }
bool OffsetMappingUnit::Concatenate(const OffsetMappingUnit& other) { … }
unsigned OffsetMappingUnit::ConvertDOMOffsetToTextContent(
unsigned offset) const { … }
unsigned OffsetMappingUnit::ConvertTextContentToFirstDOMOffset(
unsigned offset) const { … }
unsigned OffsetMappingUnit::ConvertTextContentToLastDOMOffset(
unsigned offset) const { … }
bool OffsetMapping::AcceptsPosition(const Position& position) { … }
const OffsetMapping* OffsetMapping::GetFor(const Position& position) { … }
const OffsetMapping* OffsetMapping::ForceGetFor(const Position& position) { … }
const OffsetMapping* OffsetMapping::GetFor(const LayoutObject* layout_object) { … }
LayoutBlockFlow* OffsetMapping::GetInlineFormattingContextOf(
const LayoutObject& object) { … }
OffsetMapping::OffsetMapping(UnitVector&& units, RangeMap&& ranges, String text)
: … { … }
OffsetMapping::~OffsetMapping() = default;
const OffsetMappingUnit* OffsetMapping::GetMappingUnitForPosition(
const Position& position) const { … }
OffsetMapping::UnitVector OffsetMapping::GetMappingUnitsForDOMRange(
const EphemeralRange& range) const { … }
base::span<const OffsetMappingUnit> OffsetMapping::GetMappingUnitsForNode(
const Node& node) const { … }
base::span<const OffsetMappingUnit>
OffsetMapping::GetMappingUnitsForLayoutObject(
const LayoutObject& layout_object) const { … }
base::span<const OffsetMappingUnit>
OffsetMapping::GetMappingUnitsForTextContentOffsetRange(unsigned start,
unsigned end) const { … }
std::optional<unsigned> OffsetMapping::GetTextContentOffset(
const Position& position) const { … }
Position OffsetMapping::StartOfNextNonCollapsedContent(
const Position& position) const { … }
Position OffsetMapping::EndOfLastNonCollapsedContent(
const Position& position) const { … }
bool OffsetMapping::IsBeforeNonCollapsedContent(
const Position& position) const { … }
bool OffsetMapping::IsAfterNonCollapsedContent(const Position& position) const { … }
std::optional<UChar> OffsetMapping::GetCharacterBefore(
const Position& position) const { … }
Position OffsetMapping::GetFirstPosition(unsigned offset) const { … }
const OffsetMappingUnit* OffsetMapping::GetFirstMappingUnit(
unsigned offset) const { … }
const OffsetMappingUnit* OffsetMapping::GetLastMappingUnit(
unsigned offset) const { … }
Position OffsetMapping::GetLastPosition(unsigned offset) const { … }
bool OffsetMapping::HasBidiControlCharactersOnly(unsigned start,
unsigned end) const { … }
unsigned OffsetMapping::LayoutObjectConverter::TextContentOffset(
unsigned offset) const { … }
void OffsetMappingUnit::Trace(Visitor* visitor) const { … }
}