| 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 "PointerEventsHitRules.h" |
| 22 | |
| 23 | namespace WebCore { |
| 24 | |
| 25 | PointerEventsHitRules::PointerEventsHitRules(EHitTesting hitTesting, const HitTestRequest& request, PointerEvents pointerEvents) |
| 26 | : requireVisible(false) |
| 27 | , requireFill(false) |
| 28 | , requireStroke(false) |
| 29 | , canHitStroke(false) |
| 30 | , canHitFill(false) |
| 31 | { |
| 32 | if (request.svgClipContent()) |
| 33 | pointerEvents = PointerEvents::Fill; |
| 34 | |
| 35 | if (hitTesting == SVG_PATH_HITTESTING) { |
| 36 | switch (pointerEvents) |
| 37 | { |
| 38 | case PointerEvents::VisiblePainted: |
| 39 | case PointerEvents::Auto: // "auto" is like "visiblePainted" when in SVG content |
| 40 | requireFill = true; |
| 41 | requireStroke = true; |
| 42 | FALLTHROUGH; |
| 43 | case PointerEvents::Visible: |
| 44 | requireVisible = true; |
| 45 | canHitFill = true; |
| 46 | canHitStroke = true; |
| 47 | break; |
| 48 | case PointerEvents::VisibleFill: |
| 49 | requireVisible = true; |
| 50 | canHitFill = true; |
| 51 | break; |
| 52 | case PointerEvents::VisibleStroke: |
| 53 | requireVisible = true; |
| 54 | canHitStroke = true; |
| 55 | break; |
| 56 | case PointerEvents::Painted: |
| 57 | requireFill = true; |
| 58 | requireStroke = true; |
| 59 | FALLTHROUGH; |
| 60 | case PointerEvents::All: |
| 61 | canHitFill = true; |
| 62 | canHitStroke = true; |
| 63 | break; |
| 64 | case PointerEvents::Fill: |
| 65 | canHitFill = true; |
| 66 | break; |
| 67 | case PointerEvents::Stroke: |
| 68 | canHitStroke = true; |
| 69 | break; |
| 70 | case PointerEvents::None: |
| 71 | // nothing to do here, defaults are all false. |
| 72 | break; |
| 73 | } |
| 74 | } else { |
| 75 | switch (pointerEvents) |
| 76 | { |
| 77 | case PointerEvents::VisiblePainted: |
| 78 | case PointerEvents::Auto: // "auto" is like "visiblePainted" when in SVG content |
| 79 | requireVisible = true; |
| 80 | requireFill = true; |
| 81 | requireStroke = true; |
| 82 | canHitFill = true; |
| 83 | canHitStroke = true; |
| 84 | break; |
| 85 | case PointerEvents::VisibleFill: |
| 86 | case PointerEvents::VisibleStroke: |
| 87 | case PointerEvents::Visible: |
| 88 | requireVisible = true; |
| 89 | canHitFill = true; |
| 90 | canHitStroke = true; |
| 91 | break; |
| 92 | case PointerEvents::Painted: |
| 93 | requireFill = true; |
| 94 | requireStroke = true; |
| 95 | canHitFill = true; |
| 96 | canHitStroke = true; |
| 97 | break; |
| 98 | case PointerEvents::Fill: |
| 99 | case PointerEvents::Stroke: |
| 100 | case PointerEvents::All: |
| 101 | canHitFill = true; |
| 102 | canHitStroke = true; |
| 103 | break; |
| 104 | case PointerEvents::None: |
| 105 | // nothing to do here, defaults are all false. |
| 106 | break; |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | } |
| 112 | |