Commit 3e7723da authored by aroben's avatar aroben

Change MouseEventWithHitTestResults to hold onto a HitTestResult

Reviewed by Sam.

* dom/Document.cpp:
(WebCore::Document::prepareMouseEvent):
* page/MouseEventWithHitTestResults.cpp:
(WebCore::MouseEventWithHitTestResults::MouseEventWithHitTestResults):
(WebCore::MouseEventWithHitTestResults::targetNode):
(WebCore::MouseEventWithHitTestResults::localPoint):
(WebCore::MouseEventWithHitTestResults::scrollbar):
* page/MouseEventWithHitTestResults.h:
(WebCore::MouseEventWithHitTestResults::event):
(WebCore::MouseEventWithHitTestResults::hitTestResult):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@23994 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b90617df
2007-07-04 Adam Roben <aroben@apple.com>
Change MouseEventWithHitTestResults to hold onto a HitTestResult
Reviewed by Sam.
* dom/Document.cpp:
(WebCore::Document::prepareMouseEvent):
* page/MouseEventWithHitTestResults.cpp:
(WebCore::MouseEventWithHitTestResults::MouseEventWithHitTestResults):
(WebCore::MouseEventWithHitTestResults::targetNode):
(WebCore::MouseEventWithHitTestResults::localPoint):
(WebCore::MouseEventWithHitTestResults::scrollbar):
* page/MouseEventWithHitTestResults.h:
(WebCore::MouseEventWithHitTestResults::event):
(WebCore::MouseEventWithHitTestResults::hitTestResult):
2007-07-04 Matt Lilek <pewtermoose@gmail.com>
Not reviewed, gdk build fix.
......@@ -1748,7 +1748,7 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& r
ASSERT(!renderer() || renderer()->isRenderView());
if (!renderer())
return MouseEventWithHitTestResults(event, 0, IntPoint(), 0, false);
return MouseEventWithHitTestResults(event, HitTestResult(IntPoint()));
HitTestResult result(documentPoint);
renderer()->layer()->hitTest(request, result);
......@@ -1756,8 +1756,7 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& r
if (!request.readonly)
updateRendering();
bool isOverLink = result.URLElement() && result.URLElement()->isLink();
return MouseEventWithHitTestResults(event, result.innerNode(), result.localPoint(), result.scrollbar(), isOverLink);
return MouseEventWithHitTestResults(event, result);
}
// DOM Section 1.1.1
......
......@@ -20,6 +20,9 @@
#include "config.h"
#include "MouseEventWithHitTestResults.h"
#include "Element.h"
#include "Node.h"
// Would TargetedMouseEvent be a better name?
namespace WebCore {
......@@ -34,22 +37,38 @@ static inline Element* targetElement(Node* node)
return static_cast<Element*>(parent);
}
MouseEventWithHitTestResults::MouseEventWithHitTestResults(const PlatformMouseEvent& event,
PassRefPtr<Node> node, const IntPoint& localPoint, PlatformScrollbar* scrollbar, bool isOverLink)
MouseEventWithHitTestResults::MouseEventWithHitTestResults(const PlatformMouseEvent& event, const HitTestResult& hitTestResult)
: m_event(event)
, m_targetNode(node)
, m_targetElement(targetElement(m_targetNode.get()))
, m_localPoint(localPoint)
, m_scrollbar(scrollbar)
, m_isOverLink(isOverLink)
, m_hitTestResult(hitTestResult)
{
}
Node* MouseEventWithHitTestResults::targetNode() const
{
if (m_targetElement && !m_targetNode->inDocument() && m_targetElement->inDocument())
return m_targetElement.get();
return m_targetNode.get();
Node* node = m_hitTestResult.innerNonSharedNode();
if (node && node->inDocument())
return node;
Element* element = targetElement(node);
if (element && element->inDocument())
return element;
return node;
}
const IntPoint MouseEventWithHitTestResults::localPoint() const
{
return m_hitTestResult.localPoint();
}
PlatformScrollbar* MouseEventWithHitTestResults::scrollbar() const
{
return m_hitTestResult.scrollbar();
}
bool MouseEventWithHitTestResults::isOverLink() const
{
return m_hitTestResult.URLElement() && m_hitTestResult.URLElement()->isLink();
}
}
......@@ -21,7 +21,7 @@
#ifndef MouseEventWithHitTestResults_h
#define MouseEventWithHitTestResults_h
#include "Element.h"
#include "HitTestResult.h"
#include "PlatformMouseEvent.h"
namespace WebCore {
......@@ -31,21 +31,18 @@ class PlatformScrollbar;
// FIXME: Why doesn't this class just cache a HitTestResult instead of copying all of HitTestResult's fields over?
class MouseEventWithHitTestResults {
public:
MouseEventWithHitTestResults(const PlatformMouseEvent&, PassRefPtr<Node>, const IntPoint& localPoint, PlatformScrollbar*, bool isOverLink);
MouseEventWithHitTestResults(const PlatformMouseEvent&, const HitTestResult&);
const PlatformMouseEvent& event() const { return m_event; }
const HitTestResult& hitTestResult() const { return m_hitTestResult; }
Node* targetNode() const;
const IntPoint& localPoint() const { return m_localPoint; }
PlatformScrollbar* scrollbar() const { return m_scrollbar; }
bool isOverLink() const { return m_isOverLink; }
const IntPoint localPoint() const;
PlatformScrollbar* scrollbar() const;
bool isOverLink() const;
private:
PlatformMouseEvent m_event;
RefPtr<Node> m_targetNode;
RefPtr<Element> m_targetElement;
IntPoint m_localPoint;
PlatformScrollbar* m_scrollbar;
bool m_isOverLink;
HitTestResult m_hitTestResult;
};
}
......
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