Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp

Issue 2776103002: Make RenderedRectsForMarkers() to ignore disconnected nodes. (Closed)
Patch Set: move to VisibleUnits Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 TEST_F(VisibleUnitsTest, 1970 TEST_F(VisibleUnitsTest,
1971 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { 1971 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) {
1972 setBodyContent("<p> &#x20E3;</p>"); // Leading space is necessary 1972 setBodyContent("<p> &#x20E3;</p>"); // Leading space is necessary
1973 1973
1974 Node* paragraph = document().querySelector("p"); 1974 Node* paragraph = document().querySelector("p");
1975 Node* text = paragraph->firstChild(); 1975 Node* text = paragraph->firstChild();
1976 Position start = canonicalPositionOf(Position::beforeNode(paragraph)); 1976 Position start = canonicalPositionOf(Position::beforeNode(paragraph));
1977 EXPECT_EQ(Position(text, 2), start); 1977 EXPECT_EQ(Position(text, 2), start);
1978 } 1978 }
1979 1979
1980 TEST_F(VisibleUnitsTest, boundingBoxWithEphemeralRange) {
1981 const char* bodyContent =
1982 "<p id='host'>1"
1983 "<b id='one'>22</b>"
1984 "<b id='two'>333</b>"
1985 "<b id='three'>4444</b>"
1986 "</p>";
1987 setBodyContent(bodyContent);
1988
1989 const Position startPosition(document().getElementById("one"), 0);
1990 const Position endPosition(document().getElementById("three"), 0);
1991 Range* range = Range::create(document());
1992 range->selectNode(document().body());
1993 range->setStart(document().getElementById("one"), 0,
1994 IGNORE_EXCEPTION_FOR_TESTING);
1995 range->setEnd(document().getElementById("three"), 0,
1996 IGNORE_EXCEPTION_FOR_TESTING);
1997 const EphemeralRange ephemeralRange(startPosition, endPosition);
1998 EXPECT_EQ(range->boundingBox(), boundingBox(ephemeralRange));
1999 }
2000
2001 TEST_F(VisibleUnitsTest, boundingBoxWithEphemeralRangeInFlatTree) {
2002 const char* bodyContent =
2003 "<p id='host'>1"
2004 "<b id='one'>22</b>"
2005 "<b id='two'>333</b>"
2006 "<b id='three'>4444</b>"
2007 "</p>";
2008 setBodyContent(bodyContent);
2009
2010 const PositionInFlatTree startPosition(document().getElementById("one"), 0);
2011 const PositionInFlatTree endPosition(document().getElementById("three"), 0);
2012 Range* range = Range::create(document());
2013 range->selectNode(document().body());
2014 range->setStart(document().getElementById("one"), 0,
2015 IGNORE_EXCEPTION_FOR_TESTING);
2016 range->setEnd(document().getElementById("three"), 0,
2017 IGNORE_EXCEPTION_FOR_TESTING);
2018 const EphemeralRangeInFlatTree ephemeralRangeInFlatTree(startPosition,
2019 endPosition);
2020 EXPECT_EQ(range->boundingBox(), boundingBox(ephemeralRangeInFlatTree));
2021 }
2022
1980 } // namespace blink 2023 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698