| OLD | NEW |
| 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 "core/dom/Text.h" | 8 #include "core/dom/Text.h" |
| 9 #include "core/editing/EditingTestBase.h" | 9 #include "core/editing/EditingTestBase.h" |
| 10 #include "core/editing/VisiblePosition.h" | 10 #include "core/editing/VisiblePosition.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 "id='three'>333</b>"; | 174 "id='three'>333</b>"; |
| 175 const char* shadowContent = | 175 const char* shadowContent = |
| 176 "<b id='four'>4444</b><content select=#two></content><content " | 176 "<b id='four'>4444</b><content select=#two></content><content " |
| 177 "select=#one></content><b id='five'>5555</b>"; | 177 "select=#one></content><b id='five'>5555</b>"; |
| 178 setBodyContent(bodyContent); | 178 setBodyContent(bodyContent); |
| 179 setShadowContent(shadowContent, "host"); | 179 setShadowContent(shadowContent, "host"); |
| 180 | 180 |
| 181 Element* one = document().getElementById("one"); | 181 Element* one = document().getElementById("one"); |
| 182 Element* two = document().getElementById("two"); | 182 Element* two = document().getElementById("two"); |
| 183 | 183 |
| 184 EXPECT_EQ('2', characterAfter( | 184 EXPECT_EQ( |
| 185 createVisiblePositionInDOMTree(*one->firstChild(), 1))); | 185 '2', |
| 186 EXPECT_EQ('5', characterAfter( | 186 characterAfter(createVisiblePositionInDOMTree(*one->firstChild(), 1))); |
| 187 createVisiblePositionInFlatTree(*one->firstChild(), 1))); | 187 EXPECT_EQ( |
| 188 '5', |
| 189 characterAfter(createVisiblePositionInFlatTree(*one->firstChild(), 1))); |
| 188 | 190 |
| 189 EXPECT_EQ( | 191 EXPECT_EQ( |
| 190 0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild(), 2))); | 192 0, characterAfter(createVisiblePositionInDOMTree(*two->firstChild(), 2))); |
| 191 EXPECT_EQ('1', characterAfter( | 193 EXPECT_EQ( |
| 192 createVisiblePositionInFlatTree(*two->firstChild(), 2))); | 194 '1', |
| 195 characterAfter(createVisiblePositionInFlatTree(*two->firstChild(), 2))); |
| 193 } | 196 } |
| 194 | 197 |
| 195 TEST_F(VisibleUnitsTest, canonicalPositionOfWithHTMLHtmlElement) { | 198 TEST_F(VisibleUnitsTest, canonicalPositionOfWithHTMLHtmlElement) { |
| 196 const char* bodyContent = | 199 const char* bodyContent = |
| 197 "<html><div id=one contenteditable>1</div><span id=two " | 200 "<html><div id=one contenteditable>1</div><span id=two " |
| 198 "contenteditable=false>22</span><span id=three " | 201 "contenteditable=false>22</span><span id=three " |
| 199 "contenteditable=false>333</span><span id=four " | 202 "contenteditable=false>333</span><span id=four " |
| 200 "contenteditable=false>333</span></html>"; | 203 "contenteditable=false>333</span></html>"; |
| 201 setBodyContent(bodyContent); | 204 setBodyContent(bodyContent); |
| 202 | 205 |
| (...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 "select=#one></content><p id=five>55555</p>"; | 1651 "select=#one></content><p id=five>55555</p>"; |
| 1649 setBodyContent(bodyContent); | 1652 setBodyContent(bodyContent); |
| 1650 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 1653 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| 1651 | 1654 |
| 1652 Node* one = document().getElementById("one")->firstChild(); | 1655 Node* one = document().getElementById("one")->firstChild(); |
| 1653 Node* two = document().getElementById("two")->firstChild(); | 1656 Node* two = document().getElementById("two")->firstChild(); |
| 1654 Node* three = document().getElementById("three")->firstChild(); | 1657 Node* three = document().getElementById("three")->firstChild(); |
| 1655 Node* four = shadowRoot->getElementById("four")->firstChild(); | 1658 Node* four = shadowRoot->getElementById("four")->firstChild(); |
| 1656 Node* five = shadowRoot->getElementById("five")->firstChild(); | 1659 Node* five = shadowRoot->getElementById("five")->firstChild(); |
| 1657 | 1660 |
| 1658 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(one, 1))) | 1661 EXPECT_EQ(Position(), |
| 1659 .deepEquivalent()); | 1662 rightPositionOf(createVisiblePosition(Position(one, 1))) |
| 1663 .deepEquivalent()); |
| 1660 EXPECT_EQ(PositionInFlatTree(five, 0), | 1664 EXPECT_EQ(PositionInFlatTree(five, 0), |
| 1661 rightPositionOf(createVisiblePosition(PositionInFlatTree(one, 1))) | 1665 rightPositionOf(createVisiblePosition(PositionInFlatTree(one, 1))) |
| 1662 .deepEquivalent()); | 1666 .deepEquivalent()); |
| 1663 | 1667 |
| 1664 EXPECT_EQ(Position(one, 1), | 1668 EXPECT_EQ(Position(one, 1), |
| 1665 rightPositionOf(createVisiblePosition(Position(two, 2))) | 1669 rightPositionOf(createVisiblePosition(Position(two, 2))) |
| 1666 .deepEquivalent()); | 1670 .deepEquivalent()); |
| 1667 EXPECT_EQ(PositionInFlatTree(one, 1), | 1671 EXPECT_EQ(PositionInFlatTree(one, 1), |
| 1668 rightPositionOf(createVisiblePosition(PositionInFlatTree(two, 2))) | 1672 rightPositionOf(createVisiblePosition(PositionInFlatTree(two, 2))) |
| 1669 .deepEquivalent()); | 1673 .deepEquivalent()); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) { | 2005 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) { |
| 2002 setBodyContent("<div>foo<img></div>"); | 2006 setBodyContent("<div>foo<img></div>"); |
| 2003 | 2007 |
| 2004 Node* node = document().querySelector("img"); | 2008 Node* node = document().querySelector("img"); |
| 2005 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create( | 2009 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create( |
| 2006 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren)))); | 2010 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren)))); |
| 2007 EXPECT_FALSE(rect.isEmpty()); | 2011 EXPECT_FALSE(rect.isEmpty()); |
| 2008 } | 2012 } |
| 2009 | 2013 |
| 2010 } // namespace blink | 2014 } // namespace blink |
| OLD | NEW |