| 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/input/EventHandler.h" | 5 #include "core/input/EventHandler.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/Range.h" | 8 #include "core/dom/Range.h" |
| 9 #include "core/editing/Editor.h" | 9 #include "core/editing/Editor.h" |
| 10 #include "core/editing/FrameSelection.h" | 10 #include "core/editing/FrameSelection.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 ASSERT_TRUE(selection().isCaret()); | 156 ASSERT_TRUE(selection().isCaret()); |
| 157 EXPECT_EQ(Position(line, 0), selection().start()); | 157 EXPECT_EQ(Position(line, 0), selection().start()); |
| 158 | 158 |
| 159 // Multi-tap events on editable elements should trigger selection, just | 159 // Multi-tap events on editable elements should trigger selection, just |
| 160 // like multi-click events. | 160 // like multi-click events. |
| 161 TapEventBuilder doubleTapEvent(IntPoint(0, 0), 2); | 161 TapEventBuilder doubleTapEvent(IntPoint(0, 0), 2); |
| 162 document().frame()->eventHandler().handleGestureEvent(doubleTapEvent); | 162 document().frame()->eventHandler().handleGestureEvent(doubleTapEvent); |
| 163 ASSERT_TRUE(selection().isRange()); | 163 ASSERT_TRUE(selection().isRange()); |
| 164 EXPECT_EQ(Position(line, 0), selection().start()); | 164 EXPECT_EQ(Position(line, 0), selection().start()); |
| 165 if (document().frame()->editor().isSelectTrailingWhitespaceEnabled()) { | 165 if (document().frame()->editor().isSelectTrailingWhitespaceEnabled()) { |
| 166 EXPECT_EQ(Position(line, 4), selection().end()); | 166 EXPECT_EQ(Position(line, 4), |
| 167 selection().computeVisibleSelectionInDOMTreeDeprecated().end()); |
| 167 EXPECT_EQ("One ", WebString(selection().selectedText()).utf8()); | 168 EXPECT_EQ("One ", WebString(selection().selectedText()).utf8()); |
| 168 } else { | 169 } else { |
| 169 EXPECT_EQ(Position(line, 3), selection().end()); | 170 EXPECT_EQ(Position(line, 3), |
| 171 selection().computeVisibleSelectionInDOMTreeDeprecated().end()); |
| 170 EXPECT_EQ("One", WebString(selection().selectedText()).utf8()); | 172 EXPECT_EQ("One", WebString(selection().selectedText()).utf8()); |
| 171 } | 173 } |
| 172 | 174 |
| 173 TapEventBuilder tripleTapEvent(IntPoint(0, 0), 3); | 175 TapEventBuilder tripleTapEvent(IntPoint(0, 0), 3); |
| 174 document().frame()->eventHandler().handleGestureEvent(tripleTapEvent); | 176 document().frame()->eventHandler().handleGestureEvent(tripleTapEvent); |
| 175 ASSERT_TRUE(selection().isRange()); | 177 ASSERT_TRUE(selection().isRange()); |
| 176 EXPECT_EQ(Position(line, 0), selection().start()); | 178 EXPECT_EQ(Position(line, 0), selection().start()); |
| 177 EXPECT_EQ(Position(line, 13), selection().end()); | 179 EXPECT_EQ(Position(line, 13), |
| 180 selection().computeVisibleSelectionInDOMTreeDeprecated().end()); |
| 178 EXPECT_EQ("One Two Three", WebString(selection().selectedText()).utf8()); | 181 EXPECT_EQ("One Two Three", WebString(selection().selectedText()).utf8()); |
| 179 } | 182 } |
| 180 | 183 |
| 181 TEST_F(EventHandlerTest, multiClickSelectionFromTapDisabledIfNotEditable) { | 184 TEST_F(EventHandlerTest, multiClickSelectionFromTapDisabledIfNotEditable) { |
| 182 setHtmlInnerHTML( | 185 setHtmlInnerHTML( |
| 183 "<style> body { margin: 0px; } .line { display: block; width: 300px; " | 186 "<style> body { margin: 0px; } .line { display: block; width: 300px; " |
| 184 "height: 30px; } </style>" | 187 "height: 30px; } </style>" |
| 185 "<span class='line' id='line'>One Two Three</span>"); | 188 "<span class='line' id='line'>One Two Three</span>"); |
| 186 | 189 |
| 187 Node* line = document().getElementById("line")->firstChild(); | 190 Node* line = document().getElementById("line")->firstChild(); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 WebPointerProperties::Button::Left, 1, WebInputEvent::NoModifiers, | 432 WebPointerProperties::Button::Left, 1, WebInputEvent::NoModifiers, |
| 430 TimeTicks::Now().InSeconds()); | 433 TimeTicks::Now().InSeconds()); |
| 431 mouseUpEvent.setFrameScale(1); | 434 mouseUpEvent.setFrameScale(1); |
| 432 document().frame()->eventHandler().dragSourceEndedAt(mouseUpEvent, | 435 document().frame()->eventHandler().dragSourceEndedAt(mouseUpEvent, |
| 433 DragOperationNone); | 436 DragOperationNone); |
| 434 | 437 |
| 435 // This test passes if it doesn't crash. | 438 // This test passes if it doesn't crash. |
| 436 } | 439 } |
| 437 | 440 |
| 438 } // namespace blink | 441 } // namespace blink |
| OLD | NEW |