Implement DOM3 wheel event

https://bugs.webkit.org/show_bug.cgi?id=94081

Reviewed by Darin Adler.

Source/WebCore:

Add support for DOM Level 3 WheelEvent:
http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent

Firefox, IE10 and since recently Blink already support it so
it increases our cross-browser compatibility.

The non-standard 'mousewheel' event is still supported for backward
compatibility. Note that the deltas returned by the mousewheel and
the wheel events are not identical:
- They have opposite signs.
- The wheel event reports the actual amount of pixels that should be
scrolled while the legacy mousewheel event reports a factor of the
number of mouse wheel ticks (using a constant multiplier).

Tests: fast/events/wheelevent-basic.html
       fast/events/wheelevent-constructor.html
       fast/events/wheelevent-mousewheel-interaction.html

* dom/Document.h:
* dom/Document.idl:
* dom/Element.h:
* dom/Element.idl:
* dom/EventNames.h:
* dom/EventTarget.cpp:
(WebCore::legacyType):
(WebCore::EventTarget::shouldObserveLegacyType):
(WebCore::EventTarget::setupLegacyTypeObserverIfNeeded):
(WebCore::EventTarget::fireEventListeners):
* dom/EventTarget.h:
* dom/Node.cpp:
(WebCore::Node::didMoveToNewDocument):
(WebCore::tryAddEventListener):
(WebCore::tryRemoveEventListener):
(WebCore::Node::defaultEventHandler):
* dom/WheelEvent.cpp:
(WebCore::WheelEventInit::WheelEventInit):
(WebCore::WheelEvent::WheelEvent):
(WebCore::WheelEvent::initWheelEvent):
* dom/WheelEvent.h:
(WebCore::WheelEvent::deltaX):
(WebCore::WheelEvent::deltaY):
(WebCore::WheelEvent::deltaZ):
(WebCore::WheelEvent::wheelDelta):
(WebCore::WheelEvent::wheelDeltaX):
(WebCore::WheelEvent::wheelDeltaY):
* dom/WheelEvent.idl:
* html/HTMLAttributeNames.in:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::eventNameForAttributeName):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::addEventListener):
(WebCore::DOMWindow::removeEventListener):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* page/EventHandler.cpp:
(WebCore::EventHandler::defaultWheelEventHandler):
* plugins/blackberry/PluginViewBlackBerry.cpp:
(WebCore::PluginView::handleWheelEvent):
* svg/SVGElementInstance.cpp:
* svg/SVGElementInstance.h:
* svg/SVGElementInstance.idl:

LayoutTests:

Add several layout tests to check support for DOM3 wheel event.

