Commit 3a469697 authored by Xianda Sun's avatar Xianda Sun Committed by Commit Bot

[PaintTouchActionRect] Calculate scrolling LayoutReplaced hit test rects

This is a followup patch to [1] and paints LayoutReplaced hit test rects
into the scrolling contents layer. In this way we don't need to repaint
on every scroll change.

[1] https://crrev.com/603335

Bug: 888269
Change-Id: Ic8196f59b8a2f7d08285c5234ed562a61386ee6b
Reviewed-on: https://chromium-review.googlesource.com/c/1310754
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605378}
parent 2c28f7c1
...@@ -254,12 +254,6 @@ void BoxPainter::RecordHitTestData(const PaintInfo& paint_info, ...@@ -254,12 +254,6 @@ void BoxPainter::RecordHitTestData(const PaintInfo& paint_info,
const LayoutPoint& paint_offset, const LayoutPoint& paint_offset,
const LayoutRect& paint_rect, const LayoutRect& paint_rect,
const DisplayItemClient& background_client) { const DisplayItemClient& background_client) {
// TODO(sunxd): ReplacedPainter only record hit test data for svg root which
// skips clip. We should move the conditions and ReplacedPainter's
// RecordHitTestData here.
if (layout_box_.IsLayoutReplaced())
return;
// Hit test display items are only needed for compositing. This flag is used // 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. // for for printing and drag images which do not need hit testing.
if (paint_info.GetGlobalPaintFlags() & kGlobalPaintFlattenCompositingLayers) if (paint_info.GetGlobalPaintFlags() & kGlobalPaintFlattenCompositingLayers)
......
...@@ -138,10 +138,6 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) { ...@@ -138,10 +138,6 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) {
if (skip_clip || !layout_replaced_.PhysicalContentBoxRect().IsEmpty()) { if (skip_clip || !layout_replaced_.PhysicalContentBoxRect().IsEmpty()) {
ScopedReplacedContentPaintState content_paint_state(paint_state, ScopedReplacedContentPaintState content_paint_state(paint_state,
layout_replaced_); layout_replaced_);
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled()) {
RecordHitTestData(content_paint_state.GetPaintInfo(),
content_paint_state.PaintOffset());
}
layout_replaced_.PaintReplaced(content_paint_state.GetPaintInfo(), layout_replaced_.PaintReplaced(content_paint_state.GetPaintInfo(),
content_paint_state.PaintOffset()); content_paint_state.PaintOffset());
} }
...@@ -176,30 +172,6 @@ void ReplacedPainter::Paint(const PaintInfo& paint_info) { ...@@ -176,30 +172,6 @@ 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;
// If an object is not visible, it does not participate in hit testing.
if (layout_replaced_.StyleRef().Visibility() != EVisibility::kVisible)
return;
auto touch_action = layout_replaced_.EffectiveWhitelistedTouchAction();
if (touch_action == TouchAction::kTouchActionAuto)
return;
auto rect = layout_replaced_.VisualOverflowRect();
rect.MoveBy(paint_offset);
HitTestData::RecordHitTestRect(paint_info.context, layout_replaced_,
HitTestRect(rect, touch_action));
}
bool ReplacedPainter::ShouldPaint(const ScopedPaintState& paint_state) const { bool ReplacedPainter::ShouldPaint(const ScopedPaintState& paint_state) const {
const auto& paint_info = paint_state.GetPaintInfo(); const auto& paint_info = paint_state.GetPaintInfo();
if (paint_info.phase != PaintPhase::kForeground && if (paint_info.phase != PaintPhase::kForeground &&
......
...@@ -26,10 +26,6 @@ class ReplacedPainter { ...@@ -26,10 +26,6 @@ class ReplacedPainter {
bool ShouldPaint(const ScopedPaintState&) const; bool ShouldPaint(const ScopedPaintState&) 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