Source/WebCore/ChangeLog

 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
1512012-12-05 Kentaro Hara <haraken@chromium.org>
252
353 [V8] Remove addImplicitReferencesForNodeWithEventListeners()

Source/WebKit/chromium/ChangeLog

 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 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):
 18 (WebKit::WebViewImpl::dragSourceEndedAt):
 19 (WebKit::WebViewImpl::dragSourceMovedTo):
 20 (WebKit::WebViewImpl::dragTargetDrop):
 21 (WebKit::WebViewImpl::dragTargetDragEnterOrOver):
 22 * src/WebViewImpl.h:
 23 (WebKit):
 24
1252012-12-05 Greg Billock <gbillock@google.com>
226
327 Add runtime enable for web intents.

Source/WebCore/page/EventHandler.cpp

@@const int CompositionEventKeyCode = 229;
133133using namespace SVGNames;
134134#endif
135135
 136// Delay time in second for start autoscroll if pointer is in border edge of scrollable element.
 137const double autoscrollDelay = 0.2;
 138
 139// Size of border belt for autoscroll. When mouse pointer in border belt,
 140// autoscroll is started.
 141const int autoscrollBeltSize = 20;
 142
136143// When the autoscroll or the panScroll is triggered when do the scroll every 0.05s to make it smooth
137144const double autoscrollInterval = 0.05;
138145

@@const double fakeMouseMoveIntervalReductionFraction = 0.75;
151158enum NoCursorChangeType { NoCursorChange };
152159
153160class OptionalCursor {
 161
154162public:
155163 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) { }
156164 OptionalCursor(const Cursor& cursor) : m_isCursorChange(true), m_cursor(cursor) { }

@@EventHandler::EventHandler(Frame* frame)
338346 , m_hoverTimer(this, &EventHandler::hoverTimerFired)
339347 , m_autoscrollTimer(this, &EventHandler::autoscrollTimerFired)
340348 , m_autoscrollRenderer(0)
 349 , m_autoscrollStartTime(0)
341350 , m_autoscrollInProgress(false)
 351 , m_autoscrollForDragAndDropInProgress(false)
342352 , m_mouseDownMayStartAutoscroll(false)
343353 , m_mouseDownWasInSubframe(false)
344354 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFired, fakeMouseMoveMinimumInterval)

@@bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
700710 return swallowEvent;
701711}
702712
703 // There are two kinds of renderer that can autoscroll.
704 static bool canAutoscroll(RenderObject* renderer)
 713// If specified point is in border belt, returned offset denotes direction of
 714// scrolling.
 715static IntSize calculateAutoscrollDirection(RenderObject* renderer, const IntPoint& windowPoint)
