Introduce FrameTree::CollectNodesForIsLoading and LoadingTree
We introduce FrameTree::CollectNodesForIsLoading, to output the range
to iterate over all FrameTreeNodes in this frame tree and any
FrameTreeNodes of inner frame trees but doesn't include inner frame
trees of inner delegates. This is helpful in quickly traversing nodes
and inner tree nodes to find the effective value. In a follow-up CL,
we will use it to find the FrameTree::IsLoading
value (crrev.com/c/3228366) directly.
We also introduce the delegate method on
FrameTree::Delegate::LoadingTree to return the delegate's primary
frame tree for primary and fenced frame tree and return same frame tree
for prerender frame tree for easier access and to check if two
different nodes belong to the same loading tree.
BUG=1285294
Change-Id: I3d387580fc630baffe529cfdbf582a794d33e986
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3378602
Reviewed-by: Kevin McNee <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Reviewed-by: Alexander Timin <[email protected]>
Commit-Queue: Sreeja Kamishetty <[email protected]>
Cr-Commit-Position: refs/heads/main@{#970579}
diff --git a/content/browser/renderer_host/frame_tree.h b/content/browser/renderer_host/frame_tree.h
index bb5e12f..6269806 100644
--- a/content/browser/renderer_host/frame_tree.h
+++ b/content/browser/renderer_host/frame_tree.h
@@ -140,6 +140,16 @@
// The load progress was changed.
virtual void DidChangeLoadProgress() = 0;
+ // Returns the delegate's top loading tree, which should be used to infer
+ // the values of loading-related states. The state of IsLoading() is a
+ // WebContents level concept and LoadingTree would return the frame tree to
+ // which loading events should be directed.
+ //
+ // TODO(crbug.com/1261928): Remove this method and directly rely on
+ // GetOutermostMainFrame() once portals and guest views are migrated to
+ // MPArch.
+ virtual FrameTree* LoadingTree() = 0;
+
// Returns true when the active RenderWidgetHostView should be hidden.
virtual bool IsHidden() = 0;
@@ -449,6 +459,14 @@
bool IsHidden() const { return delegate_->IsHidden(); }
+ // LoadingTree returns the following for different frame trees to direct
+ // loading related events. Please see FrameTree::Delegate::LoadingTree for
+ // more comments.
+ // - For prerender frame tree -> returns the frame tree itself.
+ // - For fenced frame and primary frame tree (including portal) -> returns
+ // the delegate's primary frame tree.
+ FrameTree* LoadingTree();
+
// Stops all ongoing navigations in each of the nodes of this FrameTree.
void StopLoading();
@@ -468,12 +486,24 @@
private:
friend class FrameTreeTest;
FRIEND_TEST_ALL_PREFIXES(RenderFrameHostImplBrowserTest, RemoveFocusedFrame);
+ FRIEND_TEST_ALL_PREFIXES(PortalBrowserTest, NodesForIsLoading);
+ FRIEND_TEST_ALL_PREFIXES(FencedFrameBrowserTest, NodesForIsLoading);
// Returns a range to iterate over all FrameTreeNodes in the frame tree in
// breadth-first traversal order, skipping the subtree rooted at
// |node|, but including |node| itself.
NodeRange NodesExceptSubtree(FrameTreeNode* node);
+ // Returns all FrameTreeNodes in this frame tree, as well as any
+ // FrameTreeNodes of inner frame trees. Note that this doesn't include inner
+ // frame trees of inner delegates. This is used to find the aggregate
+ // IsLoading value for a frame tree.
+ //
+ // TODO(crbug.com/1261928, crbug.com/1261928): Remove this method and directly
+ // rely on GetOutermostMainFrame() and NodesIncludingInnerTreeNodes() once
+ // portals and guest views are migrated to MPArch.
+ std::vector<FrameTreeNode*> CollectNodesForIsLoading();
+
const raw_ptr<Delegate> delegate_;
// These delegates are installed into all the RenderViewHosts and