This source file includes following definitions.
- m_isRectilinear
- m_isRectilinear
- m_isRectilinear
- m_isRectBased
- m_isRectilinear
- m_isRectilinear
- m_isRectilinear
- move
- intersectsRect
- intersects
- intersects
- intersects
- rectForPoint
#include "config.h"
#include "core/rendering/HitTestLocation.h"
#include "HTMLNames.h"
#include "SVGNames.h"
#include "XLinkNames.h"
namespace WebCore {
using namespace HTMLNames;
HitTestLocation::HitTestLocation()
: m_isRectBased(false)
, m_isRectilinear(true)
{
}
HitTestLocation::HitTestLocation(const LayoutPoint& point)
: m_point(point)
, m_boundingBox(rectForPoint(point, 0, 0, 0, 0))
, m_transformedPoint(point)
, m_transformedRect(m_boundingBox)
, m_isRectBased(false)
, m_isRectilinear(true)
{
}
HitTestLocation::HitTestLocation(const FloatPoint& point)
: m_point(flooredLayoutPoint(point))
, m_boundingBox(rectForPoint(m_point, 0, 0, 0, 0))
, m_transformedPoint(point)
, m_transformedRect(m_boundingBox)
, m_isRectBased(false)
, m_isRectilinear(true)
{
}
HitTestLocation::HitTestLocation(const FloatPoint& point, const FloatQuad& quad)
: m_transformedPoint(point)
, m_transformedRect(quad)
, m_isRectBased(true)
{
m_point = flooredLayoutPoint(point);
m_boundingBox = enclosingIntRect(quad.boundingBox());
m_isRectilinear = quad.isRectilinear();
}
HitTestLocation::HitTestLocation(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
: m_point(centerPoint)
, m_boundingBox(rectForPoint(centerPoint, topPadding, rightPadding, bottomPadding, leftPadding))
, m_transformedPoint(centerPoint)
, m_isRectBased(topPadding || rightPadding || bottomPadding || leftPadding)
, m_isRectilinear(true)
{
m_transformedRect = FloatQuad(m_boundingBox);
}
HitTestLocation::HitTestLocation(const HitTestLocation& other, const LayoutSize& offset)
: m_point(other.m_point)
, m_boundingBox(other.m_boundingBox)
, m_transformedPoint(other.m_transformedPoint)
, m_transformedRect(other.m_transformedRect)
, m_isRectBased(other.m_isRectBased)
, m_isRectilinear(other.m_isRectilinear)
{
move(offset);
}
HitTestLocation::HitTestLocation(const HitTestLocation& other)
: m_point(other.m_point)
, m_boundingBox(other.m_boundingBox)
, m_transformedPoint(other.m_transformedPoint)
, m_transformedRect(other.m_transformedRect)
, m_isRectBased(other.m_isRectBased)
, m_isRectilinear(other.m_isRectilinear)
{
}
HitTestLocation::~HitTestLocation()
{
}
HitTestLocation& HitTestLocation::operator=(const HitTestLocation& other)
{
m_point = other.m_point;
m_boundingBox = other.m_boundingBox;
m_transformedPoint = other.m_transformedPoint;
m_transformedRect = other.m_transformedRect;
m_isRectBased = other.m_isRectBased;
m_isRectilinear = other.m_isRectilinear;
return *this;
}
void HitTestLocation::move(const LayoutSize& offset)
{
m_point.move(offset);
m_transformedPoint.move(offset);
m_transformedRect.move(offset);
m_boundingBox = enclosingIntRect(m_transformedRect.boundingBox());
}
template<typename RectType>
bool HitTestLocation::intersectsRect(const RectType& rect) const
{
if (!rect.intersects(m_boundingBox))
return false;
if (m_isRectilinear)
return true;
if (rect.contains(m_boundingBox))
return true;
return m_transformedRect.intersectsRect(rect);
}
bool HitTestLocation::intersects(const LayoutRect& rect) const
{
return intersectsRect(rect);
}
bool HitTestLocation::intersects(const FloatRect& rect) const
{
return intersectsRect(rect);
}
bool HitTestLocation::intersects(const RoundedRect& rect) const
{
return rect.intersectsQuad(m_transformedRect);
}
IntRect HitTestLocation::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
{
IntPoint actualPoint(flooredIntPoint(point));
actualPoint -= IntSize(leftPadding, topPadding);
IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding);
actualPadding += IntSize(1, 1);
return IntRect(actualPoint, actualPadding);
}
}