705716{
706  if (!renderer->isBox())
707  return false;
 717 IntSize offset;
708718
709  // Check for a box that can be scrolled in its own right.
710  if (toRenderBox(renderer)->canBeScrolledAndHasScrollableArea())
711  return true;
712 
713  // Check for a box that represents the top level of a web page.
714  // This can be scrolled by calling Chrome::scrollRectIntoView.
715  // This only has an effect on the Mac platform in applications
716  // that put web views into scrolling containers, such as Mac OS X Mail.
717  // The code for this is in RenderLayer::scrollRectToVisible.
718  if (renderer->node() != renderer->document())
719  return false;
720719 Frame* frame = renderer->frame();
721720 if (!frame)
722  return false;
723  Page* page = frame->page();
724  return page && page->mainFrame() == frame;
 721 return IntSize();
 722
 723 FrameView* frameView = frame->view();
 724 if (!frameView)
 725 return IntSize();
 726
 727 IntPoint point = frameView->windowToContents(windowPoint);
 728 IntRect box(renderer->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
 740 return frameView->contentsToWindow(point) - windowPoint;
725741}
726742
727743#if ENABLE(DRAG_SUPPORT)

@@bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& e
751767 m_mouseDownMayStartDrag = false;
752768
753769 if (m_mouseDownMayStartAutoscroll && !m_panScrollInProgress) {
754  // Find a renderer that can autoscroll.
755  while (renderer && !canAutoscroll(renderer)) {
756  if (!renderer->parent() && renderer->node() == renderer->document() && renderer->document()->ownerElement())
757  renderer = renderer->document()->ownerElement()->renderer();
758  else
759  renderer = renderer->parent();
760  }
761 
762  if (renderer) {
 770 if (RenderObject* scrollable = renderer->findAutoscrollableRenderer()) {
763771 m_autoscrollInProgress = true;
764  handleAutoscroll(renderer);
 772 handleAutoscroll(scrollable);
765773 }
766 
767774 m_mouseDownMayStartAutoscroll = false;
768775 }
769776

@@void EventHandler::autoscrollTimerFired(Timer<EventHandler>*)
10191026 return;
10201027 }
10211028
 1029 if (m_autoscrollForDragAndDropInProgress) {
 1030 if (currentTime() - m_autoscrollStartTime > autoscrollDelay)
 1031 toRenderBox(r)->autoscroll(m_autoscrollReferencePoint);
 1032 return;
 1033 }
 1034
10221035 if (m_autoscrollInProgress) {
10231036 if (!m_mousePressed) {
10241037 stopAutoscrollTimer();
10251038 return;
10261039 }
1027  toRenderBox(r)->autoscroll();
 1040#if ENABLE(DRAG_SUPPORT)
 1041 updateSelectionForMouseDrag();
 1042#endif
 1043 toRenderBox(r)->autoscroll(currentMousePosition());
10281044 } else {
10291045 // we verify that the main frame hasn't received the order to stop the panScroll
10301046 if (Page* page = m_frame->page()) {

@@void EventHandler::updateAutoscrollRenderer()
11051121 if (Node* nodeAtPoint = hitTest.innerNode())
11061122 m_autoscrollRenderer = nodeAtPoint->renderer();
11071123
1108  while (m_autoscrollRenderer && !canAutoscroll(m_autoscrollRenderer))
 1124 while (m_autoscrollRenderer && !m_autoscrollRenderer->canAutoscroll())
11091125 m_autoscrollRenderer = m_autoscrollRenderer->parent();
11101126}
11111127

@@void EventHandler::stopAutoscrollTimer(bool rendererIsBeingDestroyed)
12081224 }
12091225
12101226 if (autoscrollRenderer()) {
1211  if (!rendererIsBeingDestroyed && (m_autoscrollInProgress || m_panScrollInProgress))
 1227 if (!rendererIsBeingDestroyed && (m_autoscrollInProgress || m_panScrollInProgress || m_autoscrollForDragAndDropInProgress))
12121228 toRenderBox(autoscrollRenderer())->stopAutoscroll();
12131229#if ENABLE(PAN_SCROLLING)
12141230 if (m_panScrollInProgress) {

@@void EventHandler::stopAutoscrollTimer(bool rendererIsBeingDestroyed)
12351251 }
12361252
12371253 m_autoscrollInProgress = false;
 1254 m_autoscrollForDragAndDropInProgress = false;
 1255 m_autoscrollStartTime = 0;
12381256}
12391257
12401258Node* EventHandler::mousePressNode() const

@@bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard*
21062124
21072125 HitTestRequest request(HitTestRequest::ReadOnly);
21082126 MouseEventWithHitTestResults mev = prepareMouseEvent(request, event);
 2127 m_autoscrollReferencePoint = event.position();
21092128
21102129 // Drag events should never go to text nodes (following IE, and proper mouseover/out dispatch)
21112130 RefPtr<Node> newTarget = mev.targetNode();
21122131 if (newTarget && newTarget->isTextNode())
21132132 newTarget = newTarget->parentNode();
21142133
 2134 RenderObject* renderer = newTarget ? newTarget->renderer() : 0;
 2135 RenderObject* scrollable = renderer ? renderer->findAutoscrollableRenderer() : 0;
 2136 IntSize offset = scrollable ? calculateAutoscrollDirection(scrollable, m_autoscrollReferencePoint) : IntSize();
 2137 if (offset.isZero())
 2138 stopAutoscrollTimer();
 2139 else {
 2140 m_autoscrollReferencePoint += offset;
 2141 if (autoscrollRenderer() != scrollable)
 2142 m_autoscrollStartTime = event.timestamp();
 2143 m_autoscrollForDragAndDropInProgress = true;
 2144 handleAutoscroll(scrollable);
 2145 }
 2146
21152147 if (m_dragTarget != newTarget) {
21162148 // FIXME: this ordering was explicitly chosen to match WinIE. However,
21172149 // it is sometimes incorrect when dragging within subframes, as seen with

@@bool EventHandler::performDragAndDrop(const PlatformMouseEvent& event, Clipboard
21952227
21962228void EventHandler::clearDragState()
21972229{
 2230 stopAutoscrollTimer();
21982231 m_dragTarget = 0;
21992232 m_capturingMouseEventsNode = 0;
22002233 m_shouldOnlyFireDragOverEvent = false;

Source/WebCore/page/EventHandler.h

@@public:
102102 void clear();
103103 void nodeWillBeRemoved(Node*);
104104
105 #if ENABLE(DRAG_SUPPORT)
106  void updateSelectionForMouseDrag();
107 #endif
108 
109105 Node* mousePressNode() const;
110106 void setMousePressNode(PassRefPtr<Node>);
111107

@@private:
353349 bool eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&);
354350#endif
355351
 352 void updateSelectionForMouseDrag();
356353#if ENABLE(DRAG_SUPPORT)
357354 void updateSelectionForMouseDrag(const HitTestResult&);
358355#endif

@@private:
408405
409406 Timer<EventHandler> m_autoscrollTimer;
410407 RenderObject* m_autoscrollRenderer;
 408 IntPoint m_autoscrollReferencePoint;
 409 double m_autoscrollStartTime;
 410 // TODO: It is better to change type of m_autoscrollInProgress to AutoscrollType
 411 // enum which has ForSelection, ForPan, and ForDragAndDrop, to integrate
 412 // m_autoscrollInProgress, m_panScrollingInProgress and m_autoscrollForDragAndDropInProgress.
411413 bool m_autoscrollInProgress;
 414 bool m_autoscrollForDragAndDropInProgress;
412415 bool m_mouseDownMayStartAutoscroll;
413416 bool m_mouseDownWasInSubframe;
414417

Source/WebCore/rendering/RenderBox.cpp

@@bool RenderBox::usesCompositedScrolling() const
628628 return hasOverflowClip() && hasLayer() && layer()->usesCompositedScrolling();
629629}
630630
631 void RenderBox::autoscroll()
 631void RenderBox::autoscroll(const IntPoint& position)
632632{
633633 if (layer())
634  layer()->autoscroll();
 634 layer()->autoscroll(position);
635635}
636636
637637void RenderBox::panScroll(const IntPoint& source)

@@void RenderBox::computePositionedLogicalHeightReplaced(LogicalExtentComputedValu
36003600 computedValues.m_position = logicalTopPos;
36013601}
36023602
 3603// There are two kinds of renderer that can autoscroll.
 3604bool RenderBox::canAutoscroll() const
 3605{
 3606 // Check for a box that can be scrolled in its own right.
 3607 if (canBeScrolledAndHasScrollableArea())
 3608 return true;
 3609
 3610 // Check for a box that represents the top level of a web page.
 3611 // This can be scrolled by calling Chrome::scrollRectIntoView.
 3612 // This only has an effect on the Mac platform in applications
 3613 // that put web views into scrolling containers, such as Mac OS X Mail.
 3614 // The code for this is in RenderLayer::scrollRectToVisible.
 3615 if (node() != document())
 3616 return false;
 3617 Frame* frame = this->frame();
 3618 if (!frame)
 3619 return false;
 3620 Page* page = frame->page();
 3621 return page && page->mainFrame() == frame;
 3622}
 3623
36033624LayoutRect RenderBox::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit* extraWidthToEndOfLine)
36043625{
36053626 // VisiblePositions at offsets inside containers either a) refer to the positions before/after

Source/WebCore/rendering/RenderBox.h

@@public:
437437 virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
438438 bool canBeScrolledAndHasScrollableArea() const;
439439 virtual bool canBeProgramaticallyScrolled() const;
440  virtual void autoscroll();
 440 virtual void autoscroll(const IntPoint&);
441441 virtual void stopAutoscroll() { }
442442 virtual void panScroll(const IntPoint&);
443443 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); }

