Commit 1c3ac04b authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[PE] Harden LayoutSVGShape::ShapeDependentStrokeContains()

There are still cases that LayoutSVGEllipse asks LayoutSVGShape
for ShapeDependentStrokeContains() when it decided to bypass the
path for optmization in UpdateShapeFromElement().

Bug: 850659
Change-Id: If8f8fd512183477ec7472ebb5b28c7d8333aa0bd
Reviewed-on: https://chromium-review.googlesource.com/1091871
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#565460}
parent e7062214
<!DOCTYPE html>
<svg id="svg">
<ellipse id="ellipse" ry="100" stroke="black" vector-effect="non-scaling-stroke"/>
</svg>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function() {
ellipse.isPointInStroke(svg.createSVGPoint());
});
</script>
......@@ -103,12 +103,8 @@ bool LayoutSVGEllipse::ShapeDependentStrokeContains(const FloatPoint& point) {
// The optimized check below for circles does not support non-circular and
// the cases that we set use_path_fallback_ in UpdateShapeFromElement().
if (use_path_fallback_ || radii_.Width() != radii_.Height()) {
// Create path for non-circular if needed.
if (!HasPath())
CreatePath();
if (use_path_fallback_ || radii_.Width() != radii_.Height())
return LayoutSVGShape::ShapeDependentStrokeContains(point);
}
const FloatPoint center =
FloatPoint(center_.X() - point.X(), center_.Y() - point.Y());
......
......@@ -155,12 +155,19 @@ FloatRect LayoutSVGShape::HitTestStrokeBoundingBox() const {
}
bool LayoutSVGShape::ShapeDependentStrokeContains(const FloatPoint& point) {
DCHECK(path_);
// In case the subclass didn't create path during UpdateShapeFromElement()
// for optimization but still calls this method.
if (!HasPath())
CreatePath();
StrokeData stroke_data;
SVGLayoutSupport::ApplyStrokeStyleToStrokeData(stroke_data, StyleRef(), *this,
DashScaleFactor());
if (HasNonScalingStroke()) {
// The reason is similar to the above code about HasPath().
if (!rare_data_)
UpdateNonScalingStrokeData();
return NonScalingStrokePath().StrokeContains(
NonScalingStrokeTransform().MapPoint(point), stroke_data);
}
......
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