Commit b229fe49 authored by eae@chromium.org's avatar eae@chromium.org

Switch HitTestResult to to new layout types

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

Reviewed by Eric Seidel.

No new tests, no functionality changes.

* page/MouseEventWithHitTestResults.cpp:
(WebCore::MouseEventWithHitTestResults::localPoint):
* page/MouseEventWithHitTestResults.h:
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::HitTestResult):
(WebCore::HitTestResult::addNodeToRectBasedTestResult):
(WebCore::HitTestResult::rectForPoint):
* rendering/HitTestResult.h:
(WebCore::HitTestResult::point):
(WebCore::HitTestResult::localPoint):
(WebCore::HitTestResult::setPoint):
(WebCore::HitTestResult::setLocalPoint):
(WebCore::HitTestResult::rectForPoint):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@90603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d4e53d67
2011-07-07 Emil A Eklund <eae@chromium.org>
Switch HitTestResult to to new layout types
https://bugs.webkit.org/show_bug.cgi?id=64131
Reviewed by Eric Seidel.
No new tests, no functionality changes.
* page/MouseEventWithHitTestResults.cpp:
(WebCore::MouseEventWithHitTestResults::localPoint):
* page/MouseEventWithHitTestResults.h:
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::HitTestResult):
(WebCore::HitTestResult::addNodeToRectBasedTestResult):
(WebCore::HitTestResult::rectForPoint):
* rendering/HitTestResult.h:
(WebCore::HitTestResult::point):
(WebCore::HitTestResult::localPoint):
(WebCore::HitTestResult::setPoint):
(WebCore::HitTestResult::setLocalPoint):
(WebCore::HitTestResult::rectForPoint):
2011-07-07 Levi Weintraub <leviw@chromium.org>
Switch remaining paint functions to new layout types
......
......@@ -33,7 +33,7 @@ MouseEventWithHitTestResults::MouseEventWithHitTestResults(const PlatformMouseEv
{
}
const IntPoint MouseEventWithHitTestResults::localPoint() const
const LayoutPoint MouseEventWithHitTestResults::localPoint() const
{
return m_hitTestResult.localPoint();
}
......
......@@ -34,7 +34,7 @@ public:
const PlatformMouseEvent& event() const { return m_event; }
const HitTestResult& hitTestResult() const { return m_hitTestResult; }
const IntPoint localPoint() const;
const LayoutPoint localPoint() const;
Scrollbar* scrollbar() const;
bool isOverLink() const;
bool isOverWidget() const { return m_hitTestResult.isOverWidget(); }
......
......@@ -55,7 +55,7 @@ HitTestResult::HitTestResult()
{
}
HitTestResult::HitTestResult(const IntPoint& point)
HitTestResult::HitTestResult(const LayoutPoint& point)
: m_point(point)
, m_isOverWidget(false)
, m_isRectBased(false)
......@@ -66,7 +66,7 @@ HitTestResult::HitTestResult(const IntPoint& point)
{
}
HitTestResult::HitTestResult(const IntPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
: m_point(centerPoint)
, m_isOverWidget(false)
, m_topPadding(topPadding)
......@@ -508,7 +508,7 @@ bool HitTestResult::isContentEditable() const
return m_innerNonSharedNode->rendererIsEditable();
}
bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const IntPoint& pointInContainer, const IntRect& rect)
bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const LayoutPoint& pointInContainer, const LayoutRect& rect)
{
// If it is not a rect-based hit test, this method has to be no-op.
// Return false, so the hit test stops.
......@@ -539,7 +539,7 @@ bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const IntPoint& poi
return !rect.contains(rectForPoint(pointInContainer));
}
bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const IntPoint& pointInContainer, const FloatRect& rect)
bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const LayoutPoint& pointInContainer, const FloatRect& rect)
{
// If it is not a rect-based hit test, this method has to be no-op.
// Return false, so the hit test stops.
......@@ -590,16 +590,16 @@ void HitTestResult::append(const HitTestResult& other)
}
}
IntRect HitTestResult::rectForPoint(const IntPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
LayoutRect HitTestResult::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
{
IntPoint actualPoint(point);
actualPoint -= IntSize(leftPadding, topPadding);
LayoutPoint actualPoint(point);
actualPoint -= LayoutSize(leftPadding, topPadding);
IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding);
// As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1".
actualPadding += IntSize(1, 1);
return IntRect(actualPoint, actualPadding);
return LayoutRect(actualPoint, actualPadding);
}
const HitTestResult::NodeSet& HitTestResult::rectBasedTestResult() const
......
......@@ -21,9 +21,7 @@
#define HitTestResult_h
#include "FloatRect.h"
#include "IntPoint.h"
#include "IntRect.h"
#include "IntSize.h"
#include "LayoutTypes.h"
#include "TextDirection.h"
#include <wtf/Forward.h>
#include <wtf/ListHashSet.h>
......@@ -38,7 +36,6 @@ class Frame;
class HTMLMediaElement;
#endif
class Image;
class IntRect;
class KURL;
class Node;
class Scrollbar;
......@@ -48,17 +45,17 @@ public:
typedef ListHashSet<RefPtr<Node> > NodeSet;
HitTestResult();
HitTestResult(const IntPoint&);
HitTestResult(const LayoutPoint&);
// Pass non-negative padding values to perform a rect-based hit test.
HitTestResult(const IntPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
HitTestResult(const HitTestResult&);
~HitTestResult();
HitTestResult& operator=(const HitTestResult&);
Node* innerNode() const { return m_innerNode.get(); }
Node* innerNonSharedNode() const { return m_innerNonSharedNode.get(); }
IntPoint point() const { return m_point; }
IntPoint localPoint() const { return m_localPoint; }
LayoutPoint point() const { return m_point; }
LayoutPoint localPoint() const { return m_localPoint; }
Element* URLElement() const { return m_innerURLElement.get(); }
Scrollbar* scrollbar() const { return m_scrollbar.get(); }
bool isOverWidget() const { return m_isOverWidget; }
......@@ -67,8 +64,8 @@ public:
void setInnerNode(Node*);
void setInnerNonSharedNode(Node*);
void setPoint(const IntPoint& p) { m_point = p; }
void setLocalPoint(const IntPoint& p) { m_localPoint = p; }
void setPoint(const LayoutPoint& p) { m_point = p; }
void setLocalPoint(const LayoutPoint& p) { m_localPoint = p; }
void setURLElement(Element*);
void setScrollbar(Scrollbar*);
void setIsOverWidget(bool b) { m_isOverWidget = b; }
......@@ -103,8 +100,8 @@ public:
// Rect-based hit test related methods.
bool isRectBasedTest() const { return m_isRectBased; }
IntRect rectForPoint(const IntPoint&) const;
static IntRect rectForPoint(const IntPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
LayoutRect rectForPoint(const LayoutPoint&) const;
static LayoutRect rectForPoint(const LayoutPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
int topPadding() const { return m_topPadding; }
int rightPadding() const { return m_rightPadding; }
int bottomPadding() const { return m_bottomPadding; }
......@@ -112,8 +109,8 @@ public:
// Returns true if it is rect-based hit test and needs to continue until the rect is fully
// enclosed by the boundaries of a node.
bool addNodeToRectBasedTestResult(Node*, const IntPoint& pointInContainer, const IntRect& = IntRect());
bool addNodeToRectBasedTestResult(Node*, const IntPoint& pointInContainer, const FloatRect&);
bool addNodeToRectBasedTestResult(Node*, const LayoutPoint& pointInContainer, const LayoutRect& = IntRect());
bool addNodeToRectBasedTestResult(Node*, const LayoutPoint& pointInContainer, const FloatRect&);
void append(const HitTestResult&);
// If m_rectBasedTestResult is 0 then set it to a new NodeSet. Return *m_rectBasedTestResult. Lazy allocation makes
......@@ -130,9 +127,9 @@ private:
RefPtr<Node> m_innerNode;
RefPtr<Node> m_innerNonSharedNode;
IntPoint m_point;
IntPoint m_localPoint; // A point in the local coordinate space of m_innerNonSharedNode's renderer. Allows us to efficiently
// determine where inside the renderer we hit on subsequent operations.
LayoutPoint m_point;
LayoutPoint m_localPoint; // A point in the local coordinate space of m_innerNonSharedNode's renderer. Allows us to efficiently
// determine where inside the renderer we hit on subsequent operations.
RefPtr<Element> m_innerURLElement;
RefPtr<Scrollbar> m_scrollbar;
bool m_isOverWidget; // Returns true if we are over a widget (and not in the border/padding area of a RenderWidget for example).
......@@ -149,7 +146,7 @@ private:
// y = p.y() - topPadding
// width = leftPadding + rightPadding + 1
// height = topPadding + bottomPadding + 1
inline IntRect HitTestResult::rectForPoint(const IntPoint& point) const
inline LayoutRect HitTestResult::rectForPoint(const LayoutPoint& point) const
{
return rectForPoint(point, m_topPadding, m_rightPadding, m_bottomPadding, m_leftPadding);
}
......
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