@@private:
633633
634634 virtual LayoutRect frameRectForStickyPositioning() const OVERRIDE { return frameRect(); }
635635
 636 virtual bool canAutoscroll() const OVERRIDE;
 637
636638private:
637639 // The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent).
638640 LayoutRect m_frameRect;

Source/WebCore/rendering/RenderLayer.cpp

@@LayoutRect RenderLayer::getRectToExpose(const LayoutRect &visibleRect, const Lay
20022002 return LayoutRect(LayoutPoint(x, y), visibleRect.size());
20032003}
20042004
2005 void RenderLayer::autoscroll()
 2005void RenderLayer::autoscroll(const IntPoint& position)
20062006{
20072007 Frame* frame = renderer()->frame();
20082008 if (!frame)

@@void RenderLayer::autoscroll()
20122012 if (!frameView)
20132013 return;
20142014
2015 #if ENABLE(DRAG_SUPPORT)
2016  frame->eventHandler()->updateSelectionForMouseDrag();
2017 #endif
2018 
2019  IntPoint currentDocumentPosition = frameView->windowToContents(frame->eventHandler()->currentMousePosition());
 2015 IntPoint currentDocumentPosition = frameView->windowToContents(position);
20202016 scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
20212017}
20222018

Source/WebCore/rendering/RenderLayer.h

