Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: content/browser/web_contents/web_contents_view_mac.mm

Issue 1733173002: Mac: Make calling WebContents::WasShown/WasHidden the responsibility of the content layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_view_mac.mm
diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm
index 18e223817d3a149895aa0aec82cf47f6963d62ae..e569f0180976be0f65ea0738f6194f1c0d37e293 100644
--- a/content/browser/web_contents/web_contents_view_mac.mm
+++ b/content/browser/web_contents/web_contents_view_mac.mm
@@ -67,6 +67,7 @@ STATIC_ASSERT_ENUM(NSDragOperationEvery, blink::WebDragOperationEvery);
- (void)cancelDeferredClose;
- (void)clearWebContentsView;
- (void)closeTabAfterEvent;
+- (void)updateWebContentsVisibility;
- (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
- (content::WebContentsImpl*)webContents;
@end
@@ -611,6 +612,15 @@ void WebContentsViewMac::CloseTab() {
FocusThroughTabTraversal(direction == NSSelectingPrevious);
}
+- (void)updateWebContentsVisibility {
+ WebContentsImpl* webContents = [self webContents];
+ if (!webContents || webContents->IsBeingDestroyed())
+ return;
+
+ const bool viewVisible = [self window] && ![self isHiddenOrHasHiddenAncestor];
+ webContents->UpdateWebContentsVisibility(viewVisible);
+}
+
// When the subviews require a layout, their size should be reset to the size
// of this view. (It is possible for the size to get out of sync as an
// optimization in preparation for an upcoming WebContentsView resize.
@@ -659,4 +669,16 @@ void WebContentsViewMac::CloseTab() {
}
}
+- (void)viewDidMoveToWindow {
+ [self updateWebContentsVisibility];
+}
+
+- (void)viewDidHide {
+ [self updateWebContentsVisibility];
+}
+
+- (void)viewDidUnhide {
+ [self updateWebContentsVisibility];
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698