OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 #ifndef HitTestResult_h | 22 #ifndef HitTestResult_h |
23 #define HitTestResult_h | 23 #define HitTestResult_h |
24 | 24 |
25 #include "core/CoreExport.h" | 25 #include "core/CoreExport.h" |
26 #include "core/editing/PositionWithAffinity.h" | 26 #include "core/editing/PositionWithAffinity.h" |
27 #include "core/layout/HitTestLocation.h" | 27 #include "core/layout/HitTestLocation.h" |
28 #include "core/layout/HitTestRequest.h" | 28 #include "core/layout/HitTestRequest.h" |
29 #include "platform/geometry/FloatQuad.h" | 29 #include "platform/geometry/FloatQuad.h" |
30 #include "platform/geometry/FloatRect.h" | 30 #include "platform/geometry/FloatRect.h" |
31 #include "platform/geometry/LayoutRect.h" | |
32 #include "platform/heap/Handle.h" | 31 #include "platform/heap/Handle.h" |
33 #include "platform/text/TextDirection.h" | 32 #include "platform/text/TextDirection.h" |
34 #include "wtf/Forward.h" | 33 #include "wtf/Forward.h" |
35 #include "wtf/ListHashSet.h" | 34 #include "wtf/ListHashSet.h" |
36 #include "wtf/OwnPtr.h" | 35 #include "wtf/OwnPtr.h" |
37 #include "wtf/RefPtr.h" | 36 #include "wtf/RefPtr.h" |
38 #include "wtf/VectorTraits.h" | 37 #include "wtf/VectorTraits.h" |
39 | 38 |
40 namespace blink { | 39 namespace blink { |
41 | 40 |
42 class Element; | 41 class Element; |
43 class LocalFrame; | 42 class LocalFrame; |
44 class HTMLAreaElement; | 43 class HTMLAreaElement; |
45 class HTMLMediaElement; | 44 class HTMLMediaElement; |
46 class Image; | 45 class Image; |
47 class KURL; | 46 class KURL; |
48 class Node; | 47 class Node; |
49 class LayoutObject; | 48 class LayoutObject; |
| 49 class Region; |
50 class Scrollbar; | 50 class Scrollbar; |
51 | 51 |
| 52 // List-based hit test testing can continue even after a hit has been found. |
| 53 // This is used to support fuzzy matching with rect-based hit tests as well as |
| 54 // penetrating tests which collect all nodes (see: HitTestRequest::RequestType). |
| 55 enum ListBasedHitTestBehavior { |
| 56 ContinueHitTesting, |
| 57 StopHitTesting |
| 58 }; |
| 59 |
52 class CORE_EXPORT HitTestResult { | 60 class CORE_EXPORT HitTestResult { |
53 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 61 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
54 | |
55 public: | 62 public: |
56 typedef WillBeHeapListHashSet<RefPtrWillBeMember<Node>> NodeSet; | 63 typedef WillBeHeapListHashSet<RefPtrWillBeMember<Node>> NodeSet; |
57 | 64 |
58 HitTestResult(); | 65 HitTestResult(); |
59 HitTestResult(const HitTestRequest&, const LayoutPoint&); | 66 HitTestResult(const HitTestRequest&, const LayoutPoint&); |
60 // Pass positive padding values to perform a rect-based hit test. | 67 // Pass positive padding values to perform a rect-based hit test. |
61 HitTestResult(const HitTestRequest&, const LayoutPoint& centerPoint, unsigne
d topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPaddin
g); | 68 HitTestResult(const HitTestRequest&, const LayoutPoint& centerPoint, unsigne
d topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPaddin
g); |
62 HitTestResult(const HitTestRequest&, const HitTestLocation&); | 69 HitTestResult(const HitTestRequest&, const HitTestLocation&); |
63 HitTestResult(const HitTestResult&); | 70 HitTestResult(const HitTestResult&); |
64 ~HitTestResult(); | 71 ~HitTestResult(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 String textContent() const; | 137 String textContent() const; |
131 bool isLiveLink() const; | 138 bool isLiveLink() const; |
132 bool isMisspelled() const; | 139 bool isMisspelled() const; |
133 bool isContentEditable() const; | 140 bool isContentEditable() const; |
134 | 141 |
135 bool isOverLink() const; | 142 bool isOverLink() const; |
136 | 143 |
137 bool isCacheable() const { return m_cacheable; } | 144 bool isCacheable() const { return m_cacheable; } |
138 void setCacheable(bool cacheable) { m_cacheable = cacheable; } | 145 void setCacheable(bool cacheable) { m_cacheable = cacheable; } |
139 | 146 |
140 // Return true if the test is a list-based test and we should continue testi
ng. | 147 // TODO(pdr): When using the default rect argument, this function does not |
141 bool addNodeToListBasedTestResult(Node*, const HitTestLocation& pointInConta
iner, const LayoutRect& = LayoutRect()); | 148 // check if the tapped area is entirely contained by the HitTestLocation's |
| 149 // bounding box. Callers should pass a LayoutRect as the third parameter so |
| 150 // hit testing can early-out when a tapped area is covered. |
| 151 ListBasedHitTestBehavior addNodeToListBasedTestResult(Node*, const HitTestLo
cation&, const LayoutRect& = LayoutRect()); |
| 152 ListBasedHitTestBehavior addNodeToListBasedTestResult(Node*, const HitTestLo
cation&, const Region&); |
| 153 |
142 void append(const HitTestResult&); | 154 void append(const HitTestResult&); |
143 | 155 |
144 // If m_listBasedTestResult is 0 then set it to a new NodeSet. Return *m_lis
tBasedTestResult. Lazy allocation makes | 156 // If m_listBasedTestResult is 0 then set it to a new NodeSet. Return *m_lis
tBasedTestResult. Lazy allocation makes |
145 // sense because the NodeSet is seldom necessary, and it's somewhat expensiv
e to allocate and initialize. This method does | 157 // sense because the NodeSet is seldom necessary, and it's somewhat expensiv
e to allocate and initialize. This method does |
146 // the same thing as mutableListBasedTestResult(), but here the return value
is const. | 158 // the same thing as mutableListBasedTestResult(), but here the return value
is const. |
147 const NodeSet& listBasedTestResult() const; | 159 const NodeSet& listBasedTestResult() const; |
148 | 160 |
149 // Collapse the rect-based test result into a single target at the specified
location. | 161 // Collapse the rect-based test result into a single target at the specified
location. |
150 void resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPoint& resolv
edPointInMainFrame); | 162 void resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPoint& resolv
edPointInMainFrame); |
151 | 163 |
(...skipping 16 matching lines...) Expand all Loading... |
168 bool m_isOverWidget; // Returns true if we are over a widget (and not in the
border/padding area of a LayoutPart for example). | 180 bool m_isOverWidget; // Returns true if we are over a widget (and not in the
border/padding area of a LayoutPart for example). |
169 | 181 |
170 mutable OwnPtrWillBeMember<NodeSet> m_listBasedTestResult; | 182 mutable OwnPtrWillBeMember<NodeSet> m_listBasedTestResult; |
171 }; | 183 }; |
172 | 184 |
173 } // namespace blink | 185 } // namespace blink |
174 | 186 |
175 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::HitTestResult); | 187 WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::HitTestResult); |
176 | 188 |
177 #endif // HitTestResult_h | 189 #endif // HitTestResult_h |
OLD | NEW |