Commit eab74a79 authored by Fabio Tirelo's avatar Fabio Tirelo

Reland "[PM] Add FrameNode viewport intersection"

This reverts commit 53d410bb.

Reason for revert: There is a CL landed after this that changes a type somewhere, reverting is not that trivial

Original change's description:
> Revert "[PM] Add FrameNode viewport intersection"
>
> This reverts commit cf2a7489.
>
> Reason for revert:
> FrameNodeImplBrowserTest.ViewportIntersection_PartiallyVisible failing on CrOS
>  - example build: https://ci.chromium.org/p/chromium/builders/ci/linux-chromeos-rel/41947
>
> TBR=pmonette@chromium.org
>
> Original change's description:
> > [PM] Add FrameNode viewport intersection
> >
> > This CLs plumbs the viewport intersection to the FrameNode, which
> > will allow the tracking of the visibility of each frame.
> >
> > Bug: 1077217
> > Change-Id: Id2811b1c52e4fa3f3c449d1b32a1cb7084f82116
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2399621
> > Reviewed-by: François Doray <fdoray@chromium.org>
> > Reviewed-by: danakj <danakj@chromium.org>
> > Reviewed-by: Nasko Oskov <nasko@chromium.org>
> > Reviewed-by: David Bokan <bokan@chromium.org>
> > Commit-Queue: Patrick Monette <pmonette@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#816728}
>
> TBR=danakj@chromium.org,nasko@chromium.org,bokan@chromium.org,fdoray@chromium.org,pmonette@chromium.org
>
> Change-Id: I4e1cb014232b82016e14fbd85352a6442323300f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1077217
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2470463
> Commit-Queue: Fabio Tirelo <ftirelo@chromium.org>
> Reviewed-by: Fabio Tirelo <ftirelo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#817024}

TBR=danakj@chromium.org,nasko@chromium.org,fdoray@chromium.org,pmonette@chromium.org,ftirelo@chromium.org

# Not skipping CQ checks because this is a reland.