@@public:
372372 void updateScrollInfoAfterLayout();
373373
374374 bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
375  void autoscroll();
 375 void autoscroll(const IntPoint&);
376376
377377 void resize(const PlatformMouseEvent&, const LayoutSize&);
378378 bool inResizeMode() const { return m_inResizeMode; }

Source/WebCore/rendering/RenderListBox.cpp

@@int RenderListBox::scrollToward(const IntPoint& destination)
554554 return listIndexAtOffset(positionOffset);
555555}
556556
557 void RenderListBox::autoscroll()
 557void RenderListBox::autoscroll(const IntPoint&)
558558{
559559 IntPoint pos = frame()->view()->windowToContents(frame()->eventHandler()->currentMousePosition());
560560

Source/WebCore/rendering/RenderListBox.h

@@private:
8484 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&);
8585
8686 virtual bool canBeProgramaticallyScrolled() const { return true; }
87  virtual void autoscroll();
 87 virtual void autoscroll(const IntPoint&);
8888 virtual void stopAutoscroll();
8989
9090 virtual bool shouldPanScroll() const { return true; }

Source/WebCore/rendering/RenderObject.cpp

3939#include "FrameView.h"
4040#include "GraphicsContext.h"
4141#include "HTMLElement.h"
 42#include "HTMLFrameOwnerElement.h"
4243#include "HTMLNames.h"
4344#include "HitTestResult.h"
4445#include "Page.h"

@@void RenderObject::handleDynamicFloatPositionChange()
16901691 }
16911692}
16921693
 1694RenderObject* RenderObject::findAutoscrollableRenderer()
 1695{
 1696 RenderObject* renderer = this;
 1697 while (renderer && !renderer->canAutoscroll()) {
 1698 if (!renderer->parent() && renderer->node() == renderer->document() && renderer->document()->ownerElement())
 1699 renderer = renderer->document()->ownerElement()->renderer();
 1700 else
 1701 renderer = renderer->parent();
 1702 }
 1703 return renderer;
 1704}
 1705
