diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 16:23:34 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:37:21 +0000 |
commit | 38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch) | |
tree | c4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/third_party/blink/renderer/core/editing/inline_box_position_test.cc | |
parent | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff) | |
download | qtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz |
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/editing/inline_box_position_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/editing/inline_box_position_test.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/editing/inline_box_position_test.cc b/chromium/third_party/blink/renderer/core/editing/inline_box_position_test.cc index 222f2d07ca1..f4ad06eea58 100644 --- a/chromium/third_party/blink/renderer/core/editing/inline_box_position_test.cc +++ b/chromium/third_party/blink/renderer/core/editing/inline_box_position_test.cc @@ -6,8 +6,10 @@ #include "third_party/blink/renderer/core/editing/position.h" #include "third_party/blink/renderer/core/editing/testing/editing_test_base.h" +#include "third_party/blink/renderer/core/editing/text_affinity.h" #include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/layout/line/inline_text_box.h" +#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h" namespace blink { @@ -23,6 +25,9 @@ std::ostream& operator<<(std::ostream& ostream, class InlineBoxPositionTest : public EditingTestBase {}; TEST_F(InlineBoxPositionTest, ComputeInlineBoxPositionBidiIsolate) { + // InlineBoxPosition is a legacy-only data structure. + ScopedLayoutNGForTest scoped_layout_ng(false); + // "|" is bidi-level 0, and "foo" and "bar" are bidi-level 2 SetBodyContent( "|<span id=sample style='unicode-bidi: isolate;'>foo<br>bar</span>|"); @@ -38,6 +43,9 @@ TEST_F(InlineBoxPositionTest, ComputeInlineBoxPositionBidiIsolate) { // http://crbug.com/716093 TEST_F(InlineBoxPositionTest, ComputeInlineBoxPositionMixedEditable) { + // InlineBoxPosition is a legacy-only data structure. + ScopedLayoutNGForTest scoped_layout_ng(false); + SetBodyContent( "<div contenteditable id=sample>abc<input contenteditable=false></div>"); Element* const sample = GetDocument().getElementById("sample"); @@ -51,6 +59,9 @@ TEST_F(InlineBoxPositionTest, ComputeInlineBoxPositionMixedEditable) { // http://crbug.com/841363 TEST_F(InlineBoxPositionTest, InFlatTreeAfterInputWithPlaceholderDoesntCrash) { + // InlineBoxPosition is a legacy-only data structure. + ScopedLayoutNGForTest scoped_layout_ng(false); + SetBodyContent("foo <input placeholder=bla> bar"); const Element* const input = GetDocument().QuerySelector("input"); const LayoutBox* const input_layout = ToLayoutBox(input->GetLayoutObject()); @@ -64,4 +75,48 @@ TEST_F(InlineBoxPositionTest, InFlatTreeAfterInputWithPlaceholderDoesntCrash) { EXPECT_EQ(1, box_position.offset_in_box); } +TEST_F(InlineBoxPositionTest, DownstreamBeforeLineBreakLTR) { + // InlineBoxPosition is a legacy-only data structure. + ScopedLayoutNGForTest scoped_layout_ng(false); + + // This test is for a bidi caret afinity specific behavior. + ScopedBidiCaretAffinityForTest scoped_bidi_affinity(true); + + SetBodyContent("<div id=div>אבג<br>ABC</div>"); + const Element* const div = GetElementById("div"); + const Node* const rtl_text = div->firstChild(); + const PositionWithAffinity before_br(Position(rtl_text, 3), + TextAffinity::kDownstream); + + const Element* const br = GetDocument().QuerySelector("br"); + const InlineBox* const box = + ToLayoutText(br->GetLayoutObject())->FirstTextBox(); + + const InlineBoxPosition box_position = ComputeInlineBoxPosition(before_br); + EXPECT_EQ(box, box_position.inline_box); + EXPECT_EQ(0, box_position.offset_in_box); +} + +TEST_F(InlineBoxPositionTest, DownstreamBeforeLineBreakRTL) { + // InlineBoxPosition is a legacy-only data structure. + ScopedLayoutNGForTest scoped_layout_ng(false); + + // This test is for a bidi caret afinity specific behavior. + ScopedBidiCaretAffinityForTest scoped_bidi_affinity(true); + + SetBodyContent("<div id=div dir=rtl>ABC<br>אבג</div>"); + const Element* const div = GetElementById("div"); + const Node* const rtl_text = div->firstChild(); + const PositionWithAffinity before_br(Position(rtl_text, 3), + TextAffinity::kDownstream); + + const Element* const br = GetDocument().QuerySelector("br"); + const InlineBox* const box = + ToLayoutText(br->GetLayoutObject())->FirstTextBox(); + + const InlineBoxPosition box_position = ComputeInlineBoxPosition(before_br); + EXPECT_EQ(box, box_position.inline_box); + EXPECT_EQ(0, box_position.offset_in_box); +} + } // namespace blink |