Changeset 61598 in webkit


Ignore:
Timestamp:
Jun 21, 2010 7:28:51 PM (14 years ago)
Author:
morrita@google.com
Message:

2010-06-21 MORITA Hajime <morrita@google.com>

Reviewed by Darin Fisher.

[Chromium] Dragging outside the frame immediately causes page to scroll
http://webkit.org/b/40461

This is regression that was introduced at http://webkit.org/b/39725.

There are 2 problems:

  1. It starts auto-scrolling immediately. We should have some delay.
  2. The scroll continues even after a mouse cursor goes outside a frame. The scroll should be stopped when the curosr has left.

This change introduced DragScrollTimer to handle 1.
At the same time, it fixed DragScrollTimer::scrollDistanceFor() to
handle 2, We now stop scrolling when the cursor gone.

  • WebKit.gyp:
  • src/DragScrollTimer.cpp: Added. (WebKit::distanceToRect): (WebKit::DragScrollTimer::DragScrollTimer): (WebKit::DragScrollTimer::~DragScrollTimer): (WebKit::DragScrollTimer::stop): (WebKit::DragScrollTimer::scroll): (WebKit::DragScrollTimer::update): (WebKit::DragScrollTimer::triggerScroll): (WebKit::DragScrollTimer::scrollDistanceFor):
  • src/DragScrollTimer.h: Added. (WebKit::DragScrollTimer::fired): (WebKit::DragScrollTimer::shouldScroll):
  • src/WebViewImpl.cpp: (WebKit::WebViewImpl::WebViewImpl): (WebKit::WebViewImpl::dragSourceEndedAt): (WebKit::WebViewImpl::dragSourceMovedTo): (WebKit::WebViewImpl::dragTargetDrop): (WebKit::WebViewImpl::dragTargetDragEnterOrOver):
  • src/WebViewImpl.h:
