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

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

Issue 2229463003: Make toPositionInFlatTree() to handle a position anchored by shadow root (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-09T14:04:01 Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/Position.h" 5 #include "core/editing/Position.h"
6 6
7 #include "core/editing/EditingTestBase.h" 7 #include "core/editing/EditingTestBase.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRoot) 132 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRoot)
133 { 133 {
134 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 134 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
135 const char* shadowContent = "<a><content select=#one></content></a>"; 135 const char* shadowContent = "<a><content select=#one></content></a>";
136 setBodyContent(bodyContent); 136 setBodyContent(bodyContent);
137 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); 137 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
138 Element* host = document().getElementById("host"); 138 Element* host = document().getElementById("host");
139 139
140 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR oot, 0))); 140 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR oot, 0)));
141 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot, 1))); 141 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot, 1)));
142 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren),
143 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::AfterChild ren)));
144 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::BeforeChildren),
145 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::BeforeChil dren)));
146 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterAnchor),
147 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::AfterAncho r)));
148 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::BeforeAnchor),
149 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::BeforeAnch or)));
142 } 150 }
143 151
144 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRootContainingSingleContent) 152 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRootContainingSingleContent)
145 { 153 {
146 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 154 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
147 const char* shadowContent = "<content select=#one></content>"; 155 const char* shadowContent = "<content select=#one></content>";
148 setBodyContent(bodyContent); 156 setBodyContent(bodyContent);
149 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); 157 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
150 Element* host = document().getElementById("host"); 158 Element* host = document().getElementById("host");
151 159
152 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR oot, 0))); 160 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR oot, 0)));
153 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot, 1))); 161 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot, 1)));
154 } 162 }
155 163
156 TEST_F(PositionTest, ToPositionInFlatTreeWithEmptyShadowRoot) 164 TEST_F(PositionTest, ToPositionInFlatTreeWithEmptyShadowRoot)
157 { 165 {
158 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 166 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
159 const char* shadowContent = ""; 167 const char* shadowContent = "";
160 setBodyContent(bodyContent); 168 setBodyContent(bodyContent);
161 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); 169 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
162 Element* host = document().getElementById("host"); 170 Element* host = document().getElementById("host");
163 171
164 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot, 0))); 172 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos itionInFlatTree(Position(shadowRoot, 0)));
165 } 173 }
166 174
167 } // namespace blink 175 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698