Commit 6fcecbbd authored by akling@apple.com's avatar akling@apple.com

Move mouse event dispatch from Node to Element.

<https://webkit.org/b/122203>

Reviewed by Anders Carlsson.

We never dispatch mouse events on text or other non-element nodes,
so move the related logic to using Element.

Node::dispatchMouseEvent() moves to Element. I also changed the
relatedTarget argument to be an Element* since the related target
is never a Node either.

Most of this patch is *Node -> *Element renames in EventHandler.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156761 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2ab68261
2013-10-01 Andreas Kling <akling@apple.com>
Move mouse event dispatch from Node to Element.
<https://webkit.org/b/122203>
Reviewed by Anders Carlsson.
We never dispatch mouse events on text or other non-element nodes,
so move the related logic to using Element.
Node::dispatchMouseEvent() moves to Element. I also changed the
relatedTarget argument to be an Element* since the related target
is never a Node either.
Most of this patch is *Node -> *Element renames in EventHandler.
2013-10-01 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Generate toCSSFooValue for CSS child values
......@@ -185,7 +185,7 @@ __ZN7WebCore12EventHandler20hitTestResultAtPointERKNS_11LayoutPointEjRKNS_10Layo
__ZN7WebCore12EventHandler21handleMousePressEventERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler23handleMouseReleaseEventERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler24logicalScrollRecursivelyENS_22ScrollLogicalDirectionENS_17ScrollGranularityEPNS_4NodeE
__ZN7WebCore12EventHandler27setCapturingMouseEventsNodeEN3WTF10PassRefPtrINS_4NodeEEE
__ZN7WebCore12EventHandler30setCapturingMouseEventsElementEN3WTF10PassRefPtrINS_7ElementEEE
__ZN7WebCore12EventHandler31passMouseMovedEventToScrollbarsERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler33sendFakeEventsAfterWidgetTrackingEP7NSEvent
__ZN7WebCore12EventHandler8keyEventERKNS_21PlatformKeyboardEventE
......
......@@ -240,6 +240,11 @@ bool Element::shouldUseInputMethod()
return isContentEditable(UserSelectAllIsAlwaysNonEditable);
}
bool Element::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicString& eventType, int detail, Element* relatedTarget)
{
return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::create(MouseEvent::create(eventType, document().defaultView(), event, detail, relatedTarget)));
}
bool Element::dispatchWheelEvent(const PlatformWheelEvent& event)
{
return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::create(event, document().defaultView()));
......
......@@ -43,6 +43,8 @@ class ElementRareData;
class HTMLDocument;
class IntSize;
class Locale;
class PlatformKeyboardEvent;
class PlatformMouseEvent;
class PlatformWheelEvent;
class PseudoElement;
class RenderRegion;
......@@ -532,6 +534,7 @@ public:
IntSize savedLayerScrollOffset() const;
void setSavedLayerScrollOffset(const IntSize&);
bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Element* relatedTarget = nullptr);
bool dispatchWheelEvent(const PlatformWheelEvent&);
bool dispatchKeyEvent(const PlatformKeyboardEvent&);
void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
......
......@@ -2110,12 +2110,6 @@ bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEven
return event->defaultHandled();
}
bool Node::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicString& eventType,
int detail, Node* relatedTarget)
{
return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::create(MouseEvent::create(eventType, document().defaultView(), event, detail, relatedTarget)));
}
#if ENABLE(GESTURE_EVENTS)
bool Node::dispatchGestureEvent(const PlatformGestureEvent& event)
{
......
......@@ -70,8 +70,6 @@ class NameNodeList;
class NodeList;
class NodeListsNodeData;
class NodeRareData;
class PlatformKeyboardEvent;
class PlatformMouseEvent;
class QualifiedName;
class RadioNodeList;
class RegisteredEventListener;
......@@ -543,7 +541,6 @@ public:
void dispatchSubtreeModifiedEvent();
bool dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent);
bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Node* relatedTarget = 0);
#if ENABLE(GESTURE_EVENTS)
bool dispatchGestureEvent(const PlatformGestureEvent&);
#endif
......
......@@ -96,7 +96,7 @@ void HTMLPlugInElement::willDetachRenderers()
if (m_isCapturingMouseEvents) {
if (Frame* frame = document().frame())
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
m_isCapturingMouseEvents = false;
}
......
......@@ -110,7 +110,7 @@ void MediaControlPanelElement::startDrag(const LayoutPoint& eventLocation)
m_lastDragEventLocation = eventLocation;
frame->eventHandler().setCapturingMouseEventsNode(this);
frame->eventHandler().setCapturingMouseEventsElement(this);
m_isBeingDragged = true;
}
......@@ -137,7 +137,7 @@ void MediaControlPanelElement::endDrag()
if (!frame)
return;
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
}
void MediaControlPanelElement::startTimer()
......
......@@ -321,7 +321,7 @@ void SliderThumbElement::setPositionFromPoint(const LayoutPoint& absolutePoint)
void SliderThumbElement::startDragging()
{
if (Frame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(this);
frame->eventHandler().setCapturingMouseEventsElement(this);
m_inDragMode = true;
}
}
......@@ -332,7 +332,7 @@ void SliderThumbElement::stopDragging()
return;
if (Frame* frame = document().frame())
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
m_inDragMode = false;
if (renderer())
renderer()->setNeedsLayout(true);
......@@ -398,7 +398,7 @@ void SliderThumbElement::willDetachRenderers()
{
if (m_inDragMode) {
if (Frame* frame = document().frame())
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
}
}
......
......@@ -120,7 +120,7 @@ void SpinButtonElement::defaultEventHandler(Event* event)
if (box->pixelSnappedBorderBoxRect().contains(local)) {
if (!m_capturing) {
if (Frame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(this);
frame->eventHandler().setCapturingMouseEventsElement(this);
m_capturing = true;
if (Page* page = document().page())
page->chrome().registerPopupOpeningObserver(this);
......@@ -196,7 +196,7 @@ void SpinButtonElement::releaseCapture()
stopRepeatingTimer();
if (m_capturing) {
if (Frame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
m_capturing = false;
if (Page* page = document().page())
page->chrome().unregisterPopupOpeningObserver(this);
......
......@@ -201,7 +201,7 @@ void SearchFieldCancelButtonElement::willDetachRenderers()
{
if (m_capturing) {
if (Frame* frame = document().frame())
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
}
}
......@@ -218,7 +218,7 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(this);
frame->eventHandler().setCapturingMouseEventsElement(this);
m_capturing = true;
}
}
......@@ -229,7 +229,7 @@ void SearchFieldCancelButtonElement::defaultEventHandler(Event* event)
if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (m_capturing) {
if (Frame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
m_capturing = false;
}
if (hovered()) {
......@@ -305,7 +305,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
if (event->type() == eventNames().mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(this);
frame->eventHandler().setCapturingMouseEventsElement(this);
m_capturing = true;
}
}
......@@ -318,7 +318,7 @@ void InputFieldSpeechButtonElement::defaultEventHandler(Event* event)
if (event->type() == eventNames().mouseupEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (m_capturing && renderer() && renderer()->visibleToHitTesting()) {
if (Frame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
m_capturing = false;
}
}
......@@ -416,7 +416,7 @@ void InputFieldSpeechButtonElement::willDetachRenderers()
{
if (m_capturing) {
if (Frame* frame = document().frame())
frame->eventHandler().setCapturingMouseEventsNode(0);
frame->eventHandler().setCapturingMouseEventsElement(nullptr);
}
if (m_listenerId) {
......
This diff is collapsed.
......@@ -138,7 +138,7 @@ public:
bool mousePressed() const { return m_mousePressed; }
void setMousePressed(bool pressed) { m_mousePressed = pressed; }
void setCapturingMouseEventsNode(PassRefPtr<Node>); // A caller is responsible for resetting capturing node to 0.
void setCapturingMouseEventsElement(PassRefPtr<Element>); // A caller is responsible for resetting capturing element to 0.
#if ENABLE(DRAG_SUPPORT)
bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*);
......@@ -448,11 +448,11 @@ private:
RenderLayer* m_resizeLayer;
RefPtr<Node> m_capturingMouseEventsNode;
bool m_eventHandlerWillResetCapturingMouseEventsNode;
RefPtr<Element> m_capturingMouseEventsElement;
bool m_eventHandlerWillResetCapturingMouseEventsElement;
RefPtr<Node> m_nodeUnderMouse;
RefPtr<Node> m_lastNodeUnderMouse;
RefPtr<Element> m_elementUnderMouse;
RefPtr<Element> m_lastElementUnderMouse;
RefPtr<Frame> m_lastMouseMoveEventSubframe;
RefPtr<Scrollbar> m_lastScrollbarUnderMouse;
Cursor m_currentMouseCursor;
......
......@@ -615,7 +615,7 @@ void RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent(Event* event)
if (event->type() == eventNames().mousedownEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
m_mouseDownWasInUnavailablePluginIndicator = isInUnavailablePluginIndicator(mouseEvent);
if (m_mouseDownWasInUnavailablePluginIndicator) {
frame().eventHandler().setCapturingMouseEventsNode(&element);
frame().eventHandler().setCapturingMouseEventsElement(&element);
element.setIsCapturingMouseEvents(true);
setUnavailablePluginIndicatorIsPressed(true);
}
......@@ -623,7 +623,7 @@ void RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent(Event* event)
}
if (event->type() == eventNames().mouseupEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
if (m_unavailablePluginIndicatorIsPressed) {
frame().eventHandler().setCapturingMouseEventsNode(0);
frame().eventHandler().setCapturingMouseEventsElement(nullptr);
element.setIsCapturingMouseEvents(false);
setUnavailablePluginIndicatorIsPressed(false);
}
......
......@@ -883,9 +883,9 @@ void PluginView::handleEvent(Event* event)
// FIXME: Clicking in a scroll bar should not change focus.
if (currentEvent->type() == WebEvent::MouseDown) {
focusPluginElement();
frame()->eventHandler().setCapturingMouseEventsNode(m_pluginElement.get());
frame()->eventHandler().setCapturingMouseEventsElement(m_pluginElement.get());
} else if (currentEvent->type() == WebEvent::MouseUp)
frame()->eventHandler().setCapturingMouseEventsNode(0);
frame()->eventHandler().setCapturingMouseEventsElement(nullptr);
didHandleEvent = m_plugin->handleMouseEvent(static_cast<const WebMouseEvent&>(*currentEvent));
if (event->type() != eventNames().mousemoveEvent)
......
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