Location:
trunk/WebKit/chromium
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r61547 r61598  
     12010-06-21  MORITA Hajime  <morrita@google.com>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [Chromium] Dragging outside the frame immediately causes page to scroll
     6        http://webkit.org/b/40461
     7
     8        This is regression that was introduced at http://webkit.org/b/39725.
     9       
     10        There are 2 problems:
     11        1. It starts auto-scrolling immediately. We should have some delay.
     12        2. The scroll continues even after a mouse cursor goes outside a frame.
     13           The scroll should be stopped when the curosr has left.
     14       
     15        This change introduced DragScrollTimer to handle 1.
     16        At the same time, it fixed DragScrollTimer::scrollDistanceFor() to
     17        handle 2, We now stop scrolling when the cursor gone.
     18       
     19        * WebKit.gyp:
     20        * src/DragScrollTimer.cpp: Added.
     21        (WebKit::distanceToRect):
     22        (WebKit::DragScrollTimer::DragScrollTimer):
     23        (WebKit::DragScrollTimer::~DragScrollTimer):
     24        (WebKit::DragScrollTimer::stop):
     25        (WebKit::DragScrollTimer::scroll):
     26        (WebKit::DragScrollTimer::update):
     27        (WebKit::DragScrollTimer::triggerScroll):
     28        (WebKit::DragScrollTimer::scrollDistanceFor):
     29        * src/DragScrollTimer.h: Added.
     30        (WebKit::DragScrollTimer::fired):
     31        (WebKit::DragScrollTimer::shouldScroll):
     32        * src/WebViewImpl.cpp:
     33        (WebKit::WebViewImpl::WebViewImpl):
     34        (WebKit::WebViewImpl::dragSourceEndedAt):
     35        (WebKit::WebViewImpl::dragSourceMovedTo):
     36        (WebKit::WebViewImpl::dragTargetDrop):
     37        (WebKit::WebViewImpl::dragTargetDragEnterOrOver):
     38        * src/WebViewImpl.h:
     39
    1402010-06-21  Kent Tamura  <tkent@chromium.org>
    241
  • trunk/WebKit/chromium/WebKit.gyp

    r61539 r61598  
    262262                'src/DragClientImpl.cpp',
    263263                'src/DragClientImpl.h',
     264                'src/DragScrollTimer.cpp',
     265                'src/DragScrollTimer.h',
    264266                'src/EditorClientImpl.cpp',
    265267                'src/EditorClientImpl.h',
  • trunk/WebKit/chromium/src/WebViewImpl.cpp

    r61484 r61598  
    4747#include "DOMUtilitiesPrivate.h"
    4848#include "DragController.h"
     49#include "DragScrollTimer.h"
    4950#include "DragData.h"
    5051#include "Editor.h"
     
    8384#include "SelectionController.h"
    8485#include "Settings.h"
     86#include "Timer.h"
    8587#include "TypingCommand.h"
    8688#include "WebAccessibilityObject.h"
     
    240242    , m_isTransparent(false)
    241243    , m_tabsToLinks(false)
     244    , m_dragScrollTimer(new DragScrollTimer())
    242245#if USE(ACCELERATED_COMPOSITING)
    243246    , m_layerRenderer(0)
     
    829832}
    830833
    831 // Computes the distance from a point outside a rect to the nearest edge of the rect.
    832 static IntSize distanceToRect(const IntPoint& point, const IntRect& rect)
    833 {
    834     int dx = 0, dy = 0;
    835     if (point.x() < rect.x())
    836         dx = point.x() - rect.x();
    837     else if (rect.right() < point.x())
    838         dx = point.x() - rect.right();
    839     if (point.y() < rect.y())
    840         dy = point.y() - rect.y();
    841     else if (rect.bottom() < point.y())
    842         dy = point.y() - rect.bottom();
    843     return IntSize(dx, dy);
    844 }
    845 
    846 void WebViewImpl::scrollForDragging(const WebPoint& clientPoint)
    847 {
    848     // This margin approximates Safari behavior, derived from an observation.
    849     static const int scrollMargin = 30;
    850 
    851     FrameView* view = mainFrameImpl()->frameView();
    852     if (!view)
    853         return;
    854 
    855     IntRect bounds(0, 0, view->visibleWidth(), view->visibleHeight());
    856     bounds.setY(bounds.y() + scrollMargin);
    857     bounds.setHeight(bounds.height() - scrollMargin * 2);
    858     bounds.setX(bounds.x() + scrollMargin);
    859     bounds.setWidth(bounds.width() - scrollMargin * 2);
    860 
    861     IntPoint point = clientPoint;
    862     if (bounds.contains(point))
    863         return;   
    864 
    865     IntSize toScroll = distanceToRect(point, bounds);
    866     if (!toScroll.isZero())
    867         view->scrollBy(toScroll);
    868 }
    869 
    870834void WebViewImpl::hideSelectPopup()
    871835{
     
    16661630    m_page->mainFrame()->eventHandler()->dragSourceEndedAt(pme,
    16671631        static_cast<DragOperation>(operation));
     1632    m_dragScrollTimer->stop();
    16681633}
    16691634
     
    16731638    WebDragOperation operation)
    16741639{
    1675     scrollForDragging(clientPoint);
     1640    m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);
    16761641}
    16771642
     
    17621727    m_dragOperation = WebDragOperationNone;
    17631728    m_dragIdentity = 0;
     1729    m_dragScrollTimer->stop();
    17641730}
    17651731
     
    17971763
    17981764    if (dragAction == DragOver)
    1799         scrollForDragging(clientPoint);
     1765        m_dragScrollTimer->triggerScroll(mainFrameImpl()->frameView(), clientPoint);
     1766    else
     1767        m_dragScrollTimer->stop();
     1768
    18001769
    18011770    return m_dragOperation;
  • trunk/WebKit/chromium/src/WebViewImpl.h

    r61484 r61598  
    6969class AutoFillPopupMenuClient;
    7070class ContextMenuClientImpl;
     71class DragScrollTimer;
    7172class SuggestionsPopupMenuClient;
    7273class WebAccessibilityObject;
     
    363364    bool scrollViewWithKeyboard(int keyCode, int modifiers);
    364365
    365     void scrollForDragging(const WebPoint&);
    366 
    367366    void hideSelectPopup();
    368367
     
    508507    typedef HashMap<WebCore::String, WebCore::String> SettingsMap;
    509508    OwnPtr<SettingsMap> m_inspectorSettingsMap;
     509    OwnPtr<DragScrollTimer> m_dragScrollTimer;
    510510
    511511#if ENABLE(NOTIFICATIONS)
Note: See TracChangeset for help on using the changeset viewer.