#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include <algorithm>
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/content_capture/content_capture_manager.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/dom/text_diff_range.h"
#include "third_party/blink/renderer/core/editing/bidi_adjustment.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/inline_box_position.h"
#include "third_party/blink/renderer/core/editing/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/position_with_affinity.h"
#include "third_party/blink/renderer/core/editing/text_affinity.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_rect.h"
#include "third_party/blink/renderer/core/layout/geometry/writing_mode_converter.h"
#include "third_party/blink/renderer/core/layout/inline/abstract_inline_text_box.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/inline_item_span.h"
#include "third_party/blink/renderer/core/layout/inline/inline_node.h"
#include "third_party/blink/renderer/core/layout/inline/offset_mapping.h"
#include "third_party/blink/renderer/core/layout/layout_block.h"
#include "third_party/blink/renderer/core/layout/layout_block_flow.h"
#include "third_party/blink/renderer/core/layout/layout_object_inlines.h"
#include "third_party/blink/renderer/core/layout/layout_text_combine.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_inline_text.h"
#include "third_party/blink/renderer/core/layout/text_autosizer.h"
#include "third_party/blink/renderer/core/paint/object_paint_invalidator.h"
#include "third_party/blink/renderer/platform/fonts/character_range.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/text/character.h"
#include "third_party/blink/renderer/platform/text/hyphenation.h"
#include "third_party/blink/renderer/platform/text/text_break_iterator.h"
#include "third_party/blink/renderer/platform/wtf/size_assertions.h"
#include "third_party/blink/renderer/platform/wtf/text/string_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/text_offset_map.h"
#include "ui/gfx/geometry/quad_f.h"
namespace blink {
namespace …
LayoutText::LayoutText(Node* node, String str)
: … { … }
void LayoutText::Trace(Visitor* visitor) const { … }
LayoutText* LayoutText::CreateEmptyAnonymous(Document& doc,
const ComputedStyle* style) { … }
bool LayoutText::IsWordBreak() const { … }
void LayoutText::StyleWillChange(StyleDifference diff,
const ComputedStyle& new_style) { … }
void LayoutText::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) { … }
void LayoutText::RemoveAndDestroyTextBoxes() { … }
void LayoutText::WillBeDestroyed() { … }
void LayoutText::DeleteTextBoxes() { … }
void LayoutText::DetachAbstractInlineTextBoxes() { … }
void LayoutText::ClearFirstInlineFragmentItemIndex() { … }
void LayoutText::SetFirstInlineFragmentItemIndex(wtf_size_t index) { … }
void LayoutText::InLayoutNGInlineFormattingContextWillChange(bool new_value) { … }
Vector<LayoutText::TextBoxInfo> LayoutText::GetTextBoxInfo() const { … }
bool LayoutText::HasInlineFragments() const { … }
String LayoutText::OriginalText() const { … }
unsigned LayoutText::OriginalTextLength() const { … }
String LayoutText::PlainText() const { … }
template <typename PhysicalRectCollector>
void LayoutText::CollectLineBoxRects(const PhysicalRectCollector& yield,
ClippingOption option) const { … }
void LayoutText::AbsoluteQuads(Vector<gfx::QuadF>& quads,
MapCoordinatesFlags mode) const { … }
bool LayoutText::MapDOMOffsetToTextContentOffset(const OffsetMapping& mapping,
unsigned* start,
unsigned* end) const { … }
void LayoutText::AbsoluteQuadsForRange(Vector<gfx::QuadF>& quads,
unsigned start,
unsigned end) const { … }
gfx::RectF LayoutText::LocalBoundingBoxRectForAccessibility() const { … }
PositionWithAffinity LayoutText::PositionForPoint(
const PhysicalOffset& point) const { … }
PhysicalRect LayoutText::LocalCaretRect(
int caret_offset,
LayoutUnit* extra_width_to_end_of_line) const { … }
bool LayoutText::IsAllCollapsibleWhitespace() const { … }
UChar32 LayoutText::FirstCharacterAfterWhitespaceCollapsing() const { … }
UChar32 LayoutText::LastCharacterAfterWhitespaceCollapsing() const { … }
PhysicalOffset LayoutText::FirstLineBoxTopLeft() const { … }
void LayoutText::LogicalStartingPointAndHeight(
LogicalOffset& logical_starting_point,
LayoutUnit& logical_height) const { … }
void LayoutText::SetTextWithOffset(String text, const TextDiffRange& diff) { … }
void LayoutText::TransformAndSecureOriginalText() { … }
static inline bool IsInlineFlowOrEmptyText(const LayoutObject* o) { … }
UChar LayoutText::PreviousCharacter() const { … }
void LayoutText::SetTextInternal(String text) { … }
String LayoutText::TransformAndSecureText(const String& original,
TextOffsetMap& offset_map) const { … }
std::pair<String, TextOffsetMap> LayoutText::SecureText(const String& plain,
UChar mask) const { … }
void LayoutText::SetVariableLengthTransformResult(
wtf_size_t original_length,
const TextOffsetMap& offset_map) { … }
VariableLengthTransformResult LayoutText::GetVariableLengthTransformResult()
const { … }
void LayoutText::ClearHasVariableLengthTransform() { … }
void LayoutText::SetTextIfNeeded(String text) { … }
void LayoutText::ForceSetText(String text) { … }
void LayoutText::SetNeedsLayoutAndIntrinsicWidthsRecalcAndFullPaintInvalidation(
LayoutInvalidationReasonForTracing reason) { … }
void LayoutText::TextDidChange() { … }
void LayoutText::TextDidChangeWithoutInvalidation() { … }
void LayoutText::InvalidateSubtreeLayoutForFontUpdates() { … }
PhysicalRect LayoutText::PhysicalLinesBoundingBox() const { … }
PhysicalRect LayoutText::VisualOverflowRect() const { … }
PhysicalRect LayoutText::LocalVisualRectIgnoringVisibility() const { … }
PhysicalRect LayoutText::LocalSelectionVisualRect() const { … }
void LayoutText::InvalidateVisualOverflow() { … }
const OffsetMapping* LayoutText::GetOffsetMapping() const { … }
Position LayoutText::PositionForCaretOffset(unsigned offset) const { … }
std::optional<unsigned> LayoutText::CaretOffsetForPosition(
const Position& position) const { … }
int LayoutText::CaretMinOffset() const { … }
int LayoutText::CaretMaxOffset() const { … }
unsigned LayoutText::NonCollapsedCaretMaxOffset() const { … }
unsigned LayoutText::ResolvedTextLength() const { … }
bool LayoutText::HasNonCollapsedText() const { … }
bool LayoutText::ContainsCaretOffset(int text_offset) const { … }
bool LayoutText::IsBeforeNonCollapsedCharacter(unsigned text_offset) const { … }
bool LayoutText::IsAfterNonCollapsedCharacter(unsigned text_offset) const { … }
void LayoutText::MomentarilyRevealLastTypedCharacter(
unsigned last_typed_character_offset) { … }
AbstractInlineTextBox* LayoutText::FirstAbstractInlineTextBox() { … }
void LayoutText::InvalidatePaint(const PaintInvalidatorContext& context) const { … }
void LayoutText::InvalidateDisplayItemClients(
PaintInvalidationReason reason) const { … }
const DisplayItemClient* LayoutText::GetSelectionDisplayItemClient() const { … }
PhysicalRect LayoutText::DebugRect() const { … }
DOMNodeId LayoutText::EnsureNodeId() { … }
ContentCaptureManager* LayoutText::GetOrResetContentCaptureManager() { … }
void LayoutText::SetInlineItems(InlineItemsData* data,
wtf_size_t begin,
wtf_size_t size) { … }
void LayoutText::ClearInlineItems() { … }
const InlineItemSpan& LayoutText::InlineItems() const { … }
#if DCHECK_IS_ON()
void LayoutText::RecalcVisualOverflow() { … }
#endif
}