Changeset 55909 in webkit


Ignore:
Timestamp:
Mar 12, 2010 9:06:39 AM (14 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/7694674> Hover states not updated when overflow section scrolls under stationary mouse pointer
https://bugs.webkit.org/show_bug.cgi?id=35949

Reviewed by Darin Adler.

WebCore:

Test: fast/events/overflow-scroll-fake-mouse-move.html

Soon after an overflow section scrolls under the mouse pointer, dispatch
a fake mouse move event. This is similar to how frame scrolling is handled
in WebKit, and has the effect of updating hover state, dispatching DOM mouse
events, and updating the tool tip.

  • page/EventHandler.cpp:

(WebCore::EventHandler::EventHandler): Initialize m_fakeMouseMoveEventTimer.
(WebCore::EventHandler::~EventHandler): Assert that the timer is not active.
(WebCore::EventHandler::clear): Stop the timer.
(WebCore::EventHandler::handleMousePressEvent): Cancel pending fake mouse
move events.
(WebCore::EventHandler::handleMouseMoveEvent): Ditto.
(WebCore::EventHandler::dispatchFakeMouseMoveEventSoonInQuad): If the mouse
is in the passed-in quad, ensure that a fake mouse move event is scheduled
to fire soon.
(WebCore::EventHandler::cancelFakeMouseMoveEvent): Does what the name says.
(WebCore::EventHandler::fakeMouseMoveEventTimerFired): Constructs a
PlatformMouseEvent with the current mouse location, modifier key state and
time stamp and calls mouseMoved().

  • page/EventHandler.h:
  • platform/PlatformKeyboardEvent.h: Declared getCurrentModifierState().
  • platform/android/KeyEventAndroid.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Stubbed out.

  • platform/brew/PlatformKeyboardEventBrew.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.

  • platform/chromium/PlatformKeyboardEventChromium.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Added.

  • platform/efl/PlatformKeyboardEventEfl.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Stubbed out.

  • platform/gtk/KeyEventGtk.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.

  • platform/haiku/PlatformKeyboardEventHaiku.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Added.

  • platform/mac/KeyEventMac.mm:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.

  • platform/qt/PlatformKeyboardEventQt.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Stubbed out.

  • platform/win/KeyEventWin.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Added.

  • platform/wx/KeyboardEventWx.cpp:

(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::scrollToOffset): Call
EventHandler::dispatchFakeMouseMoveEventSoonInQuad(). Moved things around
a little to avoid computing the repaint rect twice.

LayoutTests:

  • fast/events/overflow-scroll-fake-mouse-move-expected.txt: Added.
  • fast/events/overflow-scroll-fake-mouse-move.html: Added.
  • fast/events/touch/basic-multi-touch-events.html:
  • fast/events/touch/basic-single-touch-events.html:
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55907 r55909  
     12010-03-12  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7694674> Hover states not updated when overflow section scrolls under stationary mouse pointer
     6        https://bugs.webkit.org/show_bug.cgi?id=35949
     7
     8        * fast/events/overflow-scroll-fake-mouse-move-expected.txt: Added.
     9        * fast/events/overflow-scroll-fake-mouse-move.html: Added.
     10        * fast/events/touch/basic-multi-touch-events.html:
     11        * fast/events/touch/basic-single-touch-events.html:
     12
    1132010-03-12  Csaba Osztrogonác  <ossy@webkit.org>
    214
  • trunk/WebCore/ChangeLog

    r55896 r55909  
     12010-03-12  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7694674> Hover states not updated when overflow section scrolls under stationary mouse pointer
     6        https://bugs.webkit.org/show_bug.cgi?id=35949
     7
     8        Test: fast/events/overflow-scroll-fake-mouse-move.html
     9
     10        Soon after an overflow section scrolls under the mouse pointer, dispatch
     11        a fake mouse move event. This is similar to how frame scrolling is handled
     12        in WebKit, and has the effect of updating hover state, dispatching DOM mouse
     13        events, and updating the tool tip.
     14
     15        * page/EventHandler.cpp:
     16        (WebCore::EventHandler::EventHandler): Initialize m_fakeMouseMoveEventTimer.
     17        (WebCore::EventHandler::~EventHandler): Assert that the timer is not active.
     18        (WebCore::EventHandler::clear): Stop the timer.
     19        (WebCore::EventHandler::handleMousePressEvent): Cancel pending fake mouse
     20        move events.
     21        (WebCore::EventHandler::handleMouseMoveEvent): Ditto.
     22        (WebCore::EventHandler::dispatchFakeMouseMoveEventSoonInQuad): If the mouse
     23        is in the passed-in quad, ensure that a fake mouse move event is scheduled
     24        to fire soon.
     25        (WebCore::EventHandler::cancelFakeMouseMoveEvent): Does what the name says.
     26        (WebCore::EventHandler::fakeMouseMoveEventTimerFired): Constructs a
     27        PlatformMouseEvent with the current mouse location, modifier key state and
     28        time stamp and calls mouseMoved().
     29        * page/EventHandler.h:
     30        * platform/PlatformKeyboardEvent.h: Declared getCurrentModifierState().
     31        * platform/android/KeyEventAndroid.cpp:
     32        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Stubbed out.
     33        * platform/brew/PlatformKeyboardEventBrew.cpp:
     34        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.
     35        * platform/chromium/PlatformKeyboardEventChromium.cpp:
     36        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Added.
     37        * platform/efl/PlatformKeyboardEventEfl.cpp:
     38        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Stubbed out.
     39        * platform/gtk/KeyEventGtk.cpp:
     40        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.
     41        * platform/haiku/PlatformKeyboardEventHaiku.cpp:
     42        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Added.
     43        * platform/mac/KeyEventMac.mm:
     44        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.
     45        * platform/qt/PlatformKeyboardEventQt.cpp:
     46        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Stubbed out.
     47        * platform/win/KeyEventWin.cpp:
     48        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Added.
     49        * platform/wx/KeyboardEventWx.cpp:
     50        (WebCore::PlatformKeyboardEvent::getCurrentModifierState): Ditto.
     51        * rendering/RenderLayer.cpp:
     52        (WebCore::RenderLayer::scrollToOffset): Call
     53        EventHandler::dispatchFakeMouseMoveEventSoonInQuad(). Moved things around
     54        a little to avoid computing the repaint rect twice.
     55
    1562010-03-12  Kent Hansen  <kent.hansen@nokia.com>
    257
  • trunk/WebCore/page/EventHandler.cpp

    r55843 r55909  
    6868#include "WheelEvent.h"
    6969#include "htmlediting.h" // for comparePositions()
     70#include <wtf/CurrentTime.h>
    7071#include <wtf/StdLibExtras.h>
    7172
     
    106107// When the autoscroll or the panScroll is triggered when do the scroll every 0.05s to make it smooth
    107108const double autoscrollInterval = 0.05;
     109
     110const double fakeMouseMoveInterval = 0.1;
    108111
    109112static Frame* subframeForHitTestResult(const MouseEventWithHitTestResults&);
     
    169172    , m_mouseDownMayStartAutoscroll(false)
    170173    , m_mouseDownWasInSubframe(false)
     174    , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFired)
    171175#if ENABLE(SVG)
    172176    , m_svgPan(false)
     
    188192EventHandler::~EventHandler()
    189193{
     194    ASSERT(!m_fakeMouseMoveEventTimer.isActive());
    190195}
    191196   
     
    201206{
    202207    m_hoverTimer.stop();
     208    m_fakeMouseMoveEventTimer.stop();
    203209    m_resizeLayer = 0;
    204210    m_nodeUnderMouse = 0;
     
    375381    dragState().m_dragSrc = 0;
    376382#endif
     383
     384    cancelFakeMouseMoveEvent();
    377385
    378386    if (ScrollView* scrollView = m_frame->view()) {
     
    11511159    RefPtr<FrameView> protector(m_frame->view());
    11521160
     1161    cancelFakeMouseMoveEvent();
    11531162    m_mousePressed = true;
    11541163    m_capturesDragging = true;
     
    13411350    if (m_hoverTimer.isActive())
    13421351        m_hoverTimer.stop();
     1352
     1353    cancelFakeMouseMoveEvent();
    13431354
    13441355#if ENABLE(SVG)
     
    19421953    if (!m_hoverTimer.isActive())
    19431954        m_hoverTimer.startOneShot(0);
     1955}
     1956
     1957void EventHandler::dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad& quad)
     1958{
     1959    FrameView* view = m_frame->view();
     1960    if (!view)
     1961        return;
     1962
     1963    if (m_mousePressed || !quad.containsPoint(view->windowToContents(m_currentMousePosition)))
     1964        return;
     1965
     1966    if (!m_fakeMouseMoveEventTimer.isActive())
     1967        m_fakeMouseMoveEventTimer.startOneShot(fakeMouseMoveInterval);
     1968}
     1969
     1970void EventHandler::cancelFakeMouseMoveEvent()
     1971{
     1972    m_fakeMouseMoveEventTimer.stop();
     1973}
     1974
     1975void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer)
     1976{
     1977    ASSERT_UNUSED(timer, timer == &m_fakeMouseMoveEventTimer);
     1978    ASSERT(!m_mousePressed);
     1979
     1980    FrameView* view = m_frame->view();
     1981    if (!view)
     1982        return;
     1983
     1984    bool shiftKey;
     1985    bool ctrlKey;
     1986    bool altKey;
     1987    bool metaKey;
     1988    PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, metaKey);
     1989    IntPoint globalPoint = view->contentsToScreen(IntRect(view->windowToContents(m_currentMousePosition), IntSize())).location();
     1990    PlatformMouseEvent fakeMouseMoveEvent(m_currentMousePosition, globalPoint, NoButton, MouseEventMoved, 0, shiftKey, ctrlKey, altKey, metaKey, currentTime());
     1991    mouseMoved(fakeMouseMoveEvent);
    19441992}
    19451993
  • trunk/WebCore/page/EventHandler.h

    r55543 r55909  
    5151class EventTarget;
    5252class FloatPoint;
     53class FloatQuad;
    5354class Frame;
    5455class HitTestRequest;
     
    103104    void updateAutoscrollRenderer();
    104105
     106    void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
     107
    105108    HitTestResult hitTestResultAtPoint(const IntPoint&, bool allowShadowContent, bool ignoreClipping = false, HitTestScrollbars scrollbars = DontHitTestScrollbars);
    106109
     
    267270    void autoscrollTimerFired(Timer<EventHandler>*);
    268271
     272    void fakeMouseMoveEventTimerFired(Timer<EventHandler>*);
     273    void cancelFakeMouseMoveEvent();
     274
    269275    void invalidateClick();
    270276
     
    374380    bool m_mouseDownWasInSubframe;
    375381
     382    Timer<EventHandler> m_fakeMouseMoveEventTimer;
     383
    376384#if ENABLE(SVG)
    377385    bool m_svgPan;
  • trunk/WebCore/platform/PlatformKeyboardEvent.h

    r55633 r55909  
    156156
    157157        static bool currentCapsLockState();
     158        static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
    158159
    159160#if PLATFORM(MAC)
  • trunk/WebCore/platform/android/KeyEventAndroid.cpp

    r50971 r55909  
    252252}
    253253
     254void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     255{
     256    notImplemented();
     257    shiftKey = false;
     258    ctrlKey = false;
     259    altKey = false;
     260    metaKey = false;
     261}
     262
    254263void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
    255264{
  • trunk/WebCore/platform/brew/PlatformKeyboardEventBrew.cpp

    r54930 r55909  
    171171}
    172172
     173void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     174{
     175    notImplemented();
     176    shiftKey = false;
     177    ctrlKey = false;
     178    altKey = false;
     179    metaKey = false;
     180}
     181
    173182} // namespace WebCore
    174 
  • trunk/WebCore/platform/chromium/PlatformKeyboardEventChromium.cpp

    r52791 r55909  
    8383}
    8484
     85void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     86{
     87#if OS(WINDOWS)
     88    shiftKey = GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT;
     89    ctrlKey = GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT;
     90    altKey = GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT;
     91    metaKey = false;
     92#elif OS(DARWIN)
     93    UInt32 currentModifiers = GetCurrentKeyModifiers();
     94    shiftKey = currentModifiers & ::shiftKey;
     95    ctrlKey = currentModifiers & ::controlKey;
     96    altKey = currentModifiers & ::optionKey;
     97    metaKey = currentModifiers & ::cmdKey;
     98#else
     99    notImplemented();
     100#endif
     101}
     102
    85103} // namespace WebCore
  • trunk/WebCore/platform/efl/PlatformKeyboardEventEfl.cpp

    r55345 r55909  
    242242}
    243243
    244 }
     244void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     245{
     246    notImplemented();
     247    shiftKey = false;
     248    ctrlKey = false;
     249    altKey = false;
     250    metaKey = false;
     251}
     252
     253}
  • trunk/WebCore/platform/gtk/KeyEventGtk.cpp

    r53942 r55909  
    587587}
    588588
     589void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     590{
     591    notImplemented();
     592    shiftKey = false;
     593    ctrlKey = false;
     594    altKey = false;
     595    metaKey = false;
     596}
     597
    589598GdkEventKey* PlatformKeyboardEvent::gdkEventKey() const
    590599{
  • trunk/WebCore/platform/haiku/PlatformKeyboardEventHaiku.cpp

    r55138 r55909  
    378378}
    379379
     380void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     381{
     382    unit32 modifiers = ::modifiers();
     383    shiftKey = modifiers & B_SHIFT_KEY;
     384    ctrlKey = modifiers & B_COMMAND_KEY;
     385    altKey = modifiers & B_CONTROL_KEY;
     386    metaKey = modifiers & B_OPTION_KEY;
     387}
     388
    380389} // namespace WebCore
    381390
  • trunk/WebCore/platform/mac/KeyEventMac.mm

    r55431 r55909  
    11/*
    2  * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2004, 2006, 2007, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    877877}
    878878
    879 }
     879void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     880{
     881    UInt32 currentModifiers = GetCurrentKeyModifiers();
     882    shiftKey = currentModifiers & ::shiftKey;
     883    ctrlKey = currentModifiers & ::controlKey;
     884    altKey = currentModifiers & ::optionKey;
     885    metaKey = currentModifiers & ::cmdKey;
     886}
     887
     888}
  • trunk/WebCore/platform/qt/PlatformKeyboardEventQt.cpp

    r55501 r55909  
    552552}
    553553
     554void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     555{
     556    notImplemented();
     557    shiftKey = false;
     558    ctrlKey = false;
     559    altKey = false;
     560    metaKey = false;
     561}
     562
    554563}
    555564
  • trunk/WebCore/platform/win/KeyEventWin.cpp

    r37335 r55909  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    215215}
    216216
    217 }
     217void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     218{
     219    shiftKey = GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT;
     220    ctrlKey = GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT;
     221    altKey = GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT;
     222    metaKey = false;
     223}
     224
     225}
  • trunk/WebCore/platform/wx/KeyboardEventWx.cpp

    r43265 r55909  
    389389}
    390390
    391 }
    392 
     391void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
     392{
     393    shiftKey = wxGetKeyState(WXK_SHIFT);
     394    ctrlKey = wxGetKeyState(WXK_CONTROL);
     395    altKey = wxGetKeyState(WXK_ALT);
     396    metaKey = false;
     397}
     398
     399}
     400
  • trunk/WebCore/rendering/RenderLayer.cpp

    r55597 r55909  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
     
    12361236    }
    12371237
    1238     // The caret rect needs to be invalidated after scrolling
     1238    RenderBoxModelObject* repaintContainer = renderer()->containerForRepaint();
     1239    IntRect rectForRepaint = renderer()->clippedOverflowRectForRepaint(repaintContainer);
     1240
    12391241    Frame* frame = renderer()->document()->frame();
    1240     if (frame)
     1242    if (frame) {
     1243        // The caret rect needs to be invalidated after scrolling
    12411244        frame->selection()->setNeedsLayout();
    12421245
     1246        FloatQuad quadForFakeMouseMoveEvent = FloatQuad(rectForRepaint);
     1247        if (repaintContainer)
     1248            quadForFakeMouseMoveEvent = repaintContainer->localToAbsoluteQuad(quadForFakeMouseMoveEvent);
     1249        frame->eventHandler()->dispatchFakeMouseMoveEventSoonInQuad(quadForFakeMouseMoveEvent);
     1250    }
     1251
    12431252    // Just schedule a full repaint of our object.
    1244     if (repaint)
    1245         renderer()->repaint();
    1246    
     1253    if (view && repaint)
     1254        renderer()->repaintUsingContainer(repaintContainer, rectForRepaint);
     1255
    12471256    if (updateScrollbars) {
    12481257        if (m_hBar)
Note: See TracChangeset for help on using the changeset viewer.