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

// Copyright 2017 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/offset_mapping.h"

#include "testing/gtest/include/gtest/gtest-death-test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/first_letter_pseudo_element.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/inline/inline_node.h"
#include "third_party/blink/renderer/core/layout/layout_block_flow.h"
#include "third_party/blink/renderer/core/layout/layout_text_fragment.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.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

// Helper functions to use |EXPECT_EQ()| for |OffsetMappingUnit| and its span.
HeapVector<OffsetMappingUnit> ToVector(
    const base::span<const OffsetMappingUnit>& range) {}

bool operator==(const OffsetMappingUnit& unit, const OffsetMappingUnit& other) {}

bool operator!=(const OffsetMappingUnit& unit, const OffsetMappingUnit& other) {}

void PrintTo(const OffsetMappingUnit& unit, std::ostream* ostream) {}

bool operator==(const HeapVector<OffsetMappingUnit>& units1,
                const HeapVector<OffsetMappingUnit>& units2) {}

bool operator==(const HeapVector<OffsetMappingUnit>& units,
                const base::span<const OffsetMappingUnit>& range) {}

void PrintTo(const HeapVector<OffsetMappingUnit>& units,
             std::ostream* ostream) {}

void PrintTo(const base::span<const OffsetMappingUnit>& range,
             std::ostream* ostream) {}

class OffsetMappingTest : public RenderingTest {};

TEST_F(OffsetMappingTest, CollapseSpaces) {}

TEST_F(OffsetMappingTest, CollapseTabs) {}

TEST_F(OffsetMappingTest, CollapseNewLines) {}

TEST_F(OffsetMappingTest, CollapseNewlinesAsSpaces) {}

TEST_F(OffsetMappingTest, CollapseAcrossElements) {}

TEST_F(OffsetMappingTest, CollapseLeadingSpaces) {}

TEST_F(OffsetMappingTest, CollapseTrailingSpaces) {}

// TODO(xiaochengh): Get around whitespace LayoutText omission, and make the
// following test cases work.
TEST_F(OffsetMappingTest, DISABLED_CollapseAllSpaces) {}

TEST_F(OffsetMappingTest, CollapseLeadingNewlines) {}

TEST_F(OffsetMappingTest, CollapseTrailingNewlines) {}

TEST_F(OffsetMappingTest, CollapseNewlineAcrossElements) {}

TEST_F(OffsetMappingTest, CollapseBeforeAndAfterNewline) {}

TEST_F(OffsetMappingTest,
       CollapsibleSpaceAfterNonCollapsibleSpaceAcrossElements) {}

TEST_F(OffsetMappingTest, CollapseZeroWidthSpaces) {}

#if SEGMENT_BREAK_TRANSFORMATION_FOR_EAST_ASIAN_WIDTH
TEST_F(OffsetMappingTest, CollapseEastAsianWidth) {
  EXPECT_EQ("{1}", TestCollapsing(u"\u4E00\n\u4E00"))
      << "Newline is removed when both sides are Wide.";

  EXPECT_EQ("{}", TestCollapsing(u"\u4E00\nA"))
      << "Newline is not removed when after is Narrow.";
  EXPECT_EQ("{}", TestCollapsing(u"A\n\u4E00"))
      << "Newline is not removed when before is Narrow.";

  EXPECT_EQ("{1}{}", TestCollapsing(u"\u4E00\n", u"\u4E00"))
      << "Newline at the end of elements is removed when both sides are Wide.";
  EXPECT_EQ("{}{0}", TestCollapsing(u"\u4E00", u"\n\u4E00"))
      << "Newline at the beginning of elements is removed "
         "when both sides are Wide.";
}
#endif

#define TEST_UNIT(unit, type, owner, dom_start, dom_end, text_content_start, \
                  text_content_end)

#define TEST_RANGE(ranges, owner, start, end)

TEST_F(OffsetMappingTest, StoredResult) {}

TEST_F(OffsetMappingTest, NGInlineFormattingContextOf) {}

TEST_F(OffsetMappingTest, OneTextNode) {}

TEST_F(OffsetMappingTest, TwoTextNodes) {}

TEST_F(OffsetMappingTest, BRBetweenTextNodes) {}

TEST_F(OffsetMappingTest, OneTextNodeWithCollapsedSpace) {}

TEST_F(OffsetMappingTest, FullyCollapsedWhiteSpaceNode) {}

TEST_F(OffsetMappingTest, ReplacedElement) {}

TEST_F(OffsetMappingTest, FirstLetter) {}

TEST_F(OffsetMappingTest, FirstLetterWithLeadingSpace) {}

TEST_F(OffsetMappingTest, FirstLetterWithoutRemainingText) {}

TEST_F(OffsetMappingTest, FirstLetterInDifferentBlock) {}

TEST_F(OffsetMappingTest, WhiteSpaceTextNodeWithoutLayoutText) {}

TEST_F(OffsetMappingTest, ContainerWithGeneratedContent) {}

TEST_F(OffsetMappingTest,
       ContainerWithGeneratedContentWithCollapsedWhitespace) {}

TEST_F(OffsetMappingTest, Table) {}

TEST_F(OffsetMappingTest, GetMappingForInlineBlock) {}

TEST_F(OffsetMappingTest, NoWrapSpaceAndCollapsibleSpace) {}

TEST_F(OffsetMappingTest, PreLine) {}

TEST_F(OffsetMappingTest, BiDiAroundForcedBreakInPreLine) {}

TEST_F(OffsetMappingTest, BiDiAroundForcedBreakInPreWrap) {}

TEST_F(OffsetMappingTest, BiDiAroundForcedBreakInPre) {}

TEST_F(OffsetMappingTest, SoftHyphen) {}

// For http://crbug.com/965353
TEST_F(OffsetMappingTest, PreWrapAndReusing) {}

TEST_F(OffsetMappingTest, RestoreTrailingCollapsibleSpaceReplace) {}

TEST_F(OffsetMappingTest, RestoreTrailingCollapsibleSpaceReplaceKeep) {}

TEST_F(OffsetMappingTest, RestoreTrailingCollapsibleSpaceNone) {}

TEST_F(OffsetMappingTest, RestoreTrailingCollapsibleSpaceSplit) {}

TEST_F(OffsetMappingTest, RestoreTrailingCollapsibleSpaceSplitKeep) {}

TEST_F(OffsetMappingTest, TextOverflowEllipsis) {}

// https://crbug.com/967106
TEST_F(OffsetMappingTest, StartOfNextNonCollapsedContentWithPseudo) {}

// https://crbug.com/967106
TEST_F(OffsetMappingTest, EndOfLastNonCollapsedContentWithPseudo) {}

TEST_F(OffsetMappingTest, WordBreak) {}

// crbug.com/1443193
TEST_F(OffsetMappingTest, NoCrashByListStyleTypeChange) {}

// Test |GetOffsetMapping| which is available both for LayoutNG and for legacy.
class OffsetMappingGetterTest : public RenderingTest {};

TEST_F(OffsetMappingGetterTest, Get) {}

TEST_F(OffsetMappingTest, LayoutObjectConverter) {}

}  // namespace blink