Portals: Implement compositor pixel dumps for layout tests with Portals.
Bug: 865565
Change-Id: I47d687d9299354f15acf44a3960b3e2ad590f4df
Reviewed-on: https://chromium-review.googlesource.com/c/1366782
Reviewed-by: Charlie Reis <[email protected]>
Reviewed-by: Mason Freed <[email protected]>
Commit-Queue: Lucas Gadani <[email protected]>
Cr-Commit-Position: refs/heads/master@{#616689}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 72a0b42..e7aa06b8 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -236,9 +236,8 @@
}
// Helper for GetInnerWebContents().
-bool GetInnerWebContentsHelper(
- std::vector<WebContentsImpl*>* all_guest_contents,
- WebContents* guest_contents) {
+bool GetInnerWebContentsHelper(std::vector<WebContents*>* all_guest_contents,
+ WebContents* guest_contents) {
auto* web_contents_impl = static_cast<WebContentsImpl*>(guest_contents);
if (web_contents_impl->GetBrowserPluginGuest()->attached() &&
!GuestMode::IsCrossProcessFrameGuest(web_contents_impl)) {
@@ -1219,25 +1218,12 @@
return it->second;
}
-std::vector<WebContentsImpl*> WebContentsImpl::GetInnerWebContents() {
- std::vector<WebContentsImpl*> all_inner_contents;
- if (browser_plugin_embedder_) {
- GetBrowserContext()->GetGuestManager()->ForEachGuest(
- this,
- base::BindRepeating(&GetInnerWebContentsHelper, &all_inner_contents));
- }
- const auto& inner_contents = node_.GetInnerWebContents();
- all_inner_contents.insert(all_inner_contents.end(), inner_contents.begin(),
- inner_contents.end());
- return all_inner_contents;
-}
-
std::vector<WebContentsImpl*> WebContentsImpl::GetWebContentsAndAllInner() {
std::vector<WebContentsImpl*> all_contents(1, this);
for (size_t i = 0; i != all_contents.size(); ++i) {
for (auto* inner_contents : all_contents[i]->GetInnerWebContents()) {
- all_contents.push_back(inner_contents);
+ all_contents.push_back(static_cast<WebContentsImpl*>(inner_contents));
}
}
@@ -5433,6 +5419,19 @@
browser_plugin_embedder_.reset();
}
+RenderFrameHostImpl* WebContentsImpl::GetOuterWebContentsFrame() {
+ if (GetOuterDelegateFrameTreeNodeId() ==
+ FrameTreeNode::kFrameTreeNodeInvalidId) {
+ return nullptr;
+ }
+
+ FrameTreeNode* outer_node =
+ FrameTreeNode::GloballyFindByID(GetOuterDelegateFrameTreeNodeId());
+ // The outer node should be in the outer WebContents.
+ DCHECK_EQ(outer_node->frame_tree(), GetOuterWebContents()->GetFrameTree());
+ return outer_node->parent()->current_frame_host();
+}
+
WebContentsImpl* WebContentsImpl::GetOuterWebContents() {
if (GuestMode::IsCrossProcessFrameGuest(this))
return node_.outer_web_contents();
@@ -5443,6 +5442,19 @@
return node_.outer_web_contents();
}
+std::vector<WebContents*> WebContentsImpl::GetInnerWebContents() {
+ std::vector<WebContents*> all_inner_contents;
+ if (browser_plugin_embedder_) {
+ GetBrowserContext()->GetGuestManager()->ForEachGuest(
+ this,
+ base::BindRepeating(&GetInnerWebContentsHelper, &all_inner_contents));
+ }
+ const auto& inner_contents = node_.GetInnerWebContents();
+ all_inner_contents.insert(all_inner_contents.end(), inner_contents.begin(),
+ inner_contents.end());
+ return all_inner_contents;
+}
+
WebContentsImpl* WebContentsImpl::GetFocusedWebContents() {
return GetOutermostWebContents()->node_.focused_web_contents();
}
@@ -6500,13 +6512,14 @@
// Concurrent find sessions must not overlap, so destroy any existing
// FindRequestManagers in any inner WebContentses.
- for (WebContentsImpl* contents : GetWebContentsAndAllInner()) {
- if (contents == this)
+ for (WebContents* contents : GetWebContentsAndAllInner()) {
+ auto* web_contents_impl = static_cast<WebContentsImpl*>(contents);
+ if (web_contents_impl == this)
continue;
- if (contents->find_request_manager_) {
- contents->find_request_manager_->StopFinding(
- content::STOP_FIND_ACTION_CLEAR_SELECTION);
- contents->find_request_manager_.release();
+ if (web_contents_impl->find_request_manager_) {
+ web_contents_impl->find_request_manager_->StopFinding(
+ STOP_FIND_ACTION_CLEAR_SELECTION);
+ web_contents_impl->find_request_manager_.release();
}
}