Commit 4d299089 authored by Sam Fortiner's avatar Sam Fortiner Committed by Commit Bot

Remove use of GraphicsLayer::GetPosition from test

Modifying unit tests to validate that the layers are positioned properly
via the transform property tree or offset from transform node instead of
via checking GraphicsLayer's position.  This is in preparation for
removing GraphicsLayer's GetPosition entirely.


Bug: 999336
Change-Id: Ib591083846f411fe7bd9e3ad7180b16ed2f2573d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1897131
Commit-Queue: Sam Fortiner <samfort@microsoft.com>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712340}
parent 106224d3
......@@ -14,6 +14,7 @@
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
namespace blink {
......@@ -1251,10 +1252,22 @@ TEST_F(CompositedLayerMappingTest,
// the sticky element.
EXPECT_EQ(PhysicalOffset(0, 100), sticky->StickyPositionOffset());
// On the CompositedLayerMapping side however, the offset should have been
// removed so that the compositor can take care of it.
EXPECT_FLOAT_EQ(0, main_graphics_layer->GetPosition().x());
EXPECT_FLOAT_EQ(0, main_graphics_layer->GetPosition().y());
GraphicsLayer* root_scrolling_layer =
GetDocument().GetLayoutView()->Layer()->GraphicsLayerBacking();
const PropertyTreeState& root_layer_state =
root_scrolling_layer->GetPropertyTreeState();
const PropertyTreeState& sticky_layer_state =
main_graphics_layer->GetPropertyTreeState();
auto transform_from_sticky_to_root =
GeometryMapper::SourceToDestinationProjection(
sticky_layer_state.Transform(), root_layer_state.Transform());
// Irrespective of if the ancestor scroller is composited or not, the sticky
// position element should be at the same location.
auto sticky_position_relative_to_root =
transform_from_sticky_to_root.MapPoint(
FloatPoint(main_graphics_layer->GetOffsetFromTransformNode()));
EXPECT_FLOAT_EQ(8, sticky_position_relative_to_root.X());
EXPECT_FLOAT_EQ(8, sticky_position_relative_to_root.Y());
}
TEST_F(CompositedLayerMappingTest,
......@@ -1287,8 +1300,22 @@ TEST_F(CompositedLayerMappingTest,
FloatPoint(scrollable_area->ScrollPosition().Y(), 100));
UpdateAllLifecyclePhasesForTest();
EXPECT_FLOAT_EQ(0, main_graphics_layer->GetPosition().x());
EXPECT_FLOAT_EQ(100, main_graphics_layer->GetPosition().y());
GraphicsLayer* root_scrolling_layer =
GetDocument().GetLayoutView()->Layer()->GraphicsLayerBacking();
const PropertyTreeState& root_layer_state =
root_scrolling_layer->GetPropertyTreeState();
const PropertyTreeState& sticky_layer_state =
main_graphics_layer->GetPropertyTreeState();
auto transform_from_sticky_to_root =
GeometryMapper::SourceToDestinationProjection(
sticky_layer_state.Transform(), root_layer_state.Transform());
// Irrespective of if the ancestor scroller is composited or not, the sticky
// position element should be at the same location.
auto sticky_position_relative_to_root =
transform_from_sticky_to_root.MapPoint(
FloatPoint(main_graphics_layer->GetOffsetFromTransformNode()));
EXPECT_FLOAT_EQ(8, sticky_position_relative_to_root.X());
EXPECT_FLOAT_EQ(8, sticky_position_relative_to_root.Y());
}
TEST_F(CompositedLayerMappingTest,
......@@ -1565,8 +1592,8 @@ TEST_F(CompositedLayerMappingTest,
UpdateAllLifecyclePhasesForTest();
// 100px down from squashing's main graphics layer.
EXPECT_EQ(FloatPoint(0, 100),
squashed->GraphicsLayerBacking()->GetPosition());
EXPECT_EQ(IntPoint(0, 100),
squashed->GraphicsLayerBacking()->GetOffsetFromTransformNode());
}
TEST_F(CompositedLayerMappingTest, ContentsNotOpaqueWithForegroundLayer) {
......
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