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

Unified Diff: Source/core/editing/EditingUtilitiesTest.cpp

Issue 1306053017: Introduce composed tree version of lastEditableVisiblePositionBeforePositionInRoot() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-08T16:55:04 Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/EditingUtilities.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/EditingUtilitiesTest.cpp
diff --git a/Source/core/editing/EditingUtilitiesTest.cpp b/Source/core/editing/EditingUtilitiesTest.cpp
index 3775dcb560c07fff64afc43af3bf7a8ecb042d95..9f769f4d8f9a8ab9f8ea7400876def47174dcbb5 100644
--- a/Source/core/editing/EditingUtilitiesTest.cpp
+++ b/Source/core/editing/EditingUtilitiesTest.cpp
@@ -79,6 +79,30 @@ TEST_F(EditingUtilitiesTest, enclosingNodeOfType)
EXPECT_EQ(three, enclosingNodeOfType(PositionInComposedTree(one, 0), isEnclosingBlock));
}
+TEST_F(EditingUtilitiesTest, lastEditablePositionBeforePositionInRoot)
+{
+ const char* bodyContent = "<p id='host' contenteditable><b id='one'>1</b><b id='two'>22</b></p>";
+ const char* shadowContent = "<content select=#two></content><content select=#one></content><b id='three'>333</b>";
+ setBodyContent(bodyContent);
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
+ updateLayoutAndStyleForPainting();
+ Element* host = document().getElementById("host");
+ Node* one = document().getElementById("one");
+ Node* two = document().getElementById("two");
+ Node* three = shadowRoot->getElementById("three");
+
+ EXPECT_EQ(Position(one, 0), lastEditablePositionBeforePositionInRoot(Position(one, 0), host));
+ EXPECT_EQ(Position(one->firstChild(), 0), lastEditableVisiblePositionBeforePositionInRoot(Position(one, 0), host).deepEquivalent());
yoichio 2015/09/08 08:22:07 (one->firstChild(), 0) is after (one, 0). Ditto to
+
+ EXPECT_EQ(PositionInComposedTree(one, 0), lastEditablePositionBeforePositionInRoot(PositionInComposedTree(one, 0), host));
+ EXPECT_EQ(PositionInComposedTree(two->firstChild(), 2), lastEditableVisiblePositionBeforePositionInRoot(PositionInComposedTree(one, 0), host).deepEquivalent());
+
+ EXPECT_EQ(Position::firstPositionInNode(host), lastEditablePositionBeforePositionInRoot(Position(three, 0), host));
+ EXPECT_EQ(Position(one->firstChild(), 0), lastEditableVisiblePositionBeforePositionInRoot(Position(three, 0), host).deepEquivalent());
+ EXPECT_EQ(PositionInComposedTree::firstPositionInNode(host), lastEditablePositionBeforePositionInRoot(PositionInComposedTree(three, 0), host));
+ EXPECT_EQ(PositionInComposedTree(two->firstChild(), 0), lastEditableVisiblePositionBeforePositionInRoot(PositionInComposedTree(three, 0), host).deepEquivalent());
+}
+
TEST_F(EditingUtilitiesTest, NextNodeIndex)
{
const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</b>33</p>";
« no previous file with comments | « Source/core/editing/EditingUtilities.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698