chromium/third_party/blink/renderer/core/layout/inline/inline_node_test.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/core/layout/inline/inline_node.h"

#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/dom_token_list.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/pseudo_element.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/constraint_space.h"
#include "third_party/blink/renderer/core/layout/constraint_space_builder.h"
#include "third_party/blink/renderer/core/layout/inline/inline_child_layout_context.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_layout_algorithm.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_result.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/layout/svg/layout_svg_text.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/core/testing/mock_hyphenation.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_spacing.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"

namespace blink {

// The spec turned into a discussion that may change. Put this logic on hold
// until CSSWG resolves the issue.
// https://github.com/w3c/csswg-drafts/issues/337
#define SEGMENT_BREAK_TRANSFORMATION_FOR_EAST_ASIAN_WIDTH

ElementsAre;

class InlineNodeForTest : public InlineNode {};

class InlineNodeTest : public RenderingTest {};

#define TEST_ITEM_TYPE_OFFSET(item, type, start, end)

#define TEST_ITEM_TYPE_OFFSET_LEVEL(item, type, start, end, level)

#define TEST_ITEM_OFFSET_DIR(item, start, end, direction)

TEST_F(InlineNodeTest, CollectInlinesText) {}

TEST_F(InlineNodeTest, CollectInlinesBR) {}

TEST_F(InlineNodeTest, CollectInlinesFloat) {}

TEST_F(InlineNodeTest, CollectInlinesInlineBlock) {}

TEST_F(InlineNodeTest, CollectInlinesUTF16) {}

TEST_F(InlineNodeTest, CollectInlinesMaybeRtl) {}

TEST_F(InlineNodeTest, CollectInlinesRtl) {}

TEST_F(InlineNodeTest, CollectInlinesRtlWithSpan) {}

TEST_F(InlineNodeTest, CollectInlinesMixedText) {}

TEST_F(InlineNodeTest, CollectInlinesMixedTextEndWithON) {}

TEST_F(InlineNodeTest, CollectInlinesTextCombineBR) {}

// http://crbug.com/1222633
TEST_F(InlineNodeTest, CollectInlinesTextCombineListItemMarker) {}

TEST_F(InlineNodeTest, CollectInlinesTextCombineNewline) {}

TEST_F(InlineNodeTest, CollectInlinesTextCombineWBR) {}

TEST_F(InlineNodeTest, SegmentASCII) {}

TEST_F(InlineNodeTest, SegmentHebrew) {}

TEST_F(InlineNodeTest, SegmentSplit1To2) {}

TEST_F(InlineNodeTest, SegmentSplit3To4) {}

TEST_F(InlineNodeTest, SegmentBidiOverride) {}

static InlineNodeForTest CreateBidiIsolateNode(InlineNodeForTest node,
                                               LayoutObject* layout_object) {}

TEST_F(InlineNodeTest, SegmentBidiIsolate) {}

struct MinMaxData {} min_max_data[] =;

std::ostream& operator<<(std::ostream& os, const MinMaxData& data) {}

class MinMaxTest : public InlineNodeTest,
                   public testing::WithParamInterface<MinMaxData> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(MinMaxTest, Data) {}

// For http://crbug.com/1112560
TEST_F(InlineNodeTest, MinMaxSizesSaturated) {}

// For http://crbug.com/1116713
TEST_F(InlineNodeTest, MinMaxSizesNeedsLayout) {}

TEST_F(InlineNodeTest, AssociatedItemsWithControlItem) {}

TEST_F(InlineNodeTest, NeedsCollectInlinesOnSetText) {}

// crbug.com/325306591
// We had a crash in OffsetMapping building during SetTextWithOffset().
TEST_F(InlineNodeTest, SetTextWithOffsetWithTextTransform) {}

struct StyleChangeData {} style_change_data[] =;

std::ostream& operator<<(std::ostream& os, const StyleChangeData& data) {}

class StyleChangeTest : public InlineNodeTest,
                        public testing::WithParamInterface<StyleChangeData> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(StyleChangeTest, NeedsCollectInlinesOnStyle) {}

CreateNode;
static CreateNode node_creators[] =* element =* element =;

class NodeInsertTest : public InlineNodeTest,
                       public testing::WithParamInterface<CreateNode> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(NodeInsertTest, NeedsCollectInlinesOnInsert) {}

TEST_F(InlineNodeTest, NeedsCollectInlinesOnInsertToOutOfFlowButton) {}

class NodeRemoveTest : public InlineNodeTest,
                       public testing::WithParamInterface<const char*> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(NodeRemoveTest, NeedsCollectInlinesOnRemove) {}

TEST_F(InlineNodeTest, CollectInlinesShouldNotClearFirstInlineFragment) {}

TEST_F(InlineNodeTest, SegmentBidiChangeSetsNeedsLayout) {}

TEST_F(InlineNodeTest, InvalidateAddSpan) {}

TEST_F(InlineNodeTest, InvalidateRemoveSpan) {}

TEST_F(InlineNodeTest, InvalidateAddInnerSpan) {}

TEST_F(InlineNodeTest, InvalidateRemoveInnerSpan) {}

TEST_F(InlineNodeTest, InvalidateSetText) {}

TEST_F(InlineNodeTest, InvalidateAddAbsolute) {}

TEST_F(InlineNodeTest, InvalidateRemoveAbsolute) {}

TEST_F(InlineNodeTest, InvalidateChangeToAbsolute) {}

TEST_F(InlineNodeTest, InvalidateChangeFromAbsolute) {}

TEST_F(InlineNodeTest, InvalidateAddFloat) {}

TEST_F(InlineNodeTest, InvalidateRemoveFloat) {}

TEST_F(InlineNodeTest, SpaceRestoredByInsertingWord) {}

TEST_F(InlineNodeTest, RemoveInlineNodeDataIfBlockBecomesEmpty1) {}

TEST_F(InlineNodeTest, RemoveInlineNodeDataIfBlockBecomesEmpty2) {}

TEST_F(InlineNodeTest, RemoveInlineNodeDataIfBlockObtainsBlockChild) {}

// Test inline objects are initialized when |SplitFlow()| moves them.
TEST_F(InlineNodeTest, ClearFirstInlineFragmentOnSplitFlow) {}

TEST_F(InlineNodeTest, AddChildToSVGRoot) {}

// https://crbug.com/911220
TEST_F(InlineNodeTest, PreservedNewlineWithBidiAndRelayout) {}

TEST_F(InlineNodeTest, PreservedNewlineWithRemovedBidiAndRelayout) {}

TEST_F(InlineNodeTest, PreservedNewlineWithRemovedLtrDirAndRelayout) {}

// https://crbug.com/969089
TEST_F(InlineNodeTest, InsertedWBRWithLineBreakInRelayout) {}

TEST_F(InlineNodeTest, CollapsibleSpaceFollowingBRWithNoWrapStyle) {}

TEST_F(InlineNodeTest, CollapsibleSpaceFollowingNewlineWithPreStyle) {}

#if SEGMENT_BREAK_TRANSFORMATION_FOR_EAST_ASIAN_WIDTH
// https://crbug.com/879088
TEST_F(InlineNodeTest, RemoveSegmentBreakFromJapaneseInRelayout) {
  SetupHtml("container",
            u"<div id=container>"
            u"<span>\u30ED\u30B0\u30A4\u30F3</span>"
            u"\n"
            u"<span>\u767B\u9332</span>"
            u"<br></div>");
  EXPECT_EQ(String(u"\u30ED\u30B0\u30A4\u30F3\u767B\u9332\n"), GetText());

  Node* new_text = Text::Create(GetDocument(), "foo");
  GetElementById("container")->appendChild(new_text);
  UpdateAllLifecyclePhasesForTest();

  EXPECT_EQ(String(u"\u30ED\u30B0\u30A4\u30F3\u767B\u9332\nfoo"), GetText());
}

// https://crbug.com/879088
TEST_F(InlineNodeTest, RemoveSegmentBreakFromJapaneseInRelayout2) {
  SetupHtml("container",
            u"<div id=container>"
            u"<span>\u30ED\u30B0\u30A4\u30F3</span>"
            u"\n"
            u"<span> \u767B\u9332</span>"
            u"<br></div>");
  EXPECT_EQ(String(u"\u30ED\u30B0\u30A4\u30F3\u767B\u9332\n"), GetText());

  Node* new_text = Text::Create(GetDocument(), "foo");
  GetElementById("container")->appendChild(new_text);
  UpdateAllLifecyclePhasesForTest();

  EXPECT_EQ(String(u"\u30ED\u30B0\u30A4\u30F3\u767B\u9332\nfoo"), GetText());
}
#endif

TEST_F(InlineNodeTest, SegmentRanges) {}

// https://crbug.com/1275383
TEST_F(InlineNodeTest, ReusingWithPreservedCase1) {}

// https://crbug.com/1275383
TEST_F(InlineNodeTest, ReusingWithPreservedCase2) {}

// https://crbug.com/1275383
TEST_F(InlineNodeTest, ReusingWithPreservedCase3) {}

// https://crbug.com/1021677
TEST_F(InlineNodeTest, ReusingWithCollapsed) {}

// https://crbug.com/109654
TEST_F(InlineNodeTest, ReusingRTLAsLTR) {}

TEST_F(InlineNodeTest, ReuseFirstNonSafe) {}

TEST_F(InlineNodeTest, ReuseFirstNonSafeRtl) {}

// http://crbug.com/1409702
TEST_F(InlineNodeTest, ShouldNotResueLigature) {}

TEST_F(InlineNodeTest, InitialLetter) {}

TEST_F(InlineNodeTest, TextCombineUsesScalingX) {}

// http://crbug.com/1226930
TEST_F(InlineNodeTest, TextCombineWordSpacing) {}

// crbug.com/1034464 bad.svg
TEST_F(InlineNodeTest, FindSvgTextChunksCrash1) {}

// crbug.com/1034464 good.svg
TEST_F(InlineNodeTest, FindSvgTextChunksCrash2) {}

// crbug.com/1403838
TEST_F(InlineNodeTest, FindSvgTextChunksCrash3) {}

TEST_F(InlineNodeTest, ShapeCacheDisabled) {}

TEST_F(InlineNodeTest, ShapeCacheLongString) {}

TEST_F(InlineNodeTest, ShapeCacheMultiItems) {}

TEST_F(InlineNodeTest, ShapeCacheSpacingRequired) {}

}  // namespace blink