16931706void RenderObject::setAnimatableStyle(PassRefPtr<RenderStyle> style)
16941707{
16951708 if (!isText() && style)

Source/WebCore/rendering/RenderObject.h

@@public:
270270 // again. We have to make sure the render tree updates as needed to accommodate the new
271271 // normal flow object.
272272 void handleDynamicFloatPositionChange();
273 
 273
 274 // Autoscroll related functions
 275 virtual bool canAutoscroll() const { return false; }
 276 RenderObject* findAutoscrollableRenderer();
 277
274278 // RenderObject tree manipulation
275279 //////////////////////////////////////////
276280 virtual bool canHaveChildren() const { return virtualChildren(); }

Source/WebCore/rendering/RenderTextControlSingleLine.cpp

@@bool RenderTextControlSingleLine::textShouldBeTruncated() const
381381 && style()->textOverflow() == TextOverflowEllipsis;
382382}
383383
384 void RenderTextControlSingleLine::autoscroll()
 384void RenderTextControlSingleLine::autoscroll(const IntPoint& position)
385385{
386386 RenderLayer* layer = innerTextElement()->renderBox()->layer();
387387 if (layer)
388  layer->autoscroll();
 388 layer->autoscroll(position);
389389}
390390
391391int RenderTextControlSingleLine::scrollWidth() const

Source/WebCore/rendering/RenderTextControlSingleLine.h

@@private:
5858
5959 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
6060
61  virtual void autoscroll();
 61 virtual void autoscroll(const IntPoint&);
6262
6363 // Subclassed to forward to our inner div.
6464 virtual int scrollLeft() const;

Source/WebKit/chromium/src/WebViewImpl.cpp

5353#include "DocumentLoader.h"
5454#include "DragController.h"
5555#include "DragData.h"
56 #include "DragScrollTimer.h"
5756#include "DragSession.h"
5857#include "Editor.h"
5958#include "EventHandler.h"

@@WebViewImpl::WebViewImpl(WebViewClient* client)
414413 , m_autofillPopup(0)
415414 , m_isTransparent(false)
416415 , m_tabsToLinks(false)
417  , m_dragScrollTimer(adoptPtr(new DragScrollTimer))
418416 , m_isCancelingFullScreen(false)
419417 , m_benchmarkSupport(this)
420418#if USE(ACCELERATED_COMPOSITING)

@@void WebViewImpl::dragSourceEndedAt(
32183216 false, 0);
32193217 m_page->mainFrame()->eventHandler()->dragSourceEndedAt(pme,
32203218 static_cast<DragOperation>(operation));
3221  m_dragScrollTimer->stop();
32223219}
32233220
32243221void WebViewImpl::dragSourceMovedTo(

@@void WebViewImpl::dragSourceMovedTo(
32263223 const WebPoint& screenPoint,
32273224 WebDragOperation operation)
32283225{
3229  m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);
32303226}
32313227
32323228void WebViewImpl::dragSourceSystemDragEnded()

@@void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
33123308
33133309 m_dragOperation = WebDragOperationNone;
33143310 m_currentDragData = 0;
3315 
3316  m_dragScrollTimer->stop();
33173311}
33183312
33193313WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPoint, const WebPoint& screenPoint, DragAction dragAction, int keyModifiers)

@@WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPo
33403334 dropEffect = DragOperationNone;
33413335
33423336 m_dragOperation = static_cast<WebDragOperation>(dropEffect);
3343 
3344  if (dragAction == DragOver)
3345  m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);
3346  else
3347  m_dragScrollTimer->stop();
3348 
33493337 return m_dragOperation;
33503338}
33513339

Source/WebKit/chromium/src/WebViewImpl.h

