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

[PaintTouchActionRects] Fix some frame throttling tests

This test changes expectation for some frame throttling tests with
PaintTouchActionRects enabled. The behavior is slightly different in the
unit test and the comments explains why.

Bug: 881890
Cq-Include-Trybots: luci.chromium.try:linux-blink-gen-property-trees
Change-Id: I0e6fdeebcbe016675ee082f38d8da66ce30abbeb
Reviewed-on: https://chromium-review.googlesource.com/1237056
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592915}
parent 174387d0
...@@ -266,6 +266,11 @@ static void UpdateLayerTouchActionRects(GraphicsLayer& layer) { ...@@ -266,6 +266,11 @@ static void UpdateLayerTouchActionRects(GraphicsLayer& layer) {
const auto& layer_state = layer.GetPropertyTreeState(); const auto& layer_state = layer.GetPropertyTreeState();
Vector<TouchActionRect> touch_action_rects_in_layer_space; Vector<TouchActionRect> touch_action_rects_in_layer_space;
if (layer.Client().ShouldThrottleRendering()) {
layer.CcLayer()->SetTouchActionRegion(
TouchActionRect::BuildRegion(touch_action_rects_in_layer_space));
return;
}
for (const auto& chunk : layer.GetPaintController().PaintChunks()) { for (const auto& chunk : layer.GetPaintController().PaintChunks()) {
const auto* hit_test_data = chunk.GetHitTestData(); const auto* hit_test_data = chunk.GetHitTestData();
if (!hit_test_data || hit_test_data->touch_action_rects.IsEmpty()) if (!hit_test_data || hit_test_data->touch_action_rects.IsEmpty())
......
...@@ -778,11 +778,31 @@ TEST_P(FrameThrottlingTest, ThrottledTopLevelEventHandlerIgnored) { ...@@ -778,11 +778,31 @@ TEST_P(FrameThrottlingTest, ThrottledTopLevelEventHandlerIgnored) {
auto* frame_element = auto* frame_element =
ToHTMLIFrameElement(GetDocument().getElementById("frame")); ToHTMLIFrameElement(GetDocument().getElementById("frame"));
frame_element->setAttribute(styleAttr, "transform: translateY(480px)"); frame_element->setAttribute(styleAttr, "transform: translateY(480px)");
DocumentLifecycle::AllowThrottlingScope throttling_scope(
GetDocument().Lifecycle());
CompositeFrame(); // Throttle the frame. CompositeFrame(); // Throttle the frame.
CompositeFrame(); // Update touch handler regions. CompositeFrame(); // Update touch handler regions.
// The touch handlers in the throttled frame should have been ignored. // In here, throttle iframe doesn't throttle the main frame.
EXPECT_EQ(0u, TouchHandlerRegionSize()); EXPECT_TRUE(
frame_element->contentDocument()->View()->ShouldThrottleRendering());
EXPECT_FALSE(GetDocument().View()->ShouldThrottleRendering());
// In this test, the iframe has the same origin as the main frame, so we have
// two documents but one graphics layer tree. The test throttles the iframe
// document only. In ScrollingCoordinator::UpdateLayerTouchActionRects, we
// check whether the document associated with a certain grahpics layer is
// throttled or not. Since the layers are associated with the main document
// which is not throttled, we expect the main document to have one touch
// handler region.
// In the Non-PaintTouchActionRects world, the
// AccumulateDocumentTouchEventTargetRects goes through every document and
// check whether the document is throttled or not. So we expect no touch
// handler region.
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled())
EXPECT_EQ(1u, TouchHandlerRegionSize());
else
EXPECT_EQ(0u, TouchHandlerRegionSize());
// Unthrottling the frame makes the touch handlers active again. Note that // Unthrottling the frame makes the touch handlers active again. Note that
// both handlers get combined into the same rectangle in the region, so // both handlers get combined into the same rectangle in the region, so
...@@ -819,11 +839,31 @@ TEST_P(FrameThrottlingTest, ThrottledEventHandlerIgnored) { ...@@ -819,11 +839,31 @@ TEST_P(FrameThrottlingTest, ThrottledEventHandlerIgnored) {
auto* frame_element = auto* frame_element =
ToHTMLIFrameElement(GetDocument().getElementById("frame")); ToHTMLIFrameElement(GetDocument().getElementById("frame"));
frame_element->setAttribute(styleAttr, "transform: translateY(480px)"); frame_element->setAttribute(styleAttr, "transform: translateY(480px)");
DocumentLifecycle::AllowThrottlingScope throttling_scope(
GetDocument().Lifecycle());
CompositeFrame(); // Throttle the frame. CompositeFrame(); // Throttle the frame.
CompositeFrame(); // Update touch handler regions. CompositeFrame(); // Update touch handler regions.
// The touch handler in the throttled frame should have been ignored. // In here, throttle iframe doesn't throttle the main frame.
EXPECT_EQ(0u, TouchHandlerRegionSize()); EXPECT_TRUE(
frame_element->contentDocument()->View()->ShouldThrottleRendering());
EXPECT_FALSE(GetDocument().View()->ShouldThrottleRendering());
// In this test, the iframe has the same origin as the main frame, so we have
// two documents but one graphics layer tree. The test throttles the iframe
// document only. In ScrollingCoordinator::UpdateLayerTouchActionRects, we
// check whether the document associated with a certain grahpics layer is
// throttled or not. Since the layers are associated with the main document
// which is not throttled, we expect the main document to have one touch
// handler region.
// In the Non-PaintTouchActionRects world, the
// AccumulateDocumentTouchEventTargetRects goes through every document and
// check whether the document is throttled or not. So we expect no touch
// handler region.
if (RuntimeEnabledFeatures::PaintTouchActionRectsEnabled())
EXPECT_EQ(1u, TouchHandlerRegionSize());
else
EXPECT_EQ(0u, TouchHandlerRegionSize());
// Unthrottling the frame makes the touch handler active again. // Unthrottling the frame makes the touch handler active again.
frame_element->setAttribute(styleAttr, "transform: translateY(0px)"); frame_element->setAttribute(styleAttr, "transform: translateY(0px)");
......
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