Commit cfb90ecb authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

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/1352253Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#611618}
parent ae0aec3d
......@@ -352,6 +352,12 @@ bool LayoutSVGShape::NodeAtPoint(HitTestResult& result,
// 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 @@ bool LayoutSVGShape::NodeAtPoint(HitTestResult& result,
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 @@ bool LayoutSVGShape::NodeAtPoint(HitTestResult& result,
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))
......
......@@ -63,10 +63,6 @@ class LayoutSVGShape : public LayoutSVGModelObject {
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 @@ class LayoutSVGShape : public LayoutSVGModelObject {
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_; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment