Commit 72e43ec9 authored by dglazkov@chromium.org's avatar dglazkov@chromium.org

2011-04-05 Dimitri Glazkov <dglazkov@chromium.org>

        Reviewed by Darin Adler.

        Move WheelEvent-dispatching logic into WheelEventDispatchMediator.
        https://bugs.webkit.org/show_bug.cgi?id=57642

        Covered by existing tests, no functional change.

        * dom/Event.cpp:
        * dom/Event.h:
        (WebCore::EventDispatchMediator::EventDispatchMediator): Added default
            constructor.
        (WebCore::EventDispatchMediator::event): Inlined.
        (WebCore::EventDispatchMediator::setEvent): Added.
        * dom/EventDispatcher.cpp: Removed dispatchWheelEvent.
        * dom/EventDispatcher.h: Updated decls.
        * dom/Node.cpp:
        (WebCore::Node::dispatchWheelEvent): Changed to use the mediator and
            return a bool, like other dispatch event functions.
        * dom/Node.h: Changed decl.
        * dom/WheelEvent.cpp:
        (WebCore::granularity): Moved from EventDispatcher.
        (WebCore::WheelEventDispatchMediator::WheelEventDisatchMediator): Added.
        (WebCore::WheelEventDispatchMediator::event): Added.
        (WebCore::WheelEventDispatchMediator::dispatchEvent): Added.
        * dom/WheelEvent.h: Updated decls.
        * page/EventHandler.cpp:
        (WebCore::EventHandler::handleWheelEvent): Changed to receive and react
            to the return value.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@83298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7bd03880
