| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 EXPECT_EQ(SelectionInFlatTree::Builder(result_in_flat_tree) | 254 EXPECT_EQ(SelectionInFlatTree::Builder(result_in_flat_tree) |
| 255 .Collapse(PositionInFlatTree::BeforeNode(input)) | 255 .Collapse(PositionInFlatTree::BeforeNode(input)) |
| 256 .Extend(PositionInFlatTree(last_child, 3)) | 256 .Extend(PositionInFlatTree(last_child, 3)) |
| 257 .Build(), | 257 .Build(), |
| 258 result_in_flat_tree); | 258 result_in_flat_tree); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) { | 261 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) { |
| 262 Element* select = GetDocument().createElement("select"); | 262 Element* select = GetDocument().createElement("select"); |
| 263 GetDocument().ReplaceChild(select, GetDocument().documentElement()); | 263 GetDocument().ReplaceChild(select, GetDocument().documentElement()); |
| 264 GetDocument().UpdateStyleAndLayout(); |
| 264 Selection().SelectAll(); | 265 Selection().SelectAll(); |
| 265 EXPECT_TRUE(Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsNone()) | 266 EXPECT_TRUE(Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsNone()) |
| 266 << "Nothing should be selected if the " | 267 << "Nothing should be selected if the " |
| 267 "content of the documentElement is not " | 268 "content of the documentElement is not " |
| 268 "selctable."; | 269 "selctable."; |
| 269 } | 270 } |
| 270 | 271 |
| 271 TEST_F(FrameSelectionTest, SelectAllPreservesHandle) { | 272 TEST_F(FrameSelectionTest, SelectAllPreservesHandle) { |
| 272 SetBodyContent("<div id=sample>abc</div>"); | 273 SetBodyContent("<div id=sample>abc</div>"); |
| 273 Element* sample = GetDocument().getElementById("sample"); | 274 Element* sample = GetDocument().getElementById("sample"); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // Should not crash inside. | 344 // Should not crash inside. |
| 344 const VisibleSelectionInFlatTree& selection = | 345 const VisibleSelectionInFlatTree& selection = |
| 345 Selection().ComputeVisibleSelectionInFlatTree(); | 346 Selection().ComputeVisibleSelectionInFlatTree(); |
| 346 | 347 |
| 347 // This only records the current behavior. It might be changed in the future. | 348 // This only records the current behavior. It might be changed in the future. |
| 348 EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Base()); | 349 EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Base()); |
| 349 EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Extent()); | 350 EXPECT_EQ(PositionInFlatTree(foo, 0), selection.Extent()); |
| 350 } | 351 } |
| 351 | 352 |
| 352 } // namespace blink | 353 } // namespace blink |
| OLD | NEW |