@@class BatteryClientImpl;
8989class ContextFeaturesClientImpl;
9090class ContextMenuClientImpl;
9191class DeviceOrientationClientProxy;
92 class DragScrollTimer;
9392class GeolocationClientProxy;
9493class LinkHighlight;
9594class NonCompositedContentHost;

@@private:
814813
815814 typedef HashMap<WTF::String, WTF::String> SettingsMap;
816815 OwnPtr<SettingsMap> m_inspectorSettingsMap;
817  OwnPtr<DragScrollTimer> m_dragScrollTimer;
818816
819817#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
820818 // The provider of desktop notifications;

LayoutTests/ChangeLog

 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 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
1132012-12-05 Andrei Bucur <abucur@adobe.com>
214
315 [CSS Regions] Blocks don't relayout children if the width of a region changes

LayoutTests/fast/events/drag-and-drop-autoscroll-expected.txt

 1Check autoscroll by drag-and-drop
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS scrollable.scrollTop > 0
 7For manual testing, drag and drop "Drop Me" to "Scrollable" area.
 8

LayoutTests/fast/events/drag-and-drop-autoscroll.html

 1<html>
 2<head>
 3<style type="text/css">
 4#draggable {
 5 padding: 5pt;
 6 border: 3px solid #00cc00;
 7 background: #00cccc;
 8 width: 80px;
 9 cursor: hand;
 10}
 11
 12#scrollable {
 13 height: 200px;
 14 overflow: auto;
 15 border: solid 3px #cc0000;
 16}
 17</style>
 18<script>
 19function $(id) { return document.getElementById(id); }
 20
 21function finishTest() {
 22 eventSender.mouseUp();
 23 $('container').innerHTML = '';
 24 window.testRunner.notifyDone();
 25}
 26
 27function testIt() {
 28 var draggable = $('draggable');
 29 var scrollable = $('scrollable');
 30
 31 if (!window.eventSender)
 32 return;
 33
 34 eventSender.dragMode = false;
 35
 36 // Grab draggable
 37 eventSender.mouseMoveTo(draggable.offsetLeft + 5, draggable.offsetTop + 5);
 38 eventSender.mouseDown();
 39
 40 // Move mouse to autoscroll border belt.
 41 eventSender.mouseMoveTo(scrollable.offsetLeft + 5, scrollable.offsetTop + scrollable.offsetHeight - 10);
 42
 43 var retryCount = 0;
 44
 45 function checkScrolled()
 46 {
 47 if (scrollable.scrollTop > 0) {
 48 testPassed('scrollable.scrollTop > 0');
 49 finishTest();
 50 return;
 51 }
 52
 53 ++retryCount;
 54 if (retryCount > 10) {
 55 testFailed('No autoscroll');
 56 finishTest();
 57 return;
 58 }
 59
 60 // Autoscroll is occurred evey 0.05 sec.
 61 window.setTimeout(checkScrolled, 50);
 62 }
 63
 64 checkScrolled();
 65}
 66
 67function setUpTest()
 68{
 69 var scrollable = $('scrollable');
 70 for (var i = 0; i < 100; ++i) {
 71 var line = document.createElement('div');
 72 line.innerHTML = "line " + i;
 73 scrollable.appendChild(line);
 74 }
 75
 76 if (!window.eventSender) {
 77 console.log('Please run within DumpRenderTree');
 78 return;
 79 }
 80
 81 window.jsTestIsAsync = true;
 82 window.setTimeout(testIt, 0);
 83}
 84</script>
 85</head>
 86<body>
 87For manual testing, drag and drop "Drop Me" to "Scrollable" area.
 88<div id="container">
 89<div id="draggable" draggable="true">Drop Me</div>
 90Scrollable
 91<div id="scrollable">
 92</div>
 93</div>
 94<script src="../js/resources/js-test-pre.js"></script>
 95<script>
 96description('Check autoscroll by drag-and-drop');
 97setUpTest();
 98</script>
 99<script src="../js/resources/js-test-post.js"></script>
 100</body>
 101</html>