| 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 "core/dom/Text.h" | 7 #include "core/dom/Text.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 #include "core/editing/VisiblePosition.h" | 9 #include "core/editing/VisiblePosition.h" |
| 10 #include "core/html/TextControlElement.h" | 10 #include "core/html/TextControlElement.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 IntRect boundsInDOMTree = | 73 IntRect boundsInDOMTree = |
| 74 absoluteCaretBoundsOf(createVisiblePosition(Position(one, 0))); | 74 absoluteCaretBoundsOf(createVisiblePosition(Position(one, 0))); |
| 75 IntRect boundsInFlatTree = | 75 IntRect boundsInFlatTree = |
| 76 absoluteCaretBoundsOf(createVisiblePosition(PositionInFlatTree(one, 0))); | 76 absoluteCaretBoundsOf(createVisiblePosition(PositionInFlatTree(one, 0))); |
| 77 | 77 |
| 78 EXPECT_FALSE(boundsInDOMTree.isEmpty()); | 78 EXPECT_FALSE(boundsInDOMTree.isEmpty()); |
| 79 EXPECT_EQ(boundsInDOMTree, boundsInFlatTree); | 79 EXPECT_EQ(boundsInDOMTree, boundsInFlatTree); |
| 80 } | 80 } |
| 81 | 81 |
| 82 TEST_F(VisibleUnitsTest, absoluteSelectionBoundsOf) { |
| 83 const char* bodyContent = |
| 84 "<p id='host'><b id='one'>11</b><b id='two'>22</b></p>"; |
| 85 const char* shadowContent = |
| 86 "<div><content select=#two></content><content " |
| 87 "select=#one></content></div>"; |
| 88 setBodyContent(bodyContent); |
| 89 setShadowContent(shadowContent, "host"); |
| 90 |
| 91 Element* body = document().body(); |
| 92 Element* one = body->querySelector("#one"); |
| 93 |
| 94 IntRect boundsInDOMTree = |
| 95 absoluteSelectionBoundsOf(createVisiblePosition(Position(one, 0))); |
| 96 IntRect boundsInFlatTree = absoluteSelectionBoundsOf( |
| 97 createVisiblePosition(PositionInFlatTree(one, 0))); |
| 98 |
| 99 EXPECT_FALSE(boundsInDOMTree.isEmpty()); |
| 100 EXPECT_EQ(boundsInDOMTree, boundsInFlatTree); |
| 101 } |
| 102 |
| 82 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterPunctuations) { | 103 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterPunctuations) { |
| 83 const char* bodyContent = | 104 const char* bodyContent = |
| 84 "<style>p:first-letter {color:red;}</style><p id=sample>(a)bc</p>"; | 105 "<style>p:first-letter {color:red;}</style><p id=sample>(a)bc</p>"; |
| 85 setBodyContent(bodyContent); | 106 setBodyContent(bodyContent); |
| 86 | 107 |
| 87 Node* sample = document().getElementById("sample"); | 108 Node* sample = document().getElementById("sample"); |
| 88 Node* text = sample->firstChild(); | 109 Node* text = sample->firstChild(); |
| 89 | 110 |
| 90 LayoutTextFragment* layoutObject0 = | 111 LayoutTextFragment* layoutObject0 = |
| 91 toLayoutTextFragment(associatedLayoutObjectOf(*text, 0)); | 112 toLayoutTextFragment(associatedLayoutObjectOf(*text, 0)); |
| (...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 // Repro case of crbug.com/584030 | 2012 // Repro case of crbug.com/584030 |
| 1992 const char* bodyContent = | 2013 const char* bodyContent = |
| 1993 "<button><rt><script>document.designMode = 'on'</script></rt></button>"; | 2014 "<button><rt><script>document.designMode = 'on'</script></rt></button>"; |
| 1994 setBodyContent(bodyContent); | 2015 setBodyContent(bodyContent); |
| 1995 | 2016 |
| 1996 Node* button = document().querySelector("button"); | 2017 Node* button = document().querySelector("button"); |
| 1997 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button)); | 2018 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button)); |
| 1998 } | 2019 } |
| 1999 | 2020 |
| 2000 } // namespace blink | 2021 } // namespace blink |
| OLD | NEW |