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 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1973 TEST_F(VisibleUnitsTest, | 1973 TEST_F(VisibleUnitsTest, |
1974 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { | 1974 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { |
1975 SetBodyContent("<p> ⃣</p>"); // Leading space is necessary | 1975 SetBodyContent("<p> ⃣</p>"); // Leading space is necessary |
1976 | 1976 |
1977 Node* paragraph = GetDocument().QuerySelector("p"); | 1977 Node* paragraph = GetDocument().QuerySelector("p"); |
1978 Node* text = paragraph->firstChild(); | 1978 Node* text = paragraph->firstChild(); |
1979 Position start = CanonicalPositionOf(Position::BeforeNode(paragraph)); | 1979 Position start = CanonicalPositionOf(Position::BeforeNode(paragraph)); |
1980 EXPECT_EQ(Position(text, 2), start); | 1980 EXPECT_EQ(Position(text, 2), start); |
1981 } | 1981 } |
1982 | 1982 |
1983 TEST_F(VisibleUnitsTest, computeTextQuadDOM) { | |
1984 const char* bodyContent = | |
1985 "<style> font-family: Ahem; </style>" | |
Xiaocheng
2017/05/17 18:46:39
This is not correct CSS. There should be a selecto
| |
1986 "<p id='host'>00" | |
1987 "<b id='one'>11111</b>" | |
1988 "<b id='two'>22</b>" | |
1989 "<b id='three'>33</b>" | |
1990 "</p>"; | |
1991 SetBodyContent(bodyContent); | |
1992 | |
1993 const Position start_position(GetDocument().getElementById("host"), 0); | |
1994 const Position mid_position(GetDocument().getElementById("two"), 0); | |
1995 const Position end_position(GetDocument().getElementById("three"), 0); | |
1996 const EphemeralRange range_start_to_two(start_position, mid_position); | |
1997 const EphemeralRange range_start_to_three(start_position, end_position); | |
1998 Vector<FloatQuad> quads_start_to_two; | |
1999 Vector<FloatQuad> quads_start_to_three; | |
2000 quads_start_to_two.AppendVector(ComputeTextQuads(range_start_to_two)); | |
2001 quads_start_to_three.AppendVector(ComputeTextQuads(range_start_to_three)); | |
2002 | |
2003 EXPECT_EQ(2u, quads_start_to_two.size()); | |
2004 EXPECT_EQ(3u, quads_start_to_three.size()); | |
2005 EXPECT_EQ(quads_start_to_three[0], quads_start_to_two[0]); | |
2006 EXPECT_EQ(quads_start_to_three[1], quads_start_to_two[1]); | |
2007 EXPECT_EQ("8,8; 10,8; 10,9; 8,9", quads_start_to_two[0].ToString()); | |
2008 EXPECT_EQ("10,8; 15,8; 15,9; 10,9", quads_start_to_two[1].ToString()); | |
2009 EXPECT_EQ("8,8; 10,8; 10,9; 8,9", quads_start_to_three[0].ToString()); | |
2010 EXPECT_EQ("10,8; 15,8; 15,9; 10,9", quads_start_to_three[1].ToString()); | |
2011 EXPECT_EQ("15,8; 17,8; 17,9; 15,9", quads_start_to_three[2].ToString()); | |
2012 } | |
2013 | |
1983 } // namespace blink | 2014 } // namespace blink |
OLD | NEW |