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

Side by Side Diff: content/browser/web_contents/web_contents_view_mac.mm

Issue 670653005: Fix Flash fullscreen focus regressions, and add interactive_ui_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dedupe code in WebContentsViewMac. Created 6 years, 1 month 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
« no previous file with comments | « content/browser/web_contents/web_contents_view_mac.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 offset:offset]; 151 offset:offset];
152 } 152 }
153 153
154 void WebContentsViewMac::SizeContents(const gfx::Size& size) { 154 void WebContentsViewMac::SizeContents(const gfx::Size& size) {
155 // TODO(brettw | japhet) This is a hack and should be removed. 155 // TODO(brettw | japhet) This is a hack and should be removed.
156 // See web_contents_view.h. 156 // See web_contents_view.h.
157 // Note(erikchen): This method has /never/ worked correctly. I've removed the 157 // Note(erikchen): This method has /never/ worked correctly. I've removed the
158 // previous implementation. 158 // previous implementation.
159 } 159 }
160 160
161 gfx::NativeView WebContentsViewMac::GetNativeViewForFocus() const {
162 RenderWidgetHostView* rwhv =
163 web_contents_->GetFullscreenRenderWidgetHostView();
164 if (!rwhv)
165 rwhv = web_contents_->GetRenderWidgetHostView();
166 return rwhv ? rwhv->GetNativeView() : nil;
167 }
168
161 void WebContentsViewMac::Focus() { 169 void WebContentsViewMac::Focus() {
162 NSWindow* window = [cocoa_view_.get() window]; 170 const gfx::NativeView native_view = GetNativeViewForFocus();
163 [window makeFirstResponder:GetContentNativeView()]; 171 NSWindow* const window = [native_view window];
Avi (use Gerrit) 2014/10/24 23:04:05 Why add |const| here?
miu 2014/10/25 00:04:32 It's a declaration that the pointer will not be ch
172 [window makeFirstResponder:native_view];
164 if (![window isVisible]) 173 if (![window isVisible])
165 return; 174 return;
166 [window makeKeyAndOrderFront:nil]; 175 [window makeKeyAndOrderFront:nil];
167 } 176 }
168 177
169 void WebContentsViewMac::SetInitialFocus() { 178 void WebContentsViewMac::SetInitialFocus() {
170 if (web_contents_->FocusLocationBarByDefault()) 179 if (web_contents_->FocusLocationBarByDefault())
171 web_contents_->SetFocusToLocationBar(false); 180 web_contents_->SetFocusToLocationBar(false);
172 else 181 else
173 [[cocoa_view_.get() window] makeFirstResponder:GetContentNativeView()]; 182 Focus();
174 } 183 }
175 184
176 void WebContentsViewMac::StoreFocus() { 185 void WebContentsViewMac::StoreFocus() {
186 const gfx::NativeView native_view = GetNativeViewForFocus();
Avi (use Gerrit) 2014/10/24 23:04:05 Again, why const here and below? It's very unusual
miu 2014/10/25 00:04:32 Generally speaking, using const helps the compiler
177 // We're explicitly being asked to store focus, so don't worry if there's 187 // We're explicitly being asked to store focus, so don't worry if there's
178 // already a view saved. 188 // already a view saved.
179 focus_tracker_.reset( 189 focus_tracker_.reset(
180 [[FocusTracker alloc] initWithWindow:[cocoa_view_ window]]); 190 [[FocusTracker alloc] initWithWindow:[native_view window]]);
181 } 191 }
182 192
183 void WebContentsViewMac::RestoreFocus() { 193 void WebContentsViewMac::RestoreFocus() {
194 const gfx::NativeView native_view = GetNativeViewForFocus();
184 // TODO(avi): Could we be restoring a view that's no longer in the key view 195 // TODO(avi): Could we be restoring a view that's no longer in the key view
185 // chain? 196 // chain?
186 if (!(focus_tracker_.get() && 197 if (!(focus_tracker_.get() &&
187 [focus_tracker_ restoreFocusInWindow:[cocoa_view_ window]])) { 198 [focus_tracker_ restoreFocusInWindow:[native_view window]])) {
188 // Fall back to the default focus behavior if we could not restore focus. 199 // Fall back to the default focus behavior if we could not restore focus.
189 // TODO(shess): If location-bar gets focus by default, this will 200 // TODO(shess): If location-bar gets focus by default, this will
190 // select-all in the field. If there was a specific selection in 201 // select-all in the field. If there was a specific selection in
191 // the field when we navigated away from it, we should restore 202 // the field when we navigated away from it, we should restore
192 // that selection. 203 // that selection.
193 SetInitialFocus(); 204 SetInitialFocus();
194 } 205 }
195 206
196 focus_tracker_.reset(nil); 207 focus_tracker_.reset(nil);
197 } 208 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // When the subviews require a layout, their size should be reset to the size 588 // When the subviews require a layout, their size should be reset to the size
578 // of this view. (It is possible for the size to get out of sync as an 589 // of this view. (It is possible for the size to get out of sync as an
579 // optimization in preparation for an upcoming WebContentsView resize. 590 // optimization in preparation for an upcoming WebContentsView resize.
580 // http://crbug.com/264207) 591 // http://crbug.com/264207)
581 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { 592 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
582 for (NSView* subview in self.subviews) 593 for (NSView* subview in self.subviews)
583 [subview setFrame:self.bounds]; 594 [subview setFrame:self.bounds];
584 } 595 }
585 596
586 @end 597 @end
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_mac.h ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698