1 | /* |
2 | * Copyright (C) 2006 Apple Inc. |
3 | * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
4 | * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public License |
17 | * along with this library; see the file COPYING.LIB. If not, write to |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | * Boston, MA 02110-1301, USA. |
20 | * |
21 | */ |
22 | |
23 | #pragma once |
24 | |
25 | #include <wtf/Assertions.h> |
26 | |
27 | namespace WebCore { |
28 | |
29 | class HitTestRequest { |
30 | public: |
31 | enum RequestType { |
32 | ReadOnly = 1 << 1, |
33 | Active = 1 << 2, |
34 | Move = 1 << 3, |
35 | Release = 1 << 4, |
36 | IgnoreClipping = 1 << 5, |
37 | SVGClipContent = 1 << 6, |
38 | TouchEvent = 1 << 7, |
39 | DisallowUserAgentShadowContent = 1 << 8, |
40 | AllowFrameScrollbars = 1 << 9, |
41 | AllowChildFrameContent = 1 << 10, |
42 | ChildFrameHitTest = 1 << 11, |
43 | AccessibilityHitTest = 1 << 12, |
44 | // Collect a list of nodes instead of just one. Used for elementsFromPoint and rect-based tests. |
45 | CollectMultipleElements = 1 << 13, |
46 | // When using list-based testing, continue hit testing even after a hit has been found. |
47 | IncludeAllElementsUnderPoint = 1 << 14 |
48 | }; |
49 | |
50 | typedef unsigned HitTestRequestType; |
51 | |
52 | HitTestRequest(HitTestRequestType requestType = ReadOnly | Active | DisallowUserAgentShadowContent) |
53 | : m_requestType(requestType) |
54 | { |
55 | ASSERT(!(requestType & IncludeAllElementsUnderPoint) || (requestType & CollectMultipleElements)); |
56 | } |
57 | |
58 | bool readOnly() const { return m_requestType & ReadOnly; } |
59 | bool active() const { return m_requestType & Active; } |
60 | bool move() const { return m_requestType & Move; } |
61 | bool release() const { return m_requestType & Release; } |
62 | bool ignoreClipping() const { return m_requestType & IgnoreClipping; } |
63 | bool svgClipContent() const { return m_requestType & SVGClipContent; } |
64 | bool touchEvent() const { return m_requestType & TouchEvent; } |
65 | bool mouseEvent() const { return !touchEvent(); } |
66 | bool disallowsUserAgentShadowContent() const { return m_requestType & DisallowUserAgentShadowContent; } |
67 | bool allowsFrameScrollbars() const { return m_requestType & AllowFrameScrollbars; } |
68 | bool allowsChildFrameContent() const { return m_requestType & AllowChildFrameContent; } |
69 | bool isChildFrameHitTest() const { return m_requestType & ChildFrameHitTest; } |
70 | bool resultIsElementList() const { return m_requestType & CollectMultipleElements; } |
71 | bool includesAllElementsUnderPoint() const { return m_requestType & IncludeAllElementsUnderPoint; } |
72 | |
73 | // Convenience functions |
74 | bool touchMove() const { return move() && touchEvent(); } |
75 | bool touchRelease() const { return release() && touchEvent(); } |
76 | |
77 | HitTestRequestType type() const { return m_requestType; } |
78 | |
79 | private: |
80 | HitTestRequestType m_requestType; |
81 | }; |
82 | |
83 | } // namespace WebCore |
84 | |