OLD | NEW |
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/editing/FrameSelection.h" | 5 #include "core/editing/FrameSelection.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 EXPECT_EQ_SELECTED_TEXT("Foo"); | 120 EXPECT_EQ_SELECTED_TEXT("Foo"); |
121 // "Foo Bar | Baz," | 121 // "Foo Bar | Baz," |
122 EXPECT_FALSE(selection().selectWordAroundPosition( | 122 EXPECT_FALSE(selection().selectWordAroundPosition( |
123 createVisiblePosition(Position(text, 13)))); | 123 createVisiblePosition(Position(text, 13)))); |
124 // "Foo Bar Baz|," | 124 // "Foo Bar Baz|," |
125 EXPECT_TRUE(selection().selectWordAroundPosition( | 125 EXPECT_TRUE(selection().selectWordAroundPosition( |
126 createVisiblePosition(Position(text, 22)))); | 126 createVisiblePosition(Position(text, 22)))); |
127 EXPECT_EQ_SELECTED_TEXT("Baz"); | 127 EXPECT_EQ_SELECTED_TEXT("Baz"); |
128 } | 128 } |
129 | 129 |
| 130 // crbug.com/657996 |
| 131 TEST_F(FrameSelectionTest, SelectWordAroundPosition2) { |
| 132 setBodyContent( |
| 133 "<p style='width:70px; font-size:14px'>foo bar<em>+</em> baz</p>"); |
| 134 // "foo bar |
| 135 // b|az" |
| 136 Node* const baz = document().body()->firstChild()->lastChild(); |
| 137 EXPECT_TRUE(selection().selectWordAroundPosition( |
| 138 createVisiblePosition(Position(baz, 2)))); |
| 139 // TODO(yoichio): We should select only "baz". |
| 140 EXPECT_EQ_SELECTED_TEXT(" baz"); |
| 141 } |
| 142 |
130 TEST_F(FrameSelectionTest, ModifyExtendWithFlatTree) { | 143 TEST_F(FrameSelectionTest, ModifyExtendWithFlatTree) { |
131 setBodyContent("<span id=host></span>one"); | 144 setBodyContent("<span id=host></span>one"); |
132 setShadowContent("two<content></content>", "host"); | 145 setShadowContent("two<content></content>", "host"); |
133 Element* host = document().getElementById("host"); | 146 Element* host = document().getElementById("host"); |
134 Node* const two = FlatTreeTraversal::firstChild(*host); | 147 Node* const two = FlatTreeTraversal::firstChild(*host); |
135 // Select "two" for selection in DOM tree | 148 // Select "two" for selection in DOM tree |
136 // Select "twoone" for selection in Flat tree | 149 // Select "twoone" for selection in Flat tree |
137 selection().setSelection(SelectionInFlatTree::Builder() | 150 selection().setSelection(SelectionInFlatTree::Builder() |
138 .collapse(PositionInFlatTree(host, 0)) | 151 .collapse(PositionInFlatTree(host, 0)) |
139 .extend(PositionInFlatTree(document().body(), 2)) | 152 .extend(PositionInFlatTree(document().body(), 2)) |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 .build()); | 249 .build()); |
237 EXPECT_TRUE(selection().isHandleVisible()); | 250 EXPECT_TRUE(selection().isHandleVisible()); |
238 selection().selectAll(); | 251 selection().selectAll(); |
239 EXPECT_TRUE(selection().isHandleVisible()) | 252 EXPECT_TRUE(selection().isHandleVisible()) |
240 << "If handles were present before" | 253 << "If handles were present before" |
241 "selectAll. Then they should be present" | 254 "selectAll. Then they should be present" |
242 "after it."; | 255 "after it."; |
243 } | 256 } |
244 | 257 |
245 } // namespace blink | 258 } // namespace blink |
OLD | NEW |