PointerEventsHitRules.cpp 3.6 KB

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