| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 "event.preventDefault());"); | 283 "event.preventDefault());"); |
| 284 document().body()->appendChild(script); | 284 document().body()->appendChild(script); |
| 285 document().updateStyleAndLayout(); | 285 document().updateStyleAndLayout(); |
| 286 document().frame()->selection().setSelection( | 286 document().frame()->selection().setSelection( |
| 287 SelectionInDOMTree::Builder() | 287 SelectionInDOMTree::Builder() |
| 288 .collapse(Position(document().body(), 0)) | 288 .collapse(Position(document().body(), 0)) |
| 289 .build()); | 289 .build()); |
| 290 WebMouseEvent mouseDownEvent( | 290 WebMouseEvent mouseDownEvent( |
| 291 WebMouseEvent::MouseDown, WebFloatPoint(0, 0), WebFloatPoint(100, 200), | 291 WebMouseEvent::MouseDown, WebFloatPoint(0, 0), WebFloatPoint(100, 200), |
| 292 WebPointerProperties::Button::Right, 1, | 292 WebPointerProperties::Button::Right, 1, |
| 293 PlatformEvent::Modifiers::RightButtonDown, TimeTicks::Now().InSeconds()); | 293 WebInputEvent::Modifiers::RightButtonDown, TimeTicks::Now().InSeconds()); |
| 294 mouseDownEvent.setFrameScale(1); | 294 mouseDownEvent.setFrameScale(1); |
| 295 EXPECT_EQ( | 295 EXPECT_EQ( |
| 296 WebInputEventResult::HandledApplication, | 296 WebInputEventResult::HandledApplication, |
| 297 document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent)); | 297 document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnTap) { | 300 TEST_F(EventHandlerTest, EmptyTextfieldInsertionOnTap) { |
| 301 setHtmlInnerHTML("<textarea cols=50 rows=50></textarea>"); | 301 setHtmlInnerHTML("<textarea cols=50 rows=50></textarea>"); |
| 302 | 302 |
| 303 TapEventBuilder singleTapEvent(IntPoint(200, 200), 1); | 303 TapEventBuilder singleTapEvent(IntPoint(200, 200), 1); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 398 } |
| 399 | 399 |
| 400 TEST_F(EventHandlerTest, dragEndInNewDrag) { | 400 TEST_F(EventHandlerTest, dragEndInNewDrag) { |
| 401 setHtmlInnerHTML( | 401 setHtmlInnerHTML( |
| 402 "<style>.box { width: 100px; height: 100px; display: block; }</style>" | 402 "<style>.box { width: 100px; height: 100px; display: block; }</style>" |
| 403 "<a class='box' href=''>Drag me</a>"); | 403 "<a class='box' href=''>Drag me</a>"); |
| 404 | 404 |
| 405 WebMouseEvent mouseDownEvent( | 405 WebMouseEvent mouseDownEvent( |
| 406 WebInputEvent::MouseDown, WebFloatPoint(50, 50), WebFloatPoint(50, 50), | 406 WebInputEvent::MouseDown, WebFloatPoint(50, 50), WebFloatPoint(50, 50), |
| 407 WebPointerProperties::Button::Left, 1, | 407 WebPointerProperties::Button::Left, 1, |
| 408 PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); | 408 WebInputEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); |
| 409 mouseDownEvent.setFrameScale(1); | 409 mouseDownEvent.setFrameScale(1); |
| 410 document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent); | 410 document().frame()->eventHandler().handleMousePressEvent(mouseDownEvent); |
| 411 | 411 |
| 412 WebMouseEvent mouseMoveEvent( | 412 WebMouseEvent mouseMoveEvent( |
| 413 WebInputEvent::MouseMove, WebFloatPoint(51, 50), WebFloatPoint(51, 50), | 413 WebInputEvent::MouseMove, WebFloatPoint(51, 50), WebFloatPoint(51, 50), |
| 414 WebPointerProperties::Button::Left, 1, | 414 WebPointerProperties::Button::Left, 1, |
| 415 PlatformEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); | 415 WebInputEvent::Modifiers::LeftButtonDown, TimeTicks::Now().InSeconds()); |
| 416 mouseMoveEvent.setFrameScale(1); | 416 mouseMoveEvent.setFrameScale(1); |
| 417 document().frame()->eventHandler().handleMouseMoveEvent( | 417 document().frame()->eventHandler().handleMouseMoveEvent( |
| 418 mouseMoveEvent, Vector<WebMouseEvent>()); | 418 mouseMoveEvent, Vector<WebMouseEvent>()); |
| 419 | 419 |
| 420 // This reproduces what might be the conditions of http://crbug.com/677916 | 420 // This reproduces what might be the conditions of http://crbug.com/677916 |
| 421 // | 421 // |
| 422 // TODO(crbug.com/682047): The call sequence below should not occur outside | 422 // TODO(crbug.com/682047): The call sequence below should not occur outside |
| 423 // this contrived test. Given the current code, it is unclear how the | 423 // this contrived test. Given the current code, it is unclear how the |
| 424 // dragSourceEndedAt() call could occur before a drag operation is started. | 424 // dragSourceEndedAt() call could occur before a drag operation is started. |
| 425 | 425 |
| 426 WebMouseEvent mouseUpEvent( | 426 WebMouseEvent mouseUpEvent( |
| 427 WebInputEvent::MouseUp, WebFloatPoint(100, 50), WebFloatPoint(200, 250), | 427 WebInputEvent::MouseUp, WebFloatPoint(100, 50), WebFloatPoint(200, 250), |
| 428 WebPointerProperties::Button::Left, 1, | 428 WebPointerProperties::Button::Left, 1, WebInputEvent::NoModifiers, |
| 429 static_cast<PlatformEvent::Modifiers>(0), TimeTicks::Now().InSeconds()); | 429 TimeTicks::Now().InSeconds()); |
| 430 mouseUpEvent.setFrameScale(1); | 430 mouseUpEvent.setFrameScale(1); |
| 431 document().frame()->eventHandler().dragSourceEndedAt(mouseUpEvent, | 431 document().frame()->eventHandler().dragSourceEndedAt(mouseUpEvent, |
| 432 DragOperationNone); | 432 DragOperationNone); |
| 433 | 433 |
| 434 // This test passes if it doesn't crash. | 434 // This test passes if it doesn't crash. |
| 435 } | 435 } |
| 436 | 436 |
| 437 } // namespace blink | 437 } // namespace blink |
| OLD | NEW |