Refactoring: move EventHandler::targetNode into HitTestResult

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

Patch by Iain Merrick <husky@chromium.org> on 2012-08-15
Reviewed by Dimitri Glazkov.

Source/WebCore:

This static helper method in EventHandler was made public so that
WebFrameImpl can call it. That's untidy because EventHandler isn't
really involved. This patch turns it into an instance method of
HitTestResult (with a wrapper in MouseEventWithHitTestResult for
convenience).

Pure refactoring, no behavior change, no new test needed.

* page/EventHandler.cpp:
(WebCore::EventHandler::selectClosestWordFromMouseEvent):
(WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent):
(WebCore::EventHandler::handleMousePressEventTripleClick):
(WebCore::EventHandler::handleMousePressEventSingleClick):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::subframeForHitTestResult):
(WebCore::EventHandler::selectCursor):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::handleGestureEvent):
(WebCore::EventHandler::sendContextMenuEvent):
* page/EventHandler.h:
(EventHandler):
* page/MouseEventWithHitTestResults.h:
(WebCore::MouseEventWithHitTestResults::targetNode):
* page/chromium/EventHandlerChromium.cpp:
(WebCore::EventHandler::passMousePressEventToSubframe):
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/efl/EventHandlerEfl.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
(WebCore::EventHandler::passSubframeEventToSubframe):
* page/wx/EventHandlerWx.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::targetNode):
(WebCore):
* rendering/HitTestResult.h:
(HitTestResult):

Source/WebKit/chromium:

This static helper method in EventHandler was made public so that
WebFrameImpl can call it. That's untidy because EventHandler isn't
really involved. This patch turns it into an instance method of
HitTestResult (with a wrapper in MouseEventWithHitTestResult for
convenience).

Pure refactoring, no behavior change, no new test needed.

* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::visiblePositionForWindowPoint):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9683461d
2012-08-15 Iain Merrick <husky@chromium.org>
Refactoring: move EventHandler::targetNode into HitTestResult
https://bugs.webkit.org/show_bug.cgi?id=94107
Reviewed by Dimitri Glazkov.
This static helper method in EventHandler was made public so that
WebFrameImpl can call it. That's untidy because EventHandler isn't
really involved. This patch turns it into an instance method of
HitTestResult (with a wrapper in MouseEventWithHitTestResult for
convenience).
Pure refactoring, no behavior change, no new test needed.
* page/EventHandler.cpp:
(WebCore::EventHandler::selectClosestWordFromMouseEvent):
(WebCore::EventHandler::selectClosestWordOrLinkFromMouseEvent):
(WebCore::EventHandler::handleMousePressEventTripleClick):
(WebCore::EventHandler::handleMousePressEventSingleClick):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::handleMouseDraggedEvent):
(WebCore::EventHandler::updateSelectionForMouseDrag):
(WebCore::EventHandler::handleMouseReleaseEvent):
(WebCore::EventHandler::subframeForHitTestResult):
(WebCore::EventHandler::selectCursor):
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::updateDragAndDrop):
(WebCore::EventHandler::handleGestureEvent):
(WebCore::EventHandler::sendContextMenuEvent):
* page/EventHandler.h:
(EventHandler):
* page/MouseEventWithHitTestResults.h:
(WebCore::MouseEventWithHitTestResults::targetNode):
* page/chromium/EventHandlerChromium.cpp:
(WebCore::EventHandler::passMousePressEventToSubframe):
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/efl/EventHandlerEfl.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
(WebCore::EventHandler::passSubframeEventToSubframe):
* page/wx/EventHandlerWx.cpp:
(WebCore::EventHandler::passWidgetMouseDownEventToWidget):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::targetNode):
(WebCore):
* rendering/HitTestResult.h:
(HitTestResult):
2012-08-15 David Grogan <dgrogan@chromium.org>
IndexedDB: Add some ASSERTs
This diff is collapsed.
......@@ -230,8 +230,6 @@ public:
bool handleTouchEvent(const PlatformTouchEvent&);
#endif
static Node* targetNode(const HitTestResult&);
private:
#if ENABLE(DRAG_SUPPORT)
static DragState& dragState();
......@@ -247,8 +245,6 @@ private:
bool handleMouseDoubleClickEvent(const PlatformMouseEvent&);
static Node* targetNode(const MouseEventWithHitTestResults&);
bool handleMousePressEvent(const MouseEventWithHitTestResults&);
bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);
bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
......
......@@ -38,6 +38,7 @@ public:
Scrollbar* scrollbar() const { return m_hitTestResult.scrollbar(); }
bool isOverLink() const;
bool isOverWidget() const { return m_hitTestResult.isOverWidget(); }
Node* targetNode() const { return m_hitTestResult.targetNode(); }
private:
PlatformMouseEvent m_event;
......
......@@ -61,7 +61,7 @@ bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
IntPoint p = m_frame->view()->windowToContents(mev.event().position());
if (m_frame->selection()->contains(p)) {
VisiblePosition visiblePos(
targetNode(mev)->renderer()->positionForPoint(mev.localPoint()));
mev.targetNode()->renderer()->positionForPoint(mev.localPoint()));
VisibleSelection newSelection(visiblePos);
if (m_frame->selection()->shouldChangeSelection(newSelection))
m_frame->selection()->setSelection(newSelection);
......@@ -103,9 +103,9 @@ bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& wheelEvent,
bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
{
// Figure out which view to send the event to.
if (!targetNode(event) || !targetNode(event)->renderer() || !targetNode(event)->renderer()->isWidget())
if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetNode()->renderer()->isWidget())
return false;
return passMouseDownEventToWidget(toRenderWidget(targetNode(event)->renderer())->widget());
return passMouseDownEventToWidget(toRenderWidget(event.targetNode()->renderer())->widget());
}
bool EventHandler::passMouseDownEventToWidget(Widget* widget)
......
......@@ -63,7 +63,7 @@ void EventHandler::focusDocumentView()
bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
{
RenderObject* target = targetNode(event) ? targetNode(event)->renderer() : 0;
RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
if (!target || !target->isWidget())
return false;
......
......@@ -59,7 +59,7 @@ void EventHandler::focusDocumentView()
bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
{
// Figure out which view to send the event to.
RenderObject* target = targetNode(event) ? targetNode(event)->renderer() : 0;
RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
if (!target || !target->isWidget())
return false;
return passMouseDownEventToWidget(toRenderWidget(target)->widget());
......
......@@ -138,7 +138,7 @@ void EventHandler::focusDocumentView()
bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
{
// Figure out which view to send the event to.
RenderObject* target = targetNode(event) ? targetNode(event)->renderer() : 0;
RenderObject* target = event.targetNode() ? event.targetNode()->renderer() : 0;
if (!target || !target->isWidget())
return false;
......@@ -352,7 +352,7 @@ bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& eve
return true;
case NSLeftMouseDown: {
Node* node = targetNode(event);
Node* node = event.targetNode();
if (!node)
return false;
RenderObject* renderer = node->renderer();
......
......@@ -63,10 +63,10 @@ bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults&
bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event)
{
// Figure out which view to send the event to.
if (!targetNode(event) || !targetNode(event)->renderer() || !targetNode(event)->renderer()->isWidget())
if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetNode()->renderer()->isWidget())
return false;
return passMouseDownEventToWidget(toRenderWidget(targetNode(event)->renderer())->widget());
return passMouseDownEventToWidget(toRenderWidget(event.targetNode()->renderer())->widget());
}
bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget)
......
......@@ -795,4 +795,19 @@ Vector<String> HitTestResult::dictationAlternatives() const
return frame->editor()->dictationAlternativesForMarker(marker);
}
Node* HitTestResult::targetNode() const
{
Node* node = innerNode();
if (!node)
return 0;
if (node->inDocument())
return node;
Element* element = node->parentElement();
if (element && element->inDocument())
return element;
return node;
}
} // namespace WebCore
......@@ -177,6 +177,8 @@ public:
Vector<String> dictationAlternatives() const;
Node* targetNode() const;
private:
NodeSet& mutableRectBasedTestResult(); // See above.
......
2012-08-15 Iain Merrick <husky@chromium.org>
Refactoring: move EventHandler::targetNode into HitTestResult
https://bugs.webkit.org/show_bug.cgi?id=94107
Reviewed by Dimitri Glazkov.
This static helper method in EventHandler was made public so that
WebFrameImpl can call it. That's untidy because EventHandler isn't
really involved. This patch turns it into an instance method of
HitTestResult (with a wrapper in MouseEventWithHitTestResult for
convenience).
Pure refactoring, no behavior change, no new test needed.
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::visiblePositionForWindowPoint):
2012-08-15 David Grogan <dgrogan@chromium.org>
IndexedDB: Add some ASSERTs
......
......@@ -1503,7 +1503,7 @@ VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& poin
frame()->document()->renderView()->layer()->hitTest(request, result);
Node* node = EventHandler::targetNode(result);
Node* node = result.targetNode();
if (!node)
return VisiblePosition();
......
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