Commit 36589a21 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[IOv2] Add support for GeometryMapper-based rect computation.

This is behind a new runtime-enabled flag called
IntersectionObserverGeometryMapper.

Bug:831762

Change-Id: I022e988d3abee45e767c04487e8e9662bfc109f2
Reviewed-on: https://chromium-review.googlesource.com/1055783
Commit-Queue: Stefan Zager <szager@chromium.org>
Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558143}
parent a5732c8e
......@@ -84,8 +84,12 @@ void RemoteFrameView::UpdateViewportIntersectionsForSubtree(
LayoutRect rect(0, 0, frame_rect_.Width(), frame_rect_.Height());
rect.Move(remote_frame_->OwnerLayoutObject()->ContentBoxOffset());
IntRect viewport_intersection;
VisualRectFlags flags =
RuntimeEnabledFeatures::IntersectionObserverGeometryMapperEnabled()
? kUseGeometryMapper
: kDefaultVisualRectFlags;
if (remote_frame_->OwnerLayoutObject()->MapToVisualRectInAncestorSpace(
nullptr, rect)) {
nullptr, rect, flags)) {
IntRect root_visible_rect = local_root_view->VisibleContentRect();
IntRect intersected_rect = EnclosingIntRect(rect);
intersected_rect.Intersect(root_visible_rect);
......
......@@ -55,9 +55,18 @@ class TestIntersectionObserverDelegate : public IntersectionObserverDelegate {
} // namespace
class IntersectionObserverTest : public SimTest {};
class IntersectionObserverTest
: public testing::WithParamInterface<bool>,
public SimTest,
ScopedIntersectionObserverGeometryMapperForTest {
public:
IntersectionObserverTest()
: ScopedIntersectionObserverGeometryMapperForTest(GetParam()) {}
};
INSTANTIATE_TEST_CASE_P(All, IntersectionObserverTest, testing::Bool());
TEST_F(IntersectionObserverTest, ObserveSchedulesFrame) {
TEST_P(IntersectionObserverTest, ObserveSchedulesFrame) {
SimRequest main_resource("https://example.com/", "text/html");
LoadURL("https://example.com/");
main_resource.Complete("<div id='target'></div>");
......@@ -81,7 +90,7 @@ TEST_F(IntersectionObserverTest, ObserveSchedulesFrame) {
EXPECT_TRUE(Compositor().NeedsBeginFrame());
}
TEST_F(IntersectionObserverTest, ResumePostsTask) {
TEST_P(IntersectionObserverTest, ResumePostsTask) {
WebView().Resize(WebSize(800, 600));
SimRequest main_resource("https://example.com/", "text/html");
LoadURL("https://example.com/");
......@@ -141,7 +150,7 @@ TEST_F(IntersectionObserverTest, ResumePostsTask) {
EXPECT_EQ(observer_delegate->CallCount(), 3);
}
TEST_F(IntersectionObserverTest, DisconnectClearsNotifications) {
TEST_P(IntersectionObserverTest, DisconnectClearsNotifications) {
WebView().Resize(WebSize(800, 600));
SimRequest main_resource("https://example.com/", "text/html");
LoadURL("https://example.com/");
......@@ -177,7 +186,7 @@ TEST_F(IntersectionObserverTest, DisconnectClearsNotifications) {
EXPECT_EQ(observer_delegate->CallCount(), 1);
}
TEST_F(IntersectionObserverTest, RootIntersectionWithForceZeroLayoutHeight) {
TEST_P(IntersectionObserverTest, RootIntersectionWithForceZeroLayoutHeight) {
WebView().GetSettings()->SetForceZeroLayoutHeight(true);
WebView().Resize(WebSize(800, 600));
SimRequest main_resource("https://example.com/", "text/html");
......@@ -235,7 +244,7 @@ TEST_F(IntersectionObserverTest, RootIntersectionWithForceZeroLayoutHeight) {
EXPECT_TRUE(observer_delegate->LastIntersectionRect().IsEmpty());
}
TEST_F(IntersectionObserverTest, TrackVisibilityInit) {
TEST_P(IntersectionObserverTest, TrackVisibilityInit) {
ScopedIntersectionObserverV2ForTest iov2_enabled(true);
IntersectionObserverInit observer_init;
DummyExceptionStateForTesting exception_state;
......
......@@ -116,7 +116,11 @@ void IntersectionGeometry::InitializeRootRect() {
if (root_->IsLayoutView() &&
!RuntimeEnabledFeatures::RootLayerScrollingEnabled()) {
root_rect_ = LayoutRect(root_->GetFrameView()->VisibleContentRect());
root_->MapToVisualRectInAncestorSpace(nullptr, root_rect_);
root_->MapToVisualRectInAncestorSpace(
nullptr, root_rect_,
RuntimeEnabledFeatures::IntersectionObserverGeometryMapperEnabled()
? kUseGeometryMapper
: kDefaultVisualRectFlags);
} else if (root_->IsLayoutView() && root_->GetDocument().IsInMainFrame()) {
// The main frame is a bit special (even after RLS) as the scrolling
// viewport can differ in size from the LayoutView itself. There's two
......@@ -160,8 +164,12 @@ void IntersectionGeometry::ClipToRoot() {
LayoutBox* local_ancestor = nullptr;
if (!RootIsImplicit() || root_->GetDocument().IsInMainFrame())
local_ancestor = ToLayoutBox(root_);
VisualRectFlags flags = static_cast<VisualRectFlags>(
RuntimeEnabledFeatures::IntersectionObserverGeometryMapperEnabled()
? (kUseGeometryMapper | kEdgeInclusive)
: kEdgeInclusive);
does_intersect_ = target_->MapToVisualRectInAncestorSpace(
local_ancestor, intersection_rect_, kEdgeInclusive);
local_ancestor, intersection_rect_, flags);
if (!does_intersect_ || !local_ancestor)
return;
if (local_ancestor->HasOverflowClip())
......
......@@ -615,6 +615,9 @@
origin_trial_feature_name: "InstalledApp",
status: "experimental",
},
{
name: "IntersectionObserverGeometryMapper",
},
{
name: "IntersectionObserverV2",
},
......
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