Index: content/renderer/render_frame_impl.cc |
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
index b1449a97bbdd2abb3cd28cce5e0944e47069991b..54b7be0d2525450f4ede5293adbad5186cffa3c6 100644 |
--- a/content/renderer/render_frame_impl.cc |
+++ b/content/renderer/render_frame_impl.cc |
@@ -894,9 +894,6 @@ RenderFrameImpl* RenderFrameImpl::CreateMainFrame( |
render_view->webview()->setMainFrame(web_frame); |
render_frame->render_widget_ = RenderWidget::CreateForFrame( |
widget_routing_id, hidden, screen_info, compositor_deps, web_frame); |
- // TODO(kenrb): Observing shouldn't be necessary when we sort out |
- // WasShown and WasHidden, separating page-level visibility from |
- // frame-level visibility. |
// TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) |
<< "Main frame is no longer reusing the RenderView as its widget! " |
@@ -973,12 +970,8 @@ void RenderFrameImpl::CreateFrame( |
// TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so |
// avoid double-registering the frame as an observer. |
// https://crbug.com/545684 |
- if (web_frame->parent()) { |
- // TODO(kenrb): Observing shouldn't be necessary when we sort out |
- // WasShown and WasHidden, separating page-level visibility from |
- // frame-level visibility. |
Charlie Reis
2016/06/06 23:15:09
Did this turn out to be wrong? I see the Register
lfg
2016/06/08 20:00:24
Yes, RegisterRenderFrame() is used for many things
Charlie Reis
2016/06/08 21:39:07
Acknowledged.
|
+ if (web_frame->parent()) |
render_frame->render_widget_->RegisterRenderFrame(render_frame); |
- } |
} |
render_frame->Initialize(); |
@@ -1625,7 +1618,6 @@ void RenderFrameImpl::OnSwapOut( |
// Let WebKit know that this view is hidden so it can drop resources and |
// stop compositing. |
- // TODO(creis): Support this for subframes as well. |
if (is_main_frame_) { |
render_view_->webview()->setVisibilityState( |
blink::WebPageVisibilityStateHidden, false); |
@@ -3898,7 +3890,7 @@ void RenderFrameImpl::willSendRequest( |
int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; |
RequestExtraData* extra_data = new RequestExtraData(); |
- extra_data->set_visibility_state(render_view_->visibilityState()); |
+ extra_data->set_visibility_state(visibilityState()); |
extra_data->set_custom_user_agent(custom_user_agent); |
extra_data->set_requested_with(requested_with); |
extra_data->set_render_frame_id(routing_id_); |
@@ -4373,27 +4365,25 @@ void RenderFrameImpl::WasHidden() { |
for (auto* plugin : active_pepper_instances_) |
plugin->PageVisibilityChanged(false); |
#endif // ENABLE_PLUGINS |
+ |
+ if (GetWebFrame()->frameWidget()) { |
+ static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) |
+ ->setVisibilityState(visibilityState()); |
+ } |
} |
void RenderFrameImpl::WasShown() { |
- // TODO(kenrb): Need to figure out how to do this better. Should |
- // VisibilityState remain a page-level concept or move to frames? |
- // The semantics of 'Show' might have to change here. |
- // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
- DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) |
- << "The main render frame is no longer reusing the RenderView as its " |
- << "RenderWidget!"; |
- if (render_widget_ && render_widget_->webwidget() && |
- render_view_.get() != render_widget_.get()) { |
- static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> |
- setVisibilityState(blink::WebPageVisibilityStateVisible, false); |
- } |
FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
#if defined(ENABLE_PLUGINS) |
for (auto* plugin : active_pepper_instances_) |
plugin->PageVisibilityChanged(true); |
#endif // ENABLE_PLUGINS |
+ |
+ if (GetWebFrame()->frameWidget()) { |
+ static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) |
+ ->setVisibilityState(visibilityState()); |
+ } |
} |
void RenderFrameImpl::WidgetWillClose() { |
@@ -6090,6 +6080,24 @@ blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { |
return &blink_service_registry_; |
} |
+blink::WebPageVisibilityState RenderFrameImpl::visibilityState() const { |
+ RenderFrameImpl* local_root = |
+ RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
+ blink::WebPageVisibilityState current_state = |
+ local_root->render_widget_->is_hidden() |
+ ? blink::WebPageVisibilityStateHidden |
+ : blink::WebPageVisibilityStateVisible; |
+ blink::WebPageVisibilityState override_state = current_state; |
+ if (GetContentClient()->renderer()->ShouldOverridePageVisibilityState( |
+ this, &override_state)) |
+ return override_state; |
+ return current_state; |
+} |
+ |
+blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { |
+ return visibilityState(); |
+} |
+ |
blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
if (!is_main_frame_) |
return nullptr; |