Commit bd6cf81e authored by Daniel Nicoara's avatar Daniel Nicoara Committed by Commit Bot

cast: webview: Resize only on main RenderFrameHost changes

The underlying EXO surface should only be resized when the main
RenderFrameHost changes. Embedded RHF (eg: iframes) should not cause the
EXO surface to resize.

Bug: b/147835637
Test: On device
Change-Id: I24cab3f2cb99d0b2a3693adc815d445522c1cec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006420Reviewed-by: default avatarAlbert Chaulk <achaulk@chromium.org>
Commit-Queue: Daniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732687}
parent 5555d7ab
...@@ -161,9 +161,9 @@ void WebContentController::AttachTo(aura::Window* window, int window_id) { ...@@ -161,9 +161,9 @@ void WebContentController::AttachTo(aura::Window* window, int window_id) {
surface_->SetEmbeddedSurfaceId(base::BindRepeating( surface_->SetEmbeddedSurfaceId(base::BindRepeating(
&WebContentController::GetSurfaceId, base::Unretained(this))); &WebContentController::GetSurfaceId, base::Unretained(this)));
current_rfh_ = GetWebContents()->GetMainFrame(); content::RenderFrameHost* rfh = GetWebContents()->GetMainFrame();
if (current_rfh_) { if (rfh) {
auto size = current_rfh_->GetFrameSize(); const base::Optional<gfx::Size>& size = rfh->GetFrameSize();
if (size.has_value()) if (size.has_value())
surface_->SetEmbeddedSurfaceSize(*size); surface_->SetEmbeddedSurfaceSize(*size);
} }
...@@ -424,8 +424,11 @@ void WebContentController::OnSurfaceDestroying(exo::Surface* surface) { ...@@ -424,8 +424,11 @@ void WebContentController::OnSurfaceDestroying(exo::Surface* surface) {
void WebContentController::FrameSizeChanged( void WebContentController::FrameSizeChanged(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const gfx::Size& frame_size) { const gfx::Size& frame_size) {
if (render_frame_host == current_rfh_ && surface_) content::RenderFrameHost* rfh = GetWebContents()->GetMainFrame();
if (render_frame_host == rfh && surface_) {
surface_->SetEmbeddedSurfaceSize(frame_size); surface_->SetEmbeddedSurfaceSize(frame_size);
surface_->Commit();
}
} }
void WebContentController::RenderFrameCreated( void WebContentController::RenderFrameCreated(
...@@ -443,8 +446,6 @@ void WebContentController::RenderFrameCreated( ...@@ -443,8 +446,6 @@ void WebContentController::RenderFrameCreated(
void WebContentController::RenderFrameDeleted( void WebContentController::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
current_render_frame_set_.erase(render_frame_host); current_render_frame_set_.erase(render_frame_host);
if (render_frame_host == current_rfh_)
current_rfh_ = nullptr;
} }
void WebContentController::RenderFrameHostChanged( void WebContentController::RenderFrameHostChanged(
...@@ -452,8 +453,8 @@ void WebContentController::RenderFrameHostChanged( ...@@ -452,8 +453,8 @@ void WebContentController::RenderFrameHostChanged(
content::RenderFrameHost* new_host) { content::RenderFrameHost* new_host) {
// The surface ID may have changed, so trigger a new commit to re-issue the // The surface ID may have changed, so trigger a new commit to re-issue the
// draw quad. // draw quad.
current_rfh_ = new_host; content::RenderFrameHost* rfh = GetWebContents()->GetMainFrame();
if (surface_) { if (new_host == rfh && surface_) {
if (new_host) { if (new_host) {
auto size = new_host->GetFrameSize(); auto size = new_host->GetFrameSize();
if (size.has_value()) if (size.has_value())
......
...@@ -127,7 +127,6 @@ class WebContentController ...@@ -127,7 +127,6 @@ class WebContentController
std::deque<TouchData> touch_queue_; std::deque<TouchData> touch_queue_;
exo::Surface* surface_ = nullptr; exo::Surface* surface_ = nullptr;
content::RenderFrameHost* current_rfh_ = nullptr;
std::set<std::string> current_javascript_channel_set_; std::set<std::string> current_javascript_channel_set_;
std::set<content::RenderFrameHost*> current_render_frame_set_; std::set<content::RenderFrameHost*> current_render_frame_set_;
......
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