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/VisibleSelection.h" | 5 #include "core/editing/VisibleSelection.h" |
| 6 | 6 |
| 7 #include "core/dom/Range.h" | 7 #include "core/dom/Range.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 #include "core/editing/SelectionAdjuster.h" | 9 #include "core/editing/SelectionAdjuster.h" |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 VisibleSelectionTemplate<Strategy> expandUsingGranularity( | 63 VisibleSelectionTemplate<Strategy> expandUsingGranularity( |
| 64 const VisibleSelectionTemplate<Strategy>& selection, | 64 const VisibleSelectionTemplate<Strategy>& selection, |
| 65 TextGranularity granularity) { | 65 TextGranularity granularity) { |
| 66 return createVisibleSelection( | 66 return createVisibleSelection( |
| 67 typename SelectionTemplate<Strategy>::Builder() | 67 typename SelectionTemplate<Strategy>::Builder() |
| 68 .setBaseAndExtent(selection.base(), selection.extent()) | 68 .setBaseAndExtent(selection.base(), selection.extent()) |
| 69 .setGranularity(granularity) | 69 .setGranularity(granularity) |
| 70 .build()); | 70 .build()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // For http://crbug.com/700368 | |
| 74 TEST_F(VisibleSelectionTest, appendTrailingWhitespaceWithAfterAnchor) { | |
| 75 setBodyContent( | |
| 76 "<input type=checkbox>" | |
| 77 "<div style='user-select:none'>abc</div>"); | |
| 78 Element* const input = document().querySelector("input"); | |
| 79 | |
| 80 // Simulate double-clicking "abc" | |
|
yoichio
2017/03/15 04:49:29
double-clicking on user-select:none should not sel
yosin_UTC9
2017/03/15 05:34:26
No, this is current behavior and the test case pro
| |
| 81 VisibleSelection selection = | |
| 82 createVisibleSelection(SelectionInDOMTree::Builder() | |
| 83 .collapse(Position::beforeNode(input)) | |
| 84 .extend(Position::afterNode(input)) | |
| 85 .setGranularity(WordGranularity) | |
| 86 .build()); | |
| 87 selection.appendTrailingWhitespace(); | |
| 88 | |
| 89 EXPECT_EQ(Position::beforeNode(input), selection.start()); | |
| 90 EXPECT_EQ(Position::afterNode(input), selection.end()); | |
| 91 } | |
| 92 | |
| 73 TEST_F(VisibleSelectionTest, expandUsingGranularity) { | 93 TEST_F(VisibleSelectionTest, expandUsingGranularity) { |
| 74 const char* bodyContent = | 94 const char* bodyContent = |
| 75 "<span id=host><a id=one>1</a><a id=two>22</a></span>"; | 95 "<span id=host><a id=one>1</a><a id=two>22</a></span>"; |
| 76 const char* shadowContent = | 96 const char* shadowContent = |
| 77 "<p><b id=three>333</b><content select=#two></content><b " | 97 "<p><b id=three>333</b><content select=#two></content><b " |
| 78 "id=four>4444</b><span id=space> </span><content " | 98 "id=four>4444</b><span id=space> </span><content " |
| 79 "select=#one></content><b id=five>55555</b></p>"; | 99 "select=#one></content><b id=five>55555</b></p>"; |
| 80 setBodyContent(bodyContent); | 100 setBodyContent(bodyContent); |
| 81 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 101 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| 82 | 102 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 Element* host = document().getElementById("host"); | 528 Element* host = document().getElementById("host"); |
| 509 host->appendChild(sample); | 529 host->appendChild(sample); |
| 510 document().updateStyleAndLayout(); | 530 document().updateStyleAndLayout(); |
| 511 | 531 |
| 512 // Simulates to restore selection from undo stack. | 532 // Simulates to restore selection from undo stack. |
| 513 selection = createVisibleSelection(selection.asSelection()); | 533 selection = createVisibleSelection(selection.asSelection()); |
| 514 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start()); | 534 EXPECT_EQ(Position(sample->firstChild(), 0), selection.start()); |
| 515 } | 535 } |
| 516 | 536 |
| 517 } // namespace blink | 537 } // namespace blink |
| OLD | NEW |