rendering/FixedTableLayout.cpp
rendering/FlowThreadController.cpp
rendering/HitTestingTransformState.cpp
+ rendering/HitTestLocation.cpp
rendering/HitTestResult.cpp
rendering/InlineBox.cpp
rendering/InlineFlowBox.cpp
+2013-03-05 Mike West <mkwst@chromium.org>
+
+ Cleanup: Move HitTestLocation and HitTestResult into separate files.
+ https://bugs.webkit.org/show_bug.cgi?id=111294
+
+ Reviewed by Allan Sandfeld Jensen.
+
+ HitTestLocation and HitTestResult currently both live in
+ HitTestResult.h. That makes things more difficult to understand than
+ they should be, and violates the one-class-one-file principle that
+ WebKit generally follows. Happily, it's fairly trivial to fix.
+
+ This should have no visible change; it's strictly an internal
+ refactoring. It doesn't even touch any implementation code: we're
+ just moving bits from one place to another.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ Hey, look: a new file! Let's add it to six different build systems! :)
+ * rendering/HitTestLocation.cpp: Added.
+ (WebCore):
+ (WebCore::HitTestLocation::HitTestLocation):
+ (WebCore::HitTestLocation::~HitTestLocation):
+ (WebCore::HitTestLocation::operator=):
+ (WebCore::HitTestLocation::move):
+ (WebCore::HitTestLocation::intersectsRect):
+ (WebCore::HitTestLocation::intersects):
+ (WebCore::HitTestLocation::rectForPoint):
+ * rendering/HitTestLocation.h: Added.
+ (WebCore):
+ (HitTestLocation):
+ (WebCore::HitTestLocation::point):
+ (WebCore::HitTestLocation::roundedPoint):
+ (WebCore::HitTestLocation::region):
+ (WebCore::HitTestLocation::isRectBasedTest):
+ (WebCore::HitTestLocation::isRectilinear):
+ (WebCore::HitTestLocation::boundingBox):
+ (WebCore::HitTestLocation::topPadding):
+ (WebCore::HitTestLocation::rightPadding):
+ (WebCore::HitTestLocation::bottomPadding):
+ (WebCore::HitTestLocation::leftPadding):
+ (WebCore::HitTestLocation::transformedPoint):
+ (WebCore::HitTestLocation::transformedRect):
+ * rendering/HitTestResult.cpp:
+ * rendering/HitTestResult.h:
+ Move all this code from HitTestResult.* to HitTestLocation.*.
+ * rendering/RenderBlock.cpp:
+ Include HitTestLocation.h.
+
2013-03-05 Jochen Eisinger <jochen@chromium.org>
Refactor UserGestureIndicator::Token to be a top-level class
Source/WebCore/rendering/HitTestRequest.h \
Source/WebCore/rendering/HitTestingTransformState.cpp \
Source/WebCore/rendering/HitTestingTransformState.h \
+ Source/WebCore/rendering/HitTestLocation.cpp \
+ Source/WebCore/rendering/HitTestLocation.h \
Source/WebCore/rendering/HitTestResult.cpp \
Source/WebCore/rendering/HitTestResult.h \
Source/WebCore/rendering/InlineBox.cpp \
rendering/FixedTableLayout.cpp \
rendering/FlowThreadController.cpp \
rendering/HitTestingTransformState.cpp \
+ rendering/HitTestLocation.cpp \
rendering/HitTestResult.cpp \
rendering/InlineBox.cpp \
rendering/InlineFlowBox.cpp \
rendering/FilterEffectRenderer.h \
rendering/FixedTableLayout.h \
rendering/HitTestingTransformState.h \
+ rendering/HitTestLocation.h \
rendering/HitTestResult.h \
rendering/InlineBox.h \
rendering/InlineFlowBox.h \
'rendering/TextAutosizer.h',
'rendering/HitTestingTransformState.cpp',
'rendering/HitTestingTransformState.h',
+ 'rendering/HitTestLocation.cpp',
+ 'rendering/HitTestLocation.h',
'rendering/HitTestResult.cpp',
'rendering/InlineBox.cpp',
'rendering/InlineFlowBox.cpp',
>
</File>
<File
+ RelativePath="..\rendering\HitTestLocation.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Production|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\rendering\HitTestLocation.h"
+ >
+ </File>
+ <File
RelativePath="..\rendering\HitTestRequest.h"
>
</File>
2D481F04146B5C6B00AA7834 /* GeneratorGeneratedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D2FC0571460CD6F00263633 /* GeneratorGeneratedImage.h */; };
2D5A592F152525230036EE51 /* ImageOrientation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8748D7412CC3F89001FBA41 /* ImageOrientation.cpp */; };
2D5A5931152525D00036EE51 /* ImageOrientation.h in Headers */ = {isa = PBXBuildFile; fileRef = A8748D6612CC3763001FBA41 /* ImageOrientation.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 2D8287F616E4A0380086BD00 /* HitTestLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */; };
+ 2D8287F716E4A0380086BD00 /* HitTestLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8287F516E4A0380086BD00 /* HitTestLocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */; };
2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8FEBDB143E3EF70072502B /* CSSCrossfadeValue.h */; };
2D9066060BE141D400956998 /* LayoutState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D9066040BE141D400956998 /* LayoutState.cpp */; };
2D2FC0561460CD6F00263633 /* GeneratorGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeneratorGeneratedImage.cpp; sourceTree = "<group>"; };
2D2FC0571460CD6F00263633 /* GeneratorGeneratedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratorGeneratedImage.h; sourceTree = "<group>"; };
2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGParsingError.h; sourceTree = "<group>"; };
+ 2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestLocation.cpp; sourceTree = "<group>"; };
+ 2D8287F516E4A0380086BD00 /* HitTestLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HitTestLocation.h; sourceTree = "<group>"; };
2D8FEBDA143E3EF70072502B /* CSSCrossfadeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSCrossfadeValue.cpp; sourceTree = "<group>"; };
2D8FEBDB143E3EF70072502B /* CSSCrossfadeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSCrossfadeValue.h; sourceTree = "<group>"; };
2D9066040BE141D400956998 /* LayoutState.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutState.cpp; sourceTree = "<group>"; };
935C477409AC4D8D00A6AAB4 /* GapRects.h */,
4969B0F013D0B33F00DF3521 /* HitTestingTransformState.cpp */,
4969B0F113D0B33F00DF3521 /* HitTestingTransformState.h */,
+ 2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */,
+ 2D8287F516E4A0380086BD00 /* HitTestLocation.h */,
930908900AF7EDE40081DF01 /* HitTestRequest.h */,
9307F1D50AF2D59000DBA31A /* HitTestResult.cpp */,
9307F1D60AF2D59000DBA31A /* HitTestResult.h */,
A31C4E5416E02B40002F7957 /* JSOESTextureHalfFloat.h in Headers */,
7E66E23416D6EB6C00F7E7FF /* WebGLCompressedTextureATC.h in Headers */,
7EA30F6A16DFFE7500257D0B /* JSWebGLCompressedTextureATC.h in Headers */,
+ 2D8287F716E4A0380086BD00 /* HitTestLocation.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
A31C4E5216E02B08002F7957 /* JSOESTextureHalfFloat.cpp in Sources */,
7E66E23316D6EB6C00F7E7FF /* WebGLCompressedTextureATC.cpp in Sources */,
7EA30F6916DFFE7500257D0B /* JSWebGLCompressedTextureATC.cpp in Sources */,
+ 2D8287F616E4A0380086BD00 /* HitTestLocation.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+/*
+ * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+*/
+
+#include "config.h"
+#include "HitTestLocation.h"
+
+#include "CachedImage.h"
+#include "DocumentMarkerController.h"
+#include "Frame.h"
+#include "FrameSelection.h"
+#include "FrameTree.h"
+#include "HTMLAnchorElement.h"
+#include "HTMLImageElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLMediaElement.h"
+#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
+#include "HTMLPlugInImageElement.h"
+#include "HTMLVideoElement.h"
+#include "RenderBlock.h"
+#include "RenderImage.h"
+#include "RenderInline.h"
+#include "Scrollbar.h"
+
+#if ENABLE(SVG)
+#include "SVGNames.h"
+#include "XLinkNames.h"
+#endif
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+HitTestLocation::HitTestLocation()
+ : m_region(0)
+ , 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_region(0)
+ , 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_region(0)
+ , m_isRectBased(false)
+ , m_isRectilinear(true)
+{
+}
+
+HitTestLocation::HitTestLocation(const FloatPoint& point, const FloatQuad& quad)
+ : m_transformedPoint(point)
+ , m_transformedRect(quad)
+ , m_region(0)
+ , 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_region(0)
+ , m_isRectBased(topPadding || rightPadding || bottomPadding || leftPadding)
+ , m_isRectilinear(true)
+{
+ m_transformedRect = FloatQuad(m_boundingBox);
+}
+
+HitTestLocation::HitTestLocation(const HitTestLocation& other, const LayoutSize& offset, RenderRegion* region)
+ : m_point(other.m_point)
+ , m_boundingBox(other.m_boundingBox)
+ , m_transformedPoint(other.m_transformedPoint)
+ , m_transformedRect(other.m_transformedRect)
+ , m_region(region ? region : other.m_region)
+ , 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_region(other.m_region)
+ , 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_region = other.m_region;
+ 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
+{
+ // FIXME: When the hit test is not rect based we should use rect.contains(m_point).
+ // That does change some corner case tests though.
+
+ // First check if rect even intersects our bounding box.
+ if (!rect.intersects(m_boundingBox))
+ return false;
+
+ // If the transformed rect is rectilinear the bounding box intersection was accurate.
+ if (m_isRectilinear)
+ return true;
+
+ // If rect fully contains our bounding box, we are also sure of an intersection.
+ if (rect.contains(m_boundingBox))
+ return true;
+
+ // Otherwise we need to do a slower quad based intersection test.
+ 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);
+}
+
+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);
+ // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1".
+ // FIXME: Remove this once non-rect based hit-detection stops using IntRect:intersects.
+ actualPadding += IntSize(1, 1);
+
+ return IntRect(actualPoint, actualPadding);
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+*/
+
+#ifndef HitTestLocation_h
+#define HitTestLocation_h
+
+#include "FloatQuad.h"
+#include "FloatRect.h"
+#include "HitTestRequest.h"
+#include "LayoutRect.h"
+#include "TextDirection.h"
+#include <wtf/Forward.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Element;
+class Frame;
+#if ENABLE(VIDEO)
+class HTMLMediaElement;
+#endif
+class Image;
+class KURL;
+class Node;
+class RenderRegion;
+class Scrollbar;
+
+class HitTestLocation {
+public:
+
+ HitTestLocation();
+ HitTestLocation(const LayoutPoint&);
+ HitTestLocation(const FloatPoint&);
+ HitTestLocation(const FloatPoint&, const FloatQuad&);
+ // Pass non-zero padding values to perform a rect-based hit test.
+ HitTestLocation(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
+ // Make a copy the HitTestLocation in a new region by applying given offset to internal point and area.
+ HitTestLocation(const HitTestLocation&, const LayoutSize& offset, RenderRegion* = 0);
+ HitTestLocation(const HitTestLocation&);
+ ~HitTestLocation();
+ HitTestLocation& operator=(const HitTestLocation&);
+
+ const LayoutPoint& point() const { return m_point; }
+ IntPoint roundedPoint() const { return roundedIntPoint(m_point); }
+
+ RenderRegion* region() const { return m_region; }
+
+ // Rect-based hit test related methods.
+ bool isRectBasedTest() const { return m_isRectBased; }
+ bool isRectilinear() const { return m_isRectilinear; }
+ IntRect boundingBox() const { return m_boundingBox; }
+
+ static IntRect rectForPoint(const LayoutPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
+ int topPadding() const { return roundedPoint().y() - m_boundingBox.y(); }
+ int rightPadding() const { return m_boundingBox.maxX() - roundedPoint().x() - 1; }
+ int bottomPadding() const { return m_boundingBox.maxY() - roundedPoint().y() - 1; }
+ int leftPadding() const { return roundedPoint().x() - m_boundingBox.x(); }
+
+ bool intersects(const LayoutRect&) const;
+ bool intersects(const FloatRect&) const;
+
+ const FloatPoint& transformedPoint() const { return m_transformedPoint; }
+ const FloatQuad& transformedRect() const { return m_transformedRect; }
+
+private:
+ template<typename RectType>
+ bool intersectsRect(const RectType&) const;
+ void move(const LayoutSize& offset);
+
+ // This is cached forms of the more accurate point and area below.
+ LayoutPoint m_point;
+ IntRect m_boundingBox;
+
+ FloatPoint m_transformedPoint;
+ FloatQuad m_transformedRect;
+
+ RenderRegion* m_region; // The region we're inside.
+
+ bool m_isRectBased;
+ bool m_isRectilinear;
+};
+
+} // namespace WebCore
+
+#endif // HitTestLocation_h
#include "FrameSelection.h"
#include "FrameTree.h"
#include "HTMLAnchorElement.h"
-#include "HTMLVideoElement.h"
#include "HTMLImageElement.h"
#include "HTMLInputElement.h"
#include "HTMLMediaElement.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "HTMLPlugInImageElement.h"
+#include "HTMLVideoElement.h"
+#include "HitTestLocation.h"
#include "RenderBlock.h"
#include "RenderImage.h"
#include "RenderInline.h"
using namespace HTMLNames;
-HitTestLocation::HitTestLocation()
- : m_region(0)
- , 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_region(0)
- , 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_region(0)
- , m_isRectBased(false)
- , m_isRectilinear(true)
-{
-}
-
-HitTestLocation::HitTestLocation(const FloatPoint& point, const FloatQuad& quad)
- : m_transformedPoint(point)
- , m_transformedRect(quad)
- , m_region(0)
- , 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_region(0)
- , m_isRectBased(topPadding || rightPadding || bottomPadding || leftPadding)
- , m_isRectilinear(true)
-{
- m_transformedRect = FloatQuad(m_boundingBox);
-}
-
-HitTestLocation::HitTestLocation(const HitTestLocation& other, const LayoutSize& offset, RenderRegion* region)
- : m_point(other.m_point)
- , m_boundingBox(other.m_boundingBox)
- , m_transformedPoint(other.m_transformedPoint)
- , m_transformedRect(other.m_transformedRect)
- , m_region(region ? region : other.m_region)
- , 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_region(other.m_region)
- , 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_region = other.m_region;
- 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
-{
- // FIXME: When the hit test is not rect based we should use rect.contains(m_point).
- // That does change some corner case tests though.
-
- // First check if rect even intersects our bounding box.
- if (!rect.intersects(m_boundingBox))
- return false;
-
- // If the transformed rect is rectilinear the bounding box intersection was accurate.
- if (m_isRectilinear)
- return true;
-
- // If rect fully contains our bounding box, we are also sure of an intersection.
- if (rect.contains(m_boundingBox))
- return true;
-
- // Otherwise we need to do a slower quad based intersection test.
- 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);
-}
-
-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);
- // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1".
- // FIXME: Remove this once non-rect based hit-detection stops using IntRect:intersects.
- actualPadding += IntSize(1, 1);
-
- return IntRect(actualPoint, actualPadding);
-}
-
HitTestResult::HitTestResult()
: m_isOverWidget(false)
{
#include "FloatQuad.h"
#include "FloatRect.h"
+#include "HitTestLocation.h"
#include "HitTestRequest.h"
#include "LayoutRect.h"
#include "TextDirection.h"
class RenderRegion;
class Scrollbar;
-// FIXME: HitTestLocation should be moved to a separate file.
-class HitTestLocation {
-public:
-
- HitTestLocation();
- HitTestLocation(const LayoutPoint&);
- HitTestLocation(const FloatPoint&);
- HitTestLocation(const FloatPoint&, const FloatQuad&);
- // Pass non-zero padding values to perform a rect-based hit test.
- HitTestLocation(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
- // Make a copy the HitTestLocation in a new region by applying given offset to internal point and area.
- HitTestLocation(const HitTestLocation&, const LayoutSize& offset, RenderRegion* = 0);
- HitTestLocation(const HitTestLocation&);
- ~HitTestLocation();
- HitTestLocation& operator=(const HitTestLocation&);
-
- const LayoutPoint& point() const { return m_point; }
- IntPoint roundedPoint() const { return roundedIntPoint(m_point); }
-
- RenderRegion* region() const { return m_region; }
-
- // Rect-based hit test related methods.
- bool isRectBasedTest() const { return m_isRectBased; }
- bool isRectilinear() const { return m_isRectilinear; }
- IntRect boundingBox() const { return m_boundingBox; }
-
- static IntRect rectForPoint(const LayoutPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
- int topPadding() const { return roundedPoint().y() - m_boundingBox.y(); }
- int rightPadding() const { return m_boundingBox.maxX() - roundedPoint().x() - 1; }
- int bottomPadding() const { return m_boundingBox.maxY() - roundedPoint().y() - 1; }
- int leftPadding() const { return roundedPoint().x() - m_boundingBox.x(); }
-
- bool intersects(const LayoutRect&) const;
- bool intersects(const FloatRect&) const;
-
- const FloatPoint& transformedPoint() const { return m_transformedPoint; }
- const FloatQuad& transformedRect() const { return m_transformedRect; }
-
-private:
- template<typename RectType>
- bool intersectsRect(const RectType&) const;
- void move(const LayoutSize& offset);
-
- // This is cached forms of the more accurate point and area below.
- LayoutPoint m_point;
- IntRect m_boundingBox;
-
- FloatPoint m_transformedPoint;
- FloatQuad m_transformedRect;
-
- RenderRegion* m_region; // The region we're inside.
-
- bool m_isRectBased;
- bool m_isRectilinear;
-};
-
class HitTestResult {
public:
typedef ListHashSet<RefPtr<Node> > NodeSet;
#include "GraphicsContext.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
+#include "HitTestLocation.h"
#include "HitTestResult.h"
#include "InlineIterator.h"
#include "InlineTextBox.h"