Bug: 1077217
Change-Id: I3c36272ac57b0857400331196a506069c596d36e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2471259Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Fabio Tirelo <ftirelo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817030}
parent 05dba1f2
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/performance_manager/graph/frame_node_impl.h"
#include "base/run_loop.h"
#include "base/test/bind_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/performance_manager/graph/page_node_impl.h"
#include "components/performance_manager/performance_manager_impl.h"
#include "components/performance_manager/public/graph/page_node.h"
#include "content/public/test/browser_test.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
namespace performance_manager {
namespace {
class FrameNodeImplBrowserTest : public InProcessBrowserTest {
public:
FrameNodeImplBrowserTest() = default;
~FrameNodeImplBrowserTest() override = default;
};
} // namespace
IN_PROC_BROWSER_TEST_F(FrameNodeImplBrowserTest,
ViewportIntersection_OutOfView) {
ASSERT_TRUE(embedded_test_server()->Start());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
const GURL main_frame_url(
embedded_test_server()->GetURL("/iframe_out_of_view.html"));
base::WeakPtr<PageNode> page_node =
PerformanceManager::GetPageNodeForWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
// Navigate.
browser()->OpenURL(content::OpenURLParams(main_frame_url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
ui::PAGE_TRANSITION_TYPED, false));
// Ensure that loading is complete.
content::WaitForLoadStop(
browser()->tab_strip_model()->GetActiveWebContents());
// Verify that the viewport intersection has been set correctly on the graph.
base::RunLoop run_loop;
auto call_on_graph_cb = base::BindLambdaForTesting([&]() {
EXPECT_TRUE(page_node);
auto children = page_node.get()->GetMainFrameNode()->GetChildFrameNodes();
EXPECT_EQ(1U, children.size());
auto* iframe =
performance_manager::FrameNodeImpl::FromNode(*children.begin());
EXPECT_TRUE(iframe->viewport_intersection().IsEmpty());
run_loop.Quit();
});
PerformanceManager::CallOnGraph(FROM_HERE, call_on_graph_cb);
run_loop.Run();
}
IN_PROC_BROWSER_TEST_F(FrameNodeImplBrowserTest, ViewportIntersection_Hidden) {
ASSERT_TRUE(embedded_test_server()->Start());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
const GURL main_frame_url(
embedded_test_server()->GetURL("/iframe_hidden.html"));
base::WeakPtr<PageNode> page_node =
PerformanceManager::GetPageNodeForWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
// Navigate.
browser()->OpenURL(content::OpenURLParams(main_frame_url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
ui::PAGE_TRANSITION_TYPED, false));
// Ensure that loading is complete.
content::WaitForLoadStop(
browser()->tab_strip_model()->GetActiveWebContents());
// Verify that the viewport intersection has been set correctly on the graph.
base::RunLoop run_loop;
auto call_on_graph_cb = base::BindLambdaForTesting([&]() {
EXPECT_TRUE(page_node);
auto children = page_node.get()->GetMainFrameNode()->GetChildFrameNodes();
EXPECT_EQ(1U, children.size());
auto* iframe =
performance_manager::FrameNodeImpl::FromNode(*children.begin());
EXPECT_TRUE(iframe->viewport_intersection().IsEmpty());
run_loop.Quit();
});
PerformanceManager::CallOnGraph(FROM_HERE, call_on_graph_cb);
run_loop.Run();
}
IN_PROC_BROWSER_TEST_F(FrameNodeImplBrowserTest,
ViewportIntersection_PartiallyVisible) {
ASSERT_TRUE(embedded_test_server()->Start());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
const GURL main_frame_url(
embedded_test_server()->GetURL("/iframe_partially_visible.html"));
base::WeakPtr<PageNode> page_node =
PerformanceManager::GetPageNodeForWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
// Navigate.
browser()->OpenURL(content::OpenURLParams(main_frame_url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
ui::PAGE_TRANSITION_TYPED, false));
// Ensure that loading is complete.
content::WaitForLoadStop(
browser()->tab_strip_model()->GetActiveWebContents());
// Verify that the viewport intersection has been set correctly on the graph.
base::RunLoop run_loop;
auto call_on_graph_cb = base::BindLambdaForTesting([&]() {
EXPECT_TRUE(page_node);
auto children = page_node.get()->GetMainFrameNode()->GetChildFrameNodes();
EXPECT_EQ(1U, children.size());
auto* iframe =
performance_manager::FrameNodeImpl::FromNode(*children.begin());
// The frame is a 100x100 px square centered on the origin of the viewport.
// Thus only the bottom right quarter is visible
const gfx::Rect kExpectedViewportIntersection(0, 0, 50, 50);
EXPECT_EQ(iframe->viewport_intersection(), kExpectedViewportIntersection);
run_loop.Quit();
});
PerformanceManager::CallOnGraph(FROM_HERE, call_on_graph_cb);
run_loop.Run();
}
IN_PROC_BROWSER_TEST_F(FrameNodeImplBrowserTest, ViewportIntersection_Scaled) {
ASSERT_TRUE(embedded_test_server()->Start());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
const GURL main_frame_url(
embedded_test_server()->GetURL("/iframe_scaled.html"));
base::WeakPtr<PageNode> page_node =
PerformanceManager::GetPageNodeForWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
// Navigate.
browser()->OpenURL(content::OpenURLParams(main_frame_url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
ui::PAGE_TRANSITION_TYPED, false));
// Ensure that loading is complete.
content::WaitForLoadStop(
browser()->tab_strip_model()->GetActiveWebContents());
// Verify that the viewport intersection has been set correctly on the graph.
base::RunLoop run_loop;
auto call_on_graph_cb = base::BindLambdaForTesting([&]() {
EXPECT_TRUE(page_node);
auto children = page_node.get()->GetMainFrameNode()->GetChildFrameNodes();
EXPECT_EQ(1U, children.size());
auto* iframe =
performance_manager::FrameNodeImpl::FromNode(*children.begin());
// The iframe is a 200x200 px square centered at (200, 200) scaled to 1.5x
// its size from it's center.
// The size should be 50% larger.
EXPECT_EQ(iframe->viewport_intersection().size(), gfx::Size(300, 300));
// Because the resulting square is still centered at (200, 200), its origin
// is (200-width/2, 200-height/2) = (50, 50)
EXPECT_EQ(iframe->viewport_intersection().origin(), gfx::Point(50, 50));
run_loop.Quit();
});
PerformanceManager::CallOnGraph(FROM_HERE, call_on_graph_cb);
run_loop.Run();
}
IN_PROC_BROWSER_TEST_F(FrameNodeImplBrowserTest, ViewportIntersection_Rotated) {
ASSERT_TRUE(embedded_test_server()->Start());
EXPECT_EQ(1, browser()->tab_strip_model()->count());
const GURL main_frame_url(
embedded_test_server()->GetURL("/iframe_rotated.html"));
base::WeakPtr<PageNode> page_node =
PerformanceManager::GetPageNodeForWebContents(
browser()->tab_strip_model()->GetActiveWebContents());
// Navigate.
browser()->OpenURL(content::OpenURLParams(main_frame_url, content::Referrer(),
WindowOpenDisposition::CURRENT_TAB,
ui::PAGE_TRANSITION_TYPED, false));
// Ensure that loading is complete.
content::WaitForLoadStop(
browser()->tab_strip_model()->GetActiveWebContents());
// Verify that the viewport intersection has been set correctly on the graph.
base::RunLoop run_loop;
auto call_on_graph_cb = base::BindLambdaForTesting([&]() {
EXPECT_TRUE(page_node);
auto children = page_node.get()->GetMainFrameNode()->GetChildFrameNodes();
EXPECT_EQ(1U, children.size());
auto* iframe =
performance_manager::FrameNodeImpl::FromNode(*children.begin());
// The iframe is a 100x100 px square centered at (150, 150) rotated by 45
// degree around its center.
// This results in a diamond shape also centered at (150, 150), whose width
// can be calculated with the pythagorean theorem.
const float width = sqrt(100 * 100 + 100 * 100);
const float start = 150 - width / 2;
const gfx::RectF enclosing_rectf(start, start, width, width);
// Thus the expectation for the viewport intersection is to be equal to the
// smallest Rect that encloses the |enclosing_rectf|.
const gfx::Rect expected_viewport_intersection =
ToEnclosingRect(enclosing_rectf);
EXPECT_EQ(iframe->viewport_intersection(), expected_viewport_intersection);
run_loop.Quit();
});
PerformanceManager::CallOnGraph(FROM_HERE, call_on_graph_cb);
run_loop.Run();
}
} // namespace performance_manager
......@@ -105,6 +105,8 @@ class DiscardsGraphDumpImpl : public discards::mojom::GraphDump,
void OnFirstContentfulPaint(
const performance_manager::FrameNode* frame_node,
base::TimeDelta time_since_navigation_start) override {}
void OnViewportIntersectionChanged(
const performance_manager::FrameNode* frame_node) override {}
// PageNodeObserver implementation:
void OnPageNodeAdded(const performance_manager::PageNode* page_node) override;
......
......@@ -1168,6 +1168,7 @@ if (!is_android) {
"../browser/pdf/pdf_extension_test_util.cc",
"../browser/pdf/pdf_extension_test_util.h",
"../browser/performance_manager/background_tab_loading_policy_browsertest.cc",
"../browser/performance_manager/frame_node_impl_browsertest.cc",
"../browser/performance_manager/graph/page_node_impl_browsertest.cc",
"../browser/performance_manager/mechanisms/page_discarder_browsertest.cc",
"../browser/performance_manager/page_load_tracker_decorator_browsertest.cc",
......
<html><head><title>iframe test</title></head>
<body>
<iframe src="title1.html" style="display:none;"></iframe>
</body></html>
<!DOCTYPE html>
<html>
<body>
<style>
body {
width: 100%;
height: 100%;
margin: 0;
}
iframe {
width: 400px;
height: 400px;
/* The size of the margin is bigger than the viewport */
margin: 300%;
border: 0;
padding: 0;
overflow: scroll;
}
</style>
<p> Single &lt;iframe&gt; which is positioned out of view. </p>
<iframe src="title1.html">
</iframe>
<p> Iframe should be positioned way above </p>
</body>
</html>
<!DOCTYPE html>
<html>
<style>
iframe {
position: absolute;
left: -50px;
top: -50px;
width: 100px;
height: 100px;
/* Removing external factor that might affect pixel accuracy */
border: none;
padding: 0;
margin: 0;
}
</style>
<iframe src="title1.html">
</iframe>
</html>
<!DOCTYPE html>
<html>
<style>
iframe {
position: absolute;
left: 100px;
top: 100px;
width: 100px;
height: 100px;
transform: rotate(45deg);
/* Removing external factor that might affect pixel accuracy */
border: none;
padding: 0;
margin: 0;
}
</style>
<iframe src="title1.html">
</iframe>
</html>
<!DOCTYPE html>
<html>
<style>
iframe {
position: absolute;
left: 100px;
top: 100px;
width: 200px;
height: 200px;
transform: scale(1.5);
/* Removing external factor that might affect pixel accuracy */
border: none;
padding: 0;
margin: 0;
}
</style>
<iframe src="title1.html">
</iframe>
</html>
......@@ -14,4 +14,5 @@ include_rules = [
"+third_party/blink/public/mojom/service_worker",
"+third_party/blink/public/mojom/tokens",
"+third_party/leveldatabase",
"+ui/gfx/geometry",
]
......@@ -229,6 +229,13 @@ bool FrameNodeImpl::is_audible() const {
return is_audible_.value();
}
const gfx::Rect& FrameNodeImpl::viewport_intersection() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// The viewport intersection of the main frame is not tracked.
DCHECK(!IsMainFrame());
return viewport_intersection_.value();
}
void FrameNodeImpl::SetIsCurrent(bool is_current) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
is_current_.SetAndMaybeNotify(this, is_current);
......@@ -274,6 +281,14 @@ void FrameNodeImpl::SetIsAudible(bool is_audible) {
is_audible_.SetAndMaybeNotify(this, is_audible);
}
void FrameNodeImpl::SetViewportIntersection(
const gfx::Rect& viewport_intersection) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// The viewport intersection of the main frame is not tracked.
DCHECK(!IsMainFrame());
viewport_intersection_.SetAndMaybeNotify(this, viewport_intersection);
}
void FrameNodeImpl::OnNavigationCommitted(const GURL& url, bool same_document) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......@@ -497,6 +512,11 @@ bool FrameNodeImpl::IsAudible() const {
return is_audible();
}
const gfx::Rect& FrameNodeImpl::GetViewportIntersection() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return viewport_intersection();
}
void FrameNodeImpl::AddChildFrame(FrameNodeImpl* child_frame_node) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(child_frame_node);
......
......@@ -82,6 +82,7 @@ class FrameNodeImpl
void SetNetworkAlmostIdle() override;
void SetLifecycleState(LifecycleState state) override;
void SetHasNonEmptyBeforeUnload(bool has_nonempty_beforeunload) override;
void SetViewportIntersection(const gfx::Rect& viewport_intersection) override;
void SetOriginTrialFreezePolicy(mojom::InterventionPolicy policy) override;
void SetIsAdFrame() override;
void SetHadFormInteraction() override;
......@@ -120,6 +121,7 @@ class FrameNodeImpl
const PriorityAndReason& priority_and_reason() const;
bool had_form_interaction() const;
bool is_audible() const;
const gfx::Rect& viewport_intersection() const;
// Setters are not thread safe.
void SetIsCurrent(bool is_current);
......@@ -190,6 +192,7 @@ class FrameNodeImpl
const PriorityAndReason& GetPriorityAndReason() const override;
bool HadFormInteraction() const override;
bool IsAudible() const override;
const gfx::Rect& GetViewportIntersection() const override;
// Properties associated with a Document, which are reset when a
// different-document navigation is committed in the frame.
......@@ -336,6 +339,17 @@ class FrameNodeImpl
NotifiesOnlyOnChanges<bool, &FrameNodeObserver::OnIsAudibleChanged>
is_audible_{false};
// Tracks the intersection of this frame with the viewport.
//
// Note that the viewport intersection for the main frame is always invalid.
// This is because the main frame always occupies the entirety of the viewport
// so there is no point in tracking it. To avoid programming mistakes, it is
// forbidden to query this property for the main frame.
ObservedProperty::NotifiesOnlyOnChanges<
gfx::Rect,
&FrameNodeObserver::OnViewportIntersectionChanged>
viewport_intersection_;
// Inline storage for ExecutionContext.
std::unique_ptr<NodeAttachedData> execution_context_;
......
......@@ -6,6 +6,7 @@
#include <sstream>
#include <string>
#include <utility>
#include "base/task/task_traits.h"
#include "base/values.h"
......@@ -97,6 +98,8 @@ base::Value FrameNodeImplDescriber::DescribeFrameNodeData(
ret.SetKey("priority",
PriorityAndReasonToValue(impl->priority_and_reason_.value()));
ret.SetBoolKey("is_audible", impl->is_audible_.value());
ret.SetStringKey("viewport_intersection",
impl->viewport_intersection_.value().ToString());
return ret;
}
......
......@@ -150,6 +150,7 @@ class LenientMockObserver : public FrameNodeImpl::Observer {
void(const FrameNode*, const PriorityAndReason& previous_value));
MOCK_METHOD1(OnHadFormInteractionChanged, void(const FrameNode*));
MOCK_METHOD1(OnIsAudibleChanged, void(const FrameNode*));
MOCK_METHOD1(OnViewportIntersectionChanged, void(const FrameNode*));
MOCK_METHOD1(OnNonPersistentNotificationCreated, void(const FrameNode*));
MOCK_METHOD2(OnFirstContentfulPaint, void(const FrameNode*, base::TimeDelta));
......@@ -367,6 +368,27 @@ TEST_F(FrameNodeImplTest, IsAudible) {
graph()->RemoveFrameNodeObserver(&obs);
}
TEST_F(FrameNodeImplTest, ViewportIntersection) {
auto process = CreateNode<ProcessNodeImpl>();
auto page = CreateNode<PageNodeImpl>();
// A child frame node is used because the main frame does not have a viewport
// intersection.
auto main_frame_node = CreateFrameNodeAutoId(process.get(), page.get());
auto child_frame_node =
CreateFrameNodeAutoId(process.get(), page.get(), main_frame_node.get());
MockObserver obs;
graph()->AddFrameNodeObserver(&obs);
EXPECT_CALL(obs, OnViewportIntersectionChanged(child_frame_node.get()));
gfx::Rect kViewportIntersection(25, 25, 100, 100);
child_frame_node->SetViewportIntersection(kViewportIntersection);
EXPECT_EQ(child_frame_node->viewport_intersection(), kViewportIntersection);
graph()->RemoveFrameNodeObserver(&obs);
}
TEST_F(FrameNodeImplTest, FirstContentfulPaint) {
auto process = CreateNode<ProcessNodeImpl>();
auto page = CreateNode<PageNodeImpl>();
......@@ -386,7 +408,10 @@ TEST_F(FrameNodeImplTest, PublicInterface) {
auto process = CreateNode<ProcessNodeImpl>();
auto page = CreateNode<PageNodeImpl>();
auto frame_node = CreateFrameNodeAutoId(process.get(), page.get());
auto child_frame_node =
CreateFrameNodeAutoId(process.get(), page.get(), frame_node.get());
const FrameNode* public_frame_node = frame_node.get();
const FrameNode* public_child_frame_node = child_frame_node.get();
// Simply test that the public interface impls yield the same result as their
// private counterpart.
......@@ -427,6 +452,10 @@ TEST_F(FrameNodeImplTest, PublicInterface) {
public_frame_node->IsHoldingIndexedDBLock());
EXPECT_EQ(frame_node->had_form_interaction(),
public_frame_node->HadFormInteraction());
// Use the child frame node to test the viewport intersection because the
// viewport intersection of the main frame is not tracked.
EXPECT_EQ(child_frame_node->viewport_intersection(),
public_child_frame_node->GetViewportIntersection());
}
TEST_F(FrameNodeImplTest, VisitChildFrameNodes) {
......
......@@ -13,6 +13,7 @@
#include "components/performance_manager/public/mojom/coordination_unit.mojom.h"
#include "components/performance_manager/public/mojom/lifecycle.mojom.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "ui/gfx/geometry/rect.h"
class GURL;
......@@ -173,6 +174,9 @@ class FrameNode : public Node {
// Returns true if the frame is audible, false otherwise.
virtual bool IsAudible() const = 0;
// Returns the intersection of this frame with the viewport.
virtual const gfx::Rect& GetViewportIntersection() const = 0;
// Returns a proxy to the RenderFrameHost associated with this node. The
// proxy may only be dereferenced on the UI thread.
virtual const RenderFrameHostProxy& GetRenderFrameHostProxy() const = 0;
......@@ -240,6 +244,9 @@ class FrameNodeObserver {
// Invoked when the IsAudible property changes.
virtual void OnIsAudibleChanged(const FrameNode* frame_node) = 0;
// Invoked when a frame's intersection with the viewport changes
virtual void OnViewportIntersectionChanged(const FrameNode* frame_node) = 0;
// Events with no property changes.
// Invoked when a non-persistent notification has been issued by the frame.
......@@ -287,6 +294,7 @@ class FrameNode::ObserverDefaultImpl : public FrameNodeObserver {
const PriorityAndReason& previous_value) override {}
void OnHadFormInteractionChanged(const FrameNode* frame_node) override {}
void OnIsAudibleChanged(const FrameNode* frame_node) override {}
void OnViewportIntersectionChanged(const FrameNode* frame_node) override {}
void OnNonPersistentNotificationCreated(
const FrameNode* frame_node) override {}
void OnFirstContentfulPaint(
......
......@@ -15,5 +15,8 @@ mojom_component("mojom") {
"lifecycle.mojom",
]
public_deps = [ "//mojo/public/mojom/base" ]
public_deps = [
"//mojo/public/mojom/base",
"//ui/gfx/geometry/mojom",
]
}
......@@ -7,6 +7,7 @@ module performance_manager.mojom;
import "mojo/public/mojom/base/process_id.mojom";
import "mojo/public/mojom/base/time.mojom";
import "components/performance_manager/public/mojom/lifecycle.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
// Any new type here needs to be mirrored between coordination_unit_types.h and
// coordination_unit.mojom, and have mappings between the two defined in
......@@ -37,6 +38,7 @@ interface DocumentCoordinationUnit {
SetNetworkAlmostIdle();
SetLifecycleState(LifecycleState state);
SetHasNonEmptyBeforeUnload(bool has_nonempty_beforeunload);
// Called the first time a form in this document is interacted with.
SetHadFormInteraction();
......@@ -48,6 +50,11 @@ interface DocumentCoordinationUnit {
SetIsAdFrame();
// Called when the intersection between this frame and the viewport changes.
// The viewport is the rectangular area of the top-level document that is
// visible. This is used to drive the frame prioritization logic.
SetViewportIntersection(gfx.mojom.Rect viewport_intersection);
// Event signals.
// Called when the associated frame has caused a non-persistent notification
......
......@@ -151,6 +151,7 @@
#include "third_party/blink/renderer/platform/graphics/paint/paint_chunk_subset_recorder.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/resource_coordinator/document_resource_coordinator.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h"
#include "third_party/blink/renderer/platform/language.h"
......
......@@ -50,6 +50,11 @@ void DocumentResourceCoordinator::SetHasNonEmptyBeforeUnload(
service_->SetHasNonEmptyBeforeUnload(has_nonempty_beforeunload);
}
void DocumentResourceCoordinator::SetViewportIntersection(
const gfx::Rect& viewport_intersection) {
service_->SetViewportIntersection(viewport_intersection);
}
void DocumentResourceCoordinator::SetOriginTrialFreezePolicy(
InterventionPolicy policy) {
service_->SetOriginTrialFreezePolicy(policy);
......
......@@ -29,6 +29,7 @@ class PLATFORM_EXPORT DocumentResourceCoordinator final {
void SetNetworkAlmostIdle();
void SetLifecycleState(performance_manager::mojom::LifecycleState);
void SetHasNonEmptyBeforeUnload(bool has_nonempty_beforeunload);
void SetViewportIntersection(const gfx::Rect& viewport_intersection);
void SetOriginTrialFreezePolicy(
performance_manager::mojom::InterventionPolicy policy);
// A one way switch that marks a frame as being an adframe.
......
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