* fast/events/wheelevent-basic-expected.txt: Added.
* fast/events/wheelevent-basic.html: Added.
* fast/events/wheelevent-constructor-expected.txt: Added.
* fast/events/wheelevent-constructor.html: Added.
* fast/events/wheelevent-mousewheel-interaction-expected.txt: Added.
* fast/events/wheelevent-mousewheel-interaction.html: Added.
* platform/efl/fast/events/wheelevent-basic-expected.txt: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154673 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e57434c7
2013-08-27 Christophe Dumez <ch.dumez@sisa.samsung.com>
Implement DOM3 wheel event
https://bugs.webkit.org/show_bug.cgi?id=94081
Reviewed by Darin Adler.
Add several layout tests to check support for DOM3 wheel event.
* fast/events/wheelevent-basic-expected.txt: Added.
* fast/events/wheelevent-basic.html: Added.
* fast/events/wheelevent-constructor-expected.txt: Added.
* fast/events/wheelevent-constructor.html: Added.
* fast/events/wheelevent-mousewheel-interaction-expected.txt: Added.
* fast/events/wheelevent-mousewheel-interaction.html: Added.
* platform/efl/fast/events/wheelevent-basic-expected.txt: Added.
2013-08-26 Ryosuke Niwa <rniwa@webkit.org>
Elements in a node list of the form element's name getter should not be added to the past names map
TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
END END END END END END END END END END END END END END
Tests the basic functionality of the standard wheel event
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS WheelEvent.prototype.__proto__ is MouseEvent.prototype
PASS WheelEvent.DOM_DELTA_PIXEL is 0x00
PASS WheelEvent.DOM_DELTA_LINE is 0x01
PASS WheelEvent.DOM_DELTA_PAGE is 0x02
PASS window.onwheel is null
PASS document.onwheel is null
PASS testDiv.onwheel is null
PASS testEvent.__proto__ is WheelEvent.prototype
PASS testEvent.__proto__.__proto__ is MouseEvent.prototype
PASS testEvent.deltaZ is 0
PASS testEvent.deltaMode is WheelEvent.DOM_DELTA_PIXEL
PASS deltaX > 0 is true
PASS deltaX is expectedDeltaX
PASS deltaY > 0 is true
PASS deltaY is expectedDeltaY
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent">
<script src="../js/resources/js-test-pre.js"></script>
<script>
var deltaX = 0;
var deltaY = 0;
var expectedDeltaX;
var expectedDeltaY;
var testDiv;
function runTest() {
// Basic checks.
shouldBe('WheelEvent.prototype.__proto__', 'MouseEvent.prototype');
shouldBe('WheelEvent.DOM_DELTA_PIXEL', '0x00');
shouldBe('WheelEvent.DOM_DELTA_LINE', '0x01');
shouldBe('WheelEvent.DOM_DELTA_PAGE', '0x02');
testDiv = document.getElementById('target');
shouldBeNull('window.onwheel');
shouldBeNull('document.onwheel');
shouldBeNull('testDiv.onwheel');
testDiv.addEventListener('wheel', wheelHandler);
if (window.eventSender) {
eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);
eventSender.mouseScrollBy(-1, -2);
expectedDeltaX = testDiv.scrollLeft;
expectedDeltaY = testDiv.scrollTop;
shouldBeTrue("deltaX > 0");
shouldBe("deltaX", "expectedDeltaX");
shouldBeTrue("deltaY > 0");
shouldBe("deltaY", "expectedDeltaY");
} else {
debug("FAIL: This test requires window.eventSender.");
}
}
var testEvent;
function wheelHandler(e) {
testEvent = e;
shouldBe("testEvent.__proto__", "WheelEvent.prototype");
shouldBe("testEvent.__proto__.__proto__", "MouseEvent.prototype");
if (e.deltaX)
deltaX = e.deltaX;
if (e.deltaY)
deltaY = e.deltaY;
shouldBe("testEvent.deltaZ", "0");
shouldBe("testEvent.deltaMode", "WheelEvent.DOM_DELTA_PIXEL")
}
</script>
</head>
<body>
<span id="parent">
<div id="target" style="border:solid 1px green; width:100px; height:70px; overflow:scroll; white-space:nowrap;">
TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP<br/>
Scroll mouse wheel over here<br/>
Scroll mouse wheel over here<br/>
Scroll mouse wheel over here<br/>
Scroll mouse wheel over here<br/>
Scroll mouse wheel over here<br/>
Scroll mouse wheel over here<br/>
END END END END END END END END END END END END END END<br/>
</div>
</span>
<div id="console"></div>
<script>
description("Tests the basic functionality of the standard wheel event");
runTest();
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
Tests the constructor of the standard wheel event
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS testEvent = new WheelEvent('wheel') did not throw exception.
PASS testEvent.__proto__ is WheelEvent.prototype
PASS testEvent.deltaX is 0
PASS testEvent.deltaY is 0
PASS testEvent.deltaZ is 0
PASS testEvent.deltaMode is WheelEvent.DOM_DELTA_PIXEL
PASS testEvent = new WheelEvent('wheel', { deltaX: 10.2, deltaY: 20.3, deltaZ: 30.4, deltaMode: WheelEvent.DOM_DELTA_PAGE }) did not throw exception.
PASS testEvent.__proto__ is WheelEvent.prototype
PASS testEvent.deltaX is 10.2
PASS testEvent.deltaY is 20.3
PASS testEvent.deltaZ is 30.4
PASS testEvent.deltaMode is WheelEvent.DOM_DELTA_PAGE
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent">
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests the constructor of the standard wheel event");
var testEvent;
shouldNotThrow("testEvent = new WheelEvent('wheel')");
shouldBe("testEvent.__proto__", "WheelEvent.prototype");
shouldBe("testEvent.deltaX", "0");
shouldBe("testEvent.deltaY", "0");
shouldBe("testEvent.deltaZ", "0");
shouldBe("testEvent.deltaMode", "WheelEvent.DOM_DELTA_PIXEL");
shouldNotThrow("testEvent = new WheelEvent('wheel', { deltaX: 10.2, deltaY: 20.3, deltaZ: 30.4, deltaMode: WheelEvent.DOM_DELTA_PAGE })");
shouldBe("testEvent.__proto__", "WheelEvent.prototype");
shouldBe("testEvent.deltaX", "10.2");
shouldBe("testEvent.deltaY", "20.3");
shouldBe("testEvent.deltaZ", "30.4");
shouldBe("testEvent.deltaMode", "WheelEvent.DOM_DELTA_PAGE");
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
Tests the interaction between the standard 'wheel' event and the non-standard 'mousewheel' one
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Standard wheel event was fired.
PASS testEvent.__proto__ is WheelEvent.prototype
PASS successfullyParsed is true
TEST COMPLETE
TOP TOP TOP TOP TOP TOP TOP Scroll mouse wheel over here Scroll mouse wheel over here Scroll mouse wheel over here Scroll mouse wheel over here Scroll mouse wheel over here Scroll mouse wheel over here END END END END END END END
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent">
<script src="../js/resources/js-test-pre.js"></script>
<script>
function runTest() {
var div = document.getElementById('target');
div.addEventListener('wheel', wheelHandler);
div.addEventListener('mousewheel', mouseWheelHandler);
if (window.eventSender) {
eventSender.mouseMoveTo(div.offsetLeft + 5, div.offsetTop + 5);
eventSender.mouseScrollBy(10, 20);
finishJSTest();
} else {
debug("FAIL: This test requires window.eventSender.");
finishJSTest();
}
}
var testEvent;
function wheelHandler(e) {
testEvent = e;
testPassed("Standard wheel event was fired.");
shouldBe("testEvent.__proto__", "WheelEvent.prototype");
}
function mouseWheelHandler(e) {
testFailed("mousewheel event should not have fired.");
}
</script>
</head>
<body>
<span id="parent">
<div id="target" style="border:solid 1px green; width:220px; height:70px; overflow:scroll">
TOP TOP TOP TOP TOP TOP TOP
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
END END END END END END END
</div>
</span>
<script>
description("Tests the interaction between the standard 'wheel' event and the non-standard 'mousewheel' one");
window.jsTestIsAsync = true;
runTest();
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
Scroll mouse wheel over here
END END END END END END END END END END END END END END
Tests the basic functionality of the standard wheel event
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS WheelEvent.prototype.__proto__ is MouseEvent.prototype
PASS WheelEvent.DOM_DELTA_PIXEL is 0x00
PASS WheelEvent.DOM_DELTA_LINE is 0x01
PASS WheelEvent.DOM_DELTA_PAGE is 0x02
PASS window.onwheel is null
PASS document.onwheel is null
PASS testDiv.onwheel is null
PASS testEvent.__proto__ is WheelEvent.prototype
PASS testEvent.__proto__.__proto__ is MouseEvent.prototype
PASS testEvent.deltaZ is 0
PASS testEvent.deltaMode is WheelEvent.DOM_DELTA_PIXEL
PASS testEvent.__proto__ is WheelEvent.prototype
PASS testEvent.__proto__.__proto__ is MouseEvent.prototype
PASS testEvent.deltaZ is 0
PASS testEvent.deltaMode is WheelEvent.DOM_DELTA_PIXEL
PASS deltaX > 0 is true
PASS deltaX is expectedDeltaX
PASS deltaY > 0 is true
PASS deltaY is expectedDeltaY
PASS successfullyParsed is true
TEST COMPLETE
2013-08-27 Christophe Dumez <ch.dumez@sisa.samsung.com>
Implement DOM3 wheel event
https://bugs.webkit.org/show_bug.cgi?id=94081
Reviewed by Darin Adler.
Add support for DOM Level 3 WheelEvent:
http://www.w3.org/TR/DOM-Level-3-Events/#events-WheelEvent
Firefox, IE10 and since recently Blink already support it so
it increases our cross-browser compatibility.
The non-standard 'mousewheel' event is still supported for backward
compatibility. Note that the deltas returned by the mousewheel and
the wheel events are not identical:
- They have opposite signs.
- The wheel event reports the actual amount of pixels that should be
scrolled while the legacy mousewheel event reports a factor of the
number of mouse wheel ticks (using a constant multiplier).
Tests: fast/events/wheelevent-basic.html
fast/events/wheelevent-constructor.html
fast/events/wheelevent-mousewheel-interaction.html
* dom/Document.h:
* dom/Document.idl:
* dom/Element.h:
* dom/Element.idl:
* dom/EventNames.h:
* dom/EventTarget.cpp:
(WebCore::legacyType):
(WebCore::EventTarget::shouldObserveLegacyType):
(WebCore::EventTarget::setupLegacyTypeObserverIfNeeded):
(WebCore::EventTarget::fireEventListeners):
* dom/EventTarget.h:
* dom/Node.cpp:
(WebCore::Node::didMoveToNewDocument):
(WebCore::tryAddEventListener):
(WebCore::tryRemoveEventListener):
(WebCore::Node::defaultEventHandler):
* dom/WheelEvent.cpp:
(WebCore::WheelEventInit::WheelEventInit):
(WebCore::WheelEvent::WheelEvent):
(WebCore::WheelEvent::initWheelEvent):
* dom/WheelEvent.h:
(WebCore::WheelEvent::deltaX):
(WebCore::WheelEvent::deltaY):
(WebCore::WheelEvent::deltaZ):
(WebCore::WheelEvent::wheelDelta):
(WebCore::WheelEvent::wheelDeltaX):
(WebCore::WheelEvent::wheelDeltaY):
* dom/WheelEvent.idl:
* html/HTMLAttributeNames.in:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::eventNameForAttributeName):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::addEventListener):
(WebCore::DOMWindow::removeEventListener):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* page/EventHandler.cpp:
(WebCore::EventHandler::defaultWheelEventHandler):
* plugins/blackberry/PluginViewBlackBerry.cpp:
(WebCore::PluginView::handleWheelEvent):
* svg/SVGElementInstance.cpp:
* svg/SVGElementInstance.h:
* svg/SVGElementInstance.idl:
2013-08-27 Allan Sandfeld Jensen <allan.jensen@digia.com>
Assertion while scrolling news.google.com
......@@ -278,6 +278,7 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(scroll);
DEFINE_ATTRIBUTE_EVENT_LISTENER(select);
DEFINE_ATTRIBUTE_EVENT_LISTENER(submit);
DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
DEFINE_ATTRIBUTE_EVENT_LISTENER(blur);
DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
......
......@@ -274,6 +274,7 @@
[NotEnumerable] attribute EventListener onscroll;
[NotEnumerable] attribute EventListener onselect;
[NotEnumerable] attribute EventListener onsubmit;
[NotEnumerable] attribute EventListener onwheel;
// [NotEnumerable] attribute EventListener oncanplay;
// [NotEnumerable] attribute EventListener oncanplaythrough;
......
......@@ -97,6 +97,7 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(scroll);
DEFINE_ATTRIBUTE_EVENT_LISTENER(select);
DEFINE_ATTRIBUTE_EVENT_LISTENER(submit);
DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
// These four attribute event handler attributes are overridden by HTMLBodyElement
// and HTMLFrameSetElement to forward to the DOMWindow.
......
......@@ -189,6 +189,7 @@
[NotEnumerable] attribute EventListener onscroll;
[NotEnumerable] attribute EventListener onselect;
[NotEnumerable] attribute EventListener onsubmit;
[NotEnumerable] attribute EventListener onwheel;
// [NotEnumerable] attribute EventListener oncanplay;
// [NotEnumerable] attribute EventListener oncanplaythrough;
......
......@@ -122,6 +122,7 @@ namespace WebCore {
macro(upgradeneeded) \
macro(versionchange) \
macro(visibilitychange) \
macro(wheel) \
macro(write) \
macro(writeend) \
macro(writestart) \
......
......@@ -161,12 +161,50 @@ void EventTarget::uncaughtExceptionInEventHandler()
{
}
static AtomicString prefixedType(const Event* event)
static const AtomicString& legacyType(const Event* event)
{
if (event->type() == eventNames().transitionendEvent)
return eventNames().webkitTransitionEndEvent;
return emptyString();
if (event->type() == eventNames().wheelEvent)
return eventNames().mousewheelEvent;
return emptyAtom;
}
static inline bool shouldObserveLegacyType(const AtomicString& legacyTypeName, bool hasLegacyTypeListeners, bool hasNewTypeListeners, FeatureObserver::Feature& feature)
{
if (legacyTypeName == eventNames().webkitTransitionEndEvent) {
if (hasLegacyTypeListeners) {
if (hasNewTypeListeners)
feature = FeatureObserver::PrefixedAndUnprefixedTransitionEndEvent;
else
feature = FeatureObserver::PrefixedTransitionEndEvent;
} else {
ASSERT(hasNewTypeListeners);
feature = FeatureObserver::UnprefixedTransitionEndEvent;
}
return true;
}
return false;
}
void EventTarget::setupLegacyTypeObserverIfNeeded(const AtomicString& legacyTypeName, bool hasLegacyTypeListeners, bool hasNewTypeListeners)
{
ASSERT(!legacyTypeName.isEmpty());
ASSERT(hasLegacyTypeListeners || hasNewTypeListeners);
ScriptExecutionContext* context = scriptExecutionContext();
if (!context || !context->isDocument())
return;
Document* document = toDocument(context);
if (!document->domWindow())
return;
FeatureObserver::Feature feature;
if (shouldObserveLegacyType(legacyTypeName, hasLegacyTypeListeners, hasNewTypeListeners, feature))
FeatureObserver::observe(document->domWindow(), feature);
}
bool EventTarget::fireEventListeners(Event* event)
......@@ -178,37 +216,24 @@ bool EventTarget::fireEventListeners(Event* event)
if (!d)
return true;
EventListenerVector* listenerPrefixedVector = 0;
AtomicString prefixedTypeName = prefixedType(event);
if (!prefixedTypeName.isEmpty())
listenerPrefixedVector = d->eventListenerMap.find(prefixedTypeName);
EventListenerVector* legacyListenersVector = 0;
const AtomicString& legacyTypeName = legacyType(event);
if (!legacyTypeName.isEmpty())
legacyListenersVector = d->eventListenerMap.find(legacyTypeName);
EventListenerVector* listenerUnprefixedVector = d->eventListenerMap.find(event->type());
EventListenerVector* listenersVector = d->eventListenerMap.find(event->type());
if (listenerUnprefixedVector)
fireEventListeners(event, d, *listenerUnprefixedVector);
else if (listenerPrefixedVector) {
AtomicString unprefixedTypeName = event->type();
event->setType(prefixedTypeName);
fireEventListeners(event, d, *listenerPrefixedVector);
event->setType(unprefixedTypeName);
if (listenersVector)
fireEventListeners(event, d, *listenersVector);
else if (legacyListenersVector) {
AtomicString typeName = event->type();
event->setType(legacyTypeName);
fireEventListeners(event, d, *legacyListenersVector);
event->setType(typeName);
}
if (!prefixedTypeName.isEmpty()) {
ScriptExecutionContext* context = scriptExecutionContext();
if (context && context->isDocument()) {
Document* document = toDocument(context);
if (document->domWindow()) {
if (listenerPrefixedVector)
if (listenerUnprefixedVector)
FeatureObserver::observe(document->domWindow(), FeatureObserver::PrefixedAndUnprefixedTransitionEndEvent);
else
FeatureObserver::observe(document->domWindow(), FeatureObserver::PrefixedTransitionEndEvent);
else if (listenerUnprefixedVector)
FeatureObserver::observe(document->domWindow(), FeatureObserver::UnprefixedTransitionEndEvent);
}
}
}
if (!legacyTypeName.isEmpty() && (legacyListenersVector || listenersVector))
setupLegacyTypeObserverIfNeeded(legacyTypeName, !!legacyListenersVector, !!listenersVector);
return !event->defaultPrevented();
}
......
......@@ -147,6 +147,7 @@ namespace WebCore {
virtual void derefEventTarget() = 0;
void fireEventListeners(Event*, EventTargetData*, EventListenerVector&);
void setupLegacyTypeObserverIfNeeded(const AtomicString& legacyTypeName, bool hasLegacyTypeListeners, bool hasNewTypeListeners);
friend class EventListenerIterator;
};
......
......@@ -1878,7 +1878,13 @@ void Node::didMoveToNewDocument(Document* oldDocument)
if (AXObjectCache* cache = oldDocument->existingAXObjectCache())
cache->remove(this);
const EventListenerVector& wheelListeners = getEventListeners(eventNames().mousewheelEvent);
const EventListenerVector& mousewheelListeners = getEventListeners(eventNames().mousewheelEvent);
for (size_t i = 0; i < mousewheelListeners.size(); ++i) {
oldDocument->didRemoveWheelEventHandler();
document()->didAddWheelEventHandler();
}
const EventListenerVector& wheelListeners = getEventListeners(eventNames().wheelEvent);
for (size_t i = 0; i < wheelListeners.size(); ++i) {
oldDocument->didRemoveWheelEventHandler();
document()->didAddWheelEventHandler();
......@@ -1913,7 +1919,7 @@ static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
if (Document* document = targetNode->document()) {
document->addListenerTypeIfNeeded(eventType);
if (eventType == eventNames().mousewheelEvent)
if (eventType == eventNames().wheelEvent || eventType == eventNames().mousewheelEvent)
document->didAddWheelEventHandler();
else if (eventNames().isTouchEventType(eventType))
document->didAddTouchEventHandler(targetNode);
......@@ -1935,7 +1941,7 @@ static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
// FIXME: Notify Document that the listener has vanished. We need to keep track of a number of
// listeners for each type, not just a bool - see https://bugs.webkit.org/show_bug.cgi?id=33861
if (Document* document = targetNode->document()) {
if (eventType == eventNames().mousewheelEvent)
if (eventType == eventNames().wheelEvent || eventType == eventNames().mousewheelEvent)
document->didRemoveWheelEventHandler();
else if (eventNames().isTouchEventType(eventType))
document->didRemoveTouchEventHandler(targetNode);
......@@ -2243,7 +2249,7 @@ void Node::defaultEventHandler(Event* event)
}
}
#endif
} else if (eventType == eventNames().mousewheelEvent && event->hasInterface(eventNames().interfaceForWheelEvent)) {
} else if ((eventType == eventNames().wheelEvent || eventType == eventNames().mousewheelEvent) && event->hasInterface(eventNames().interfaceForWheelEvent)) {
WheelEvent* wheelEvent = static_cast<WheelEvent*>(event);
// If we don't have a renderer, send the wheel event to the first node we find with a renderer.
......
......@@ -3,6 +3,7 @@
* Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
* Copyright (C) 2003, 2005, 2006, 2008, 2010, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -33,21 +34,30 @@
namespace WebCore {
WheelEventInit::WheelEventInit()
: wheelDeltaX(0)
, wheelDeltaY(0)
: deltaX(0)
, deltaY(0)
, deltaZ(0)
, deltaMode(WheelEvent::DOM_DELTA_PIXEL)
, wheelDeltaX(0)
, wheelDeltaY(0)
{
}
WheelEvent::WheelEvent()
: m_deltaMode(DOM_DELTA_PIXEL)
: m_deltaX(0)
, m_deltaY(0)
, m_deltaZ(0)
, m_deltaMode(DOM_DELTA_PIXEL)
, m_directionInvertedFromDevice(false)
{
}
WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializer)
: MouseEvent(type, initializer)
, m_wheelDelta(IntPoint(initializer.wheelDeltaX, initializer.wheelDeltaY))
, m_wheelDelta(initializer.wheelDeltaX ? initializer.wheelDeltaX : -initializer.deltaX, initializer.wheelDeltaY ? initializer.wheelDeltaY : -initializer.deltaY)
, m_deltaX(initializer.deltaX ? initializer.deltaX : -initializer.wheelDeltaX)
, m_deltaY(initializer.deltaY ? initializer.deltaY : -initializer.wheelDeltaY)
, m_deltaZ(initializer.deltaZ)
, m_deltaMode(initializer.deltaMode)
{
}
......@@ -55,15 +65,17 @@ WheelEvent::WheelEvent(const AtomicString& type, const WheelEventInit& initializ
WheelEvent::WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta, unsigned deltaMode,
PassRefPtr<AbstractView> view, const IntPoint& screenLocation, const IntPoint& pageLocation,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool directionInvertedFromDevice, double timestamp)
: MouseEvent(eventNames().mousewheelEvent,
: MouseEvent(eventNames().wheelEvent,
true, true, timestamp, view, 0, screenLocation.x(), screenLocation.y(),
pageLocation.x(), pageLocation.y(),
#if ENABLE(POINTER_LOCK)
0, 0,
#endif
ctrlKey, altKey, shiftKey, metaKey, 0, 0, 0, false)
, m_wheelDelta(IntPoint(static_cast<int>(wheelTicks.x() * TickMultiplier), static_cast<int>(wheelTicks.y() * TickMultiplier)))
, m_rawDelta(roundedIntPoint(rawDelta))
, m_wheelDelta(wheelTicks.x() * TickMultiplier, wheelTicks.y() * TickMultiplier)
, m_deltaX(-rawDelta.x())
, m_deltaY(-rawDelta.y())
, m_deltaZ(0)
, m_deltaMode(deltaMode)
, m_directionInvertedFromDevice(directionInvertedFromDevice)
{
......@@ -76,18 +88,19 @@ void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<Abstrac
if (dispatched())
return;
initUIEvent(eventNames().mousewheelEvent, true, true, view, 0);
initUIEvent(eventNames().wheelEvent, true, true, view, 0);
m_screenLocation = IntPoint(screenX, screenY);
m_ctrlKey = ctrlKey;
m_altKey = altKey;
m_shiftKey = shiftKey;
m_metaKey = metaKey;
// Normalize to the Windows 120 multiple
// Normalize to 120 multiple for compatibility with IE.
m_wheelDelta = IntPoint(rawDeltaX * TickMultiplier, rawDeltaY * TickMultiplier);
m_rawDelta = IntPoint(rawDeltaX, rawDeltaY);
m_deltaX = -rawDeltaX;
m_deltaY = -rawDeltaY;
m_deltaMode = DOM_DELTA_PIXEL;
m_directionInvertedFromDevice = false;
......
......@@ -3,6 +3,7 @@
* Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -35,9 +36,12 @@ class PlatformWheelEvent;
struct WheelEventInit : public MouseEventInit {
WheelEventInit();