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

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

Issue 2531483003: Make Range::createAdjustedToTreeScope() to handle the shadow root at end of document tree correctly. (Closed)
Patch Set: Created 4 years 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/dom/Range.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 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/ExceptionStatePlaceholder.h" 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/NodeList.h" 9 #include "core/dom/NodeList.h"
10 #include "core/dom/Text.h" 10 #include "core/dom/Text.h"
(...skipping 23 matching lines...) Expand all
34 m_document = HTMLDocument::create(); 34 m_document = HTMLDocument::create();
35 HTMLHtmlElement* html = HTMLHtmlElement::create(*m_document); 35 HTMLHtmlElement* html = HTMLHtmlElement::create(*m_document);
36 html->appendChild(HTMLBodyElement::create(*m_document)); 36 html->appendChild(HTMLBodyElement::create(*m_document));
37 m_document->appendChild(html); 37 m_document->appendChild(html);
38 } 38 }
39 39
40 HTMLDocument& RangeTest::document() const { 40 HTMLDocument& RangeTest::document() const {
41 return *m_document; 41 return *m_document;
42 } 42 }
43 43
44 TEST_F(RangeTest, createAdjustedToTreeScopeWithPositionInShadowTree) {
45 document().body()->setInnerHTML("<div><select><option>012</option></div>");
46 Element* const selectElement = document().querySelector("select");
47 const Position& position =
48 Position::afterNode(selectElement->userAgentShadowRoot());
49 Range* const range = Range::createAdjustedToTreeScope(document(), position);
50 EXPECT_EQ(range->startContainer(), selectElement->parentNode());
51 EXPECT_EQ(static_cast<unsigned>(range->startOffset()),
52 selectElement->nodeIndex());
53 EXPECT_TRUE(range->collapsed());
54 }
55
44 TEST_F(RangeTest, SplitTextNodeRangeWithinText) { 56 TEST_F(RangeTest, SplitTextNodeRangeWithinText) {
45 document().body()->setInnerHTML("1234", ASSERT_NO_EXCEPTION); 57 document().body()->setInnerHTML("1234", ASSERT_NO_EXCEPTION);
46 Text* oldText = toText(document().body()->firstChild()); 58 Text* oldText = toText(document().body()->firstChild());
47 59
48 Range* range04 = Range::create(document(), oldText, 0, oldText, 4); 60 Range* range04 = Range::create(document(), oldText, 0, oldText, 4);
49 Range* range02 = Range::create(document(), oldText, 0, oldText, 2); 61 Range* range02 = Range::create(document(), oldText, 0, oldText, 2);
50 Range* range22 = Range::create(document(), oldText, 2, oldText, 2); 62 Range* range22 = Range::create(document(), oldText, 2, oldText, 2);
51 Range* range24 = Range::create(document(), oldText, 2, oldText, 4); 63 Range* range24 = Range::create(document(), oldText, 2, oldText, 4);
52 64
53 oldText->splitText(2, ASSERT_NO_EXCEPTION); 65 oldText->splitText(2, ASSERT_NO_EXCEPTION);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 text->deleteData(0, 3, ASSERT_NO_EXCEPTION); 213 text->deleteData(0, 3, ASSERT_NO_EXCEPTION);
202 214
203 EXPECT_TRUE(range->boundaryPointsValid()); 215 EXPECT_TRUE(range->boundaryPointsValid());
204 EXPECT_EQ(span2, range->startContainer()); 216 EXPECT_EQ(span2, range->startContainer());
205 EXPECT_EQ(0, range->startOffset()); 217 EXPECT_EQ(0, range->startOffset());
206 EXPECT_EQ(div, range->endContainer()); 218 EXPECT_EQ(div, range->endContainer());
207 EXPECT_EQ(2, range->endOffset()); 219 EXPECT_EQ(2, range->endOffset());
208 } 220 }
209 221
210 } // namespace blink 222 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Range.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698