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 16 matching lines...) Expand all Loading... |
27 #include "core/layout/HitTestRequest.h" | 27 #include "core/layout/HitTestRequest.h" |
28 #include "platform/geometry/FloatQuad.h" | 28 #include "platform/geometry/FloatQuad.h" |
29 #include "platform/geometry/FloatRect.h" | 29 #include "platform/geometry/FloatRect.h" |
30 #include "platform/geometry/LayoutRect.h" | 30 #include "platform/geometry/LayoutRect.h" |
31 #include "platform/heap/Handle.h" | 31 #include "platform/heap/Handle.h" |
32 #include "platform/text/TextDirection.h" | 32 #include "platform/text/TextDirection.h" |
33 #include "wtf/Forward.h" | 33 #include "wtf/Forward.h" |
34 #include "wtf/ListHashSet.h" | 34 #include "wtf/ListHashSet.h" |
35 #include "wtf/OwnPtr.h" | 35 #include "wtf/OwnPtr.h" |
36 #include "wtf/RefPtr.h" | 36 #include "wtf/RefPtr.h" |
| 37 #include "wtf/VectorTraits.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 class Element; | 41 class Element; |
41 class LocalFrame; | 42 class LocalFrame; |
42 class HTMLAreaElement; | 43 class HTMLAreaElement; |
43 class HTMLMediaElement; | 44 class HTMLMediaElement; |
44 class Image; | 45 class Image; |
45 class KURL; | 46 class KURL; |
46 class Node; | 47 class Node; |
47 class LayoutObject; | 48 class LayoutObject; |
48 class PositionWithAffinity; | 49 class PositionWithAffinity; |
49 class Scrollbar; | 50 class Scrollbar; |
50 | 51 |
51 class CORE_EXPORT HitTestResult { | 52 class CORE_EXPORT HitTestResult { |
52 DISALLOW_ALLOCATION(); | 53 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 54 |
53 public: | 55 public: |
54 typedef WillBeHeapListHashSet<RefPtrWillBeMember<Node>> NodeSet; | 56 typedef WillBeHeapListHashSet<RefPtrWillBeMember<Node>> NodeSet; |
55 | 57 |
56 HitTestResult(); | 58 HitTestResult(); |
57 HitTestResult(const HitTestRequest&, const LayoutPoint&); | 59 HitTestResult(const HitTestRequest&, const LayoutPoint&); |
58 // Pass positive padding values to perform a rect-based hit test. | 60 // Pass positive padding values to perform a rect-based hit test. |
59 HitTestResult(const HitTestRequest&, const LayoutPoint& centerPoint, unsigne
d topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPaddin
g); | 61 HitTestResult(const HitTestRequest&, const LayoutPoint& centerPoint, unsigne
d topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPaddin
g); |
60 HitTestResult(const HitTestRequest&, const HitTestLocation&); | 62 HitTestResult(const HitTestRequest&, const HitTestLocation&); |
61 HitTestResult(const HitTestResult&); | 63 HitTestResult(const HitTestResult&); |
62 ~HitTestResult(); | 64 ~HitTestResult(); |
63 HitTestResult& operator=(const HitTestResult&); | 65 HitTestResult& operator=(const HitTestResult&); |
64 DECLARE_TRACE(); | 66 DECLARE_TRACE(); |
65 | 67 |
| 68 bool equalForCacheability(const HitTestResult&) const; |
| 69 void cacheValues(const HitTestResult&); |
| 70 |
| 71 // Populate this object based on another HitTestResult; similar to assignmen
t operator |
| 72 // but don't assign any of the request parameters. ie. Thie method avoids se
tting |
| 73 // |m_hitTestLocation|, |m_hitTestRequest|. |
| 74 void populateFromCachedResult(const HitTestResult&); |
| 75 |
66 // For point-based hit tests, these accessors provide information about the
node | 76 // For point-based hit tests, these accessors provide information about the
node |
67 // under the point. For rect-based hit tests they are meaningless (reflect t
he | 77 // under the point. For rect-based hit tests they are meaningless (reflect t
he |
68 // last candidate node observed in the rect). | 78 // last candidate node observed in the rect). |
69 // FIXME: Make these less error-prone for rect-based hit tests (center point
or fail). | 79 // FIXME: Make these less error-prone for rect-based hit tests (center point
or fail). |
70 Node* innerNode() const { return m_innerNode.get(); } | 80 Node* innerNode() const { return m_innerNode.get(); } |
71 Node* innerPossiblyPseudoNode() const { return m_innerPossiblyPseudoNode.get
(); } | 81 Node* innerPossiblyPseudoNode() const { return m_innerPossiblyPseudoNode.get
(); } |
72 Element* innerElement() const; | 82 Element* innerElement() const; |
73 | 83 |
74 // If innerNode is an image map or image map area, return the associated ima
ge node. | 84 // If innerNode is an image map or image map area, return the associated ima
ge node. |
75 Node* innerNodeOrImageMapImage() const; | 85 Node* innerNodeOrImageMapImage() const; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 KURL absoluteImageURL() const; | 127 KURL absoluteImageURL() const; |
118 KURL absoluteMediaURL() const; | 128 KURL absoluteMediaURL() const; |
119 KURL absoluteLinkURL() const; | 129 KURL absoluteLinkURL() const; |
120 String textContent() const; | 130 String textContent() const; |
121 bool isLiveLink() const; | 131 bool isLiveLink() const; |
122 bool isMisspelled() const; | 132 bool isMisspelled() const; |
123 bool isContentEditable() const; | 133 bool isContentEditable() const; |
124 | 134 |
125 bool isOverLink() const; | 135 bool isOverLink() const; |
126 | 136 |
| 137 bool isCacheable() const { return m_cacheable; } |
| 138 void setCacheable(bool cacheable) { m_cacheable = cacheable; } |
| 139 |
127 // Return true if the test is a list-based test and we should continue testi
ng. | 140 // Return true if the test is a list-based test and we should continue testi
ng. |
128 bool addNodeToListBasedTestResult(Node*, const HitTestLocation& pointInConta
iner, const LayoutRect& = LayoutRect()); | 141 bool addNodeToListBasedTestResult(Node*, const HitTestLocation& pointInConta
iner, const LayoutRect& = LayoutRect()); |
129 bool addNodeToListBasedTestResult(Node*, const HitTestLocation& pointInConta
iner, const FloatRect&); | 142 bool addNodeToListBasedTestResult(Node*, const HitTestLocation& pointInConta
iner, const FloatRect&); |
130 void append(const HitTestResult&); | 143 void append(const HitTestResult&); |
131 | 144 |
132 // If m_listBasedTestResult is 0 then set it to a new NodeSet. Return *m_lis
tBasedTestResult. Lazy allocation makes | 145 // If m_listBasedTestResult is 0 then set it to a new NodeSet. Return *m_lis
tBasedTestResult. Lazy allocation makes |
133 // sense because the NodeSet is seldom necessary, and it's somewhat expensiv
e to allocate and initialize. This method does | 146 // sense because the NodeSet is seldom necessary, and it's somewhat expensiv
e to allocate and initialize. This method does |
134 // the same thing as mutableListBasedTestResult(), but here the return value
is const. | 147 // the same thing as mutableListBasedTestResult(), but here the return value
is const. |
135 const NodeSet& listBasedTestResult() const; | 148 const NodeSet& listBasedTestResult() const; |
136 | 149 |
137 // Collapse the rect-based test result into a single target at the specified
location. | 150 // Collapse the rect-based test result into a single target at the specified
location. |
138 void resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPoint& resolv
edPointInMainFrame); | 151 void resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPoint& resolv
edPointInMainFrame); |
139 | 152 |
140 private: | 153 private: |
141 NodeSet& mutableListBasedTestResult(); // See above. | 154 NodeSet& mutableListBasedTestResult(); // See above. |
142 HTMLMediaElement* mediaElement() const; | 155 HTMLMediaElement* mediaElement() const; |
143 | 156 |
144 HitTestLocation m_hitTestLocation; | 157 HitTestLocation m_hitTestLocation; |
145 HitTestRequest m_hitTestRequest; | 158 HitTestRequest m_hitTestRequest; |
| 159 bool m_cacheable; |
146 | 160 |
147 RefPtrWillBeMember<Node> m_innerNode; | 161 RefPtrWillBeMember<Node> m_innerNode; |
148 RefPtrWillBeMember<Node> m_innerPossiblyPseudoNode; | 162 RefPtrWillBeMember<Node> m_innerPossiblyPseudoNode; |
149 // FIXME: Nothing changes this to a value different from m_hitTestLocation! | 163 // FIXME: Nothing changes this to a value different from m_hitTestLocation! |
150 LayoutPoint m_pointInInnerNodeFrame; // The hit-tested point in innerNode fr
ame coordinates. | 164 LayoutPoint m_pointInInnerNodeFrame; // The hit-tested point in innerNode fr
ame coordinates. |
151 LayoutPoint m_localPoint; // A point in the local coordinate space of m_inne
rNode's layoutObject. Allows us to efficiently | 165 LayoutPoint m_localPoint; // A point in the local coordinate space of m_inne
rNode's layoutObject. Allows us to efficiently |
152 // determine where inside the layoutObject we hit on subsequent operatio
ns. | 166 // determine where inside the layoutObject we hit on subsequent operatio
ns. |
153 RefPtrWillBeMember<Element> m_innerURLElement; | 167 RefPtrWillBeMember<Element> m_innerURLElement; |
154 RefPtrWillBeMember<Scrollbar> m_scrollbar; | 168 RefPtrWillBeMember<Scrollbar> m_scrollbar; |
155 bool m_isOverWidget; // Returns true if we are over a widget (and not in the
border/padding area of a LayoutPart for example). | 169 bool m_isOverWidget; // Returns true if we are over a widget (and not in the
border/padding area of a LayoutPart for example). |
156 | 170 |
157 mutable OwnPtrWillBeMember<NodeSet> m_listBasedTestResult; | 171 mutable OwnPtrWillBeMember<NodeSet> m_listBasedTestResult; |
158 }; | 172 }; |
159 | 173 |
160 } // namespace blink | 174 } // namespace blink |
161 | 175 |
| 176 #if ENABLE(OILPAN) |
| 177 // TODO(sof): the trait override/specialization is needed by HitTestCache's |
| 178 // HeapVector<> to handle unused slots. It is not correct for HitTestResult |
| 179 // in the wider sense of what canInitializeWithMemset provides, so fix this |
| 180 // by introducing a trait that encompasses "unused slot" handling and use it |
| 181 // here instead. |
| 182 // |
| 183 // Until that time, make this trait specialization conditional on OILPAN to |
| 184 // limit exposure. |
| 185 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::HitTestResult); |
| 186 #endif |
| 187 |
162 #endif // HitTestResult_h | 188 #endif // HitTestResult_h |
OLD | NEW |