Clean up LayoutSVGShape::NodeAtPoint
Since LayoutSVGShape::NodeAtPointInternal is now only called from
LayoutSVGShape::NodeAtPoint, we can make it private. Rename it to
something more helper-like - HitTestShape.
Move the check of 'visibility' to LayoutSVGShape::NodeAtPoint from
HitTestShape, to better match other similar methods.
Change-Id: If251b8b9258b754bfc94044739d6a8c41f1b04e7
Reviewed-on: https://chromium-review.googlesource.com/c/1352253
Reviewed-by: Philip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#611618}
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc
index 41eede2..891762d 100644
--- a/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc
+++ b/third_party/blink/renderer/core/layout/svg/layout_svg_shape.cc
@@ -352,6 +352,12 @@
// We only draw in the foreground phase, so we only hit-test then.
if (hit_test_action != kHitTestForeground)
return false;
+ const ComputedStyle& style = StyleRef();
+ const PointerEventsHitRules hit_rules(
+ PointerEventsHitRules::SVG_GEOMETRY_HITTESTING,
+ result.GetHitTestRequest(), style.PointerEvents());
+ if (hit_rules.require_visible && style.Visibility() != EVisibility::kVisible)
+ return false;
TransformedHitTestLocation local_location(location_in_parent,
LocalToSVGParentTransform());
@@ -360,11 +366,7 @@
if (!SVGLayoutSupport::IntersectsClipPath(*this, *local_location))
return false;
- PointerEventsHitRules hit_rules(
- PointerEventsHitRules::SVG_GEOMETRY_HITTESTING,
- result.GetHitTestRequest(), StyleRef().PointerEvents());
- if (NodeAtPointInternal(result.GetHitTestRequest(), *local_location,
- hit_rules)) {
+ if (HitTestShape(result.GetHitTestRequest(), *local_location, hit_rules)) {
const LayoutPoint local_layout_point(local_location->TransformedPoint());
UpdateHitTestResult(result, local_layout_point);
if (result.AddNodeToListBasedTestResult(GetElement(), *local_location) ==
@@ -375,18 +377,15 @@
return false;
}
-bool LayoutSVGShape::NodeAtPointInternal(const HitTestRequest& request,
- const HitTestLocation& local_location,
- PointerEventsHitRules hit_rules) {
- const ComputedStyle& style = StyleRef();
- if (hit_rules.require_visible && style.Visibility() != EVisibility::kVisible)
- return false;
+bool LayoutSVGShape::HitTestShape(const HitTestRequest& request,
+ const HitTestLocation& local_location,
+ PointerEventsHitRules hit_rules) {
if (hit_rules.can_hit_bounding_box &&
local_location.Intersects(ObjectBoundingBox()))
return true;
// TODO(chrishtr): support rect-based intersections in the cases below.
- const SVGComputedStyle& svg_style = style.SvgStyle();
+ const SVGComputedStyle& svg_style = StyleRef().SvgStyle();
if (hit_rules.can_hit_stroke &&
(svg_style.HasStroke() || !hit_rules.require_stroke) &&
StrokeContains(local_location, hit_rules.require_stroke))
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_shape.h b/third_party/blink/renderer/core/layout/svg/layout_svg_shape.h
index 6aa1bf1..dc37505 100644
--- a/third_party/blink/renderer/core/layout/svg/layout_svg_shape.h
+++ b/third_party/blink/renderer/core/layout/svg/layout_svg_shape.h
@@ -63,10 +63,6 @@
void SetNeedsBoundariesUpdate() final { needs_boundaries_update_ = true; }
void SetNeedsTransformUpdate() final { needs_transform_update_ = true; }
- bool NodeAtPointInternal(const HitTestRequest&,
- const HitTestLocation&,
- PointerEventsHitRules);
-
Path& GetPath() const {
DCHECK(path_);
return *path_;
@@ -167,6 +163,9 @@
const HitTestLocation& location_in_parent,
const LayoutPoint& accumulated_offset,
HitTestAction) final;
+ bool HitTestShape(const HitTestRequest&,
+ const HitTestLocation&,
+ PointerEventsHitRules);
FloatRect StrokeBoundingBox() const final { return stroke_bounding_box_; }