2 * Copyright (C) 2006 Apple Computer, Inc.
3 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
4 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
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.
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.
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.
23 #ifndef HitTestRequest_h
24 #define HitTestRequest_h
26 #include "wtf/Allocator.h"
27 #include "wtf/Assertions.h"
31 class HitTestRequest
{
32 DISALLOW_ALLOCATION();
39 IgnoreClipping
= 1 << 5,
40 SVGClipContent
= 1 << 6,
42 AllowChildFrameContent
= 1 << 8,
43 ChildFrameHitTest
= 1 << 9,
44 IgnorePointerEventsNone
= 1 << 10,
45 // Collect a list of nodes instead of just one.
46 // (This is for elementsFromPoint and rect-based tests).
48 // When using list-based testing, this flag causes us to continue hit
49 // testing after a hit has been found.
50 PenetratingList
= 1 << 12,
54 typedef unsigned HitTestRequestType
;
56 HitTestRequest(HitTestRequestType requestType
)
57 : m_requestType(requestType
)
59 // Penetrating lists should also be list-based.
60 ASSERT(!(requestType
& PenetratingList
) || (requestType
& ListBased
));
63 bool readOnly() const { return m_requestType
& ReadOnly
; }
64 bool active() const { return m_requestType
& Active
; }
65 bool move() const { return m_requestType
& Move
; }
66 bool release() const { return m_requestType
& Release
; }
67 bool ignoreClipping() const { return m_requestType
& IgnoreClipping
; }
68 bool svgClipContent() const { return m_requestType
& SVGClipContent
; }
69 bool touchEvent() const { return m_requestType
& TouchEvent
; }
70 bool allowsChildFrameContent() const { return m_requestType
& AllowChildFrameContent
; }
71 bool isChildFrameHitTest() const { return m_requestType
& ChildFrameHitTest
; }
72 bool ignorePointerEventsNone() const { return m_requestType
& IgnorePointerEventsNone
; }
73 bool listBased() const { return m_requestType
& ListBased
; }
74 bool penetratingList() const { return m_requestType
& PenetratingList
; }
75 bool avoidCache() const { return m_requestType
& AvoidCache
; }
77 // Convenience functions
78 bool touchMove() const { return move() && touchEvent(); }
80 HitTestRequestType
type() const { return m_requestType
; }
82 // The Cacheability bits don't affect hit testing computation.
83 // TODO(dtapuska): These bits really shouldn't be fields on the HitTestRequest as
84 // they don't influence the result; but rather are hints on the output as to what to do.
85 // Perhaps move these fields to another enum ?
86 static const HitTestRequestType CacheabilityBits
= ReadOnly
| Active
| Move
| Release
| TouchEvent
;
87 bool equalForCacheability(const HitTestRequest
& value
) const
89 return (m_requestType
| CacheabilityBits
) == (value
.m_requestType
| CacheabilityBits
);
93 HitTestRequestType m_requestType
;
98 #endif // HitTestRequest_h