Commit 8608f015 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

[SPV2] Support touch action rects in composite-after-paint

This patch implements touch-action rects in composite-after-paint by
generalizing the ScrollingCoordinator UpdateLayerTouchActionRects
function to work with both SPV1 and SPV2.

Several tests are failing due to cc::Layer::position being zero,
though the touch-action rects are correct. Expectation entries have
been added for these.

This patch also reorders some lines in internals.h. This was found in
the review of http://crrev.com/611376 but was mistakenly left out when
the patch landed.

Bug: 909749

Change-Id: I9d66ebdfef25d46388ce5740121a7b4844de1ca5
Reviewed-on: https://chromium-review.googlesource.com/c/1351802
Commit-Queue: Philip Rogers <pdr@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611785}
parent 64ba0653
......@@ -59,6 +59,7 @@
#include "third_party/blink/renderer/platform/animation/compositor_animation_host.h"
#include "third_party/blink/renderer/platform/animation/compositor_animation_timeline.h"
#include "third_party/blink/renderer/platform/geometry/region.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/graphics/graphics_layer.h"
#include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
......@@ -254,44 +255,21 @@ static void ForAllGraphicsLayers(GraphicsLayer& layer,
// on the GraphicsLayer's paint chunks.
static void UpdateLayerTouchActionRects(GraphicsLayer& layer) {
DCHECK(RuntimeEnabledFeatures::PaintTouchActionRectsEnabled());
// TODO(pdr): This will need to be moved to PaintArtifactCompositor (or later)
// for SPV2 because composited layers are not known until then. The SPV2
// implementation will iterate over the paint chunks in each composited layer
// and will look almost the same as this function.
DCHECK(!RuntimeEnabledFeatures::SlimmingPaintV2Enabled());
if (!layer.DrawsContent())
return;
const auto& layer_state = layer.GetPropertyTreeState();
Vector<HitTestRect> touch_action_rects_in_layer_space;
if (layer.Client().ShouldThrottleRendering()) {
layer.CcLayer()->SetTouchActionRegion(
HitTestRect::BuildRegion(touch_action_rects_in_layer_space));
layer.CcLayer()->SetTouchActionRegion(cc::TouchActionRegion());
return;
}
for (const auto& chunk : layer.GetPaintController().PaintChunks()) {
const auto* hit_test_data = chunk.hit_test_data.get();
if (!hit_test_data || hit_test_data->touch_action_rects.IsEmpty())
continue;
const auto& chunk_state = chunk.properties.GetPropertyTreeState();
for (auto touch_action_rect : hit_test_data->touch_action_rects) {
auto rect =
FloatClipRect(FloatRect(PixelSnappedIntRect(touch_action_rect.rect)));
if (!GeometryMapper::LocalToAncestorVisualRect(chunk_state, layer_state,
rect)) {
continue;
}
LayoutRect layout_rect = LayoutRect(rect.Rect());
layout_rect.MoveBy(-layer.GetOffsetFromTransformNode());
touch_action_rects_in_layer_space.emplace_back(
HitTestRect(layout_rect, touch_action_rect.whitelisted_touch_action));
}
}
layer.CcLayer()->SetTouchActionRegion(
HitTestRect::BuildRegion(touch_action_rects_in_layer_space));
auto offset = layer.GetOffsetFromTransformNode();
gfx::Vector2dF layer_offset = gfx::Vector2dF(offset.X(), offset.Y());
PaintChunkSubset paint_chunks =
PaintChunkSubset(layer.GetPaintController().PaintChunks());
PaintArtifactCompositor::UpdateTouchActionRects(layer.CcLayer(), layer_offset,
layer.GetPropertyTreeState(),
paint_chunks);
}
static void ClearPositionConstraintExceptForLayer(GraphicsLayer* layer,
......
......@@ -155,6 +155,7 @@
#include "third_party/blink/renderer/platform/cursor.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h"
#include "third_party/blink/renderer/platform/geometry/layout_rect.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/graphics/graphics_layer.h"
#include "third_party/blink/renderer/platform/graphics/paint/raster_invalidation_tracking.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
......@@ -1903,6 +1904,38 @@ HitTestLayerRectList* Internals::touchEventTargetLayerRects(
return nullptr;
}
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
auto* pac = document->View()->GetPaintArtifactCompositorForTesting();
pac->EnableExtraDataForTesting();
document->View()->UpdateAllLifecyclePhases(
DocumentLifecycle::LifecycleUpdateReason::kTest);
const auto& content_layers = pac->GetExtraDataForTesting()->content_layers;
HitTestLayerRectList* hit_test_rects = HitTestLayerRectList::Create();
for (const auto& layer : content_layers) {
const cc::TouchActionRegion& touch_action_region =
layer->touch_action_region();
if (!touch_action_region.region().IsEmpty()) {
IntRect layer_rect(RoundedIntPoint(FloatPoint(layer->position())),
IntSize(layer->bounds()));
Vector<IntRect> layer_hit_test_rects;
for (const gfx::Rect& hit_test_rect : touch_action_region.region())
layer_hit_test_rects.push_back(IntRect(hit_test_rect));
MergeRects(layer_hit_test_rects);
for (const IntRect& hit_test_rect : layer_hit_test_rects) {
if (!hit_test_rect.IsEmpty()) {
hit_test_rects->Append(DOMRectReadOnly::FromIntRect(layer_rect),
DOMRectReadOnly::FromIntRect(hit_test_rect));
}
}
}
}
return hit_test_rects;
}
if (ScrollingCoordinator* scrolling_coordinator =
document->GetPage()->GetScrollingCoordinator()) {
FrameView* view = document->GetPage()->MainFrame()->View();
......
......@@ -43,11 +43,11 @@ namespace blink {
class Animation;
class CallbackFunctionTest;
class CanvasRenderingContext;
class DOMArrayBuffer;
class DOMPoint;
class DOMRect;
class DOMRectList;
class DOMRectReadOnly;
class DOMArrayBuffer;
class DOMPoint;
class DOMWindow;
class DictionaryTest;
class Document;
......@@ -56,15 +56,15 @@ class Element;
class ExceptionState;
class ExecutionContext;
class GCObservation;
class HitTestLocation;
class HitTestResult;
class HTMLInputElement;
class HTMLMediaElement;
class HTMLSelectElement;
class HTMLVideoElement;
class HitTestLayerRectList;
class HitTestLocation;
class HitTestResult;
class InternalRuntimeFlags;
class InternalSettings;
class HitTestLayerRectList;
class LocalDOMWindow;
class LocalFrame;
class Location;
......@@ -73,15 +73,16 @@ class OriginTrialsTest;
class Page;
class Range;
class RecordTest;
class ScrollState;
class SequenceTest;
class SerializedScriptValue;
class ShadowRoot;
template <typename NodeType>
class StaticNodeTypeList;
class StaticSelection;
class TypeConversions;
class UnionTypesTest;
class ScrollState;
template <typename NodeType>
class StaticNodeTypeList;
using StaticNodeList = StaticNodeTypeList<Node>;
class Internals final : public ScriptWrappable {
......
......@@ -289,6 +289,36 @@ PaintArtifactCompositor::CompositedLayerForPendingLayer(
return cc_layer;
}
void PaintArtifactCompositor::UpdateTouchActionRects(
cc::Layer* layer,
const gfx::Vector2dF& layer_offset,
const PropertyTreeState& layer_state,
const PaintChunkSubset& paint_chunks) {
Vector<HitTestRect> touch_action_rects_in_layer_space;
for (const auto& chunk : paint_chunks) {
const auto* hit_test_data = chunk.hit_test_data.get();
if (!hit_test_data || hit_test_data->touch_action_rects.IsEmpty())
continue;
const auto& chunk_state = chunk.properties.GetPropertyTreeState();
for (auto touch_action_rect : hit_test_data->touch_action_rects) {
auto rect =
FloatClipRect(FloatRect(PixelSnappedIntRect(touch_action_rect.rect)));
if (!GeometryMapper::LocalToAncestorVisualRect(chunk_state, layer_state,
rect)) {
continue;
}
LayoutRect layout_rect = LayoutRect(rect.Rect());
layout_rect.MoveBy(
LayoutPoint(FloatPoint(-layer_offset.x(), -layer_offset.y())));
touch_action_rects_in_layer_space.emplace_back(
HitTestRect(layout_rect, touch_action_rect.whitelisted_touch_action));
}
}
layer->SetTouchActionRegion(
HitTestRect::BuildRegion(touch_action_rects_in_layer_space));
}
bool PaintArtifactCompositor::PropertyTreeStateChanged(
const PropertyTreeState& state) const {
const PropertyTreeState root = PropertyTreeState::Root();
......@@ -791,6 +821,15 @@ void PaintArtifactCompositor::Update(
paint_artifact, pending_layer, layer_offset, new_content_layer_clients,
new_scroll_hit_test_layers);
// Pre-SPV2, touch action rects are updated through
// ScrollingCoordinator::UpdateLayerTouchActionRects.
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
auto paint_chunks = paint_artifact->GetPaintChunkSubset(
pending_layer.paint_chunk_indices);
UpdateTouchActionRects(layer.get(), layer_offset, property_state,
paint_chunks);
}
layer->SetLayerTreeHost(root_layer_->layer_tree_host());
int transform_id =
......
......@@ -112,6 +112,13 @@ class PLATFORM_EXPORT PaintArtifactCompositor final
return content_layer_clients_;
}
// Update the cc::Layer's touch action region from the touch action rects of
// the paint chunks.
static void UpdateTouchActionRects(cc::Layer*,
const gfx::Vector2dF& layer_offset,
const PropertyTreeState& layer_state,
const PaintChunkSubset& paint_chunks);
private:
// A pending layer is a collection of paint chunks that will end up in
// the same cc::Layer.
......
......@@ -327,21 +327,7 @@ Bug(none) fast/events/platform-wheelevent-paging-xy-in-scrolling-page.html [ Fai
Bug(none) fast/events/platform-wheelevent-paging-y-in-scrolling-page.html [ Failure ]
Bug(none) fast/events/scroll-after-click-on-tab-index.html [ Failure ]
Bug(none) fast/events/space-scroll-textinput-canceled.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-animation.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-global.html [ Failure Crash ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-many.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-non-composited-scroll.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-non-composited-scroll-overflow-with-handler.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-scroll.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-squashing.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-trigger-commit.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-transform-changed-nolayout.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects-with-negative-child.html [ Failure ]
Bug(none) fast/events/touch/compositor-touch-hit-rects.html [ Failure ]
Bug(none) fast/events/touch/gesture/gesture-scroll-by-page.html [ Failure ]
Bug(none) fast/events/touch/touch-handler-assert-input-range.html [ Failure ]
Bug(none) fast/events/touch/touch-rect-assert-first-layer-special.html [ Failure ]
Bug(none) fast/events/touch/touch-rect-crash-on-unpromote-layer.html [ Failure ]
Bug(none) fast/webgl/pixelated.html [ Failure ]
Bug(none) images/color-profile-reflection.html [ Crash Failure ]
Bug(none) images/color-profile-svg-foreign-object.html [ Failure ]
......@@ -757,10 +743,6 @@ Bug(none) paint/invalidation/selection/japanese-rl-selection-repaint.html [ Fail
Bug(none) virtual/threaded/external/wpt/feature-policy/experimental-features/vertical-scroll-touch-action-manual.tentative.html [ Failure ]
Bug(none) virtual/threaded/external/wpt/feature-policy/experimental-features/vertical-scroll-touch-block-manual.tentative.html [ Failure ]
# Many of these tests are currently failing or crashing, and the tests change
# quickly, so just tolerate the whole directory until we start to work on them.
Bug(none) fast/events/touch [ Failure Pass Crash ]
Bug(none) virtual/threaded/fast/events/pinch/gesture-pinch-fake-mouse-wheel.html [ Pass Failure Crash ]
Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-into-center.html [ Pass Failure Crash ]
Bug(none) virtual/threaded/fast/events/pinch/pinch-zoom-pan-position-fixed.html [ Pass Failure Crash ]
......@@ -776,6 +758,17 @@ Bug(none) synthetic_gestures/animated-wheel-tiny-delta.html [ Failure ]
# Duplicated display item id of background of scrollable table cell.
Bug(none) fast/table/overflowHidden.html [ Crash ]
# These tests have incorrect layer positions.
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-animation.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-global.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-many.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-non-composited-scroll-overflow-with-handler.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-non-composited-scroll.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-scroll.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-squashing.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects-with-negative-child.html [ Failure ]
crbug.com/909749 fast/events/touch/compositor-touch-hit-rects.html [ Failure ]
# These tests have failures that were introduced between enabling BGPT for the
# first time and later disabling it. These are not real failures and can be
# rebaselined.
......
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