375801d230942524e92fd1b1d159ff900064796b
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / PointerEventsHitRules.cpp
1 /*
2     Copyright (C) 2007 Rob Buis <buis@kde.org>
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Library General Public
6     License as published by the Free Software Foundation; either
7     version 2 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Library General Public License for more details.
13
14     You should have received a copy of the GNU Library General Public License
15     aint with this library; see the file COPYING.LIB.  If not, write to
16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     Boston, MA 02110-1301, USA.
18 */
19
20 #include "config.h"
21 #include "core/rendering/PointerEventsHitRules.h"
22
23 #include "wtf/Assertions.h"
24
25 namespace blink {
26
27 struct SameSizeAsPointerEventsHitRules {
28     unsigned bitfields;
29 };
30
31 COMPILE_ASSERT(sizeof(PointerEventsHitRules) <= sizeof(SameSizeAsPointerEventsHitRules), PointerEventsHitRules_should_stay_small);
32
33 PointerEventsHitRules::PointerEventsHitRules(EHitTesting hitTesting, const HitTestRequest& request, EPointerEvents pointerEvents)
34     : requireVisible(false)
35     , requireFill(false)
36     , requireStroke(false)
37     , canHitStroke(false)
38     , canHitFill(false)
39     , canHitBoundingBox(false)
40 {
41     if (request.svgClipContent())
42         pointerEvents = PE_FILL;
43
44     if (hitTesting == SVG_GEOMETRY_HITTESTING) {
45         switch (pointerEvents)
46         {
47             case PE_BOUNDINGBOX:
48                 canHitBoundingBox = true;
49                 break;
50             case PE_VISIBLE_PAINTED:
51             case PE_AUTO: // "auto" is like "visiblePainted" when in SVG content
52                 requireFill = true;
53                 requireStroke = true;
54             case PE_VISIBLE:
55                 requireVisible = true;
56                 canHitFill = true;
57                 canHitStroke = true;
58                 break;
59             case PE_VISIBLE_FILL:
60                 requireVisible = true;
61                 canHitFill = true;
62                 break;
63             case PE_VISIBLE_STROKE:
64                 requireVisible = true;
65                 canHitStroke = true;
66                 break;
67             case PE_PAINTED:
68                 requireFill = true;
69                 requireStroke = true;
70             case PE_ALL:
71                 canHitFill = true;
72                 canHitStroke = true;
73                 break;
74             case PE_FILL:
75                 canHitFill = true;
76                 break;
77             case PE_STROKE:
78                 canHitStroke = true;
79                 break;
80             case PE_NONE:
81                 // nothing to do here, defaults are all false.
82                 break;
83         }
84     } else {
85         switch (pointerEvents)
86         {
87             case PE_BOUNDINGBOX:
88                 canHitBoundingBox = true;
89                 break;
90             case PE_VISIBLE_PAINTED:
91             case PE_AUTO: // "auto" is like "visiblePainted" when in SVG content
92                 requireVisible = true;
93                 requireFill = true;
94                 requireStroke = true;
95                 canHitFill = true;
96                 canHitStroke = true;
97                 break;
98             case PE_VISIBLE_FILL:
99             case PE_VISIBLE_STROKE:
100             case PE_VISIBLE:
101                 requireVisible = true;
102                 canHitFill = true;
103                 canHitStroke = true;
104                 break;
105             case PE_PAINTED:
106                 requireFill = true;
107                 requireStroke = true;
108                 canHitFill = true;
109                 canHitStroke = true;
110                 break;
111             case PE_FILL:
112             case PE_STROKE:
113             case PE_ALL:
114                 canHitFill = true;
115                 canHitStroke = true;
116                 break;
117             case PE_NONE:
118                 // nothing to do here, defaults are all false.
119                 break;
120         }
121     }
122 }
123
124 }
125
126 // vim:ts=4:noet