#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/layout/inline/inline_items_builder.h"
#include <type_traits>
#include "base/containers/adapters.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/html/html_area_element.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/inline_node_data.h"
#include "third_party/blink/renderer/core/layout/inline/offset_mapping_builder.h"
#include "third_party/blink/renderer/core/layout/inline/transformed_string.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h"
#include "third_party/blink/renderer/platform/wtf/text/text_offset_map.h"
namespace blink {
class HTMLAreaElement;
template <typename MappingBuilder>
InlineItemsBuilderTemplate<MappingBuilder>::InlineItemsBuilderTemplate(
LayoutBlockFlow* block_flow,
HeapVector<InlineItem>* items,
const String& previous_text_content,
const SvgTextChunkOffsets* chunk_offsets)
: … { … }
template <typename MappingBuilder>
bool InlineItemsBuilderTemplate<MappingBuilder>::NeedsBoxInfo() { … }
template <typename MappingBuilder>
InlineItemsBuilderTemplate<MappingBuilder>::~InlineItemsBuilderTemplate() { … }
template <typename MappingBuilder>
String InlineItemsBuilderTemplate<MappingBuilder>::ToString() { … }
namespace {
constexpr bool kDisableForcedBreakInRubyColumn = …;
#define SEGMENT_BREAK_TRANSFORMATION_FOR_EAST_ASIAN_WIDTH …
#if SEGMENT_BREAK_TRANSFORMATION_FOR_EAST_ASIAN_WIDTH
bool IsAmbiguosEastAsianWidthWide(const ComputedStyle* style) {
UScriptCode script = style->GetFontDescription().GetScript();
return script == USCRIPT_KATAKANA_OR_HIRAGANA ||
script == USCRIPT_SIMPLIFIED_HAN || script == USCRIPT_TRADITIONAL_HAN;
}
bool IsEastAsianWidthWide(UChar32 c, const ComputedStyle* style) {
UEastAsianWidth eaw = static_cast<UEastAsianWidth>(
u_getIntPropertyValue(c, UCHAR_EAST_ASIAN_WIDTH));
return eaw == U_EA_WIDE || eaw == U_EA_FULLWIDTH || eaw == U_EA_HALFWIDTH ||
(eaw == U_EA_AMBIGUOUS && style &&
IsAmbiguosEastAsianWidthWide(style));
}
#endif
bool ShouldRemoveNewlineSlow(const StringBuilder& before,
unsigned space_index,
const ComputedStyle* before_style,
const StringView& after,
const ComputedStyle* after_style) { … }
bool ShouldRemoveNewline(const StringBuilder& before,
unsigned space_index,
const ComputedStyle* before_style,
const StringView& after,
const ComputedStyle* after_style) { … }
inline InlineItem& AppendItem(HeapVector<InlineItem>* items,
InlineItem::InlineItemType type,
unsigned start,
unsigned end,
LayoutObject* layout_object) { … }
inline bool ShouldIgnore(UChar c) { … }
inline bool IsControlItemCharacter(UChar c) { … }
inline bool MoveToEndOfCollapsibleSpaces(const StringView& string,
unsigned* offset,
UChar* c) { … }
InlineItem* LastItemToCollapseWith(HeapVector<InlineItem>* items) { … }
inline bool IsNonOrc16BitCharacter(UChar ch) { … }
}
template <typename MappingBuilder>
InlineItemsBuilderTemplate<MappingBuilder>::BoxInfo::BoxInfo(
unsigned item_index,
const InlineItem& item)
: … { … }
template <typename MappingBuilder>
bool InlineItemsBuilderTemplate<MappingBuilder>::BoxInfo::
ShouldCreateBoxFragmentForChild(const BoxInfo& child) const { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::BoxInfo::
SetShouldCreateBoxFragment(HeapVector<InlineItem>* items) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendTextItem(
const TransformedString& transformed,
LayoutText* layout_object) { … }
template <typename MappingBuilder>
InlineItem& InlineItemsBuilderTemplate<MappingBuilder>::AppendTextItem(
InlineItem::InlineItemType type,
const TransformedString& transformed,
LayoutText* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendEmptyTextItem(
LayoutText* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::
AppendGeneratedBreakOpportunity(LayoutObject* layout_object) { … }
template <typename MappingBuilder>
inline void InlineItemsBuilderTemplate<MappingBuilder>::DidAppendForcedBreak() { … }
template <typename MappingBuilder>
inline void InlineItemsBuilderTemplate<MappingBuilder>::DidAppendTextReusing(
const InlineItem& item) { … }
template <typename MappingBuilder>
bool InlineItemsBuilderTemplate<MappingBuilder>::AppendTextReusing(
const InlineNodeData& original_data,
LayoutText* layout_text) { … }
template <>
bool InlineItemsBuilderTemplate<OffsetMappingBuilder>::AppendTextReusing(
const InlineNodeData&,
LayoutText*) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendText(
LayoutText* layout_text,
const InlineNodeData* previous_data) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendText(
const String& string,
LayoutText* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendText(
const TransformedString& transformed,
LayoutText& layout_object) { … }
template <typename MappingBuilder>
bool InlineItemsBuilderTemplate<MappingBuilder>::AppendTextChunks(
const TransformedString& transformed,
LayoutText& layout_text) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendTransformedString(
const TransformedString& transformed,
const LayoutText& layout_text) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendCollapseWhitespace(
const TransformedString& transformed,
const ComputedStyle* style,
LayoutText* layout_object) { … }
template <typename MappingBuilder>
bool InlineItemsBuilderTemplate<MappingBuilder>::
ShouldInsertBreakOpportunityAfterLeadingPreservedSpaces(
StringView string,
const ComputedStyle& style,
unsigned index) const { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::
InsertBreakOpportunityAfterLeadingPreservedSpaces(
const TransformedString& transformed,
const ComputedStyle& style,
LayoutText* layout_object,
unsigned* start) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendPreserveWhitespace(
const TransformedString& transformed,
const ComputedStyle* style,
LayoutText* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendPreserveNewline(
const TransformedString& transformed,
const ComputedStyle* style,
LayoutText* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendForcedBreak(
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::
AppendForcedBreakCollapseWhitespace(LayoutObject* layout_object) { … }
template <typename MappingBuilder>
InlineItem& InlineItemsBuilderTemplate<MappingBuilder>::AppendBreakOpportunity(
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::ExitAndEnterSvgTextChunk(
LayoutText& layout_text) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::EnterSvgTextChunk(
const ComputedStyle* style) { … }
template <typename MappingBuilder>
InlineItem& InlineItemsBuilderTemplate<MappingBuilder>::Append(
InlineItem::InlineItemType type,
UChar character,
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendAtomicInline(
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendBlockInInline(
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendFloating(
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendOutOfFlowPositioned(
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
InlineItem& InlineItemsBuilderTemplate<MappingBuilder>::AppendOpaque(
InlineItem::InlineItemType type,
UChar character,
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::AppendOpaque(
InlineItem::InlineItemType type,
LayoutObject* layout_object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<
MappingBuilder>::RemoveTrailingCollapsibleSpaceIfExists() { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::RemoveTrailingCollapsibleSpace(
InlineItem* item) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<
MappingBuilder>::RestoreTrailingCollapsibleSpaceIfRemoved() { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<
MappingBuilder>::RestoreTrailingCollapsibleSpace(InlineItem* item) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::EnterBidiContext(
LayoutObject* node,
UChar enter,
UChar exit) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::EnterBidiContext(
LayoutObject* node,
const ComputedStyle* style,
UChar ltr_enter,
UChar rtl_enter,
UChar exit) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::EnterBlock(
const ComputedStyle* style) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::EnterInline(
LayoutInline* node) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::ExitBlock() { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::ExitInline(
LayoutObject* node) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::Exit(LayoutObject* node) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::DidFinishCollectInlines(
InlineNodeData* data) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::SetHasInititialLetterBox() { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::SetIsSymbolMarker() { … }
template <typename MappingBuilder>
bool InlineItemsBuilderTemplate<MappingBuilder>::ShouldUpdateLayoutObject()
const { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::ClearInlineFragment(
LayoutObject* object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::ClearNeedsLayout(
LayoutObject* object) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::UpdateShouldCreateBoxFragment(
LayoutInline* object) { … }
template <>
bool InlineItemsBuilderTemplate<
OffsetMappingBuilder>::ShouldUpdateLayoutObject() const { … }
template <>
void InlineItemsBuilderTemplate<OffsetMappingBuilder>::ClearNeedsLayout(
LayoutObject* object) { … }
template <>
void InlineItemsBuilderTemplate<OffsetMappingBuilder>::ClearInlineFragment(
LayoutObject*) { … }
template <>
void InlineItemsBuilderTemplate<
OffsetMappingBuilder>::UpdateShouldCreateBoxFragment(LayoutInline*) { … }
template <typename MappingBuilder>
void InlineItemsBuilderTemplate<MappingBuilder>::BidiContext::Trace(
Visitor* visitor) const { … }
template class CORE_TEMPLATE_EXPORT
InlineItemsBuilderTemplate<EmptyOffsetMappingBuilder>;
template class CORE_TEMPLATE_EXPORT
InlineItemsBuilderTemplate<OffsetMappingBuilder>;
}