Changeset 139044 in webkit
- Timestamp:
- Jan 8, 2013 12:57:56 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r139040 r139044 1 2013-01-08 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 Hajime Morita. 7 8 This patch adds new test for autoscroll during drag-and-drop. 9 10 * fast/events/drag-and-drop-autoscroll-expected.txt: Added. 11 * fast/events/drag-and-drop-autoscroll.html: Added. 12 1 13 2013-01-08 Yuki Sekiguchi <yuki.sekiguchi@access-company.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r139043 r139044 1 2013-01-08 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 Hajime Morita. 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/AutoscrollController.cpp: 19 (WebCore::AutoscrollController::AutoscrollController): Changed to initialize m_dragAndDropAutoscrollStartTime. 20 (WebCore::AutoscrollController::updateDragAndDrop): Added for start/stop autoscroll during drag-and-drop. 21 (WebCore::AutoscrollController::autoscrollTimerFired): Changed to add autoscroll for drag-and-drop, and to pass last know position to RenderBox::autoscroll(). 22 * page/AutoscrollController.h: 23 (AutoscrollController): Changed to add updateDragAndDrop() and m_dragAndDropAutoscrollReferencePosition and m_dragAndDropAutoscrollStartTime. 24 * page/EventHandler.cpp: 25 (WebCore::EventHandler::updateDragAndDrop): Changed to call AutoscrollController::updateDragAndDrop(). 26 * rendering/RenderBox.cpp: 27 (WebCore::RenderBox::autoscroll): Changed for new parameter position. 28 (WebCore::RenderBox::calculateAutoscrollDirection): Added for autoscroll. 29 * rendering/RenderBox.h: 30 (RenderBox): 31 * rendering/RenderLayer.cpp: 32 (WebCore::RenderLayer::autoscroll): Changed for new parameter position and move updateSelectionForMouseDrag() to AutoscrollController. 33 * rendering/RenderLayer.h: 34 (RenderLayer): 35 * rendering/RenderListBox.cpp: 36 (WebCore::RenderListBox::autoscroll): Changed for new parameter position. 37 * rendering/RenderListBox.h: 38 (RenderListBox): 39 * rendering/RenderTextControlSingleLine.cpp: 40 (WebCore::RenderTextControlSingleLine::autoscroll): Changed for new parameter position. 41 * rendering/RenderTextControlSingleLine.h: 42 (RenderTextControlSingleLine): 43 1 44 2013-01-08 Jochen Eisinger <jochen@chromium.org> 2 45 -
trunk/Source/WebCore/page/AutoscrollController.cpp
r137726 r139044 36 36 #include "RenderBox.h" 37 37 #include "ScrollView.h" 38 #include <wtf/CurrentTime.h> 38 39 39 40 namespace WebCore { 41 42 // Delay time in second for start autoscroll if pointer is in border edge of scrollable element. 43 static double autoscrollDelay = 0.2; 40 44 41 45 // When the autoscroll or the panScroll is triggered when do the scroll every 0.05s to make it smooth … … 54 58 , m_autoscrollRenderer(0) 55 59 , m_autoscrollType(NoAutoscroll) 60 , m_dragAndDropAutoscrollStartTime(0) 56 61 #if ENABLE(PAN_SCROLLING) 57 62 , m_panScrollButtonPressed(false) … … 145 150 } 146 151 152 void AutoscrollController::updateDragAndDrop(Node* dropTargetNode, const IntPoint& eventPosition, double eventTime) 153 { 154 if (!dropTargetNode) { 155 stopAutoscrollTimer(); 156 return; 157 } 158 159 RenderBox* scrollable = RenderBox::findAutoscrollable(dropTargetNode->renderer()); 160 if (!scrollable) { 161 stopAutoscrollTimer(); 162 return; 163 } 164 165 IntSize offset = scrollable->calculateAutoscrollDirection(eventPosition); 166 if (offset.isZero()) { 167 stopAutoscrollTimer(); 168 return; 169 } 170 171 m_dragAndDropAutoscrollReferencePosition = eventPosition + offset; 172 173 if (m_autoscrollType == NoAutoscroll) { 174 m_autoscrollType = AutoscrollForDragAndDrop; 175 m_autoscrollRenderer = scrollable; 176 m_dragAndDropAutoscrollStartTime = eventTime; 177 startAutoscrollTimer(); 178 } else if (m_autoscrollRenderer != scrollable) { 179 m_dragAndDropAutoscrollStartTime = eventTime; 180 m_autoscrollRenderer = scrollable; 181 } 182 } 183 147 184 #if ENABLE(PAN_SCROLLING) 148 185 void AutoscrollController::didPanScrollStart() … … 201 238 Frame* frame = m_autoscrollRenderer->frame(); 202 239 switch (m_autoscrollType) { 203 case AutoscrollForSelection: 204 if (!frame->eventHandler()->mousePressed()) { 240 case AutoscrollForDragAndDrop: 241 if (WTF::currentTime() - m_dragAndDropAutoscrollStartTime > autoscrollDelay) 242 m_autoscrollRenderer->autoscroll(m_dragAndDropAutoscrollReferencePosition); 243 break; 244 case AutoscrollForSelection: { 245 EventHandler* eventHandler = frame->eventHandler(); 246 if (!eventHandler->mousePressed()) { 205 247 stopAutoscrollTimer(); 206 248 return; 207 249 } 208 m_autoscrollRenderer->autoscroll(); 250 eventHandler->updateSelectionForMouseDrag(); 251 m_autoscrollRenderer->autoscroll(eventHandler->lastKnownMousePosition()); 209 252 break; 253 } 210 254 case NoAutoscroll: 211 255 break; -
trunk/Source/WebCore/page/AutoscrollController.h
r137726 r139044 35 35 class Frame; 36 36 class FrameView; 37 class Node; 37 38 class PlatformMouseEvent; 38 39 class RenderBox; … … 41 42 enum AutoscrollType { 42 43 NoAutoscroll, 44 AutoscrollForDragAndDrop, 43 45 AutoscrollForSelection, 44 46 #if ENABLE(PAN_SCROLLING) … … 57 59 void stopAutoscrollTimer(bool rendererIsBeingDestroyed = false); 58 60 void updateAutoscrollRenderer(); 61 void updateDragAndDrop(Node* targetNode, const IntPoint& eventPosition, double eventTime); 59 62 #if ENABLE(PAN_SCROLLING) 60 63 void didPanScrollStart(); … … 75 78 RenderBox* m_autoscrollRenderer; 76 79 AutoscrollType m_autoscrollType; 80 IntPoint m_dragAndDropAutoscrollReferencePosition; 81 double m_dragAndDropAutoscrollStartTime; 77 82 #if ENABLE(PAN_SCROLLING) 78 83 IntPoint m_panScrollStartPos; -
trunk/Source/WebCore/page/EventHandler.cpp
r139022 r139044 1964 1964 newTarget = newTarget->parentNode(); 1965 1965 1966 m_autoscrollController->updateDragAndDrop(newTarget.get(), event.position(), event.timestamp()); 1967 1966 1968 if (m_dragTarget != newTarget) { 1967 1969 // FIXME: this ordering was explicitly chosen to match WinIE. However, -
trunk/Source/WebCore/rendering/RenderBox.cpp
r139013 r139044 82 82 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = 0; 83 83 84 85 // Size of border belt for autoscroll. When mouse pointer in border belt, 86 // autoscroll is started. 87 static const int autoscrollBeltSize = 20; 88 84 89 bool RenderBox::s_hadOverflowClip = false; 85 90 … … 681 686 } 682 687 683 void RenderBox::autoscroll( )688 void RenderBox::autoscroll(const IntPoint& position) 684 689 { 685 690 if (layer()) 686 layer()->autoscroll( );691 layer()->autoscroll(position); 687 692 } 688 693 … … 706 711 Page* page = frame->page(); 707 712 return page && page->mainFrame() == frame; 713 } 714 715 // If specified point is in border belt, returned offset denotes direction of 716 // scrolling. 717 IntSize RenderBox::calculateAutoscrollDirection(const IntPoint& windowPoint) const 718 { 719 if (!frame()) 720 return IntSize(); 721 722 FrameView* frameView = frame()->view(); 723 if (!frameView) 724 return IntSize(); 725 726 IntSize offset; 727 IntPoint point = frameView->windowToContents(windowPoint); 728 IntRect box(absoluteBoundingBoxRect()); 729 730 if (point.x() < box.x() + autoscrollBeltSize) 731 point.move(-autoscrollBeltSize, 0); 732 else if (point.x() > box.maxX() - autoscrollBeltSize) 733 point.move(autoscrollBeltSize, 0); 734 735 if (point.y() < box.y() + autoscrollBeltSize) 736 point.move(0, -autoscrollBeltSize); 737 else if (point.y() > box.maxY() - autoscrollBeltSize) 738 point.move(0, autoscrollBeltSize); 739 return frameView->contentsToWindow(point) - windowPoint; 708 740 } 709 741 -
trunk/Source/WebCore/rendering/RenderBox.h
r139013 r139044 444 444 bool canBeScrolledAndHasScrollableArea() const; 445 445 virtual bool canBeProgramaticallyScrolled() const; 446 virtual void autoscroll( );446 virtual void autoscroll(const IntPoint&); 447 447 bool canAutoscroll() const; 448 IntSize calculateAutoscrollDirection(const IntPoint& windowPoint) const; 448 449 static RenderBox* findAutoscrollable(RenderObject*); 449 450 virtual void stopAutoscroll() { } -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r138823 r139044 2292 2292 } 2293 2293 2294 void RenderLayer::autoscroll( )2294 void RenderLayer::autoscroll(const IntPoint& position) 2295 2295 { 2296 2296 Frame* frame = renderer()->frame(); … … 2302 2302 return; 2303 2303 2304 #if ENABLE(DRAG_SUPPORT) 2305 frame->eventHandler()->updateSelectionForMouseDrag(); 2306 #endif 2307 2308 IntPoint currentDocumentPosition = frameView->windowToContents(frame->eventHandler()->lastKnownMousePosition()); 2304 IntPoint currentDocumentPosition = frameView->windowToContents(position); 2309 2305 scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded); 2310 2306 } -
trunk/Source/WebCore/rendering/RenderLayer.h
r138809 r139044 375 375 376 376 bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); 377 void autoscroll( );377 void autoscroll(const IntPoint&); 378 378 379 379 void resize(const PlatformMouseEvent&, const LayoutSize&); -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r137539 r139044 555 555 } 556 556 557 void RenderListBox::autoscroll( )557 void RenderListBox::autoscroll(const IntPoint&) 558 558 { 559 559 IntPoint pos = frame()->view()->windowToContents(frame()->eventHandler()->lastKnownMousePosition()); -
trunk/Source/WebCore/rendering/RenderListBox.h
r137539 r139044 85 85 86 86 virtual bool canBeProgramaticallyScrolled() const { return true; } 87 virtual void autoscroll( );87 virtual void autoscroll(const IntPoint&); 88 88 virtual void stopAutoscroll(); 89 89 -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r133976 r139044 382 382 } 383 383 384 void RenderTextControlSingleLine::autoscroll( )384 void RenderTextControlSingleLine::autoscroll(const IntPoint& position) 385 385 { 386 386 RenderLayer* layer = innerTextElement()->renderBox()->layer(); 387 387 if (layer) 388 layer->autoscroll( );388 layer->autoscroll(position); 389 389 } 390 390 -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h
r126859 r139044 59 59 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE; 60 60 61 virtual void autoscroll( );61 virtual void autoscroll(const IntPoint&); 62 62 63 63 // Subclassed to forward to our inner div. -
trunk/Source/WebKit/chromium/ChangeLog
r139037 r139044 1 2013-01-08 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 Hajime Morita. 7 8 This patch removes DragScrollTimer used for automatic scrolling of main 9 frame drag-and-drop which is now implemented in EventHandler. 10 11 Another patch will remove DragScrollTimer.{cpp,h} and update GYP files to 12 make patch size small. 13 14 No tests. Existing test covers this change. 15 16 * src/WebViewImpl.cpp: 17 (WebKit::WebViewImpl::WebViewImpl): Changed to remove m_dragScrollTimer. 18 (WebKit::WebViewImpl::dragSourceEndedAt): ditto 19 (WebKit::WebViewImpl::dragSourceMovedTo): ditto 20 (WebKit::WebViewImpl::dragTargetDrop): ditto 21 (WebKit::WebViewImpl::dragTargetDragEnterOrOver): ditto 22 * src/WebViewImpl.h: 23 (WebKit): Chagned to remove DragScrollTimer. 24 1 25 2013-01-07 Steve Block <steveblock@chromium.org> 2 26 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r139017 r139044 54 54 #include "DragController.h" 55 55 #include "DragData.h" 56 #include "DragScrollTimer.h"57 56 #include "DragSession.h" 58 57 #include "Editor.h" … … 415 414 , m_isTransparent(false) 416 415 , m_tabsToLinks(false) 417 , m_dragScrollTimer(adoptPtr(new DragScrollTimer))418 416 , m_isCancelingFullScreen(false) 419 417 , m_benchmarkSupport(this) … … 3228 3226 m_page->mainFrame()->eventHandler()->dragSourceEndedAt(pme, 3229 3227 static_cast<DragOperation>(operation)); 3230 m_dragScrollTimer->stop();3231 3228 } 3232 3229 … … 3236 3233 WebDragOperation operation) 3237 3234 { 3238 m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);3239 3235 } 3240 3236 … … 3322 3318 m_dragOperation = WebDragOperationNone; 3323 3319 m_currentDragData = 0; 3324 3325 m_dragScrollTimer->stop();3326 3320 } 3327 3321 … … 3350 3344 3351 3345 m_dragOperation = static_cast<WebDragOperation>(dropEffect); 3352 3353 if (dragAction == DragOver)3354 m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);3355 else3356 m_dragScrollTimer->stop();3357 3346 3358 3347 return m_dragOperation; -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r138859 r139044 90 90 class ContextMenuClientImpl; 91 91 class DeviceOrientationClientProxy; 92 class DragScrollTimer;93 92 class GeolocationClientProxy; 94 93 class LinkHighlight; … … 813 812 typedef HashMap<WTF::String, WTF::String> SettingsMap; 814 813 OwnPtr<SettingsMap> m_inspectorSettingsMap; 815 OwnPtr<DragScrollTimer> m_dragScrollTimer;816 814 817 815 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
Note: See TracChangeset
for help on using the changeset viewer.