Commit fc6eae27 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Add RecordHitTestData in LayoutReplacedPainter

This CL adds RecordHitTestData in LayoutReplacedPainter. Two layout
tests are added for SVG root and HTML image element cases.

Bug: 876468
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Iea6a2318bcd7029b252ebccc92d62d93ad0b6c23
Reviewed-on: https://chromium-review.googlesource.com/1196914
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588250}
parent 0b4b4577
...@@ -1412,3 +1412,7 @@ Bug(none) virtual/paint-touchaction-rects/fast/events/touch/compositor-touch-hit ...@@ -1412,3 +1412,7 @@ Bug(none) virtual/paint-touchaction-rects/fast/events/touch/compositor-touch-hit
Bug(none) paint/float/float-under-inline-self-painting-change.html [ Failure ] Bug(none) paint/float/float-under-inline-self-painting-change.html [ Failure ]
Bug(none) virtual/paint-touchaction-rects/fast/events/touch/compositor-touch-hit-rects-svg-image.html [ Failure ] Bug(none) virtual/paint-touchaction-rects/fast/events/touch/compositor-touch-hit-rects-svg-image.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-svg-image.html [ Failure ] Bug(none) fast/events/touch/compositor-touch-hit-rects-svg-image.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-img-element.html [ Failure ]
Bug(none) virtual/paint-touchaction-rects/fast/events/touch/compositor-touch-hit-rects-svg-root.html [ Failure ]
Bug(none) virtual/paint-touchaction-rects/fast/events/touch/compositor-touch-hit-rects-img-element.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-svg-root.html [ Failure ]
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="resources/compositor-touch-hit-rects.css">
</head>
<div id="tests">
<img class="testcase" src="../../../images/resources/grid-small.png">
</div>
<div id="console"></div>
<script src="resources/compositor-touch-hit-rects.js"></script>
</body>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="resources/compositor-touch-hit-rects.css">
</head>
<div id="tests">
<svg class="testcase" width="51" height="52">
</svg>
</div>
<div id="console"></div>
<script src="resources/compositor-touch-hit-rects.js"></script>
</body>
...@@ -130,6 +130,8 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) { ...@@ -130,6 +130,8 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) {
} }
} }
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled())
RecordHitTestData(paint_info, paint_offset);
layout_replaced_.PaintReplaced(transformed_paint_info, paint_offset); layout_replaced_.PaintReplaced(transformed_paint_info, paint_offset);
} }
...@@ -163,6 +165,26 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) { ...@@ -163,6 +165,26 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) {
} }
} }
void ReplacedPainter::RecordHitTestData(const PaintInfo& paint_info,
const LayoutPoint& paint_offset) {
// 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;
if (paint_info.phase != PaintPhase::kForeground)
return;
auto touch_action = layout_replaced_.EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
return;
auto rect = layout_replaced_.VisualOverflowRect();
rect.MoveBy(paint_offset);
HitTestData::RecordTouchActionRect(paint_info.context, layout_replaced_,
TouchActionRect(rect, touch_action));
}
bool ReplacedPainter::ShouldPaint( bool ReplacedPainter::ShouldPaint(
const PaintInfoWithOffset& paint_info_with_offset) const { const PaintInfoWithOffset& paint_info_with_offset) const {
const auto& paint_info = paint_info_with_offset.GetPaintInfo(); const auto& paint_info = paint_info_with_offset.GetPaintInfo();
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_REPLACED_PAINTER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_REPLACED_PAINTER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_REPLACED_PAINTER_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_REPLACED_PAINTER_H_
#include "third_party/blink/renderer/platform/geometry/layout_point.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink { namespace blink {
...@@ -25,6 +26,10 @@ class ReplacedPainter { ...@@ -25,6 +26,10 @@ class ReplacedPainter {
bool ShouldPaint(const PaintInfoWithOffset&) const; bool ShouldPaint(const PaintInfoWithOffset&) const;
private: private:
// Paint a hit test display item and record hit test data. This should be
// called in the background paint phase even if there is no other painted
// content.
void RecordHitTestData(const PaintInfo&, const LayoutPoint& paint_offset);
const LayoutReplaced& layout_replaced_; const LayoutReplaced& layout_replaced_;
}; };
......
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