Changeset 20761 in webkit


Ignore:
Timestamp:
Apr 6, 2007 2:37:48 PM (17 years ago)
Author:
hyatt
Message:

Fix for bug 13274. Rework mouse events so that subframe capturing works again. Make sure
everything just comes down through the top FrameView even when capturing is in effect. Update
scrollbar handling logic so that scrollbars receive events correctly while capturing is in
effect. Eliminate the notion of widget capture. Fix mouse moves so that they only fire
on the innermost hit frame.

Reviewed by olliej

  • page/EventHandler.cpp: (WebCore::EventHandler::handleMouseDraggedEvent): (WebCore::subframeForTargetNode): (WebCore::EventHandler::handleMousePressEvent): (WebCore::EventHandler::handleMouseMoveEvent): (WebCore::EventHandler::handleMouseReleaseEvent):
  • page/EventHandler.h:
  • platform/PopupMenu.h: (WebCore::PopupMenu::scrollbarCapturingMouse): (WebCore::PopupMenu::setScrollbarCapturingMouse):
  • platform/ScrollBar.h: (WebCore::Scrollbar::handleMouseReleaseEvent):
  • platform/Widget.h: (WebCore::Widget::geometryChanged):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r20760 r20761  
     12007-04-06  David Hyatt  <hyatt@apple.com>
     2
     3        Fix for bug 13274.  Rework mouse events so that subframe capturing works again.  Make sure
     4        everything just comes down through the top FrameView even when capturing is in effect.  Update
     5        scrollbar handling logic so that scrollbars receive events correctly while capturing is in
     6        effect.  Eliminate the notion of widget capture.  Fix mouse moves so that they only fire
     7        on the innermost hit frame.
     8
     9        Reviewed by olliej
     10
     11        * page/EventHandler.cpp:
     12        (WebCore::EventHandler::handleMouseDraggedEvent):
     13        (WebCore::subframeForTargetNode):
     14        (WebCore::EventHandler::handleMousePressEvent):
     15        (WebCore::EventHandler::handleMouseMoveEvent):
     16        (WebCore::EventHandler::handleMouseReleaseEvent):
     17        * page/EventHandler.h:
     18        * platform/PopupMenu.h:
     19        (WebCore::PopupMenu::scrollbarCapturingMouse):
     20        (WebCore::PopupMenu::setScrollbarCapturingMouse):
     21        * platform/ScrollBar.h:
     22        (WebCore::Scrollbar::handleMouseReleaseEvent):
     23        * platform/Widget.h:
     24        (WebCore::Widget::geometryChanged):
     25
    1262007-04-06  Justin Garcia  <justin.garcia@apple.com>
    227
  • trunk/WebCore/page/EventHandler.cpp

    r20753 r20761  
    306306}
    307307
    308 bool EventHandler::handleMouseMoveEvent(const MouseEventWithHitTestResults& event)
     308bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& event)
    309309{
    310310    if (handleDrag(event))
     
    593593}
    594594
    595 static Frame* subframeForTargetNode(Node* node)
     595Frame* subframeForTargetNode(Node* node)
    596596{
    597597    if (!node)
     
    788788    Frame* subframe = subframeForTargetNode(mev.targetNode());
    789789    if (subframe && passMousePressEventToSubframe(mev, subframe)) {
     790        // Start capturing future events for this frame.  We only do this if we didn't clear
     791        // the m_mousePressed flag, which may happen if an AppKit widget entered a modal event loop.
     792        if (m_mousePressed)
     793            m_capturingMouseEventsNode = mev.targetNode();
    790794        invalidateClick();
    791795        return true;
     
    884888        return dispatchMouseEvent(mousemoveEvent, m_frameSetBeingResized.get(), false, 0, mouseEvent, false);
    885889
     890    // Send events right to a scrollbar if the mouse is pressed.
     891    if (m_lastScrollbarUnderMouse && m_mousePressed)
     892        return m_lastScrollbarUnderMouse->handleMouseMoveEvent(mouseEvent);
     893
    886894    // Treat mouse move events while the mouse is pressed as "read-only" in prepareMouseEvent
    887895    // if we are allowed to select.
     
    891899    MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent);
    892900
    893     if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree()->isDescendantOf(m_frame))
    894         passMouseMoveEventToSubframe(mev, m_lastMouseMoveEventSubframe.get());
    895 
    896     bool swallowEvent = dispatchMouseEvent(mousemoveEvent, mev.targetNode(), false, 0, mouseEvent, true);
    897 
    898901    PlatformScrollbar* scrollbar = 0;
    899902    if (m_frame->view())
     
    913916        m_resizeLayer->resize(mouseEvent, m_offsetFromResizeCorner);
    914917
    915     if (!swallowEvent)
    916         swallowEvent = handleMouseMoveEvent(mev);
    917    
    918     RefPtr<Frame> newSubframe = subframeForTargetNode(mev.targetNode());
    919     if (newSubframe) {
    920         if (m_lastMouseMoveEventSubframe != newSubframe)
    921             swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get());
    922     } else {
     918    bool swallowEvent = false;
     919    Node* targetNode = m_capturingMouseEventsNode.get() ? m_capturingMouseEventsNode.get() : mev.targetNode();
     920    RefPtr<Frame> newSubframe = subframeForTargetNode(targetNode);
     921    if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree()->isDescendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe)
     922        passMouseMoveEventToSubframe(mev, m_lastMouseMoveEventSubframe.get());
     923    if (newSubframe)
     924        swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get());
     925    else {
    923926        if (scrollbar && !m_mousePressed)
    924927            scrollbar->handleMouseMoveEvent(mouseEvent); // Handle hover effects on platforms that support visual feedback on scrollbar hovering.
     
    926929            m_frame->view()->setCursor(selectCursor(mev, m_frame, m_mousePressed, scrollbar, m_capturingMouseEventsNode));
    927930    }
    928 
     931   
    929932    m_lastMouseMoveEventSubframe = newSubframe;
     933
     934    if (swallowEvent)
     935        return true;
     936       
     937    swallowEvent = dispatchMouseEvent(mousemoveEvent, mev.targetNode(), false, 0, mouseEvent, true);
     938    if (!swallowEvent)
     939        swallowEvent = handleMouseDraggedEvent(mev);
    930940
    931941    return swallowEvent;
     
    951961        return dispatchMouseEvent(mouseupEvent, m_frameSetBeingResized.get(), true, m_clickCount, mouseEvent, false);
    952962
     963    if (m_lastScrollbarUnderMouse) {
     964        invalidateClick();
     965        return m_lastScrollbarUnderMouse->handleMouseReleaseEvent(mouseEvent);
     966    }
     967
    953968    MouseEventWithHitTestResults mev = prepareMouseEvent(HitTestRequest(false, false, false, true), mouseEvent);
    954     Frame* subframe = subframeForTargetNode(mev.targetNode());
     969    Node* targetNode = m_capturingMouseEventsNode.get() ? m_capturingMouseEventsNode.get() : mev.targetNode();
     970    setCapturingMouseEventsNode(0);
     971    Frame* subframe = subframeForTargetNode(targetNode);
    955972    if (subframe && passMouseReleaseEventToSubframe(mev, subframe))
    956973        return true;
  • trunk/WebCore/page/EventHandler.h

    r19879 r20761  
    185185    bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
    186186    bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
    187     bool handleMouseMoveEvent(const MouseEventWithHitTestResults&);
     187    bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&);
    188188    bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
    189189
  • trunk/WebCore/platform/PopupMenu.h

    r20475 r20761  
    104104    void reduceWheelDelta(int delta);
    105105    int wheelDelta() const { return m_wheelDelta; }
     106
     107    bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
     108    void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
    106109#endif
    107110
     
    141144    int m_wheelDelta;
    142145    int m_focusedIndex;
     146    bool m_scrollbarCapturingMouse;
    143147#endif
    144148
  • trunk/WebCore/platform/ScrollBar.h

    r20518 r20761  
    9393    virtual bool handleMouseOutEvent(const PlatformMouseEvent&) { return false; }
    9494
     95    // Used by some platform scrollbars to know when they've been released from capture.
     96    virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) { return false; }
     97   
    9598protected:
    9699    virtual void updateThumbPosition() = 0;
  • trunk/WebCore/platform/Widget.h

    r19772 r20761  
    121121
    122122        virtual void geometryChanged() const {};
    123 
    124         bool capturingMouse() const;
    125         void setCapturingMouse(bool);
    126         Widget* capturingTarget();
    127         Widget* capturingChild();
    128         void setCapturingChild(Widget*);
    129123       
    130124        IntRect convertToContainingWindow(const IntRect&) const;
Note: See TracChangeset for help on using the changeset viewer.