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

Side by Side Diff: third_party/WebKit/Source/core/dom/RangeTest.cpp

Issue 2953683004: Make Position::AfterNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-22T12:37:16 Created 3 years, 6 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 | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/dom/Range.h" 5 #include "core/dom/Range.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/NodeList.h" 10 #include "core/dom/NodeList.h"
(...skipping 14 matching lines...) Expand all
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 namespace blink { 27 namespace blink {
28 28
29 class RangeTest : public EditingTestBase {}; 29 class RangeTest : public EditingTestBase {};
30 30
31 TEST_F(RangeTest, createAdjustedToTreeScopeWithPositionInShadowTree) { 31 TEST_F(RangeTest, createAdjustedToTreeScopeWithPositionInShadowTree) {
32 GetDocument().body()->setInnerHTML("<div><select><option>012</option></div>"); 32 GetDocument().body()->setInnerHTML("<div><select><option>012</option></div>");
33 Element* const select_element = GetDocument().QuerySelector("select"); 33 Element* const select_element = GetDocument().QuerySelector("select");
34 const Position& position = 34 const Position& position =
35 Position::AfterNode(select_element->UserAgentShadowRoot()); 35 Position::AfterNode(*select_element->UserAgentShadowRoot());
36 Range* const range = 36 Range* const range =
37 Range::CreateAdjustedToTreeScope(GetDocument(), position); 37 Range::CreateAdjustedToTreeScope(GetDocument(), position);
38 EXPECT_EQ(range->startContainer(), select_element->parentNode()); 38 EXPECT_EQ(range->startContainer(), select_element->parentNode());
39 EXPECT_EQ(static_cast<unsigned>(range->startOffset()), 39 EXPECT_EQ(static_cast<unsigned>(range->startOffset()),
40 select_element->NodeIndex()); 40 select_element->NodeIndex());
41 EXPECT_TRUE(range->collapsed()); 41 EXPECT_TRUE(range->collapsed());
42 } 42 }
43 43
44 TEST_F(RangeTest, extractContentsWithDOMMutationEvent) { 44 TEST_F(RangeTest, extractContentsWithDOMMutationEvent) {
45 GetDocument().body()->setInnerHTML("<span><b>abc</b>def</span>"); 45 GetDocument().body()->setInnerHTML("<span><b>abc</b>def</span>");
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 TEST_F(RangeTest, ToPosition) { 248 TEST_F(RangeTest, ToPosition) {
249 Node& textarea = *HTMLTextAreaElement::Create(GetDocument()); 249 Node& textarea = *HTMLTextAreaElement::Create(GetDocument());
250 Range& range = *Range::Create(GetDocument()); 250 Range& range = *Range::Create(GetDocument());
251 const Position position = Position(&textarea, 0); 251 const Position position = Position(&textarea, 0);
252 range.setStart(position, ASSERT_NO_EXCEPTION); 252 range.setStart(position, ASSERT_NO_EXCEPTION);
253 EXPECT_EQ(position, range.StartPosition()); 253 EXPECT_EQ(position, range.StartPosition());
254 EXPECT_EQ(position, range.EndPosition()); 254 EXPECT_EQ(position, range.EndPosition());
255 } 255 }
256 256
257 } // namespace blink 257 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/EditingUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698