Chromium Code Reviews| 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" |
| 11 #include "core/dom/NodeList.h" | |
| 11 #include "core/dom/Text.h" | 12 #include "core/dom/Text.h" |
| 12 #include "core/editing/EditingTestBase.h" | 13 #include "core/editing/EditingTestBase.h" |
| 13 #include "core/editing/FrameCaret.h" | 14 #include "core/editing/FrameCaret.h" |
| 14 #include "core/editing/SelectionController.h" | 15 #include "core/editing/SelectionController.h" |
| 15 #include "core/frame/FrameView.h" | 16 #include "core/frame/FrameView.h" |
| 16 #include "core/html/HTMLBodyElement.h" | 17 #include "core/html/HTMLBodyElement.h" |
| 17 #include "core/input/EventHandler.h" | 18 #include "core/input/EventHandler.h" |
| 18 #include "core/layout/LayoutBlock.h" | 19 #include "core/layout/LayoutBlock.h" |
| 19 #include "core/paint/PaintInfo.h" | 20 #include "core/paint/PaintInfo.h" |
| 20 #include "core/paint/PaintLayer.h" | 21 #include "core/paint/PaintLayer.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 EXPECT_EQ_SELECTED_TEXT("Foo"); | 121 EXPECT_EQ_SELECTED_TEXT("Foo"); |
| 121 // "Foo Bar | Baz," | 122 // "Foo Bar | Baz," |
| 122 EXPECT_FALSE(selection().selectWordAroundPosition( | 123 EXPECT_FALSE(selection().selectWordAroundPosition( |
| 123 createVisiblePosition(Position(text, 13)))); | 124 createVisiblePosition(Position(text, 13)))); |
| 124 // "Foo Bar Baz|," | 125 // "Foo Bar Baz|," |
| 125 EXPECT_TRUE(selection().selectWordAroundPosition( | 126 EXPECT_TRUE(selection().selectWordAroundPosition( |
| 126 createVisiblePosition(Position(text, 22)))); | 127 createVisiblePosition(Position(text, 22)))); |
| 127 EXPECT_EQ_SELECTED_TEXT("Baz"); | 128 EXPECT_EQ_SELECTED_TEXT("Baz"); |
| 128 } | 129 } |
| 129 | 130 |
| 131 // crbug.com/657996 | |
| 132 TEST_F(FrameSelectionTest, SelectWordAroundPosition2) { | |
| 133 setBodyContent( | |
| 134 "<p style='width:70px; font-size:14px'>foo bar<em>+</em> baz</p>"); | |
| 135 // "foo bar | |
| 136 // b|az" | |
| 137 Node* const baz = document().body()->firstChild()->childNodes()->item(2); | |
|
yosin_UTC9
2017/03/01 03:31:03
document().body()->firstChild()->lastChild() is ea
yoichio
2017/03/01 03:42:09
Done.
| |
| 138 EXPECT_TRUE(selection().selectWordAroundPosition( | |
| 139 createVisiblePosition(Position(baz, 2)))); | |
| 140 // TODO(yoichio): We should select only "baz". | |
| 141 EXPECT_EQ_SELECTED_TEXT(" baz"); | |
| 142 } | |
| 143 | |
| 130 TEST_F(FrameSelectionTest, ModifyExtendWithFlatTree) { | 144 TEST_F(FrameSelectionTest, ModifyExtendWithFlatTree) { |
| 131 setBodyContent("<span id=host></span>one"); | 145 setBodyContent("<span id=host></span>one"); |
| 132 setShadowContent("two<content></content>", "host"); | 146 setShadowContent("two<content></content>", "host"); |
| 133 Element* host = document().getElementById("host"); | 147 Element* host = document().getElementById("host"); |
| 134 Node* const two = FlatTreeTraversal::firstChild(*host); | 148 Node* const two = FlatTreeTraversal::firstChild(*host); |
| 135 // Select "two" for selection in DOM tree | 149 // Select "two" for selection in DOM tree |
| 136 // Select "twoone" for selection in Flat tree | 150 // Select "twoone" for selection in Flat tree |
| 137 selection().setSelection(SelectionInFlatTree::Builder() | 151 selection().setSelection(SelectionInFlatTree::Builder() |
| 138 .collapse(PositionInFlatTree(host, 0)) | 152 .collapse(PositionInFlatTree(host, 0)) |
| 139 .extend(PositionInFlatTree(document().body(), 2)) | 153 .extend(PositionInFlatTree(document().body(), 2)) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 .build()); | 250 .build()); |
| 237 EXPECT_TRUE(selection().isHandleVisible()); | 251 EXPECT_TRUE(selection().isHandleVisible()); |
| 238 selection().selectAll(); | 252 selection().selectAll(); |
| 239 EXPECT_TRUE(selection().isHandleVisible()) | 253 EXPECT_TRUE(selection().isHandleVisible()) |
| 240 << "If handles were present before" | 254 << "If handles were present before" |
| 241 "selectAll. Then they should be present" | 255 "selectAll. Then they should be present" |
| 242 "after it."; | 256 "after it."; |
| 243 } | 257 } |
| 244 | 258 |
| 245 } // namespace blink | 259 } // namespace blink |
| OLD | NEW |