| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/editing/VisibleUnits.h" | 5 #include "core/editing/VisibleUnits.h" |
| 6 | 6 |
| 7 #include <ostream> // NOLINT | 7 #include <ostream> // NOLINT |
| 8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
| 9 #include "core/dom/Text.h" | 9 #include "core/dom/Text.h" |
| 10 #include "core/editing/EditingTestBase.h" | 10 #include "core/editing/EditingTestBase.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 Element* sample = GetDocument().getElementById("sample"); | 287 Element* sample = GetDocument().getElementById("sample"); |
| 288 Node* text = sample->firstChild(); | 288 Node* text = sample->firstChild(); |
| 289 | 289 |
| 290 const InlineBoxPosition& actual = | 290 const InlineBoxPosition& actual = |
| 291 ComputeInlineBoxPosition(Position(text, 0), TextAffinity::kDownstream); | 291 ComputeInlineBoxPosition(Position(text, 0), TextAffinity::kDownstream); |
| 292 EXPECT_EQ(ToLayoutText(text->GetLayoutObject())->FirstTextBox(), | 292 EXPECT_EQ(ToLayoutText(text->GetLayoutObject())->FirstTextBox(), |
| 293 actual.inline_box); | 293 actual.inline_box); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // http://crbug.com/716093 |
| 297 TEST_F(VisibleUnitsTest, ComputeInlineBoxPositionMixedEditable) { |
| 298 SetBodyContent( |
| 299 "<div contenteditable id=sample>abc<input contenteditable=false></div>"); |
| 300 Element* const sample = GetDocument().getElementById("sample"); |
| 301 |
| 302 const InlineBoxPosition& actual = ComputeInlineBoxPosition( |
| 303 Position::LastPositionInNode(sample), TextAffinity::kDownstream); |
| 304 // Should not be in infinite-loop |
| 305 EXPECT_EQ(nullptr, actual.inline_box); |
| 306 // TODO(editing-dev): We should return 0 for |InlineBoxPosition| when |
| 307 // |inline_box| is null. |
| 308 EXPECT_EQ(2, actual.offset_in_box); |
| 309 } |
| 310 |
| 296 TEST_F(VisibleUnitsTest, endOfDocument) { | 311 TEST_F(VisibleUnitsTest, endOfDocument) { |
| 297 const char* body_content = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; | 312 const char* body_content = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; |
| 298 const char* shadow_content = | 313 const char* shadow_content = |
| 299 "<p><content select=#two></content></p><p><content " | 314 "<p><content select=#two></content></p><p><content " |
| 300 "select=#one></content></p>"; | 315 "select=#one></content></p>"; |
| 301 SetBodyContent(body_content); | 316 SetBodyContent(body_content); |
| 302 SetShadowContent(shadow_content, "host"); | 317 SetShadowContent(shadow_content, "host"); |
| 303 | 318 |
| 304 Element* one = GetDocument().getElementById("one"); | 319 Element* one = GetDocument().getElementById("one"); |
| 305 Element* two = GetDocument().getElementById("two"); | 320 Element* two = GetDocument().getElementById("two"); |
| (...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1974 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { | 1989 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { |
| 1975 SetBodyContent("<p> ⃣</p>"); // Leading space is necessary | 1990 SetBodyContent("<p> ⃣</p>"); // Leading space is necessary |
| 1976 | 1991 |
| 1977 Node* paragraph = GetDocument().QuerySelector("p"); | 1992 Node* paragraph = GetDocument().QuerySelector("p"); |
| 1978 Node* text = paragraph->firstChild(); | 1993 Node* text = paragraph->firstChild(); |
| 1979 Position start = CanonicalPositionOf(Position::BeforeNode(paragraph)); | 1994 Position start = CanonicalPositionOf(Position::BeforeNode(paragraph)); |
| 1980 EXPECT_EQ(Position(text, 2), start); | 1995 EXPECT_EQ(Position(text, 2), start); |
| 1981 } | 1996 } |
| 1982 | 1997 |
| 1983 } // namespace blink | 1998 } // namespace blink |
| OLD | NEW |