2011-04-05 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Darin Adler.
Move WheelEvent-dispatching logic into WheelEventDispatchMediator.
https://bugs.webkit.org/show_bug.cgi?id=57642
Covered by existing tests, no functional change.
* dom/Event.cpp:
* dom/Event.h:
(WebCore::EventDispatchMediator::EventDispatchMediator): Added default
constructor.
(WebCore::EventDispatchMediator::event): Inlined.
(WebCore::EventDispatchMediator::setEvent): Added.
* dom/EventDispatcher.cpp: Removed dispatchWheelEvent.
* dom/EventDispatcher.h: Updated decls.
* dom/Node.cpp:
(WebCore::Node::dispatchWheelEvent): Changed to use the mediator and
return a bool, like other dispatch event functions.
* dom/Node.h: Changed decl.
* dom/WheelEvent.cpp:
(WebCore::granularity): Moved from EventDispatcher.
(WebCore::WheelEventDispatchMediator::WheelEventDisatchMediator): Added.
(WebCore::WheelEventDispatchMediator::event): Added.
(WebCore::WheelEventDispatchMediator::dispatchEvent): Added.
* dom/WheelEvent.h: Updated decls.
* page/EventHandler.cpp:
(WebCore::EventHandler::handleWheelEvent): Changed to receive and react
to the return value.
2011-04-08 Jessie Berlin <jberlin@apple.com>
Windows build warning fix.
......@@ -313,9 +313,4 @@ bool EventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
return dispatcher->dispatchEvent(m_event.get());
}
Event* EventDispatchMediator::event() const
{
return m_event.get();
}
} // namespace WebCore
......@@ -200,11 +200,31 @@ public:
virtual ~EventDispatchMediator();
virtual bool dispatchEvent(EventDispatcher*) const;
protected:
EventDispatchMediator();
Event* event() const;
void setEvent(PassRefPtr<Event>);
private:
RefPtr<Event> m_event;
};
inline EventDispatchMediator::EventDispatchMediator()
{
}
inline Event* EventDispatchMediator::event() const
{
return m_event.get();
}
inline void EventDispatchMediator::setEvent(PassRefPtr<Event> event)
{
m_event = event;
}
} // namespace WebCore
#endif // Event_h
......@@ -33,7 +33,6 @@
#include "InspectorInstrumentation.h"
#include "MouseEvent.h"
#include "Node.h"
#include "PlatformWheelEvent.h"
#include "ScopedEventQueue.h"
#if ENABLE(SVG)
......@@ -44,7 +43,6 @@
#include "UIEvent.h"
#include "UIEventWithKeyState.h"
#include "WheelEvent.h"
#include "WindowEventContext.h"
#include <wtf/RefPtr.h>
......@@ -124,28 +122,6 @@ void EventDispatcher::dispatchSimulatedClick(Node* node, PassRefPtr<Event> under
gNodesDispatchingSimulatedClicks->remove(node);
}
inline static WheelEvent::Granularity granularity(const PlatformWheelEvent& event)
{
return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::Page : WheelEvent::Pixel;
}
void EventDispatcher::dispatchWheelEvent(Node* node, PlatformWheelEvent& event)
{
ASSERT(!eventDispatchForbidden());
if (!(event.deltaX() || event.deltaY()))
return;
EventDispatcher dispatcher(node);
RefPtr<WheelEvent> wheelEvent = WheelEvent::create(event.wheelTicksX(), event.wheelTicksY(), event.deltaX(), event.deltaY(), granularity(event),
node->document()->defaultView(), event.globalX(), event.globalY(), event.x(), event.y(),
event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey());
if (!dispatcher.dispatchEvent(wheelEvent) || wheelEvent->defaultHandled())
event.accept();
}
// FIXME: Once https://bugs.webkit.org/show_bug.cgi?id=52963 lands, this should
// be greatly improved. See https://bugs.webkit.org/show_bug.cgi?id=54025.
PassRefPtr<EventTarget> EventDispatcher::adjustRelatedTarget(PassRefPtr<EventTarget> relatedTarget)
......
......@@ -52,7 +52,6 @@ public:
static void dispatchScopedEvent(Node*, PassRefPtr<Event>);
static void dispatchSimulatedClick(Node*, PassRefPtr<Event> underlyingEvent, bool sendMouseEvents, bool showPressedLook);
static void dispatchWheelEvent(Node*, PlatformWheelEvent&);
bool dispatchEvent(PassRefPtr<Event>);
PassRefPtr<EventTarget> adjustRelatedTarget(PassRefPtr<EventTarget>);
......
......@@ -2666,9 +2666,9 @@ void Node::dispatchSimulatedClick(PassRefPtr<Event> event, bool sendMouseEvents,
EventDispatcher::dispatchSimulatedClick(this, event, sendMouseEvents, showPressedLook);
}
void Node::dispatchWheelEvent(PlatformWheelEvent& e)
bool Node::dispatchWheelEvent(const PlatformWheelEvent& event)
{
EventDispatcher::dispatchWheelEvent(this, e);
return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator(event, document()->defaultView()));
}
void Node::dispatchFocusEvent()
......
......@@ -536,7 +536,7 @@ public:
void dispatchSubtreeModifiedEvent();
void dispatchUIEvent(const AtomicString& eventType, int detail, PassRefPtr<Event> underlyingEvent);
bool dispatchKeyEvent(const PlatformKeyboardEvent&);
void dispatchWheelEvent(PlatformWheelEvent&);
bool dispatchWheelEvent(const PlatformWheelEvent&);
bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Node* relatedTarget = 0);
void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true);
......
......@@ -23,7 +23,10 @@
#include "config.h"
#include "WheelEvent.h"
#include "EventDispatcher.h"
#include "EventNames.h"
#include "PlatformWheelEvent.h"
#include <wtf/MathExtras.h>
namespace WebCore {
......@@ -92,4 +95,32 @@ bool WheelEvent::isWheelEvent() const
return true;
}
inline static WheelEvent::Granularity granularity(const PlatformWheelEvent& event)
{
return event.granularity() == ScrollByPageWheelEvent ? WheelEvent::Page : WheelEvent::Pixel;
}
WheelEventDispatchMediator::WheelEventDispatchMediator(const PlatformWheelEvent& event, PassRefPtr<AbstractView> view)
{
if (!(event.deltaX() || event.deltaY()))
return;
setEvent(WheelEvent::create(event.wheelTicksX(), event.wheelTicksY(), event.deltaX(), event.deltaY(), granularity(event),
view, event.globalX(), event.globalY(), event.x(), event.y(), event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()));
}
WheelEvent* WheelEventDispatchMediator::event() const
{
return static_cast<WheelEvent*>(EventDispatchMediator::event());
}
bool WheelEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
{
if (!event())
return true;
return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->defaultHandled();
}
} // namespace WebCore
......@@ -82,6 +82,15 @@ namespace WebCore {
Granularity m_granularity;
};
class WheelEventDispatchMediator : public EventDispatchMediator {
public:
WheelEventDispatchMediator(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
private:
WheelEvent* event() const;
virtual bool dispatchEvent(EventDispatcher*) const;
};
} // namespace WebCore
#endif // WheelEvent_h
......@@ -2099,9 +2099,10 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e)
}
node = node->shadowAncestorNode();
node->dispatchWheelEvent(e);
if (e.isAccepted())
if (!node->dispatchWheelEvent(e)) {
e.accept();
return true;
}
}
if (e.isAccepted())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment