12012-12-04 Yoshifumi Inoue <yosin@chromium.org>
2
3 Dragging over an element with scrollbars should scroll the element when dragging near edges
4 https://bugs.webkit.org/show_bug.cgi?id=39725
5
6 Reviewed by NOBODY (OOPS!).
7
8 This patch introduces auto scrolling functionality during drag-and-drop
9 when drop source is near edge of scrollable element.
10
11 When drop source is inside 20px of scrollable element more than 200ms,
12 scrollable element is automatically scrolled every 50ms toward drop
13 source position, e.g. vertically scroll up when drop source is in top
14 edge.
15
16 Test: fast/events/drag-and-drop-autoscroll.html
17
18 * page/EventHandler.cpp:
19 (canAutoscroll): Moved to RenderBox class.
20 (WebCore::EventHandler::EventHandler): Changed to initialize m_autoscrollStartTime and m_autoscollForDragAndRopInprogress.
21 (WebCore::calculateAutoscrollDirection): Added to calculate autoscroll direction for drag-and-drop.
22 (WebCore::EventHandler::handleMouseDraggedEvent): Changed to use RenderObject::findAutoscrollableRenderer().
23 (WebCore::EventHandler::autoscrollTimerFired): Changed to support autoscroll for drag-and-drop and moved calling updateSelectionForMouseDrag() from RenderLayer::autoscroll().
24 (WebCore::EventHandler::updateAutoscrollRenderer): Changed to use RenderObject::canAutoscoll().
25 (WebCore::EventHandler::stopAutoscrollTimer): Changed to reset m_autoscrollForDragAndDropInProgress and m_autoscrollStartTime.
26 (WebCore::EventHandler::updateDragAndDrop): Changed to call handleAutoscroll() if needed.
27 (WebCore::EventHandler::clearDragState): Changed to call stopAutoscrollTimer() to stop autoscroll during drag-and-drop.
28 * page/EventHandler.h: Changed to move updateSelectionForMouseDrag() to private and add m_autoscrollStartTime and m_autoscollForDragAndRopInprogress.
29 * rendering/RenderBox.cpp:
30 (WebCore::RenderBox::autoscroll): Changed to add new parameter position.
31 (WebCore::RenderBox::canAutoscroll): Moved from EventHandler.cpp.
32 * rendering/RenderBox.h:
33 (RenderBox): Changed to add new parameter to autoscroll() and to add new function canAutoscroll() and findAutoscrollableRenderer().
34 * rendering/RenderLayer.cpp:
35 (WebCore::RenderLayer::autoscroll): Changed to use position parameter instead of EventHandler::currentMousePosition() and to move call of EventHandler::updateSelectionForMouseDrag() to EventHandler::autoscrollTimerFired().
36 * rendering/RenderLayer.h:
37 (RenderLayer): Changed for new parameter position to autoscroll().
38 * rendering/RenderListBox.cpp:
39 (WebCore::RenderListBox::autoscroll): Change to add new parameter to autoscroll().
40 * rendering/RenderListBox.h:
41 (RenderListBox): Change to add new parameter to autoscroll().
42 * rendering/RenderObject.cpp:
43 (WebCore::RenderObject::findAutoscrollableRenderer): Added.
44 * rendering/RenderObject.h:
45 (RenderObject): Added canAutoscroll() and findAutoscrollableRenderer().
46 * rendering/RenderTextControlSingleLine.cpp:
47 (WebCore::RenderTextControlSingleLine::autoscroll): Changed to add new parameter to autoscroll()
48 * rendering/RenderTextControlSingleLine.h:
49 (RenderTextControlSingleLine): Changed to add new parameter to autoscroll()
50