Commit 7f010897 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Record HitTestData in SVGShapePainter

Right now none of SVG related painters call RecordHitTestData, that's
why the "svgline" test case in the compositor-touch-hit-rects.html is
failing.

This CL adds a RecordHitTestData API in SVGShapePainter. It will fix
the failing test. However, any SVG related painters should have such an
API. It will be addressed in follow-up CLs together with new test cases.

Bug: 853912
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I7b8aa3869d8703a38a4f3265e4f1fc2744b6bd6a
Reviewed-on: https://chromium-review.googlesource.com/1151616
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578747}
parent e55c0dad
...@@ -1393,3 +1393,6 @@ Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-into-center.html [ Pass ...@@ -1393,3 +1393,6 @@ Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-into-center.html [ Pass
Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-pan-position-fixed.html [ Pass Failure Crash ] Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-pan-position-fixed.html [ Pass Failure Crash ]
Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-pan-within-zoomed-viewport.html [ Pass Failure Crash ] Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-pan-within-zoomed-viewport.html [ Pass Failure Crash ]
Bug(none) compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned.html [ Failure ] Bug(none) compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-svg.html [ Failure ]
Bug(none) virtual/paint-touchaction-rects/fast/events/touch/compositor-touch-hit-rects-svg.html [ Failure ]
This tests verifies the hit test regions given to the compositor for svg elements. It can only be run in DumpRenderTree.
svgline: #document scrolling (13, 80, 100, 10)
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="resources/compositor-touch-hit-rects.css">
<style>
svg {
width: 100px;
height: 10px;
}
</style>
</head>
<body>
<p id="description">
This tests verifies the hit test regions given to the compositor for svg elements.
It can only be run in DumpRenderTree.</p>
<div id="tests">
<div>
<svg id="svg2">
<line class="testcase" id="svgline" x1="0" y1="5" x2="20" y2="5" stroke-width="3" stroke="black"/>
<line x1="40" y1="5" x2="60" y2="5" stroke-width="3" stroke="black"/>
</svg>
</div>
</div>
<div id="console"></div>
<script src="resources/compositor-touch-hit-rects.js"></script>
</body>
This tests verifies the hit test regions given to the compositor for svg elements. It can only be run in DumpRenderTree.
svgline: #document scrolling (13, 84, 22, 3)
...@@ -40,6 +40,21 @@ static SkPath::FillType FillRuleFromStyle(const PaintInfo& paint_info, ...@@ -40,6 +40,21 @@ static SkPath::FillType FillRuleFromStyle(const PaintInfo& paint_info,
: svg_style.FillRule()); : svg_style.FillRule());
} }
void SVGShapePainter::RecordHitTestData(const PaintInfo& paint_info) {
// Hit test display items are only needed for compositing. This flag is used
// for for printing and drag images which do not need hit testing.
if (paint_info.GetGlobalPaintFlags() & kGlobalPaintFlattenCompositingLayers)
return;
auto touch_action = layout_svg_shape_.EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
return;
auto rect = LayoutRect(layout_svg_shape_.VisualRectInLocalSVGCoordinates());
HitTestData::RecordTouchActionRect(paint_info.context, layout_svg_shape_,
TouchActionRect(rect, touch_action));
}
void SVGShapePainter::Paint(const PaintInfo& paint_info) { void SVGShapePainter::Paint(const PaintInfo& paint_info) {
if (paint_info.phase != PaintPhase::kForeground || if (paint_info.phase != PaintPhase::kForeground ||
layout_svg_shape_.Style()->Visibility() != EVisibility::kVisible || layout_svg_shape_.Style()->Visibility() != EVisibility::kVisible ||
...@@ -64,6 +79,8 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) { ...@@ -64,6 +79,8 @@ void SVGShapePainter::Paint(const PaintInfo& paint_info) {
!DrawingRecorder::UseCachedDrawingIfPossible( !DrawingRecorder::UseCachedDrawingIfPossible(
paint_context.GetPaintInfo().context, layout_svg_shape_, paint_context.GetPaintInfo().context, layout_svg_shape_,
paint_context.GetPaintInfo().phase)) { paint_context.GetPaintInfo().phase)) {
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled())
RecordHitTestData(paint_info);
DrawingRecorder recorder(paint_context.GetPaintInfo().context, DrawingRecorder recorder(paint_context.GetPaintInfo().context,
layout_svg_shape_, layout_svg_shape_,
paint_context.GetPaintInfo().phase); paint_context.GetPaintInfo().phase);
......
...@@ -36,6 +36,10 @@ class SVGShapePainter { ...@@ -36,6 +36,10 @@ class SVGShapePainter {
const LayoutSVGResourceMarker&, const LayoutSVGResourceMarker&,
const MarkerPosition&, const MarkerPosition&,
float stroke_width); float stroke_width);
// Paint a hit test display item and record hit test data. This should be
// called when painting the background even if there is no other painted
// content.
void RecordHitTestData(const PaintInfo&);
const LayoutSVGShape& layout_svg_shape_; const LayoutSVGShape& layout_svg_shape_;
}; };
......
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