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

Side by Side 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: rollback unnecessary test diffs Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 6
7 #import "content/browser/web_contents/web_contents_view_mac.h" 7 #import "content/browser/web_contents/web_contents_view_mac.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 - (void)registerDragTypes; 60 - (void)registerDragTypes;
61 - (void)setCurrentDragOperation:(NSDragOperation)operation; 61 - (void)setCurrentDragOperation:(NSDragOperation)operation;
62 - (DropData*)dropData; 62 - (DropData*)dropData;
63 - (void)startDragWithDropData:(const DropData&)dropData 63 - (void)startDragWithDropData:(const DropData&)dropData
64 dragOperationMask:(NSDragOperation)operationMask 64 dragOperationMask:(NSDragOperation)operationMask
65 image:(NSImage*)image 65 image:(NSImage*)image
66 offset:(NSPoint)offset; 66 offset:(NSPoint)offset;
67 - (void)cancelDeferredClose; 67 - (void)cancelDeferredClose;
68 - (void)clearWebContentsView; 68 - (void)clearWebContentsView;
69 - (void)closeTabAfterEvent; 69 - (void)closeTabAfterEvent;
70 - (void)checkWebContentsShowState;
70 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; 71 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
71 - (content::WebContentsImpl*)webContents; 72 - (content::WebContentsImpl*)webContents;
72 @end 73 @end
73 74
74 namespace content { 75 namespace content {
75 76
76 WebContentsView* CreateWebContentsView( 77 WebContentsView* CreateWebContentsView(
77 WebContentsImpl* web_contents, 78 WebContentsImpl* web_contents,
78 WebContentsViewDelegate* delegate, 79 WebContentsViewDelegate* delegate,
79 RenderViewHostDelegateView** render_view_host_delegate_view) { 80 RenderViewHostDelegateView** render_view_host_delegate_view) {
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 NSSelectionDirection direction = 605 NSSelectionDirection direction =
605 static_cast<NSSelectionDirection>([[[notification userInfo] 606 static_cast<NSSelectionDirection>([[[notification userInfo]
606 objectForKey:kSelectionDirection] unsignedIntegerValue]); 607 objectForKey:kSelectionDirection] unsignedIntegerValue]);
607 if (direction == NSDirectSelection) 608 if (direction == NSDirectSelection)
608 return; 609 return;
609 610
610 [self webContents]-> 611 [self webContents]->
611 FocusThroughTabTraversal(direction == NSSelectingPrevious); 612 FocusThroughTabTraversal(direction == NSSelectingPrevious);
612 } 613 }
613 614
615 - (void)checkWebContentsShowState {
Avi (use Gerrit) 2016/02/26 17:50:23 We're not checking it, we're updating it, and I do
tapted 2016/02/29 06:49:00 Done.
616 WebContentsImpl* webContents = [self webContents];
617 if (!webContents || webContents->IsBeingDestroyed())
618 return;
619
620 const bool viewVisible = [self window] && ![self isHiddenOrHasHiddenAncestor];
621 webContents->UpdateWebContentsVisibility(viewVisible);
622 }
623
614 // When the subviews require a layout, their size should be reset to the size 624 // When the subviews require a layout, their size should be reset to the size
615 // of this view. (It is possible for the size to get out of sync as an 625 // of this view. (It is possible for the size to get out of sync as an
616 // optimization in preparation for an upcoming WebContentsView resize. 626 // optimization in preparation for an upcoming WebContentsView resize.
617 // http://crbug.com/264207) 627 // http://crbug.com/264207)
618 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { 628 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
619 for (NSView* subview in self.subviews) 629 for (NSView* subview in self.subviews)
620 [subview setFrame:self.bounds]; 630 [subview setFrame:self.bounds];
621 } 631 }
622 632
623 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { 633 - (void)viewWillMoveToWindow:(NSWindow*)newWindow {
(...skipping 28 matching lines...) Expand all
652 WebContentsImpl* webContents = [self webContents]; 662 WebContentsImpl* webContents = [self webContents];
653 if (window && webContents && !webContents->IsBeingDestroyed()) { 663 if (window && webContents && !webContents->IsBeingDestroyed()) {
654 if ([window occlusionState] & NSWindowOcclusionStateVisible) { 664 if ([window occlusionState] & NSWindowOcclusionStateVisible) {
655 webContents->WasUnOccluded(); 665 webContents->WasUnOccluded();
656 } else { 666 } else {
657 webContents->WasOccluded(); 667 webContents->WasOccluded();
658 } 668 }
659 } 669 }
660 } 670 }
661 671
672 - (void)viewDidMoveToWindow {
673 [self checkWebContentsShowState];
674 }
675
676 - (void)viewDidHide {
677 [self checkWebContentsShowState];
678 }
679
680 - (void)viewDidUnhide {
681 [self checkWebContentsShowState];
682 }
683
662 @end 684 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698