Make gfx::NativeView and gfx::NativeWindow not be NSView and NSWindow
It is no longer the case that a gfx::NativeView/Window refers to an NSView/Window in the same process. Because of RemoteMacViews, they may refer to an NSView/Window that is in another process. Make gfx::NativeView/Window be a pass-by-value struct, and make converting from a gfx::NativeView/Window to an NSView/Window require an explicit conversion function. Mechanically add this conversion as needed. Also define a gfx::kNullNativeView/Window to match other types. Allow some temporary sloppiness to keep the patch size manageable: - Provide a non-explicit constructor that takes a NSView/Window. This will be removed in a follow-on patch (which will mechanically add constructors). - Provide a bool-cast operator to allow if-statements to still compile. These statements can later be changed to comparison with the gfx::kNullNativeView/Window. R=avi, ellyjones TBR=jochen (OWNER of remaining files) Bug: 893719 Change-Id: I39ccac1fd117fe0660fcc21bcb276c8d90dbe550 Reviewed-on: https://chromium-review.googlesource.com/c/1270343 Commit-Queue: ccameron <ccameron@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org> Cr-Commit-Position: refs/heads/master@{#600685}
This commit is contained in:

committed by
Commit Bot

parent
5c3eb58e66
commit
359c61e2a6
chrome
browser
app_controller_mac.mmapp_controller_mac_browsertest.mmglobal_keyboard_shortcuts_mac_browsertest.mmnative_window_notification_source.hplatform_util_mac.mmweb_contents_sizer.mm
download
extensions
api
bookmarks
printing
renderer_host
chrome_render_widget_host_view_mac_delegate.mmchrome_render_widget_host_view_mac_history_swiper_browsertest.mm
pepper
spellchecker
ui
autofill
cocoa
applescript
apps
browser_window_mac_browsertest.mmfullscreen
media_picker
native_window_tracker_cocoa.mmpermission_bubble
renderer_context_menu
share_menu_controller.mmshare_menu_controller_browsertest.mmsingle_web_contents_dialog_manager_cocoa.mmtab_contents
touchbar
web_contents_modal_dialog_host_cocoa.mmtabs
test
views
apps
certificate_viewer_mac_browsertest.mmcertificate_viewer_mac_views.mmframe
permission_bubble
policy
status_bubble_views_browsertest_mac.mmtoolbar
window_sizer
test
components
constrained_window
web_modal
content
browser
media
renderer_host
web_contents
public
shell
extensions/shell/browser
headless/lib/browser
printing
ui
accessibility
platform
base
display
gfx
shell_dialogs
snapshot
views
BUILD.gnevent_monitor_mac.mm
accessibility
bubble
cocoa
bridged_native_widget_host_impl.hbridged_native_widget_host_impl.mmbridged_native_widget_interactive_uitest.mmbridged_native_widget_unittest.mmdrag_drop_client_mac_unittest.mm
controls
menu
menu_closure_animation_mac.mmmenu_host.ccmenu_pre_target_handler_mac.mmmenu_runner_cocoa_unittest.mmmenu_runner_impl_cocoa.mmmenu_runner_unittest.cc
native
tabbed_pane
views_text_services_context_menu_mac.mmfocus
test
view_unittest_mac.mmwidget
views_bridge_mac
@ -635,12 +635,11 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||
// happened during a space change. Now that the change has
|
||||
// completed, raise browser windows.
|
||||
reopenTime_ = base::TimeTicks();
|
||||
std::set<NSWindow*> browserWindows;
|
||||
std::set<gfx::NativeWindow> browserWindows;
|
||||
for (auto* browser : *BrowserList::GetInstance())
|
||||
browserWindows.insert(browser->window()->GetNativeWindow());
|
||||
if (!browserWindows.empty()) {
|
||||
if (!browserWindows.empty())
|
||||
ui::FocusWindowSetOnCurrentSpace(browserWindows);
|
||||
}
|
||||
}
|
||||
|
||||
// Called when shutting down or logging out.
|
||||
@ -925,9 +924,8 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||
return YES;
|
||||
|
||||
Browser* browser = chrome::GetLastActiveBrowser();
|
||||
return browser &&
|
||||
[[browser->window()->GetNativeWindow() attachedSheet]
|
||||
isKindOfClass:[NSWindow class]];
|
||||
return browser && [[browser->window()->GetNativeWindow().GetNativeNSWindow()
|
||||
attachedSheet] isKindOfClass:[NSWindow class]];
|
||||
}
|
||||
|
||||
// Called to validate menu items when there are no key windows. All the
|
||||
@ -1175,7 +1173,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||
// If there are any, return here. Otherwise, the windows are panels or
|
||||
// notifications so we still need to open a new window.
|
||||
if (hasVisibleWindows) {
|
||||
std::set<NSWindow*> browserWindows;
|
||||
std::set<gfx::NativeWindow> browserWindows;
|
||||
for (auto* browser : *BrowserList::GetInstance()) {
|
||||
// When focusing Chrome, don't focus any browser windows associated with
|
||||
// a currently running app shim, so ignore them.
|
||||
|
@ -224,8 +224,10 @@ IN_PROC_BROWSER_TEST_F(AppControllerPlatformAppBrowserTest,
|
||||
NSWindow* app_window = extensions::AppWindowRegistry::Get(profile())
|
||||
->GetAppWindowsForApp(app->id())
|
||||
.front()
|
||||
->GetNativeWindow();
|
||||
NSWindow* browser_window = browser()->window()->GetNativeWindow();
|
||||
->GetNativeWindow()
|
||||
.GetNativeNSWindow();
|
||||
NSWindow* browser_window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
chrome::testing::NSRunLoopRunAllPending();
|
||||
EXPECT_LE([[NSApp orderedWindows] indexOfObject:app_window],
|
||||
|
@ -56,8 +56,9 @@ DownloadFilePicker::DownloadFilePicker(DownloadItem* item,
|
||||
file_type_info.include_all_files = true;
|
||||
file_type_info.allowed_paths =
|
||||
ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH;
|
||||
gfx::NativeWindow owning_window = web_contents ?
|
||||
platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL;
|
||||
gfx::NativeWindow owning_window =
|
||||
web_contents ? platform_util::GetTopLevel(web_contents->GetNativeView())
|
||||
: gfx::kNullNativeWindow;
|
||||
|
||||
select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE,
|
||||
base::string16(),
|
||||
|
@ -36,8 +36,9 @@ id<NSDraggingSource> GetDraggingSource() {
|
||||
|
||||
void DragDownloadItem(const download::DownloadItem* download,
|
||||
gfx::Image* icon,
|
||||
gfx::NativeView view) {
|
||||
gfx::NativeView native_view) {
|
||||
DCHECK_EQ(download::DownloadItem::COMPLETE, download->GetState());
|
||||
NSView* view = native_view.GetNativeNSView();
|
||||
NSPoint current_position = [[view window] mouseLocationOutsideOfEventStream];
|
||||
current_position =
|
||||
[view backingAlignedRect:NSMakeRect(current_position.x,
|
||||
|
@ -741,9 +741,9 @@ void BookmarksIOFunction::ShowSelectFileDialog(
|
||||
ui::SelectFileDialog::FileTypeInfo file_type_info;
|
||||
file_type_info.extensions.resize(1);
|
||||
file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html"));
|
||||
gfx::NativeWindow owning_window = web_contents ?
|
||||
platform_util::GetTopLevel(web_contents->GetNativeView())
|
||||
: NULL;
|
||||
gfx::NativeWindow owning_window =
|
||||
web_contents ? platform_util::GetTopLevel(web_contents->GetNativeView())
|
||||
: gfx::kNullNativeWindow;
|
||||
// |web_contents| can be NULL (for background pages), which is fine. In such
|
||||
// a case if file-selection dialogs are forbidden by policy, we will not
|
||||
// show an InfoBar, which is better than letting one appear out of the blue.
|
||||
|
@ -56,7 +56,8 @@ void SendEvent(NSEvent* ns_event) {
|
||||
#define MAYBE_SwitchTabsMac
|
||||
#endif
|
||||
IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, SwitchTabsMac) {
|
||||
NSWindow* ns_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* ns_window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
TabStripModel* tab_strip = browser()->tab_strip_model();
|
||||
|
||||
// Set up window with 2 tabs.
|
||||
@ -89,7 +90,8 @@ IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, SwitchTabsMac) {
|
||||
// Test that cmd + left arrow can be used for history navigation.
|
||||
IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, HistoryNavigation) {
|
||||
TabStripModel* tab_strip = browser()->tab_strip_model();
|
||||
NSWindow* ns_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* ns_window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
GURL test_url = ui_test_utils::GetTestUrl(
|
||||
base::FilePath(), base::FilePath(FILE_PATH_LITERAL("title1.html")));
|
||||
@ -125,7 +127,8 @@ IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, CopyPasteOmnibox) {
|
||||
OmniboxView* omnibox_view = location_bar->GetOmniboxView();
|
||||
ASSERT_TRUE(omnibox_view);
|
||||
|
||||
NSWindow* ns_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* ns_window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
// Cmd+L focuses the omnibox and selects all the text.
|
||||
SendEvent(SynthesizeKeyEvent(ns_window, /*keydown=*/true, ui::VKEY_L,
|
||||
@ -167,7 +170,8 @@ IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, CopyPasteOmnibox) {
|
||||
|
||||
// Tests that the shortcut to reopen a previous tab works.
|
||||
IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, ReopenPreviousTab) {
|
||||
NSWindow* ns_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* ns_window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
TabStripModel* tab_strip = browser()->tab_strip_model();
|
||||
|
||||
// Set up window with 2 tabs.
|
||||
@ -206,7 +210,8 @@ IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, ReopenPreviousTab) {
|
||||
// Checks that manually configured hotkeys in the main menu have higher priority
|
||||
// than unconfigurable hotkeys not present in the main menu.
|
||||
IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, MenuCommandPriority) {
|
||||
NSWindow* ns_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* ns_window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
TabStripModel* tab_strip = browser()->tab_strip_model();
|
||||
|
||||
// Set up window with 4 tabs.
|
||||
|
@ -5,9 +5,12 @@
|
||||
#ifndef CHROME_BROWSER_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_
|
||||
#define CHROME_BROWSER_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/browser/notification_source.h"
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
|
||||
namespace content {
|
||||
|
||||
// Specialization of the Source class for native windows. On Windows, these are
|
||||
@ -28,6 +31,8 @@ class Source<gfx::NativeWindow> : public content::NotificationSource {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace content
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CHROME_BROWSER_NATIVE_WINDOW_NOTIFICATION_SOURCE_H_
|
||||
|
@ -84,44 +84,50 @@ void OpenExternal(Profile* profile, const GURL& url) {
|
||||
}
|
||||
|
||||
gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
|
||||
return [view window];
|
||||
return gfx::NativeWindow([view.GetNativeNSView() window]);
|
||||
}
|
||||
|
||||
gfx::NativeView GetViewForWindow(gfx::NativeWindow window) {
|
||||
gfx::NativeView GetViewForWindow(gfx::NativeWindow native_window) {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
DCHECK(window);
|
||||
DCHECK([window contentView]);
|
||||
return [window contentView];
|
||||
return gfx::NativeView([window contentView]);
|
||||
}
|
||||
|
||||
gfx::NativeView GetParent(gfx::NativeView view) {
|
||||
return nil;
|
||||
return gfx::NativeView(nil);
|
||||
}
|
||||
|
||||
bool IsWindowActive(gfx::NativeWindow window) {
|
||||
bool IsWindowActive(gfx::NativeWindow native_window) {
|
||||
// If |window| is a doppelganger NSWindow being used to track an NSWindow that
|
||||
// is being hosted in another process, then use the views::Widget interface to
|
||||
// interact with it.
|
||||
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
|
||||
views::Widget* widget =
|
||||
views::Widget::GetWidgetForNativeWindow(native_window);
|
||||
if (widget)
|
||||
return widget->IsActive();
|
||||
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
return [window isKeyWindow] || [window isMainWindow];
|
||||
}
|
||||
|
||||
void ActivateWindow(gfx::NativeWindow window) {
|
||||
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
|
||||
void ActivateWindow(gfx::NativeWindow native_window) {
|
||||
views::Widget* widget =
|
||||
views::Widget::GetWidgetForNativeWindow(native_window);
|
||||
if (widget)
|
||||
return widget->Activate();
|
||||
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
[window makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
bool IsVisible(gfx::NativeView view) {
|
||||
views::Widget* widget = views::Widget::GetWidgetForNativeView(view);
|
||||
bool IsVisible(gfx::NativeView native_view) {
|
||||
views::Widget* widget = views::Widget::GetWidgetForNativeView(native_view);
|
||||
if (widget)
|
||||
return widget->IsVisible();
|
||||
|
||||
// A reasonable approximation of how you'd expect this to behave.
|
||||
NSView* view = native_view.GetNativeNSView();
|
||||
return (view &&
|
||||
![view isHiddenOrHasHiddenAncestor] &&
|
||||
[view window] &&
|
||||
|
@ -18,7 +18,7 @@ namespace {
|
||||
void ShowPrintErrorDialogTask() {
|
||||
Browser* browser = chrome::FindLastActive();
|
||||
chrome::ShowWarningMessageBox(
|
||||
browser ? browser->window()->GetNativeWindow() : NULL,
|
||||
browser ? browser->window()->GetNativeWindow() : gfx::kNullNativeWindow,
|
||||
l10n_util::GetStringUTF16(IDS_PRINT_SPOOL_FAILED_TITLE_TEXT),
|
||||
l10n_util::GetStringUTF16(IDS_PRINT_SPOOL_FAILED_ERROR_TEXT));
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ using content::RenderViewHost;
|
||||
}
|
||||
|
||||
- (NSView*)viewThatWantsHistoryOverlay {
|
||||
return renderWidgetHost_->GetView()->GetNativeView();
|
||||
return renderWidgetHost_->GetView()->GetNativeView().GetNativeNSView();
|
||||
}
|
||||
|
||||
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
|
||||
@ -266,7 +266,7 @@ using content::RenderViewHost;
|
||||
// window should become key.
|
||||
- (void)resignFirstResponder {
|
||||
NSWindow* browserWindow =
|
||||
renderWidgetHost_->GetView()->GetNativeView().window;
|
||||
[renderWidgetHost_->GetView()->GetNativeView().GetNativeNSView() window];
|
||||
DCHECK(browserWindow);
|
||||
|
||||
// If the browser window is already key, there's nothing to do.
|
||||
@ -295,7 +295,8 @@ using content::RenderViewHost;
|
||||
- (void)windowDidBecomeKey {
|
||||
if (resigningFirstResponder_)
|
||||
return;
|
||||
NSView* view = renderWidgetHost_->GetView()->GetNativeView();
|
||||
NSView* view =
|
||||
renderWidgetHost_->GetView()->GetNativeView().GetNativeNSView();
|
||||
if (view.window.firstResponder == view)
|
||||
[self makeAnyDialogKey];
|
||||
}
|
||||
|
@ -198,7 +198,8 @@ class ChromeRenderWidgetHostViewMacHistorySwiperTest
|
||||
->GetRenderViewHost()
|
||||
->GetWidget()
|
||||
->GetView()
|
||||
->GetNativeView();
|
||||
->GetNativeView()
|
||||
.GetNativeNSView();
|
||||
NSWindow* window = [view window];
|
||||
[(NSEvent*)[[event stub] andReturnValue:OCMOCK_VALUE(window)] window];
|
||||
|
||||
@ -330,7 +331,8 @@ class ChromeRenderWidgetHostViewMacHistorySwiperTest
|
||||
->GetRenderViewHost()
|
||||
->GetWidget()
|
||||
->GetView()
|
||||
->GetNativeView();
|
||||
->GetNativeView()
|
||||
.GetNativeNSView();
|
||||
BOOL run_loop = queued_event.runMessageLoop;
|
||||
switch (queued_event.deployment) {
|
||||
case DEPLOYMENT_GESTURE_BEGIN:
|
||||
|
@ -48,7 +48,7 @@ void MonitorFinder::FetchMonitorFromWidget() {
|
||||
return;
|
||||
|
||||
gfx::NativeView native_view = rfh->GetNativeView();
|
||||
NSWindow* window = [native_view window];
|
||||
NSWindow* window = [native_view.GetNativeNSView() window];
|
||||
NSScreen* screen = [window screen];
|
||||
CGDirectDisplayID display_id =
|
||||
[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
|
||||
|
@ -34,7 +34,7 @@ IN_PROC_BROWSER_TEST_F(SpellCheckMacViewBrowserTest, SpellCheckPanelVisible) {
|
||||
embedded_test_server()->GetURL("/title1.html"));
|
||||
|
||||
SEL show_guess_panel = NSSelectorFromString(@"showGuessPanel:");
|
||||
[web_contents->GetRenderWidgetHostView()->GetNativeView()
|
||||
[web_contents->GetRenderWidgetHostView()->GetNativeView().GetNativeNSView()
|
||||
performSelector:show_guess_panel];
|
||||
browser_client.RunUntilBind();
|
||||
spellcheck::SpellCheckMockPanelHost* host =
|
||||
|
@ -63,7 +63,7 @@ void AutofillPopupControllerImplMac::Show(
|
||||
|
||||
if (@available(macOS 10.12.2, *)) {
|
||||
touch_bar_controller_ = [WebTextfieldTouchBarController
|
||||
controllerForWindow:[container_view() window]];
|
||||
controllerForWindow:[container_view().GetNativeNSView() window]];
|
||||
[touch_bar_controller_ showCreditCardAutofillWithController:this];
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@
|
||||
- (NSWindow*)nativeHandle {
|
||||
// window() can be NULL during startup.
|
||||
if (browser_->window())
|
||||
return browser_->window()->GetNativeWindow();
|
||||
return browser_->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -150,14 +150,16 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
|
||||
extensions::AppWindow* app_1_app_window = FirstWindowForApp(app_1_);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowDidBecomeMainNotification
|
||||
object:app_1_app_window->GetNativeWindow()];
|
||||
object:app_1_app_window->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
CheckHasAppMenus(app_1_);
|
||||
|
||||
// When another app is focused, the menu item for the app should change.
|
||||
extensions::AppWindow* app_2_app_window = FirstWindowForApp(app_2_);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowDidBecomeMainNotification
|
||||
object:app_2_app_window->GetNativeWindow()];
|
||||
object:app_2_app_window->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
CheckHasAppMenus(app_2_);
|
||||
|
||||
// When a browser window is focused, the menu items for the app should be
|
||||
@ -166,7 +168,8 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
|
||||
(*BrowserList::GetInstance()->begin())->window();
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowDidBecomeMainNotification
|
||||
object:chrome_window->GetNativeWindow()];
|
||||
object:chrome_window->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
CheckNoAppMenus();
|
||||
|
||||
// When an app window is closed and there are no other app windows, the menu
|
||||
@ -175,11 +178,13 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
|
||||
chrome_window->Close();
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowDidBecomeMainNotification
|
||||
object:app_2_app_window->GetNativeWindow()];
|
||||
object:app_2_app_window->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
CheckHasAppMenus(app_2_);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowDidResignMainNotification
|
||||
object:app_2_app_window->GetNativeWindow()];
|
||||
object:app_2_app_window->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
app_2_app_window->GetBaseWindow()->Close();
|
||||
CheckNoAppMenus();
|
||||
}
|
||||
@ -193,7 +198,7 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
|
||||
|
||||
{
|
||||
ui::test::ScopedFakeNSWindowFocus fake_focus;
|
||||
[app_1_app_window->GetNativeWindow() makeMainWindow];
|
||||
[app_1_app_window->GetNativeWindow().GetNativeNSWindow() makeMainWindow];
|
||||
CheckHasAppMenus(app_1_);
|
||||
|
||||
// Closing a background window without focusing it should not change menus.
|
||||
@ -202,7 +207,8 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
|
||||
chrome_window->Close();
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowWillCloseNotification
|
||||
object:chrome_window->GetNativeWindow()];
|
||||
object:chrome_window->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
CheckHasAppMenus(app_1_);
|
||||
|
||||
// |fake_focus| going out of scope sends NSWindowWillResignMainNotification.
|
||||
@ -234,14 +240,18 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
|
||||
// Focus the hosted app.
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowDidBecomeMainNotification
|
||||
object:hosted_app_browser->window()->GetNativeWindow()];
|
||||
object:hosted_app_browser->window()
|
||||
->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
CheckEditMenu(hosted_app_);
|
||||
|
||||
// Now focus a platform app, the Edit menu should not have the additional
|
||||
// options.
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowDidBecomeMainNotification
|
||||
object:FirstWindowForApp(app_1_)->GetNativeWindow()];
|
||||
object:FirstWindowForApp(app_1_)
|
||||
->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
CheckEditMenu(app_1_);
|
||||
}
|
||||
|
||||
@ -252,7 +262,8 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
|
||||
|
||||
FirstWindowForApp(app_2_)->GetBaseWindow()->Close();
|
||||
(*BrowserList::GetInstance()->begin())->window()->Close();
|
||||
NSWindow* app_1_window = FirstWindowForApp(app_1_)->GetNativeWindow();
|
||||
NSWindow* app_1_window =
|
||||
FirstWindowForApp(app_1_)->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
ui::test::ScopedFakeNSWindowFocus fake_focus;
|
||||
[app_1_window makeMainWindow];
|
||||
|
@ -78,12 +78,13 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, HideShowWithApp) {
|
||||
|
||||
AppWindow* app_window = windows.front();
|
||||
extensions::NativeAppWindow* native_window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = native_window->GetNativeWindow();
|
||||
NSWindow* ns_window = native_window->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
AppWindow* other_app_window = windows.back();
|
||||
extensions::NativeAppWindow* other_native_window =
|
||||
other_app_window->GetBaseWindow();
|
||||
NSWindow* other_ns_window = other_native_window->GetNativeWindow();
|
||||
NSWindow* other_ns_window =
|
||||
other_native_window->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
// Normal Hide/Show.
|
||||
app_window->Hide();
|
||||
@ -183,7 +184,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest,
|
||||
|
||||
extensions::AppWindow* app_window = windows.front();
|
||||
extensions::NativeAppWindow* native_window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = native_window->GetNativeWindow();
|
||||
NSWindow* ns_window = native_window->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
// HideWithApp.
|
||||
native_window->HideWithApp();
|
||||
@ -216,7 +217,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Fullscreen) {
|
||||
extensions::AppWindow* app_window =
|
||||
CreateTestAppWindow("{\"alwaysOnTop\": true }");
|
||||
extensions::NativeAppWindow* window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter(
|
||||
[[NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]);
|
||||
|
||||
@ -268,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Minimize) {
|
||||
SetUpAppWithWindows(1);
|
||||
AppWindow* app_window = GetFirstAppWindow();
|
||||
extensions::NativeAppWindow* window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
NSRect initial_frame = [ns_window frame];
|
||||
|
||||
@ -303,7 +304,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Maximize) {
|
||||
SetUpAppWithWindows(1);
|
||||
AppWindow* app_window = GetFirstAppWindow();
|
||||
extensions::NativeAppWindow* window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<WindowedNSNotificationObserver> watcher;
|
||||
|
||||
gfx::Rect initial_restored_bounds = window->GetRestoredBounds();
|
||||
@ -359,7 +360,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, MaximizeConstrained) {
|
||||
AppWindow* app_window = CreateTestAppWindow(
|
||||
"{\"outerBounds\": {\"maxWidth\":200, \"maxHeight\":300}}");
|
||||
extensions::NativeAppWindow* window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<WindowedNSNotificationObserver> watcher;
|
||||
|
||||
gfx::Rect initial_restored_bounds = window->GetRestoredBounds();
|
||||
@ -395,7 +396,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, MinimizeMaximize) {
|
||||
SetUpAppWithWindows(1);
|
||||
AppWindow* app_window = GetFirstAppWindow();
|
||||
extensions::NativeAppWindow* window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<WindowedNSNotificationObserver> watcher;
|
||||
|
||||
NSRect initial_frame = [ns_window frame];
|
||||
@ -445,7 +446,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, MaximizeFullscreen) {
|
||||
SetUpAppWithWindows(1);
|
||||
AppWindow* app_window = GetFirstAppWindow();
|
||||
extensions::NativeAppWindow* window = app_window->GetBaseWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<WindowedNSNotificationObserver> watcher;
|
||||
base::scoped_nsobject<NSWindowFullscreenNotificationWaiter> waiter(
|
||||
[[NSWindowFullscreenNotificationWaiter alloc] initWithWindow:ns_window]);
|
||||
@ -502,8 +503,9 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, MaximizeFullscreen) {
|
||||
// window.
|
||||
IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Frameless) {
|
||||
AppWindow* app_window = CreateTestAppWindow("{\"frame\": \"none\"}");
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSView* web_contents = app_window->web_contents()->GetNativeView();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
NSView* web_contents =
|
||||
app_window->web_contents()->GetNativeView().GetNativeNSView();
|
||||
EXPECT_TRUE(NSEqualSizes(NSMakeSize(512, 384), [web_contents frame].size));
|
||||
// Move and resize the window.
|
||||
NSRect new_frame = NSMakeRect(50, 50, 200, 200);
|
||||
@ -527,7 +529,7 @@ namespace {
|
||||
|
||||
// Test that resize and fullscreen controls are correctly enabled/disabled.
|
||||
void TestControls(AppWindow* app_window) {
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
// The window is resizable.
|
||||
EXPECT_TRUE([ns_window styleMask] & NSResizableWindowMask);
|
||||
@ -545,7 +547,8 @@ void TestControls(AppWindow* app_window) {
|
||||
app_window->SetContentSizeConstraints(gfx::Size(), gfx::Size(200, 201));
|
||||
EXPECT_EQ(200, [ns_window contentMaxSize].width);
|
||||
EXPECT_EQ(201, [ns_window contentMaxSize].height);
|
||||
NSView* web_contents = app_window->web_contents()->GetNativeView();
|
||||
NSView* web_contents =
|
||||
app_window->web_contents()->GetNativeView().GetNativeNSView();
|
||||
EXPECT_EQ(200, [web_contents frame].size.width);
|
||||
EXPECT_EQ(201, [web_contents frame].size.height);
|
||||
|
||||
@ -619,7 +622,7 @@ IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, FrameColor) {
|
||||
// components are CGFloats in the range [0, 1].
|
||||
extensions::AppWindow* app_window = CreateTestAppWindow(
|
||||
"{\"frame\": {\"color\": \"#FF0000\", \"inactiveColor\": \"#0000FF\"}}");
|
||||
NSWindow* ns_window = app_window->GetNativeWindow();
|
||||
NSWindow* ns_window = app_window->GetNativeWindow().GetNativeNSWindow();
|
||||
// No color correction in the default case.
|
||||
[ns_window setColorSpace:[NSColorSpace sRGBColorSpace]];
|
||||
|
||||
|
@ -30,8 +30,9 @@ class BrowserWindowMacTest : public InProcessBrowserTest {
|
||||
// that is destroyed.
|
||||
IN_PROC_BROWSER_TEST_F(BrowserWindowMacTest, MenuCommandsAfterDestroy) {
|
||||
// Simulate AppKit (e.g. NSMenu) retaining an NSWindow.
|
||||
base::scoped_nsobject<NSWindow> window(browser()->window()->GetNativeWindow(),
|
||||
base::scoped_policy::RETAIN);
|
||||
base::scoped_nsobject<NSWindow> window(
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow(),
|
||||
base::scoped_policy::RETAIN);
|
||||
base::scoped_nsobject<NSMenuItem> bookmark_menu_item(
|
||||
[[[[NSApp mainMenu] itemWithTag:IDC_BOOKMARKS_MENU] submenu]
|
||||
itemWithTag:IDC_BOOKMARK_PAGE],
|
||||
|
@ -5,6 +5,7 @@
|
||||
#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller_views.h"
|
||||
|
||||
#include "chrome/browser/ui/views/frame/browser_view.h"
|
||||
#include "ui/views/cocoa/bridged_native_widget_host_impl.h"
|
||||
#include "ui/views_bridge_mac/bridged_native_widget_impl.h"
|
||||
|
||||
@implementation FullscreenToolbarControllerViews
|
||||
@ -26,20 +27,28 @@
|
||||
}
|
||||
|
||||
- (BOOL)isFullscreenTransitionInProgress {
|
||||
views::BridgedNativeWidgetImpl* bridge_widget =
|
||||
views::BridgedNativeWidgetImpl::GetFromNativeWindow([self window]);
|
||||
if (bridge_widget)
|
||||
return bridge_widget->in_fullscreen_transition();
|
||||
return NO;
|
||||
views::BridgedNativeWidgetHostImpl* bridge_host =
|
||||
views::BridgedNativeWidgetHostImpl::GetFromNativeWindow([self window]);
|
||||
if (bridge_host) {
|
||||
if (bridge_host->bridge_impl())
|
||||
return bridge_host->bridge_impl()->in_fullscreen_transition();
|
||||
else
|
||||
DLOG(ERROR) << "Cannot query remote NSWindow fullscreen status.";
|
||||
}
|
||||
return bridge_host->bridge_impl()->in_fullscreen_transition();
|
||||
}
|
||||
|
||||
- (NSWindow*)window {
|
||||
NSWindow* ns_window = browserView_->GetNativeWindow();
|
||||
NSWindow* ns_window = browserView_->GetNativeWindow().GetNativeNSWindow();
|
||||
if (!ns_view_) {
|
||||
views::BridgedNativeWidgetImpl* bridge_widget =
|
||||
views::BridgedNativeWidgetImpl::GetFromNativeWindow(ns_window);
|
||||
if (bridge_widget)
|
||||
ns_view_.reset([bridge_widget->ns_view() retain]);
|
||||
views::BridgedNativeWidgetHostImpl* bridge_host =
|
||||
views::BridgedNativeWidgetHostImpl::GetFromNativeWindow(ns_window);
|
||||
if (bridge_host) {
|
||||
if (bridge_host->bridge_impl())
|
||||
ns_view_.reset([bridge_host->bridge_impl()->ns_view() retain]);
|
||||
else
|
||||
DLOG(ERROR) << "Cannot retain remote NSView.";
|
||||
}
|
||||
}
|
||||
return ns_window;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ void DesktopMediaPickerCocoa::Show(
|
||||
const DoneCallback& done_callback) {
|
||||
controller_.reset([[DesktopMediaPickerController alloc]
|
||||
initWithSourceLists:std::move(source_lists)
|
||||
parent:params.parent
|
||||
parent:params.parent.GetNativeNSWindow()
|
||||
callback:done_callback
|
||||
appName:params.app_name
|
||||
targetName:params.target_name
|
||||
|
@ -48,7 +48,9 @@
|
||||
|
||||
@end
|
||||
|
||||
NativeWindowTrackerCocoa::NativeWindowTrackerCocoa(gfx::NativeWindow window) {
|
||||
NativeWindowTrackerCocoa::NativeWindowTrackerCocoa(
|
||||
gfx::NativeWindow native_window) {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
bridge_.reset([[BridgedNativeWindowTracker alloc] initWithNSWindow:window]);
|
||||
}
|
||||
|
||||
|
@ -67,13 +67,15 @@ class PermissionBubbleInteractiveUITest : public InProcessBrowserTest {
|
||||
|
||||
test_api_->AddSimpleRequest(CONTENT_SETTINGS_TYPE_GEOLOCATION);
|
||||
|
||||
EXPECT_TRUE([browser()->window()->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_TRUE([browser()->window()->GetNativeWindow().GetNativeNSWindow()
|
||||
isKeyWindow]);
|
||||
|
||||
// The PermissionRequestManager displays prompts asynchronously.
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// The bubble should steal key focus when shown.
|
||||
EnsureWindowActive(test_api_->GetPromptWindow(), "show permission bubble");
|
||||
EnsureWindowActive(test_api_->GetPromptWindow().GetNativeNSWindow(),
|
||||
"show permission bubble");
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -87,7 +89,8 @@ class PermissionBubbleInteractiveUITest : public InProcessBrowserTest {
|
||||
// There is only one tab. Cmd+w will close it along with the browser window.
|
||||
IN_PROC_BROWSER_TEST_F(PermissionBubbleInteractiveUITest, CmdWClosesWindow) {
|
||||
base::scoped_nsobject<NSWindow> browser_window(
|
||||
browser()->window()->GetNativeWindow(), base::scoped_policy::RETAIN);
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow(),
|
||||
base::scoped_policy::RETAIN);
|
||||
EXPECT_TRUE([browser_window isVisible]);
|
||||
|
||||
content::WindowedNotificationObserver observer(
|
||||
@ -104,7 +107,8 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleInteractiveUITest, CmdWClosesWindow) {
|
||||
// Add a tab, ensure we can switch away and back using Cmd+Alt+Left/Right and
|
||||
// curly braces.
|
||||
IN_PROC_BROWSER_TEST_F(PermissionBubbleInteractiveUITest, SwitchTabs) {
|
||||
NSWindow* browser_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* browser_window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
|
||||
EXPECT_TRUE(test_api_->GetPromptWindow());
|
||||
@ -132,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleInteractiveUITest, SwitchTabs) {
|
||||
|
||||
// Note we don't need to makeKeyAndOrderFront: the permission window will take
|
||||
// focus when it is shown again.
|
||||
EnsureWindowActive(test_api_->GetPromptWindow(),
|
||||
EnsureWindowActive(test_api_->GetPromptWindow().GetNativeNSWindow(),
|
||||
"switched to permission tab with arrow");
|
||||
EXPECT_TRUE(test_api_->GetPromptWindow());
|
||||
|
||||
@ -151,7 +155,7 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleInteractiveUITest, SwitchTabs) {
|
||||
chrome::FocusLocationBar(browser());
|
||||
SendAccelerator(ui::VKEY_OEM_4, true, false);
|
||||
EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
|
||||
EnsureWindowActive(test_api_->GetPromptWindow(),
|
||||
EnsureWindowActive(test_api_->GetPromptWindow().GetNativeNSWindow(),
|
||||
"switch to permission tab with curly brace");
|
||||
EXPECT_TRUE(test_api_->GetPromptWindow());
|
||||
|
||||
|
@ -28,7 +28,8 @@ class RenderViewContextMenuMacCocoaBrowserTest : public InProcessBrowserTest {
|
||||
textField_.reset(
|
||||
[[NSTextField alloc] initWithFrame:NSMakeRect(20, 20, 100, 20)]);
|
||||
[textField_ setStringValue:@"some text"];
|
||||
NSWindow* window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* window =
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
[[window contentView] addSubview:textField_];
|
||||
}
|
||||
|
||||
@ -70,7 +71,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewContextMenuMacCocoaBrowserTest,
|
||||
// filters all context menus no matter which control invokes them (as well as
|
||||
// the application Services menu). So to test, we just need a control with a
|
||||
// bit of selected text.
|
||||
NSWindow* window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* window = browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
[window makeFirstResponder:textField_];
|
||||
[textField_ selectText:nil];
|
||||
|
||||
|
@ -156,7 +156,7 @@ NSString* const kRemindersSharingServiceName =
|
||||
|
||||
// Saves details required by delegate methods for the transition animation.
|
||||
- (void)saveTransitionDataFromBrowser:(Browser*)browser {
|
||||
windowForShare_ = browser->window()->GetNativeWindow();
|
||||
windowForShare_ = browser->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
BrowserView* browserView = BrowserView::GetBrowserViewForBrowser(browser);
|
||||
if (!browserView)
|
||||
return;
|
||||
|
@ -172,7 +172,7 @@ IN_PROC_BROWSER_TEST_F(ShareMenuControllerTest, SharingDelegate) {
|
||||
MakeMockSharingService();
|
||||
|
||||
NSWindow* browser_window =
|
||||
browser()->window()->GetNativeWindow();
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
EXPECT_NSNE([controller_ sharingService:mockService
|
||||
sourceFrameOnScreenForShareItem:url],
|
||||
NSZeroRect);
|
||||
|
@ -37,19 +37,21 @@ void SingleWebContentsDialogManagerCocoa::Show() {
|
||||
if (!host_)
|
||||
return;
|
||||
|
||||
NSView* parent_view = host_->GetHostView();
|
||||
NSView* parent_view = host_->GetHostView().GetNativeNSView();
|
||||
// Note that simply [parent_view window] for an inactive tab is nil. However,
|
||||
// the following should always be non-nil for all WebContents containers.
|
||||
NSWindow* parent_window =
|
||||
delegate_->GetWebContents()->GetTopLevelNativeWindow();
|
||||
NSWindow* parent_window = delegate_->GetWebContents()
|
||||
->GetTopLevelNativeWindow()
|
||||
.GetNativeNSWindow();
|
||||
|
||||
[[ConstrainedWindowSheetController controllerForParentWindow:parent_window]
|
||||
showSheet:sheet_ forParentView:parent_view];
|
||||
}
|
||||
|
||||
void SingleWebContentsDialogManagerCocoa::Hide() {
|
||||
NSWindow* parent_window =
|
||||
delegate_->GetWebContents()->GetTopLevelNativeWindow();
|
||||
NSWindow* parent_window = delegate_->GetWebContents()
|
||||
->GetTopLevelNativeWindow()
|
||||
.GetNativeNSWindow();
|
||||
[[ConstrainedWindowSheetController controllerForParentWindow:parent_window]
|
||||
hideSheet:sheet_];
|
||||
}
|
||||
|
@ -129,7 +129,8 @@ ChromeWebContentsViewDelegateMac::CreateRenderViewContextMenu(
|
||||
gfx::NativeView parent_view =
|
||||
GetActiveRenderWidgetHostView()->GetNativeView();
|
||||
|
||||
return new RenderViewContextMenuMacCocoa(focused_frame, params, parent_view);
|
||||
return new RenderViewContextMenuMacCocoa(focused_frame, params,
|
||||
parent_view.GetNativeNSView());
|
||||
}
|
||||
|
||||
content::RenderWidgetHostView*
|
||||
@ -141,5 +142,5 @@ ChromeWebContentsViewDelegateMac::GetActiveRenderWidgetHostView() const {
|
||||
|
||||
NSWindow* ChromeWebContentsViewDelegateMac::GetNSWindowForFocusTracker() const {
|
||||
content::RenderWidgetHostView* rwhv = GetActiveRenderWidgetHostView();
|
||||
return rwhv ? [rwhv->GetNativeView() window] : nil;
|
||||
return rwhv ? [rwhv->GetNativeView().GetNativeNSView() window] : nil;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class BrowserWindowTouchBarControllerTest : public InProcessBrowserTest {
|
||||
}
|
||||
|
||||
NSWindow* native_window() const {
|
||||
return browser()->window()->GetNativeWindow();
|
||||
return browser()->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
}
|
||||
|
||||
API_AVAILABLE(macos(10.12.2))
|
||||
|
@ -63,6 +63,6 @@ void WebContentsModalDialogHostCocoa::RemoveObserver(
|
||||
gfx::Size WebContentsModalDialogHostCocoa::GetMaximumDialogSize() {
|
||||
// The dialog should try to fit within the overlay for the web contents.
|
||||
// Note that, for things like print preview, this is just a suggested maximum.
|
||||
return gfx::Size(
|
||||
[sheet_controller_ overlayWindowSizeForParentView:GetHostView()]);
|
||||
return gfx::Size([sheet_controller_
|
||||
overlayWindowSizeForParentView:GetHostView().GetNativeNSView()]);
|
||||
}
|
||||
|
@ -2621,10 +2621,10 @@ TEST_P(TabStripModelTest, TabBlockedState) {
|
||||
// DummySingleWebContentsDialogManager doesn't care about the
|
||||
// dialog window value, so any dummy value works.
|
||||
DummySingleWebContentsDialogManager* native_manager =
|
||||
new DummySingleWebContentsDialogManager(
|
||||
reinterpret_cast<gfx::NativeWindow>(0), modal_dialog_manager);
|
||||
new DummySingleWebContentsDialogManager(gfx::kNullNativeWindow,
|
||||
modal_dialog_manager);
|
||||
modal_dialog_manager->ShowDialogWithManager(
|
||||
reinterpret_cast<gfx::NativeWindow>(0),
|
||||
gfx::kNullNativeWindow,
|
||||
std::unique_ptr<web_modal::SingleWebContentsDialogManager>(
|
||||
native_manager));
|
||||
EXPECT_TRUE(strip_src.IsTabBlocked(1));
|
||||
|
@ -94,7 +94,7 @@ bool TestBrowserDialog::VerifyUi() {
|
||||
// docked magnifier or Chromevox being enabled.
|
||||
views::Widget* dialog_widget = *(added.begin());
|
||||
const gfx::Rect dialog_bounds = dialog_widget->GetWindowBoundsInScreen();
|
||||
auto* native_window = dialog_widget->GetNativeWindow();
|
||||
gfx::NativeWindow native_window = dialog_widget->GetNativeWindow();
|
||||
DCHECK(native_window);
|
||||
display::Screen* screen = display::Screen::GetScreen();
|
||||
const gfx::Rect display_work_area =
|
||||
|
@ -37,19 +37,22 @@
|
||||
selector:@selector(onWindowWillStartLiveResize:)
|
||||
name:NSWindowWillStartLiveResizeNotification
|
||||
object:static_cast<ui::BaseWindow*>(nativeAppWindow)
|
||||
->GetNativeWindow()];
|
||||
->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(onWindowWillExitFullScreen:)
|
||||
name:NSWindowWillExitFullScreenNotification
|
||||
object:static_cast<ui::BaseWindow*>(nativeAppWindow)
|
||||
->GetNativeWindow()];
|
||||
->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(onWindowDidExitFullScreen:)
|
||||
name:NSWindowDidExitFullScreenNotification
|
||||
object:static_cast<ui::BaseWindow*>(nativeAppWindow)
|
||||
->GetNativeWindow()];
|
||||
->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -95,8 +98,10 @@ ChromeNativeAppWindowViewsMac::~ChromeNativeAppWindowViewsMac() {
|
||||
}
|
||||
|
||||
void ChromeNativeAppWindowViewsMac::OnWindowWillStartLiveResize() {
|
||||
if (!NSWindowIsMaximized(GetNativeWindow()) && !in_fullscreen_transition_)
|
||||
bounds_before_maximize_ = [GetNativeWindow() frame];
|
||||
if (!NSWindowIsMaximized(GetNativeWindow().GetNativeNSWindow()) &&
|
||||
!in_fullscreen_transition_) {
|
||||
bounds_before_maximize_ = [GetNativeWindow().GetNativeNSWindow() frame];
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeNativeAppWindowViewsMac::OnWindowWillExitFullScreen() {
|
||||
@ -130,11 +135,11 @@ ChromeNativeAppWindowViewsMac::CreateNonStandardAppFrame() {
|
||||
|
||||
bool ChromeNativeAppWindowViewsMac::IsMaximized() const {
|
||||
return !IsMinimized() && !IsFullscreen() &&
|
||||
NSWindowIsMaximized(GetNativeWindow());
|
||||
NSWindowIsMaximized(GetNativeWindow().GetNativeNSWindow());
|
||||
}
|
||||
|
||||
gfx::Rect ChromeNativeAppWindowViewsMac::GetRestoredBounds() const {
|
||||
if (NSWindowIsMaximized(GetNativeWindow()))
|
||||
if (NSWindowIsMaximized(GetNativeWindow().GetNativeNSWindow()))
|
||||
return gfx::ScreenRectFromNSRect(bounds_before_maximize_);
|
||||
|
||||
return ChromeNativeAppWindowViews::GetRestoredBounds();
|
||||
@ -161,7 +166,7 @@ void ChromeNativeAppWindowViewsMac::Maximize() {
|
||||
if (IsFullscreen())
|
||||
return;
|
||||
|
||||
NSWindow* window = GetNativeWindow();
|
||||
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
||||
if (!NSWindowIsMaximized(window))
|
||||
[window setFrame:[[window screen] visibleFrame] display:YES animate:YES];
|
||||
|
||||
@ -170,7 +175,7 @@ void ChromeNativeAppWindowViewsMac::Maximize() {
|
||||
}
|
||||
|
||||
void ChromeNativeAppWindowViewsMac::Restore() {
|
||||
NSWindow* window = GetNativeWindow();
|
||||
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
||||
if (NSWindowIsMaximized(window))
|
||||
[window setFrame:bounds_before_maximize_ display:YES animate:YES];
|
||||
|
||||
|
@ -22,7 +22,7 @@ NativeAppWindowFrameViewMac::~NativeAppWindowFrameViewMac() {
|
||||
|
||||
gfx::Rect NativeAppWindowFrameViewMac::GetWindowBoundsForClientBounds(
|
||||
const gfx::Rect& client_bounds) const {
|
||||
NSWindow* ns_window = GetWidget()->GetNativeWindow();
|
||||
NSWindow* ns_window = GetWidget()->GetNativeWindow().GetNativeNSWindow();
|
||||
gfx::Rect window_bounds = gfx::ScreenRectFromNSRect([ns_window
|
||||
frameRectForContentRect:gfx::ScreenRectToNSRect(client_bounds)]);
|
||||
// Enforce minimum size (1, 1) in case that |client_bounds| is passed with
|
||||
|
@ -50,7 +50,8 @@ IN_PROC_BROWSER_TEST_F(SSLCertificateViewerMacTest, Basic) {
|
||||
ASSERT_TRUE(cert.get());
|
||||
content::WebContents* web_contents =
|
||||
browser()->tab_strip_model()->GetActiveWebContents();
|
||||
NSWindow* window = web_contents->GetTopLevelNativeWindow();
|
||||
NSWindow* window =
|
||||
web_contents->GetTopLevelNativeWindow().GetNativeNSWindow();
|
||||
WebContentsModalDialogManager* web_contents_modal_dialog_manager =
|
||||
WebContentsModalDialogManager::FromWebContents(web_contents);
|
||||
EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
|
||||
@ -74,7 +75,8 @@ IN_PROC_BROWSER_TEST_F(SSLCertificateViewerMacTest, HideShow) {
|
||||
content::WebContents* web_contents =
|
||||
browser()->tab_strip_model()->GetActiveWebContents();
|
||||
|
||||
NSWindow* window = web_contents->GetTopLevelNativeWindow();
|
||||
NSWindow* window =
|
||||
web_contents->GetTopLevelNativeWindow().GetNativeNSWindow();
|
||||
WebContentsModalDialogManager* web_contents_modal_dialog_manager =
|
||||
WebContentsModalDialogManager::FromWebContents(web_contents);
|
||||
|
||||
|
@ -158,7 +158,8 @@ class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView {
|
||||
views::Widget* overlayWindow =
|
||||
constrained_window::ShowWebModalDialogWithOverlayViews(this,
|
||||
web_contents);
|
||||
[certificate_viewer_ showCertificateSheet:overlayWindow->GetNativeWindow()];
|
||||
[certificate_viewer_ showCertificateSheet:overlayWindow->GetNativeWindow()
|
||||
.GetNativeNSWindow()];
|
||||
[certificate_viewer_ setOverlayWindow:overlayWindow];
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class BrowserFrameMac : public views::NativeWidgetMac,
|
||||
NativeWidgetMacNSWindow* CreateNSWindow(
|
||||
const views::Widget::InitParams& params) override;
|
||||
views::BridgeFactoryHost* GetBridgeFactoryHost() override;
|
||||
void OnWindowDestroying(NSWindow* window) override;
|
||||
void OnWindowDestroying(gfx::NativeWindow window) override;
|
||||
|
||||
// Overridden from NativeBrowserFrame:
|
||||
int GetMinimizeButtonOffset() const override;
|
||||
|
@ -102,7 +102,7 @@ BrowserWindowTouchBarController* BrowserFrameMac::GetTouchBarController()
|
||||
int BrowserFrameMac::SheetPositionY() {
|
||||
web_modal::WebContentsModalDialogHost* dialog_host =
|
||||
browser_view_->GetWebContentsModalDialogHost();
|
||||
NSView* view = dialog_host->GetHostView();
|
||||
NSView* view = dialog_host->GetHostView().GetNativeNSView();
|
||||
// Get the position of the host view relative to the window since
|
||||
// ModalDialogHost::GetDialogPosition() is relative to the host view.
|
||||
int host_view_y =
|
||||
@ -118,7 +118,7 @@ void BrowserFrameMac::InitNativeWidget(
|
||||
const views::Widget::InitParams& params) {
|
||||
views::NativeWidgetMac::InitNativeWidget(params);
|
||||
|
||||
[[GetNativeWindow() contentView] setWantsLayer:YES];
|
||||
[[GetNativeWindow().GetNativeNSWindow() contentView] setWantsLayer:YES];
|
||||
}
|
||||
|
||||
NativeWidgetMacNSWindow* BrowserFrameMac::CreateNSWindow(
|
||||
@ -171,11 +171,12 @@ views::BridgeFactoryHost* BrowserFrameMac::GetBridgeFactoryHost() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BrowserFrameMac::OnWindowDestroying(NSWindow* window) {
|
||||
void BrowserFrameMac::OnWindowDestroying(gfx::NativeWindow native_window) {
|
||||
// Clear delegates set in CreateNSWindow() to prevent objects with a reference
|
||||
// to |window| attempting to validate commands by looking for a Browser*.
|
||||
NativeWidgetMacNSWindow* ns_window =
|
||||
base::mac::ObjCCastStrict<NativeWidgetMacNSWindow>(window);
|
||||
base::mac::ObjCCastStrict<NativeWidgetMacNSWindow>(
|
||||
native_window.GetNativeNSWindow());
|
||||
[ns_window setCommandHandler:nil];
|
||||
[ns_window setCommandDispatcherDelegate:nil];
|
||||
[ns_window setWindowTouchBarDelegate:nil];
|
||||
@ -237,7 +238,7 @@ bool BrowserFrameMac::HandleKeyboardEvent(
|
||||
|
||||
// Redispatch the event. If it's a keyEquivalent:, this gives
|
||||
// CommandDispatcher the opportunity to finish passing the event to consumers.
|
||||
NSWindow* window = GetNativeWindow();
|
||||
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
||||
DCHECK([window.class conformsToProtocol:@protocol(CommandDispatchingWindow)]);
|
||||
NSObject<CommandDispatchingWindow>* command_dispatching_window =
|
||||
base::mac::ObjCCastStrict<NSObject<CommandDispatchingWindow>>(window);
|
||||
|
@ -112,7 +112,7 @@ int BrowserNonClientFrameViewMac::GetTopInset(bool restored) const {
|
||||
CGFloat y_offset = TopUIFullscreenYOffset();
|
||||
if (y_offset > 0) {
|
||||
// When menubar shows up, we need to update mouse tracking area.
|
||||
NSWindow* window = GetWidget()->GetNativeWindow();
|
||||
NSWindow* window = GetWidget()->GetNativeWindow().GetNativeNSWindow();
|
||||
NSRect content_bounds = [[window contentView] bounds];
|
||||
// Backing bar tracking area uses native coordinates.
|
||||
CGFloat tracking_height =
|
||||
|
@ -66,13 +66,15 @@ class PermissionBubbleViewsInteractiveUITest : public InProcessBrowserTest {
|
||||
|
||||
test_api_->AddSimpleRequest(CONTENT_SETTINGS_TYPE_GEOLOCATION);
|
||||
|
||||
EXPECT_TRUE([browser()->window()->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_TRUE([browser()->window()->GetNativeWindow().GetNativeNSWindow()
|
||||
isKeyWindow]);
|
||||
|
||||
// The PermissionRequestManager displays prompts asynchronously.
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// The bubble should steal key focus when shown.
|
||||
EnsureWindowActive(test_api_->GetPromptWindow(), "show permission bubble");
|
||||
EnsureWindowActive(test_api_->GetPromptWindow().GetNativeNSWindow(),
|
||||
"show permission bubble");
|
||||
}
|
||||
|
||||
private:
|
||||
@ -85,7 +87,8 @@ class PermissionBubbleViewsInteractiveUITest : public InProcessBrowserTest {
|
||||
IN_PROC_BROWSER_TEST_F(PermissionBubbleViewsInteractiveUITest,
|
||||
CmdWClosesWindow) {
|
||||
base::scoped_nsobject<NSWindow> browser_window(
|
||||
browser()->window()->GetNativeWindow(), base::scoped_policy::RETAIN);
|
||||
browser()->window()->GetNativeWindow().GetNativeNSWindow(),
|
||||
base::scoped_policy::RETAIN);
|
||||
EXPECT_TRUE([browser_window isVisible]);
|
||||
|
||||
content::WindowedNotificationObserver observer(
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace policy {
|
||||
|
||||
void StartModal(gfx::NativeWindow dialog) {
|
||||
[NSApp runModalForWindow:dialog];
|
||||
[NSApp runModalForWindow:dialog.GetNativeNSWindow()];
|
||||
}
|
||||
void StopModal() {
|
||||
[NSApp stopModal];
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace test {
|
||||
|
||||
float GetNativeWindowAlphaValue(gfx::NativeWindow window) {
|
||||
return [window alphaValue];
|
||||
return [window.GetNativeNSWindow() alphaValue];
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
@ -10,7 +10,7 @@
|
||||
#import "ui/base/test/windowed_nsnotification_observer.h"
|
||||
|
||||
bool BrowserActionTestUtil::WaitForPopup() {
|
||||
NSWindow* window = [GetPopupNativeView() window];
|
||||
NSWindow* window = [GetPopupNativeView().GetNativeNSView() window];
|
||||
if (!window)
|
||||
return false;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
void ResizeWebContents(content::WebContents* web_contents,
|
||||
const gfx::Rect& new_bounds) {
|
||||
NSView* view = web_contents->GetNativeView();
|
||||
NSView* view = web_contents->GetNativeView().GetNativeNSView();
|
||||
NSRect old_wcv_frame = [view frame];
|
||||
CGFloat new_x = old_wcv_frame.origin.x;
|
||||
CGFloat new_y =
|
||||
|
@ -22,7 +22,7 @@ gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) {
|
||||
NSPoint corner = NSMakePoint(NSMinX(work_area), NSMaxY(work_area));
|
||||
|
||||
if (Browser* browser = chrome::FindLastActive()) {
|
||||
NSWindow* window = browser->window()->GetNativeWindow();
|
||||
NSWindow* window = browser->window()->GetNativeWindow().GetNativeNSWindow();
|
||||
NSRect window_frame = [window frame];
|
||||
|
||||
// Limit to not overflow the work area right and bottom edges.
|
||||
|
@ -146,11 +146,13 @@ void SendGlobalKeyEventsHelper::SendGlobalKeyEvent(int key_code,
|
||||
|
||||
namespace ui_test_utils {
|
||||
|
||||
void HideNativeWindow(gfx::NativeWindow window) {
|
||||
void HideNativeWindow(gfx::NativeWindow native_window) {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
[window orderOut:nil];
|
||||
}
|
||||
|
||||
bool ShowAndFocusNativeWindow(gfx::NativeWindow window) {
|
||||
bool ShowAndFocusNativeWindow(gfx::NativeWindow native_window) {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
// Make sure an unbundled program can get the input focus.
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn,kProcessTransformToForegroundApplication);
|
||||
|
@ -20,7 +20,8 @@ using web_modal::SingleWebContentsDialogManager;
|
||||
namespace {
|
||||
|
||||
// Sets visibility and mouse events for a Cocoa NSWindow* and an attached sheet.
|
||||
void SetSheetVisible(gfx::NativeWindow overlay, bool visible) {
|
||||
void SetSheetVisible(gfx::NativeWindow native_window, bool visible) {
|
||||
NSWindow* overlay = native_window.GetNativeNSWindow();
|
||||
CGFloat alpha = visible ? 1.0 : 0.0;
|
||||
BOOL ignore_events = visible ? NO : YES;
|
||||
|
||||
@ -53,8 +54,8 @@ void NativeWebContentsModalDialogManagerViewsMac::OnPositionRequiresUpdate() {
|
||||
content::WebContents* web_contents = native_delegate()->GetWebContents();
|
||||
// Note: Can't use WebContents container bounds here because it doesn't
|
||||
// include the DevTool panel width.
|
||||
CGFloat window_width =
|
||||
NSWidth([web_contents->GetTopLevelNativeWindow() frame]);
|
||||
CGFloat window_width = NSWidth(
|
||||
[web_contents->GetTopLevelNativeWindow().GetNativeNSWindow() frame]);
|
||||
gfx::Rect tab_view_size = web_contents->GetContainerBounds();
|
||||
widget->SetBounds(gfx::Rect(tab_view_size.x(),
|
||||
widget->GetWindowBoundsInScreen().y(),
|
||||
@ -63,7 +64,7 @@ void NativeWebContentsModalDialogManagerViewsMac::OnPositionRequiresUpdate() {
|
||||
|
||||
void NativeWebContentsModalDialogManagerViewsMac::ShowWidget(
|
||||
views::Widget* widget) {
|
||||
NSWindow* dialog_window = widget->GetNativeWindow();
|
||||
NSWindow* dialog_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
[dialog_window setAlphaValue:0.0];
|
||||
// Because |dialog_window| is transparent, it won't accept mouse events until
|
||||
// ignoresMouseEvents is set. NSWindows start off accepting mouse events only
|
||||
@ -88,7 +89,7 @@ void NativeWebContentsModalDialogManagerViewsMac::ShowWidget(
|
||||
|
||||
void NativeWebContentsModalDialogManagerViewsMac::HideWidget(
|
||||
views::Widget* widget) {
|
||||
NSWindow* dialog_window = widget->GetNativeWindow();
|
||||
NSWindow* dialog_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
// Avoid views::Widget::Hide(), as a call to orderOut: on a NSWindow with an
|
||||
// attached sheet will close the sheet. Instead, just set the sheet to 0
|
||||
// opacity and don't accept click events.
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/web_modal/single_web_contents_dialog_manager.h"
|
||||
#include "components/web_modal/test_web_contents_modal_dialog_manager_delegate.h"
|
||||
#include "content/public/test/test_renderer_host.h"
|
||||
@ -107,7 +108,12 @@ class WebContentsModalDialogManagerTest
|
||||
gfx::NativeWindow MakeFakeDialog() {
|
||||
// WebContentsModalDialogManager treats the dialog window as an opaque
|
||||
// type, so creating fake dialog windows using reinterpret_cast is valid.
|
||||
#if defined(OS_MACOSX)
|
||||
NSWindow* window = reinterpret_cast<NSWindow*>(next_dialog_id++);
|
||||
return gfx::NativeWindow(window);
|
||||
#else
|
||||
return reinterpret_cast<gfx::NativeWindow>(next_dialog_id++);
|
||||
#endif
|
||||
}
|
||||
|
||||
int next_dialog_id;
|
||||
|
@ -135,12 +135,12 @@ MouseCursorOverlayController::~MouseCursorOverlayController() {
|
||||
Stop();
|
||||
}
|
||||
|
||||
void MouseCursorOverlayController::SetTargetView(NSView* view) {
|
||||
void MouseCursorOverlayController::SetTargetView(gfx::NativeView view) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(ui_sequence_checker_);
|
||||
|
||||
observer_.reset();
|
||||
if (view) {
|
||||
observer_ = std::make_unique<Observer>(this, view);
|
||||
observer_ = std::make_unique<Observer>(this, view.GetNativeNSView());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,8 @@ NativeWebKeyboardEvent::NativeWebKeyboardEvent(
|
||||
modifierFlags:flags
|
||||
timestamp:ui::EventTimeStampToSeconds(
|
||||
web_event.TimeStamp())
|
||||
windowNumber:[[native_view window] windowNumber]
|
||||
windowNumber:[[native_view.GetNativeNSView() window]
|
||||
windowNumber]
|
||||
context:nil
|
||||
characters:text
|
||||
charactersIgnoringModifiers:unmodified_text
|
||||
|
@ -202,8 +202,8 @@ void WebContentsViewMac::Focus() {
|
||||
delegate()->ResetStoredFocus();
|
||||
|
||||
gfx::NativeView native_view = GetNativeViewForFocus();
|
||||
NSWindow* window = [native_view window];
|
||||
[window makeFirstResponder:native_view];
|
||||
NSWindow* window = [native_view.GetNativeNSView() window];
|
||||
[window makeFirstResponder:native_view.GetNativeNSView()];
|
||||
}
|
||||
|
||||
void WebContentsViewMac::SetInitialFocus() {
|
||||
@ -376,7 +376,7 @@ RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget(
|
||||
// with us. In case there are other siblings of the content area, we want
|
||||
// to make sure the content area is on the bottom so other things draw over
|
||||
// it.
|
||||
NSView* view_view = view->GetNativeView();
|
||||
NSView* view_view = view->GetNativeView().GetNativeNSView();
|
||||
[view_view setFrame:[cocoa_view_.get() bounds]];
|
||||
[view_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||
// Add the new view below all other views; this also keeps it below any
|
||||
|
@ -69,7 +69,8 @@ class WebContentsViewMacTest : public RenderViewHostTestHarness {
|
||||
void SetUp() override {
|
||||
RenderViewHostTestHarness::SetUp();
|
||||
window_.reset([[CocoaTestHelperWindow alloc] init]);
|
||||
[[window_ contentView] addSubview:web_contents()->GetNativeView()];
|
||||
[[window_ contentView]
|
||||
addSubview:web_contents()->GetNativeView().GetNativeNSView()];
|
||||
}
|
||||
|
||||
base::scoped_nsobject<CocoaTestHelperWindow> window_;
|
||||
|
@ -122,7 +122,7 @@ void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds) {
|
||||
new_bounds.origin.y - new_bounds.size.height;
|
||||
}
|
||||
|
||||
[window setFrame:new_bounds display:NO];
|
||||
[window.GetNativeNSWindow() setFrame:new_bounds display:NO];
|
||||
}
|
||||
|
||||
void GetStringAtPointForRenderWidget(
|
||||
|
@ -147,7 +147,8 @@ void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
|
||||
NOTREACHED() << "Unknown UI control";
|
||||
return;
|
||||
}
|
||||
[[[window_ contentView] viewWithTag:id] setEnabled:is_enabled];
|
||||
[[[window_.GetNativeNSWindow() contentView] viewWithTag:id]
|
||||
setEnabled:is_enabled];
|
||||
}
|
||||
|
||||
void Shell::PlatformSetAddressBarURL(const GURL& url) {
|
||||
@ -182,32 +183,33 @@ void Shell::PlatformCreateWindow(int width, int height) {
|
||||
defer:NO];
|
||||
window_ = window;
|
||||
[window setShell:this];
|
||||
[window_ setTitle:kWindowTitle];
|
||||
NSView* content = [window_ contentView];
|
||||
[window_.GetNativeNSWindow() setTitle:kWindowTitle];
|
||||
NSView* content = [window_.GetNativeNSWindow() contentView];
|
||||
|
||||
// If the window is allowed to get too small, it will wreck the view bindings.
|
||||
NSSize min_size = NSMakeSize(kMinimumWindowWidth, kMinimumWindowHeight);
|
||||
min_size = [content convertSize:min_size toView:nil];
|
||||
// Note that this takes window coordinates.
|
||||
[window_ setContentMinSize:min_size];
|
||||
[window_.GetNativeNSWindow() setContentMinSize:min_size];
|
||||
|
||||
// Set the shell window to participate in Lion Fullscreen mode. Set
|
||||
// Setting this flag has no effect on Snow Leopard or earlier.
|
||||
NSUInteger collectionBehavior = [window_ collectionBehavior];
|
||||
NSUInteger collectionBehavior =
|
||||
[window_.GetNativeNSWindow() collectionBehavior];
|
||||
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
[window_ setCollectionBehavior:collectionBehavior];
|
||||
[window_.GetNativeNSWindow() setCollectionBehavior:collectionBehavior];
|
||||
|
||||
// Rely on the window delegate to clean us up rather than immediately
|
||||
// releasing when the window gets closed. We use the delegate to do
|
||||
// everything from the autorelease pool so the shell isn't on the stack
|
||||
// during cleanup (ie, a window close from javascript).
|
||||
[window_ setReleasedWhenClosed:NO];
|
||||
[window_.GetNativeNSWindow() setReleasedWhenClosed:NO];
|
||||
|
||||
// Create a window delegate to watch for when it's asked to go away. It will
|
||||
// clean itself up so we don't need to hold a reference.
|
||||
ContentShellWindowDelegate* delegate =
|
||||
[[ContentShellWindowDelegate alloc] initWithShell:this];
|
||||
[window_ setDelegate:delegate];
|
||||
[window_.GetNativeNSWindow() setDelegate:delegate];
|
||||
|
||||
if (!hide_toolbar_) {
|
||||
NSRect button_frame =
|
||||
@ -237,11 +239,11 @@ void Shell::PlatformCreateWindow(int width, int height) {
|
||||
}
|
||||
|
||||
// show the window
|
||||
[window_ makeKeyAndOrderFront:nil];
|
||||
[window_.GetNativeNSWindow() makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
void Shell::PlatformSetContents() {
|
||||
NSView* web_view = web_contents_->GetNativeView();
|
||||
NSView* web_view = web_contents_->GetNativeView().GetNativeNSView();
|
||||
[web_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
|
||||
if (headless_) {
|
||||
@ -249,7 +251,7 @@ void Shell::PlatformSetContents() {
|
||||
return;
|
||||
}
|
||||
|
||||
NSView* content = [window_ contentView];
|
||||
NSView* content = [window_.GetNativeNSWindow() contentView];
|
||||
[content addSubview:web_view];
|
||||
|
||||
NSRect frame = [content bounds];
|
||||
@ -264,10 +266,10 @@ void Shell::SizeTo(const gfx::Size& content_size) {
|
||||
int toolbar_height = hide_toolbar_ ? 0 : kURLBarHeight;
|
||||
NSRect frame = NSMakeRect(0, 0, content_size.width(),
|
||||
content_size.height() + toolbar_height);
|
||||
[window().contentView setFrame:frame];
|
||||
[window().GetNativeNSWindow().contentView setFrame:frame];
|
||||
return;
|
||||
}
|
||||
NSView* web_view = web_contents_->GetNativeView();
|
||||
NSView* web_view = web_contents_->GetNativeView().GetNativeNSView();
|
||||
NSRect frame = NSMakeRect(0, 0, content_size.width(), content_size.height());
|
||||
[web_view setFrame:frame];
|
||||
}
|
||||
@ -281,14 +283,14 @@ void Shell::PlatformSetTitle(const base::string16& title) {
|
||||
return;
|
||||
|
||||
NSString* title_string = base::SysUTF16ToNSString(title);
|
||||
[window_ setTitle:title_string];
|
||||
[window_.GetNativeNSWindow() setTitle:title_string];
|
||||
}
|
||||
|
||||
void Shell::Close() {
|
||||
if (headless_)
|
||||
delete this;
|
||||
else
|
||||
[window_ performClose:nil];
|
||||
[window_.GetNativeNSWindow() performClose:nil];
|
||||
}
|
||||
|
||||
void Shell::ActionPerformed(int control) {
|
||||
@ -327,7 +329,7 @@ bool Shell::HandleKeyboardEvent(WebContents* source,
|
||||
if ([event.os_event type] == NSKeyDown) {
|
||||
if (([event.os_event modifierFlags] & NSCommandKeyMask) &&
|
||||
[[event.os_event characters] isEqual:@"l"]) {
|
||||
[window_ makeFirstResponder:url_edit_view_];
|
||||
[window_.GetNativeNSWindow() makeFirstResponder:url_edit_view_];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ void ShellWebContentsViewDelegate::ShowContextMenu(
|
||||
YES,
|
||||
delegate);
|
||||
|
||||
NSView* parent_view = web_contents_->GetContentNativeView();
|
||||
NSView* parent_view = web_contents_->GetContentNativeView().GetNativeNSView();
|
||||
NSEvent* currentEvent = [NSApp currentEvent];
|
||||
NSWindow* window = [parent_view window];
|
||||
NSPoint position = [window mouseLocationOutsideOfEventStream];
|
||||
|
@ -64,7 +64,7 @@ ShellNativeAppWindowMac::ShellNativeAppWindowMac(
|
||||
[[window_controller_ window] setDelegate:window_controller_];
|
||||
[window_controller_ setAppWindow:this];
|
||||
|
||||
NSView* view = app_window->web_contents()->GetNativeView();
|
||||
NSView* view = app_window->web_contents()->GetNativeView().GetNativeNSView();
|
||||
NSView* frameView = [window() contentView];
|
||||
[view setFrame:[frameView bounds]];
|
||||
[frameView addSubview:view];
|
||||
|
@ -75,7 +75,8 @@ void HeadlessBrowserImpl::PlatformStart() {
|
||||
|
||||
void HeadlessBrowserImpl::PlatformInitializeWebContents(
|
||||
HeadlessWebContentsImpl* web_contents) {
|
||||
NSView* web_view = web_contents->web_contents()->GetNativeView();
|
||||
NSView* web_view =
|
||||
web_contents->web_contents()->GetNativeView().GetNativeNSView();
|
||||
[web_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
|
||||
// TODO(eseckler): Support enabling BeginFrameControl on Mac. This is tricky
|
||||
// because it's a ui::Compositor startup setting and ui::Compositors are
|
||||
@ -85,7 +86,8 @@ void HeadlessBrowserImpl::PlatformInitializeWebContents(
|
||||
void HeadlessBrowserImpl::PlatformSetWebContentsBounds(
|
||||
HeadlessWebContentsImpl* web_contents,
|
||||
const gfx::Rect& bounds) {
|
||||
NSView* web_view = web_contents->web_contents()->GetNativeView();
|
||||
NSView* web_view =
|
||||
web_contents->web_contents()->GetNativeView().GetNativeNSView();
|
||||
NSRect frame = gfx::ScreenRectToNSRect(bounds);
|
||||
[web_view setFrame:frame];
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ void PrintingContextMac::AskUserForSettings(int max_pages,
|
||||
// Set the print job title text.
|
||||
gfx::NativeView parent_view = delegate_->GetParentView();
|
||||
if (parent_view) {
|
||||
NSString* job_title = [[parent_view window] title];
|
||||
NSString* job_title = [[parent_view.GetNativeNSView() window] title];
|
||||
if (job_title) {
|
||||
PMPrintSettings printSettings =
|
||||
(PMPrintSettings)[printInfo PMPrintSettings];
|
||||
|
@ -805,7 +805,7 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) {
|
||||
}
|
||||
|
||||
- (id)AXWindow {
|
||||
return node_->GetDelegate()->GetTopLevelWidget();
|
||||
return node_->GetDelegate()->GetTopLevelWidget().GetNativeNSWindow();
|
||||
}
|
||||
|
||||
- (id)AXTopLevelUIElement {
|
||||
|
@ -22,8 +22,7 @@ class UI_BASE_EXPORT BubbleCloser {
|
||||
public:
|
||||
// Installs an event monitor watching for mouse clicks outside of |window| or
|
||||
// any of its child windows. Invokes |on_click_outside| on each event.
|
||||
BubbleCloser(gfx::NativeWindow window,
|
||||
base::RepeatingClosure on_click_outside);
|
||||
BubbleCloser(NSWindow* window, base::RepeatingClosure on_click_outside);
|
||||
~BubbleCloser();
|
||||
|
||||
private:
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
BubbleCloser::BubbleCloser(gfx::NativeWindow window,
|
||||
BubbleCloser::BubbleCloser(NSWindow* window,
|
||||
base::RepeatingClosure on_click_outside)
|
||||
: on_click_outside_(std::move(on_click_outside)), factory_(this) {
|
||||
// Capture a WeakPtr via NSObject. This allows the block to detect another
|
||||
|
@ -13,7 +13,7 @@ namespace {
|
||||
// This attempts to match OS X's native behavior, namely that a window
|
||||
// is only ever deminiaturized if ALL windows on ALL workspaces are
|
||||
// miniaturized.
|
||||
void FocusWindowSetHelper(const std::set<NSWindow*>& windows,
|
||||
void FocusWindowSetHelper(const std::set<gfx::NativeWindow>& windows,
|
||||
bool allow_workspace_switch,
|
||||
bool visible_windows_only) {
|
||||
NSArray* ordered_windows = [NSApp orderedWindows];
|
||||
@ -55,11 +55,11 @@ void FocusWindowSetHelper(const std::set<NSWindow*>& windows,
|
||||
|
||||
} // namespace
|
||||
|
||||
void FocusWindowSet(const std::set<NSWindow*>& windows) {
|
||||
void FocusWindowSet(const std::set<gfx::NativeWindow>& windows) {
|
||||
FocusWindowSetHelper(windows, true, true);
|
||||
}
|
||||
|
||||
void FocusWindowSetOnCurrentSpace(const std::set<NSWindow*>& windows) {
|
||||
void FocusWindowSetOnCurrentSpace(const std::set<gfx::NativeWindow>& windows) {
|
||||
// This callback runs before AppKit picks its own window to
|
||||
// deminiaturize, so we get to pick one from the right set. Limit to
|
||||
// the windows on the current workspace. Otherwise we jump spaces
|
||||
|
@ -268,8 +268,8 @@ bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
|
||||
DCHECK(base::MessageLoopForUI::IsCurrent());
|
||||
|
||||
std::vector<NSEvent*> events;
|
||||
SynthesizeKeyEventsSequence(
|
||||
window, key, control, shift, alt, command, &events);
|
||||
SynthesizeKeyEventsSequence(window.GetNativeNSWindow(), key, control, shift,
|
||||
alt, command, &events);
|
||||
|
||||
// TODO(suzhe): Using [NSApplication postEvent:atStart:] here causes
|
||||
// BrowserKeyEventsTest.CommandKeyEvents to fail. See http://crbug.com/49270
|
||||
|
@ -168,7 +168,8 @@ class ScreenMac : public Screen {
|
||||
return gfx::ScreenPointFromNSPoint([NSEvent mouseLocation]);
|
||||
}
|
||||
|
||||
bool IsWindowUnderCursor(gfx::NativeWindow window) override {
|
||||
bool IsWindowUnderCursor(gfx::NativeWindow native_window) override {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
return [NSWindow windowNumberAtPoint:[NSEvent mouseLocation]
|
||||
belowWindowWithWindowNumber:0] == [window windowNumber];
|
||||
}
|
||||
@ -184,7 +185,9 @@ class ScreenMac : public Screen {
|
||||
return displays_;
|
||||
}
|
||||
|
||||
Display GetDisplayNearestWindow(gfx::NativeWindow window) const override {
|
||||
Display GetDisplayNearestWindow(
|
||||
gfx::NativeWindow native_window) const override {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
EnsureDisplaysValid();
|
||||
if (displays_.size() == 1)
|
||||
return displays_[0];
|
||||
@ -202,7 +205,8 @@ class ScreenMac : public Screen {
|
||||
return GetCachedDisplayForScreen(match_screen);
|
||||
}
|
||||
|
||||
Display GetDisplayNearestView(gfx::NativeView view) const override {
|
||||
Display GetDisplayNearestView(gfx::NativeView native_view) const override {
|
||||
NSView* view = native_view.GetNativeNSView();
|
||||
NSWindow* window = [view window];
|
||||
if (!window)
|
||||
return GetPrimaryDisplay();
|
||||
@ -366,12 +370,14 @@ class ScreenMac : public Screen {
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
gfx::NativeWindow Screen::GetWindowForView(gfx::NativeView view) {
|
||||
NSWindow* window = nil;
|
||||
gfx::NativeWindow Screen::GetWindowForView(gfx::NativeView native_view) {
|
||||
#if !defined(USE_AURA)
|
||||
window = [view window];
|
||||
#endif
|
||||
NSView* view = native_view.GetNativeNSView();
|
||||
return [view window];
|
||||
#else
|
||||
gfx::NativeWindow window = nil;
|
||||
return window;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(USE_AURA)
|
||||
|
@ -417,6 +417,7 @@ source_set("native_widget_types") {
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
":gfx_export",
|
||||
"//base",
|
||||
]
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "build/build_config.h"
|
||||
#include "ui/gfx/gfx_export.h"
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#include "base/android/scoped_java_ref.h"
|
||||
@ -117,21 +118,80 @@ typedef ui::Cursor NativeCursor;
|
||||
typedef aura::Window* NativeView;
|
||||
typedef aura::Window* NativeWindow;
|
||||
typedef ui::Event* NativeEvent;
|
||||
constexpr NativeView kNullNativeView = nullptr;
|
||||
constexpr NativeWindow kNullNativeWindow = nullptr;
|
||||
#elif defined(OS_IOS)
|
||||
typedef void* NativeCursor;
|
||||
typedef UIView* NativeView;
|
||||
typedef UIWindow* NativeWindow;
|
||||
typedef UIEvent* NativeEvent;
|
||||
constexpr NativeView kNullNativeView = nullptr;
|
||||
constexpr NativeWindow kNullNativeWindow = nullptr;
|
||||
#elif defined(OS_MACOSX)
|
||||
typedef NSCursor* NativeCursor;
|
||||
typedef NSView* NativeView;
|
||||
typedef NSWindow* NativeWindow;
|
||||
typedef NSEvent* NativeEvent;
|
||||
// NativeViews and NativeWindows on macOS are not necessarily in the same
|
||||
// process as the NSViews and NSWindows that they represent. Require an
|
||||
// explicit function call (GetNativeNSView or GetNativeNSWindow) to retrieve
|
||||
// the underlying NSView or NSWindow.
|
||||
// https://crbug.com/893719
|
||||
class GFX_EXPORT NativeView {
|
||||
public:
|
||||
constexpr NativeView() {}
|
||||
// TODO(ccameron): Make this constructor explicit.
|
||||
constexpr NativeView(NSView* ns_view) : ns_view_(ns_view) {}
|
||||
|
||||
// This function name is verbose (that is, not just GetNSView) so that it
|
||||
// is easily grep-able.
|
||||
NSView* GetNativeNSView() const { return ns_view_; }
|
||||
|
||||
operator bool() const { return ns_view_ != 0; }
|
||||
bool operator==(const NativeView& other) const {
|
||||
return ns_view_ == other.ns_view_;
|
||||
}
|
||||
bool operator!=(const NativeView& other) const {
|
||||
return ns_view_ != other.ns_view_;
|
||||
}
|
||||
bool operator<(const NativeView& other) const {
|
||||
return ns_view_ < other.ns_view_;
|
||||
}
|
||||
|
||||
private:
|
||||
NSView* ns_view_ = nullptr;
|
||||
};
|
||||
class GFX_EXPORT NativeWindow {
|
||||
public:
|
||||
constexpr NativeWindow() {}
|
||||
// TODO(ccameron): Make this constructor explicit.
|
||||
constexpr NativeWindow(NSWindow* ns_window) : ns_window_(ns_window) {}
|
||||
|
||||
// This function name is verbose (that is, not just GetNSWindow) so that it
|
||||
// is easily grep-able.
|
||||
NSWindow* GetNativeNSWindow() const { return ns_window_; }
|
||||
|
||||
operator bool() const { return ns_window_ != 0; }
|
||||
bool operator==(const NativeWindow& other) const {
|
||||
return ns_window_ == other.ns_window_;
|
||||
}
|
||||
bool operator!=(const NativeWindow& other) const {
|
||||
return ns_window_ != other.ns_window_;
|
||||
}
|
||||
bool operator<(const NativeWindow& other) const {
|
||||
return ns_window_ < other.ns_window_;
|
||||
}
|
||||
|
||||
private:
|
||||
NSWindow* ns_window_ = nullptr;
|
||||
};
|
||||
constexpr NativeView kNullNativeView = NativeView(nullptr);
|
||||
constexpr NativeWindow kNullNativeWindow = NativeWindow(nullptr);
|
||||
#elif defined(OS_ANDROID)
|
||||
typedef void* NativeCursor;
|
||||
typedef ui::ViewAndroid* NativeView;
|
||||
typedef ui::WindowAndroid* NativeWindow;
|
||||
typedef base::android::ScopedJavaGlobalRef<jobject> NativeEvent;
|
||||
constexpr NativeView kNullNativeView = nullptr;
|
||||
constexpr NativeWindow kNullNativeWindow = nullptr;
|
||||
#else
|
||||
#error Unknown build environment.
|
||||
#endif
|
||||
|
@ -97,7 +97,7 @@ SelectFileDialogImpl::SelectFileDialogImpl(
|
||||
[[SelectFileDialogBridge alloc] initWithSelectFileDialogImpl:this]) {}
|
||||
|
||||
bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const {
|
||||
return parents_.find(parent_window) != parents_.end();
|
||||
return parents_.find(parent_window.GetNativeNSWindow()) != parents_.end();
|
||||
}
|
||||
|
||||
void SelectFileDialogImpl::ListenerDestroyed() {
|
||||
@ -141,11 +141,12 @@ void SelectFileDialogImpl::SelectFileImpl(
|
||||
const FileTypeInfo* file_types,
|
||||
int file_type_index,
|
||||
const base::FilePath::StringType& default_extension,
|
||||
gfx::NativeWindow owning_window,
|
||||
gfx::NativeWindow owning_native_window,
|
||||
void* params) {
|
||||
DCHECK(type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER ||
|
||||
type == SELECT_EXISTING_FOLDER || type == SELECT_OPEN_FILE ||
|
||||
type == SELECT_OPEN_MULTI_FILE || type == SELECT_SAVEAS_FILE);
|
||||
NSWindow* owning_window = owning_native_window.GetNativeNSWindow();
|
||||
parents_.insert(owning_window);
|
||||
|
||||
// Note: we need to retain the dialog as owning_window can be null.
|
||||
|
@ -15,9 +15,10 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
bool GrabViewSnapshot(gfx::NativeView view,
|
||||
bool GrabViewSnapshot(gfx::NativeView native_view,
|
||||
const gfx::Rect& snapshot_bounds,
|
||||
gfx::Image* image) {
|
||||
NSView* view = native_view.GetNativeNSView();
|
||||
NSWindow* window = [view window];
|
||||
NSScreen* screen = [[NSScreen screens] firstObject];
|
||||
gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame]));
|
||||
@ -55,11 +56,12 @@ bool GrabViewSnapshot(gfx::NativeView view,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GrabWindowSnapshot(gfx::NativeWindow window,
|
||||
bool GrabWindowSnapshot(gfx::NativeWindow native_window,
|
||||
const gfx::Rect& snapshot_bounds,
|
||||
gfx::Image* image) {
|
||||
// Make sure to grab the "window frame" view so we get current tab +
|
||||
// tabstrip.
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
return GrabViewSnapshot([[window contentView] superview], snapshot_bounds,
|
||||
image);
|
||||
}
|
||||
@ -78,9 +80,10 @@ void GrabViewSnapshotAsync(gfx::NativeView view,
|
||||
callback.Run(gfx::Image());
|
||||
}
|
||||
|
||||
void GrabWindowSnapshotAsync(gfx::NativeWindow window,
|
||||
void GrabWindowSnapshotAsync(gfx::NativeWindow native_window,
|
||||
const gfx::Rect& source_rect,
|
||||
const GrabWindowSnapshotAsyncCallback& callback) {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
return GrabViewSnapshotAsync([[window contentView] superview], source_rect,
|
||||
callback);
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ jumbo_component("views") {
|
||||
"bubble/tooltip_icon.h",
|
||||
"button_drag_utils.h",
|
||||
"cocoa/bridge_factory_host.h",
|
||||
"cocoa/bridged_native_widget_host_impl.h",
|
||||
"color_chooser/color_chooser_listener.h",
|
||||
"color_chooser/color_chooser_view.h",
|
||||
"context_menu_controller.h",
|
||||
@ -457,7 +458,6 @@ jumbo_component("views") {
|
||||
"../views_bridge_mac/views_scrollbar_bridge.h",
|
||||
"../views_bridge_mac/views_scrollbar_bridge.mm",
|
||||
"cocoa/bridge_factory_host.cc",
|
||||
"cocoa/bridged_native_widget_host_impl.h",
|
||||
"cocoa/bridged_native_widget_host_impl.mm",
|
||||
"cocoa/drag_drop_client_mac.h",
|
||||
"cocoa/drag_drop_client_mac.mm",
|
||||
|
@ -26,7 +26,7 @@ gfx::NativeViewAccessible ViewAXPlatformNodeDelegateMac::GetParent() {
|
||||
return view()->parent()->GetNativeViewAccessible();
|
||||
|
||||
if (view()->GetWidget())
|
||||
return view()->GetWidget()->GetNativeView();
|
||||
return view()->GetWidget()->GetNativeView().GetNativeNSView();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ void BubbleDialogDelegateView::OnWidgetActivationChanged(Widget* widget,
|
||||
// Install |mac_bubble_closer_| the first time the widget becomes active.
|
||||
if (active && !mac_bubble_closer_ && GetWidget()) {
|
||||
mac_bubble_closer_ = std::make_unique<ui::BubbleCloser>(
|
||||
GetWidget()->GetNativeWindow(),
|
||||
GetWidget()->GetNativeWindow().GetNativeNSWindow(),
|
||||
base::BindRepeating(&BubbleDialogDelegateView::OnDeactivate,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
@ -51,10 +51,11 @@ class VIEWS_EXPORT BridgedNativeWidgetHostImpl
|
||||
public ui::LayerOwner,
|
||||
public ui::AcceleratedWidgetMacNSView {
|
||||
public:
|
||||
// Retrieves the bridge host associated with the given NSWindow. Returns null
|
||||
// if the supplied handle has no associated Widget.
|
||||
// Retrieves the bridge host associated with the given NativeWindow. Returns
|
||||
// null if the supplied handle has no associated Widget.
|
||||
static BridgedNativeWidgetHostImpl* GetFromNativeWindow(
|
||||
gfx::NativeWindow window);
|
||||
static BridgedNativeWidgetHostImpl* GetFromNativeView(gfx::NativeView view);
|
||||
|
||||
// Unique integer id handles are used to bridge between the
|
||||
// BridgedNativeWidgetHostImpl in one process and the BridgedNativeWidgetHost
|
||||
|
@ -59,7 +59,8 @@ uint64_t g_last_bridged_native_widget_id = 0;
|
||||
|
||||
// static
|
||||
BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
gfx::NativeWindow window) {
|
||||
gfx::NativeWindow native_window) {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
if (NativeWidgetMacNSWindow* widget_window =
|
||||
base::mac::ObjCCast<NativeWidgetMacNSWindow>(window)) {
|
||||
return GetFromId([widget_window bridgedNativeWidgetId]);
|
||||
@ -67,6 +68,12 @@ BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
return nullptr; // Not created by NativeWidgetMac.
|
||||
}
|
||||
|
||||
// static
|
||||
BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromNativeView(
|
||||
gfx::NativeView native_view) {
|
||||
return GetFromNativeWindow([native_view.GetNativeNSView() window]);
|
||||
}
|
||||
|
||||
// static
|
||||
BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromId(
|
||||
uint64_t bridged_native_widget_id) {
|
||||
|
@ -66,7 +66,7 @@ class BridgedNativeWidgetUITest : public test::WidgetTest {
|
||||
}
|
||||
|
||||
NSWindow* test_window() {
|
||||
return widget_->GetNativeWindow();
|
||||
return widget_->GetNativeWindow().GetNativeNSWindow();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -296,7 +296,7 @@ TEST_F(BridgedNativeWidgetUITest, DISABLED_HitTest) {
|
||||
const NSPoint bottom_right_point = {398, 2};
|
||||
const NSPoint right_of_bottom_right = {398 + 10, 2};
|
||||
|
||||
NSWindow* window = widget.GetNativeWindow();
|
||||
NSWindow* window = widget.GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
EXPECT_FALSE([window ignoresMouseEvents]);
|
||||
// OSX uses both the alpha value of the window and the underlying CALayer to
|
||||
|
@ -313,9 +313,8 @@ class MockNativeWidgetMac : public NativeWidgetMac {
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO]);
|
||||
bridge_host_for_testing()->CreateLocalBridge(window);
|
||||
if (BridgedNativeWidgetHostImpl* parent =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
[params.parent window])) {
|
||||
if (auto* parent =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeView(params.parent)) {
|
||||
bridge_host_for_testing()->SetParent(parent);
|
||||
}
|
||||
bridge_host_for_testing()->InitWindow(params);
|
||||
@ -359,7 +358,8 @@ class BridgedNativeWidgetTestBase : public ui::CocoaTest {
|
||||
// corresponding |key_code|.
|
||||
NSEvent* VkeyKeyDown(ui::KeyboardCode key_code) {
|
||||
return cocoa_test_event_utils::SynthesizeKeyEvent(
|
||||
widget_->GetNativeWindow(), true /* keyDown */, key_code, 0);
|
||||
widget_->GetNativeWindow().GetNativeNSWindow(), true /* keyDown */,
|
||||
key_code, 0);
|
||||
}
|
||||
|
||||
// Generate an autoreleased KeyDown NSEvent* using the given keycode, and
|
||||
@ -1124,7 +1124,7 @@ TEST_F(BridgedNativeWidgetTest, TextInput_AccentedCharacter) {
|
||||
|
||||
// First an insertText: message with key 'a' is generated.
|
||||
SetKeyDownEvent(cocoa_test_event_utils::SynthesizeKeyEvent(
|
||||
widget_->GetNativeWindow(), true, ui::VKEY_A, 0));
|
||||
widget_->GetNativeWindow().GetNativeNSWindow(), true, ui::VKEY_A, 0));
|
||||
[ns_view_ insertText:@"a" replacementRange:EmptyRange()];
|
||||
[dummy_text_view_ insertText:@"a" replacementRange:EmptyRange()];
|
||||
SetKeyDownEvent(nil);
|
||||
@ -1135,7 +1135,7 @@ TEST_F(BridgedNativeWidgetTest, TextInput_AccentedCharacter) {
|
||||
// keys, setMarkedText action message is generated which replaces the earlier
|
||||
// inserted 'a'.
|
||||
SetKeyDownEvent(cocoa_test_event_utils::SynthesizeKeyEvent(
|
||||
widget_->GetNativeWindow(), true, ui::VKEY_RIGHT, 0));
|
||||
widget_->GetNativeWindow().GetNativeNSWindow(), true, ui::VKEY_RIGHT, 0));
|
||||
[ns_view_ setMarkedText:@"à"
|
||||
selectedRange:NSMakeRange(0, 1)
|
||||
replacementRange:NSMakeRange(3, 1)];
|
||||
@ -1152,7 +1152,8 @@ TEST_F(BridgedNativeWidgetTest, TextInput_AccentedCharacter) {
|
||||
|
||||
// On pressing enter, the marked text is confirmed.
|
||||
SetKeyDownEvent(cocoa_test_event_utils::SynthesizeKeyEvent(
|
||||
widget_->GetNativeWindow(), true, ui::VKEY_RETURN, 0));
|
||||
widget_->GetNativeWindow().GetNativeNSWindow(), true, ui::VKEY_RETURN,
|
||||
0));
|
||||
[ns_view_ insertText:@"à" replacementRange:EmptyRange()];
|
||||
[dummy_text_view_ insertText:@"à" replacementRange:EmptyRange()];
|
||||
SetKeyDownEvent(nil);
|
||||
@ -1740,7 +1741,7 @@ TEST_F(BridgedNativeWidgetTest, TextInput_RecursiveUpdateWindows) {
|
||||
|
||||
// Everything happens with this one event.
|
||||
NSEvent* return_with_fake_ime = cocoa_test_event_utils::SynthesizeKeyEvent(
|
||||
widget_->GetNativeWindow(), true, ui::VKEY_RETURN, 0);
|
||||
widget_->GetNativeWindow().GetNativeNSWindow(), true, ui::VKEY_RETURN, 0);
|
||||
|
||||
InterpretKeyEventsCallback generate_return_and_fake_ime = base::BindRepeating(
|
||||
[](int* saw_return_count, id view) {
|
||||
@ -1835,7 +1836,7 @@ typedef BridgedNativeWidgetTestBase BridgedNativeWidgetSimulateFullscreenTest;
|
||||
TEST_F(BridgedNativeWidgetSimulateFullscreenTest, FailToEnterAndExit) {
|
||||
BridgedNativeWidgetTestWindow* window =
|
||||
base::mac::ObjCCastStrict<BridgedNativeWidgetTestWindow>(
|
||||
widget_->GetNativeWindow());
|
||||
widget_->GetNativeWindow().GetNativeNSWindow());
|
||||
[window setIgnoreToggleFullScreen:YES];
|
||||
widget_->Show();
|
||||
|
||||
|
@ -188,10 +188,9 @@ class DragDropClientMacTest : public WidgetTest {
|
||||
gfx::Rect bounds(0, 0, 100, 100);
|
||||
widget_->SetBounds(bounds);
|
||||
|
||||
bridge_ = BridgedNativeWidgetImpl::GetFromNativeWindow(
|
||||
widget_->GetNativeWindow());
|
||||
bridge_host_ = BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
widget_->GetNativeWindow());
|
||||
bridge_ = bridge_host_->bridge_impl();
|
||||
widget_->Show();
|
||||
|
||||
target_ = new DragDropView();
|
||||
|
@ -86,7 +86,7 @@ void MenuClosureAnimationMac::DisableAnimationsForTesting() {
|
||||
|
||||
void MenuClosureAnimationMac::AnimationProgressed(
|
||||
const gfx::Animation* animation) {
|
||||
NSWindow* window = menu_->GetWidget()->GetNativeWindow();
|
||||
NSWindow* window = menu_->GetWidget()->GetNativeWindow().GetNativeNSWindow();
|
||||
[window setAlphaValue:animation->CurrentValueBetween(1.0, 0.0)];
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ void MenuHost::InitMenuHost(Widget* parent,
|
||||
params.opacity = (bubble_border || rounded_border) ?
|
||||
Widget::InitParams::TRANSLUCENT_WINDOW :
|
||||
Widget::InitParams::OPAQUE_WINDOW;
|
||||
params.parent = parent ? parent->GetNativeView() : NULL;
|
||||
params.parent = parent ? parent->GetNativeView() : gfx::kNullNativeView;
|
||||
params.bounds = bounds;
|
||||
// If MenuHost has no parent widget, it needs to be marked
|
||||
// Activatable, so that calling Show in ShowMenuHost will
|
||||
|
@ -26,7 +26,7 @@ MenuPreTargetHandlerMac::MenuPreTargetHandlerMac(MenuController* controller,
|
||||
if (!ui::WeakPtrNSObjectFactory<MenuPreTargetHandlerMac>::Get(handle))
|
||||
return event;
|
||||
|
||||
if (!target_window || [event window] == target_window) {
|
||||
if (!target_window || [event window] == target_window.GetNativeNSWindow()) {
|
||||
std::unique_ptr<ui::Event> ui_event = ui::EventFromNative(event);
|
||||
if (ui_event && ui_event->IsKeyEvent() &&
|
||||
controller_->OnWillDispatchKeyEvent(ui_event->AsKeyEvent()) !=
|
||||
|
@ -106,7 +106,8 @@ class MenuRunnerCocoaTest : public ViewsTestBase,
|
||||
gfx::Rect(kWindowOffset, kWindowOffset, kWindowWidth, kWindowHeight));
|
||||
parent_->Show();
|
||||
|
||||
native_view_subview_count_ = [[parent_->GetNativeView() subviews] count];
|
||||
native_view_subview_count_ =
|
||||
[[parent_->GetNativeView().GetNativeNSView() subviews] count];
|
||||
|
||||
base::Closure on_close = base::Bind(&MenuRunnerCocoaTest::MenuCloseCallback,
|
||||
base::Unretained(this));
|
||||
@ -119,7 +120,7 @@ class MenuRunnerCocoaTest : public ViewsTestBase,
|
||||
|
||||
void TearDown() override {
|
||||
EXPECT_EQ(native_view_subview_count_,
|
||||
[[parent_->GetNativeView() subviews] count]);
|
||||
[[parent_->GetNativeView().GetNativeNSView() subviews] count]);
|
||||
|
||||
if (runner_) {
|
||||
runner_->Release();
|
||||
@ -252,7 +253,7 @@ class MenuRunnerCocoaTest : public ViewsTestBase,
|
||||
}
|
||||
|
||||
void ComboboxRunMenuAtCallback() {
|
||||
NSArray* subviews = [parent_->GetNativeView() subviews];
|
||||
NSArray* subviews = [parent_->GetNativeView().GetNativeNSView() subviews];
|
||||
// An anchor view should only be added for Native menus.
|
||||
if (GetParam() == MenuType::NATIVE) {
|
||||
ASSERT_EQ(native_view_subview_count_ + 1, [subviews count]);
|
||||
|
@ -176,11 +176,12 @@ void MenuRunnerImplCocoa::RunMenuAt(Widget* parent,
|
||||
// Ensure the UI can update while the menu is fading out.
|
||||
base::ScopedPumpMessagesInPrivateModes pump_private;
|
||||
|
||||
NSWindow* window = parent->GetNativeWindow();
|
||||
NSWindow* window = parent->GetNativeWindow().GetNativeNSWindow();
|
||||
NSView* view = parent->GetNativeView().GetNativeNSView();
|
||||
if (run_types & MenuRunner::CONTEXT_MENU) {
|
||||
[NSMenu popUpContextMenu:[menu_controller_ menu]
|
||||
withEvent:EventForPositioningContextMenu(bounds, window)
|
||||
forView:parent->GetNativeView()];
|
||||
forView:view];
|
||||
} else if (run_types & MenuRunner::COMBOBOX) {
|
||||
NSMenuItem* checked_item = FirstCheckedItem(menu_controller_);
|
||||
NSMenu* menu = [menu_controller_ menu];
|
||||
|
@ -413,8 +413,9 @@ class MenuRunnerWidgetTest : public MenuRunnerTest {
|
||||
TEST_F(MenuRunnerWidgetTest, WidgetDoesntTakeCapture) {
|
||||
AddMenuLauncherEventHandler(owner());
|
||||
|
||||
EXPECT_EQ(nullptr, internal::NativeWidgetPrivate::GetGlobalCapture(
|
||||
widget()->GetNativeView()));
|
||||
EXPECT_EQ(gfx::kNullNativeView,
|
||||
internal::NativeWidgetPrivate::GetGlobalCapture(
|
||||
widget()->GetNativeView()));
|
||||
auto generator(EventGeneratorForWidget(widget()));
|
||||
// Implicit capture should not be held by |widget|.
|
||||
generator->PressLeftButton();
|
||||
|
@ -114,12 +114,14 @@ void NativeViewHostMac::OnHostableViewDestroying() {
|
||||
void NativeViewHostMac::AttachNativeView() {
|
||||
DCHECK(host_->native_view());
|
||||
DCHECK(!native_view_);
|
||||
native_view_.reset([host_->native_view() retain]);
|
||||
native_view_.reset([host_->native_view().GetNativeNSView() retain]);
|
||||
EnsureNativeViewHasNoChildWidgets(native_view_);
|
||||
|
||||
auto* bridge_host = GetBridgedNativeWidgetHost();
|
||||
DCHECK(bridge_host);
|
||||
[bridge_host->native_widget_mac()->GetNativeView() addSubview:native_view_];
|
||||
NSView* superview =
|
||||
bridge_host->native_widget_mac()->GetNativeView().GetNativeNSView();
|
||||
[superview addSubview:native_view_];
|
||||
bridge_host->SetAssociationForView(host_, native_view_);
|
||||
|
||||
if ([native_view_ conformsToProtocol:@protocol(ViewsHostable)]) {
|
||||
@ -137,21 +139,22 @@ void NativeViewHostMac::NativeViewDetaching(bool destroyed) {
|
||||
|
||||
// |native_view_| can be nil here if RemovedFromWidget() is called before
|
||||
// NativeViewHost::Detach().
|
||||
NSView* host_native_view = host_->native_view().GetNativeNSView();
|
||||
if (!native_view_) {
|
||||
DCHECK(![host_->native_view() superview]);
|
||||
DCHECK(![host_native_view superview]);
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(native_view_ == host_->native_view());
|
||||
[host_->native_view() setHidden:YES];
|
||||
[host_->native_view() removeFromSuperview];
|
||||
DCHECK(native_view_ == host_native_view);
|
||||
[native_view_ setHidden:YES];
|
||||
[native_view_ removeFromSuperview];
|
||||
|
||||
if (native_view_hostable_) {
|
||||
native_view_hostable_->OnViewsHostableDetached();
|
||||
native_view_hostable_ = nullptr;
|
||||
}
|
||||
|
||||
EnsureNativeViewHasNoChildWidgets(host_->native_view());
|
||||
EnsureNativeViewHasNoChildWidgets(native_view_);
|
||||
auto* bridge_host = GetBridgedNativeWidgetHost();
|
||||
// BridgedNativeWidgetImpl can be null when Widget is closing.
|
||||
if (bridge_host)
|
||||
@ -212,24 +215,24 @@ void NativeViewHostMac::ShowWidget(int x,
|
||||
// Convert window coordinates to the hosted view's superview, since that's how
|
||||
// coordinates of the hosted view's frame is based.
|
||||
NSRect container_rect =
|
||||
[[host_->native_view() superview] convertRect:window_rect fromView:nil];
|
||||
[host_->native_view() setFrame:container_rect];
|
||||
[host_->native_view() setHidden:NO];
|
||||
[[native_view_ superview] convertRect:window_rect fromView:nil];
|
||||
[native_view_ setFrame:container_rect];
|
||||
[native_view_ setHidden:NO];
|
||||
|
||||
if (native_view_hostable_)
|
||||
native_view_hostable_->OnViewsHostableShow(gfx::Rect(x, y, w, h));
|
||||
}
|
||||
|
||||
void NativeViewHostMac::HideWidget() {
|
||||
[host_->native_view() setHidden:YES];
|
||||
[native_view_ setHidden:YES];
|
||||
|
||||
if (native_view_hostable_)
|
||||
native_view_hostable_->OnViewsHostableHide();
|
||||
}
|
||||
|
||||
void NativeViewHostMac::SetFocus() {
|
||||
if ([host_->native_view() acceptsFirstResponder])
|
||||
[[host_->native_view() window] makeFirstResponder:host_->native_view()];
|
||||
if ([native_view_ acceptsFirstResponder])
|
||||
[[native_view_ window] makeFirstResponder:native_view_];
|
||||
|
||||
if (native_view_hostable_)
|
||||
native_view_hostable_->OnViewsHostableMakeFirstResponder();
|
||||
|
@ -76,7 +76,7 @@ class NativeViewHostMacTest : public test::NativeViewHostTestBase {
|
||||
toplevel()->GetRootView()->AddChildView(host());
|
||||
EXPECT_TRUE(native_host());
|
||||
|
||||
host()->Attach(native_view_);
|
||||
host()->Attach(native_view_.get());
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -118,7 +118,7 @@ TEST_F(NativeViewHostMacTest, Attach) {
|
||||
EXPECT_FALSE([native_view_ window]);
|
||||
EXPECT_NSEQ(NSZeroRect, [native_view_ frame]);
|
||||
|
||||
host()->Attach(native_view_);
|
||||
host()->Attach(native_view_.get());
|
||||
EXPECT_TRUE([native_view_ superview]);
|
||||
EXPECT_TRUE([native_view_ window]);
|
||||
|
||||
@ -141,7 +141,7 @@ TEST_F(NativeViewHostMacTest, AccessibilityParent) {
|
||||
TestViewsHostable views_hostable;
|
||||
[view setViewsHostableView:&views_hostable];
|
||||
|
||||
host()->Attach(view);
|
||||
host()->Attach(view.get());
|
||||
EXPECT_NSEQ(views_hostable.parent_accessibility_element(),
|
||||
toplevel()->GetRootView()->GetNativeViewAccessible());
|
||||
|
||||
@ -186,14 +186,14 @@ TEST_F(NativeViewHostMacTest, NativeViewHidden) {
|
||||
|
||||
host()->SetVisible(false);
|
||||
EXPECT_FALSE([native_view_ isHidden]); // Stays visible.
|
||||
host()->Attach(native_view_);
|
||||
host()->Attach(native_view_.get());
|
||||
EXPECT_TRUE([native_view_ isHidden]); // Hidden when attached.
|
||||
|
||||
host()->Detach();
|
||||
[native_view_ setHidden:YES];
|
||||
host()->SetVisible(true);
|
||||
EXPECT_TRUE([native_view_ isHidden]); // Stays hidden.
|
||||
host()->Attach(native_view_);
|
||||
host()->Attach(native_view_.get());
|
||||
EXPECT_FALSE([native_view_ isHidden]); // Made visible when attached.
|
||||
|
||||
EXPECT_TRUE([native_view_ superview]);
|
||||
|
@ -56,7 +56,8 @@ class TabbedPaneAccessibilityMacTest : public WidgetTest {
|
||||
id A11yElementAtPoint(const gfx::Point& point) {
|
||||
// Accessibility hit tests come in Cocoa screen coordinates.
|
||||
NSPoint ns_point = gfx::ScreenPointToNSPoint(point);
|
||||
return [widget_->GetNativeWindow() accessibilityHitTest:ns_point];
|
||||
return [widget_->GetNativeWindow().GetNativeNSWindow()
|
||||
accessibilityHitTest:ns_point];
|
||||
}
|
||||
|
||||
gfx::Point TabCenterPoint(int index) {
|
||||
|
@ -114,7 +114,7 @@ class ViewsTextServicesContextMenuMac
|
||||
gfx::DecoratedText text;
|
||||
if (client()->GetWordLookupDataFromSelection(&text, &baseline_point)) {
|
||||
Widget* widget = client()->GetWidget();
|
||||
gfx::NativeView view = widget->GetNativeView();
|
||||
NSView* view = widget->GetNativeView().GetNativeNSView();
|
||||
views::View::ConvertPointToTarget(client(), widget->GetRootView(),
|
||||
&baseline_point);
|
||||
|
||||
|
@ -34,10 +34,11 @@ std::unique_ptr<EventMonitor> EventMonitor::CreateWindowMonitor(
|
||||
}
|
||||
|
||||
EventMonitorMac::EventMonitorMac(ui::EventObserver* event_observer,
|
||||
gfx::NativeWindow target_window,
|
||||
gfx::NativeWindow target_native_window,
|
||||
const std::set<ui::EventType>& types)
|
||||
: factory_(this), types_(types) {
|
||||
DCHECK(event_observer);
|
||||
NSWindow* target_window = target_native_window.GetNativeNSWindow();
|
||||
|
||||
// Capture a WeakPtr via NSObject. This allows the block to detect another
|
||||
// event monitor for the same event deleting |this|.
|
||||
|
@ -154,14 +154,14 @@ TEST_F(FocusManagerTest, WidgetFocusChangeListener) {
|
||||
gfx::NativeView native_view1 = widget1->GetNativeView();
|
||||
test::WidgetTest::SimulateNativeActivate(widget1.get());
|
||||
ASSERT_EQ(2u, widget_listener.focus_changes().size());
|
||||
EXPECT_EQ(nullptr, widget_listener.focus_changes()[0]);
|
||||
EXPECT_EQ(gfx::kNullNativeView, widget_listener.focus_changes()[0]);
|
||||
EXPECT_EQ(native_view1, widget_listener.focus_changes()[1]);
|
||||
|
||||
widget_listener.ClearFocusChanges();
|
||||
gfx::NativeView native_view2 = widget2->GetNativeView();
|
||||
test::WidgetTest::SimulateNativeActivate(widget2.get());
|
||||
ASSERT_EQ(2u, widget_listener.focus_changes().size());
|
||||
EXPECT_EQ(nullptr, widget_listener.focus_changes()[0]);
|
||||
EXPECT_EQ(gfx::kNullNativeView, widget_listener.focus_changes()[0]);
|
||||
EXPECT_EQ(native_view2, widget_listener.focus_changes()[1]);
|
||||
}
|
||||
|
||||
|
@ -386,15 +386,16 @@ EventGeneratorDelegateMac::EventGeneratorDelegateMac(
|
||||
// Retain the NSWindow (note it can be nil). This matches Cocoa's tendency to
|
||||
// have autoreleased objects, or objects still in the event queue, that
|
||||
// reference the NSWindow.
|
||||
window_.reset([window retain]);
|
||||
window_.reset([window.GetNativeNSWindow() retain]);
|
||||
|
||||
// Normally, edit menu items have a `nil` target. This results in -[NSMenu
|
||||
// performKeyEquivalent:] relying on -[NSApplication targetForAction:to:from:]
|
||||
// to find a target starting at the first responder of the key window. Since
|
||||
// non-interactive tests have no key window, that won't work. So set (or
|
||||
// clear) the target explicitly on all menu items.
|
||||
[[fake_menu_ itemArray] makeObjectsPerformSelector:@selector(setTarget:)
|
||||
withObject:[window firstResponder]];
|
||||
[[fake_menu_ itemArray]
|
||||
makeObjectsPerformSelector:@selector(setTarget:)
|
||||
withObject:[window.GetNativeNSWindow() firstResponder]];
|
||||
|
||||
if (owner_) {
|
||||
swizzle_pressed_.reset(new base::mac::ScopedObjCClassSwizzler(
|
||||
@ -557,11 +558,12 @@ void EventGeneratorDelegateMac::OnScrollEvent(ui::ScrollEvent* event) {
|
||||
gfx::Point EventGeneratorDelegateMac::CenterOfTarget(
|
||||
const ui::EventTarget* target) const {
|
||||
DCHECK_EQ(target, this);
|
||||
return CenterOfWindow(window_);
|
||||
return CenterOfWindow(gfx::NativeWindow(window_));
|
||||
}
|
||||
|
||||
gfx::Point EventGeneratorDelegateMac::CenterOfWindow(
|
||||
gfx::NativeWindow window) const {
|
||||
gfx::NativeWindow native_window) const {
|
||||
NSWindow* window = native_window.GetNativeNSWindow();
|
||||
DCHECK_EQ(window, window_);
|
||||
// Assume the window is at the top-left of the coordinate system (even if
|
||||
// AppKit has moved it into the work area) see ConvertRootPointToTarget().
|
||||
|
@ -19,7 +19,8 @@ void PlatformTestHelper::SimulateNativeDestroy(Widget* widget) {
|
||||
// Retain the window while closing it, otherwise the window may lose its
|
||||
// last owner before -[NSWindow close] completes (this offends AppKit).
|
||||
// Usually this reference will exist on an event delivered to the runloop.
|
||||
base::scoped_nsobject<NSWindow> window([widget->GetNativeWindow() retain]);
|
||||
base::scoped_nsobject<NSWindow> window(
|
||||
[widget->GetNativeWindow().GetNativeNSWindow() retain]);
|
||||
[window close];
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ void WidgetTest::SimulateNativeActivate(Widget* widget) {
|
||||
object:g_simulated_active_window_];
|
||||
}
|
||||
|
||||
g_simulated_active_window_ = widget->GetNativeWindow();
|
||||
g_simulated_active_window_ = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
DCHECK(g_simulated_active_window_);
|
||||
|
||||
// For now, don't simulate main status or windows that can't activate.
|
||||
@ -44,7 +44,7 @@ void WidgetTest::SimulateNativeActivate(Widget* widget) {
|
||||
|
||||
// static
|
||||
bool WidgetTest::IsNativeWindowVisible(gfx::NativeWindow window) {
|
||||
return [window isVisible];
|
||||
return [window.GetNativeNSWindow() isVisible];
|
||||
}
|
||||
|
||||
// static
|
||||
@ -57,8 +57,8 @@ bool WidgetTest::IsWindowStackedAbove(Widget* above, Widget* below) {
|
||||
EXPECT_TRUE(below->IsVisible());
|
||||
|
||||
// -[NSApplication orderedWindows] are ordered front-to-back.
|
||||
NSWindow* first = above->GetNativeWindow();
|
||||
NSWindow* second = below->GetNativeWindow();
|
||||
NSWindow* first = above->GetNativeWindow().GetNativeNSWindow();
|
||||
NSWindow* second = below->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
for (NSWindow* window in [NSApp orderedWindows]) {
|
||||
if (window == second)
|
||||
@ -71,7 +71,8 @@ bool WidgetTest::IsWindowStackedAbove(Widget* above, Widget* below) {
|
||||
}
|
||||
|
||||
gfx::Size WidgetTest::GetNativeWidgetMinimumContentSize(Widget* widget) {
|
||||
return gfx::Size([widget->GetNativeWindow() contentMinSize]);
|
||||
return gfx::Size(
|
||||
[widget->GetNativeWindow().GetNativeNSWindow() contentMinSize]);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -88,7 +89,7 @@ ui::internal::InputMethodDelegate* WidgetTest::GetInputMethodDelegateForWidget(
|
||||
|
||||
// static
|
||||
bool WidgetTest::IsNativeWindowTransparent(gfx::NativeWindow window) {
|
||||
return ![window isOpaque];
|
||||
return ![window.GetNativeNSWindow() isOpaque];
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -96,13 +96,14 @@ class ViewMacTest : public test::WidgetTest {
|
||||
[[FakeSwipeEvent alloc] init]);
|
||||
[swipe_event setDeltaX:dx];
|
||||
[swipe_event setDeltaY:dy];
|
||||
[swipe_event setWindow:widget_->GetNativeWindow()];
|
||||
[swipe_event setWindow:widget_->GetNativeWindow().GetNativeNSWindow()];
|
||||
[swipe_event setLocationInWindow:NSMakePoint(50, 50)];
|
||||
[swipe_event setTimestamp:[[NSProcessInfo processInfo] systemUptime]];
|
||||
|
||||
// BridgedContentView should create an appropriate ui::GestureEvent and pass
|
||||
// it to the Widget.
|
||||
[[widget_->GetNativeWindow() contentView] swipeWithEvent:swipe_event];
|
||||
[[widget_->GetNativeWindow().GetNativeNSWindow() contentView]
|
||||
swipeWithEvent:swipe_event];
|
||||
return view_->last_swipe_gesture();
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,8 @@ class AXNativeWidgetMacTest : public test::WidgetTest {
|
||||
// Accessibility hit tests come in Cocoa screen coordinates.
|
||||
NSPoint midpoint_in_screen_ = gfx::ScreenPointToNSPoint(
|
||||
widget()->GetWindowBoundsInScreen().CenterPoint());
|
||||
return
|
||||
[widget()->GetNativeWindow() accessibilityHitTest:midpoint_in_screen_];
|
||||
return [widget()->GetNativeWindow().GetNativeNSWindow()
|
||||
accessibilityHitTest:midpoint_in_screen_];
|
||||
}
|
||||
|
||||
id AttributeValueAtMidpoint(NSString* attribute) {
|
||||
@ -411,7 +411,7 @@ TEST_F(AXNativeWidgetMacTest, NativeWindowProperties) {
|
||||
// Make sure it's |view| in the hit test by checking its accessibility role.
|
||||
EXPECT_EQ(NSAccessibilityGroupRole, AXRoleString());
|
||||
|
||||
NSWindow* window = widget()->GetNativeWindow();
|
||||
NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();
|
||||
EXPECT_NSEQ(window, AttributeValueAtMidpoint(NSAccessibilityWindowAttribute));
|
||||
EXPECT_NSEQ(window, AttributeValueAtMidpoint(
|
||||
NSAccessibilityTopLevelUIElementAttribute));
|
||||
@ -747,7 +747,8 @@ TEST_F(AXNativeWidgetMacTest, ProtectedTextfields) {
|
||||
|
||||
// Get the Textfield accessibility object.
|
||||
NSPoint midpoint = gfx::ScreenPointToNSPoint(GetWidgetBounds().CenterPoint());
|
||||
id ax_node = [widget()->GetNativeWindow() accessibilityHitTest:midpoint];
|
||||
id ax_node = [widget()->GetNativeWindow().GetNativeNSWindow()
|
||||
accessibilityHitTest:midpoint];
|
||||
EXPECT_TRUE(ax_node);
|
||||
|
||||
// Create a native Cocoa NSSecureTextField to compare against.
|
||||
|
@ -159,7 +159,7 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
|
||||
virtual BridgeFactoryHost* GetBridgeFactoryHost();
|
||||
|
||||
// Optional hook for subclasses invoked by WindowDestroying().
|
||||
virtual void OnWindowDestroying(NSWindow* window) {}
|
||||
virtual void OnWindowDestroying(gfx::NativeWindow window) {}
|
||||
|
||||
internal::NativeWidgetDelegate* delegate() { return delegate_; }
|
||||
views_bridge_mac::mojom::BridgedNativeWidget* bridge() const;
|
||||
|
@ -97,7 +97,7 @@ void NativeWidgetMac::WindowDestroyed() {
|
||||
}
|
||||
|
||||
int NativeWidgetMac::SheetPositionY() {
|
||||
NSView* view = GetNativeView();
|
||||
NSView* view = GetNativeView().GetNativeNSView();
|
||||
return
|
||||
[view convertPoint:NSMakePoint(0, NSHeight([view frame])) toView:nil].y;
|
||||
}
|
||||
@ -109,7 +109,7 @@ void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) {
|
||||
ownership_ = params.ownership;
|
||||
name_ = params.name;
|
||||
BridgedNativeWidgetHostImpl* parent_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow([params.parent window]);
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeView(params.parent);
|
||||
|
||||
// Determine the factory through which to create the bridge
|
||||
BridgeFactoryHost* bridge_factory_host =
|
||||
@ -188,7 +188,7 @@ const Widget* NativeWidgetMac::GetWidget() const {
|
||||
|
||||
gfx::NativeView NativeWidgetMac::GetNativeView() const {
|
||||
// Returns a BridgedContentView, unless there is no views::RootView set.
|
||||
return [GetNativeWindow() contentView];
|
||||
return [GetNativeWindow().GetNativeNSWindow() contentView];
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const {
|
||||
@ -344,8 +344,9 @@ void NativeWidgetMac::SetSize(const gfx::Size& size) {
|
||||
}
|
||||
|
||||
void NativeWidgetMac::StackAbove(gfx::NativeView native_view) {
|
||||
NSInteger view_parent = native_view.window.windowNumber;
|
||||
[GetNativeWindow() orderWindow:NSWindowAbove relativeTo:view_parent];
|
||||
NSInteger view_parent = native_view.GetNativeNSView().window.windowNumber;
|
||||
[GetNativeWindow().GetNativeNSWindow() orderWindow:NSWindowAbove
|
||||
relativeTo:view_parent];
|
||||
}
|
||||
|
||||
void NativeWidgetMac::StackAtTop() {
|
||||
@ -424,11 +425,12 @@ bool NativeWidgetMac::IsActive() const {
|
||||
}
|
||||
|
||||
void NativeWidgetMac::SetAlwaysOnTop(bool always_on_top) {
|
||||
gfx::SetNSWindowAlwaysOnTop(GetNativeWindow(), always_on_top);
|
||||
gfx::SetNSWindowAlwaysOnTop(GetNativeWindow().GetNativeNSWindow(),
|
||||
always_on_top);
|
||||
}
|
||||
|
||||
bool NativeWidgetMac::IsAlwaysOnTop() const {
|
||||
return gfx::IsNSWindowAlwaysOnTop(GetNativeWindow());
|
||||
return gfx::IsNSWindowAlwaysOnTop(GetNativeWindow().GetNativeNSWindow());
|
||||
}
|
||||
|
||||
void NativeWidgetMac::SetVisibleOnAllWorkspaces(bool always_visible) {
|
||||
@ -507,14 +509,14 @@ void NativeWidgetMac::RunShellDrag(View* view,
|
||||
|
||||
void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) {
|
||||
// |rect| is relative to client area of the window.
|
||||
NSWindow* window = GetNativeWindow();
|
||||
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
||||
NSRect client_rect = [window contentRectForFrameRect:[window frame]];
|
||||
NSRect target_rect = rect.ToCGRect();
|
||||
|
||||
// Convert to Appkit coordinate system (origin at bottom left).
|
||||
target_rect.origin.y =
|
||||
NSHeight(client_rect) - target_rect.origin.y - NSHeight(target_rect);
|
||||
[GetNativeView() setNeedsDisplayInRect:target_rect];
|
||||
[GetNativeView().GetNativeNSView() setNeedsDisplayInRect:target_rect];
|
||||
if (bridge_host_ && bridge_host_->layer())
|
||||
bridge_host_->layer()->SchedulePaint(rect);
|
||||
}
|
||||
@ -694,7 +696,7 @@ NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
|
||||
// static
|
||||
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
|
||||
gfx::NativeView native_view) {
|
||||
return GetNativeWidgetForNativeWindow([native_view window]);
|
||||
return GetNativeWidgetForNativeWindow([native_view.GetNativeNSView() window]);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -711,7 +713,7 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
|
||||
NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
|
||||
gfx::NativeView native_view) {
|
||||
BridgedNativeWidgetHostImpl* bridge_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow([native_view window]);
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeView(native_view);
|
||||
if (!bridge_host)
|
||||
return nullptr;
|
||||
while (bridge_host->parent())
|
||||
@ -723,22 +725,23 @@ NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
|
||||
void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
|
||||
Widget::Widgets* children) {
|
||||
BridgedNativeWidgetHostImpl* bridge_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow([native_view window]);
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeView(native_view);
|
||||
if (!bridge_host) {
|
||||
NSView* ns_view = native_view.GetNativeNSView();
|
||||
// The NSWindow is not itself a views::Widget, but it may have children that
|
||||
// are. Support returning Widgets that are parented to the NSWindow, except:
|
||||
// - Ignore requests for children of an NSView that is not a contentView.
|
||||
// - We do not add a Widget for |native_view| to |children| (there is none).
|
||||
if ([[native_view window] contentView] != native_view)
|
||||
if ([[ns_view window] contentView] != ns_view)
|
||||
return;
|
||||
|
||||
// Collect -sheets and -childWindows. A window should never appear in both,
|
||||
// since that causes AppKit to glitch.
|
||||
NSArray* sheet_children = [[native_view window] sheets];
|
||||
NSArray* sheet_children = [[ns_view window] sheets];
|
||||
for (NSWindow* native_child in sheet_children)
|
||||
GetAllChildWidgets([native_child contentView], children);
|
||||
|
||||
for (NSWindow* native_child in [[native_view window] childWindows]) {
|
||||
for (NSWindow* native_child in [[ns_view window] childWindows]) {
|
||||
DCHECK(![sheet_children containsObject:native_child]);
|
||||
GetAllChildWidgets([native_child contentView], children);
|
||||
}
|
||||
@ -770,7 +773,7 @@ void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
|
||||
void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view,
|
||||
Widget::Widgets* owned) {
|
||||
BridgedNativeWidgetHostImpl* bridge_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow([native_view window]);
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeView(native_view);
|
||||
if (!bridge_host) {
|
||||
GetAllChildWidgets(native_view, owned);
|
||||
return;
|
||||
@ -785,24 +788,28 @@ void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view,
|
||||
void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
|
||||
gfx::NativeView new_parent) {
|
||||
DCHECK_NE(native_view, new_parent);
|
||||
DCHECK([new_parent window]);
|
||||
if (!new_parent || [native_view superview] == new_parent) {
|
||||
DCHECK([new_parent.GetNativeNSView() window]);
|
||||
if (!new_parent || [native_view.GetNativeNSView() superview] ==
|
||||
new_parent.GetNativeNSView()) {
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
|
||||
BridgedNativeWidgetHostImpl* bridge_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow([native_view window]);
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeView(native_view);
|
||||
DCHECK(bridge_host);
|
||||
NSView* bridge_view = bridge_host->native_widget_mac()->GetNativeView();
|
||||
NSWindow* bridge_window = bridge_host->native_widget_mac()->GetNativeWindow();
|
||||
gfx::NativeView bridge_view =
|
||||
bridge_host->native_widget_mac()->GetNativeView();
|
||||
gfx::NativeWindow bridge_window =
|
||||
bridge_host->native_widget_mac()->GetNativeWindow();
|
||||
bool bridge_is_top_level =
|
||||
bridge_host->native_widget_mac()->GetWidget()->is_top_level();
|
||||
DCHECK([native_view isDescendantOf:bridge_view]);
|
||||
DCHECK(bridge_window && ![bridge_window isSheet]);
|
||||
DCHECK([native_view.GetNativeNSView()
|
||||
isDescendantOf:bridge_view.GetNativeNSView()]);
|
||||
DCHECK(bridge_window && ![bridge_window.GetNativeNSWindow() isSheet]);
|
||||
|
||||
BridgedNativeWidgetHostImpl* parent_bridge_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow([new_parent window]);
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeView(new_parent);
|
||||
|
||||
// Early out for no-op changes.
|
||||
if (native_view == bridge_view && bridge_is_top_level &&
|
||||
@ -831,16 +838,16 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
|
||||
// path is unused and remove it.
|
||||
LOG(ERROR) << "Reparenting a non-top-level BridgedNativeWidget. This is "
|
||||
"likely unsupported.";
|
||||
[new_parent addSubview:native_view];
|
||||
[bridge_window setAlphaValue:0];
|
||||
[bridge_window setIgnoresMouseEvents:YES];
|
||||
[new_parent.GetNativeNSView() addSubview:native_view.GetNativeNSView()];
|
||||
[bridge_window.GetNativeNSWindow() setAlphaValue:0];
|
||||
[bridge_window.GetNativeNSWindow() setIgnoresMouseEvents:YES];
|
||||
}
|
||||
} else {
|
||||
// TODO(ccameron): This path likely violates assumptions. Verify that this
|
||||
// path is unused and remove it.
|
||||
LOG(ERROR) << "Reparenting with a non-root BridgedNativeWidget NSView. "
|
||||
"This is likely unsupported.";
|
||||
[new_parent addSubview:native_view];
|
||||
[new_parent.GetNativeNSView() addSubview:native_view.GetNativeNSView()];
|
||||
}
|
||||
|
||||
// And now, notify them that they have a brand new parent.
|
||||
|
@ -82,7 +82,7 @@ TEST_P(NativeWidgetMacInteractiveUITest, ShowAttainsKeyStatus) {
|
||||
wait_for_first_active.Wait();
|
||||
}
|
||||
EXPECT_TRUE(widget->IsActive());
|
||||
EXPECT_TRUE([widget->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_TRUE([widget->GetNativeWindow().GetNativeNSWindow() isKeyWindow]);
|
||||
EXPECT_EQ(1, activation_count_);
|
||||
EXPECT_EQ(0, deactivation_count_);
|
||||
|
||||
@ -101,7 +101,7 @@ TEST_P(NativeWidgetMacInteractiveUITest, ShowAttainsKeyStatus) {
|
||||
|
||||
{
|
||||
WidgetActivationWaiter wait_for_external_activate(widget, true);
|
||||
[widget->GetNativeWindow() makeKeyAndOrderFront:nil];
|
||||
[widget->GetNativeWindow().GetNativeNSWindow() makeKeyAndOrderFront:nil];
|
||||
wait_for_external_activate.Wait();
|
||||
}
|
||||
EXPECT_TRUE(widget->IsActive());
|
||||
@ -118,27 +118,28 @@ TEST_P(NativeWidgetMacInteractiveUITest, ShowAttainsKeyStatus) {
|
||||
// Test that ShowInactive does not take keyWindow status.
|
||||
TEST_P(NativeWidgetMacInteractiveUITest, ShowInactiveIgnoresKeyStatus) {
|
||||
Widget* widget = MakeWidget();
|
||||
NSWindow* widget_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
base::scoped_nsobject<WindowedNSNotificationObserver> waiter(
|
||||
[[WindowedNSNotificationObserver alloc]
|
||||
initForNotification:NSWindowDidBecomeKeyNotification
|
||||
object:widget->GetNativeWindow()]);
|
||||
object:widget_window]);
|
||||
|
||||
EXPECT_FALSE(widget->IsVisible());
|
||||
EXPECT_FALSE([widget->GetNativeWindow() isVisible]);
|
||||
EXPECT_FALSE([widget_window isVisible]);
|
||||
EXPECT_FALSE(widget->IsActive());
|
||||
EXPECT_FALSE([widget->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_FALSE([widget_window isKeyWindow]);
|
||||
widget->ShowInactive();
|
||||
|
||||
EXPECT_TRUE(widget->IsVisible());
|
||||
EXPECT_TRUE([widget->GetNativeWindow() isVisible]);
|
||||
EXPECT_TRUE([widget_window isVisible]);
|
||||
EXPECT_FALSE(widget->IsActive());
|
||||
EXPECT_FALSE([widget->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_FALSE([widget_window isKeyWindow]);
|
||||
|
||||
// If the window were to become active, this would activate it.
|
||||
RunPendingMessages();
|
||||
EXPECT_FALSE(widget->IsActive());
|
||||
EXPECT_FALSE([widget->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_FALSE([widget_window isKeyWindow]);
|
||||
EXPECT_EQ(0, [waiter notificationCount]);
|
||||
|
||||
// Activating the inactive widget should make it key, asynchronously.
|
||||
@ -146,7 +147,7 @@ TEST_P(NativeWidgetMacInteractiveUITest, ShowInactiveIgnoresKeyStatus) {
|
||||
[waiter wait];
|
||||
EXPECT_EQ(1, [waiter notificationCount]);
|
||||
EXPECT_TRUE(widget->IsActive());
|
||||
EXPECT_TRUE([widget->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_TRUE([widget_window isKeyWindow]);
|
||||
|
||||
widget->CloseNow();
|
||||
}
|
||||
@ -155,13 +156,14 @@ namespace {
|
||||
|
||||
// Show |widget| and wait for it to become the key window.
|
||||
void ShowKeyWindow(Widget* widget) {
|
||||
NSWindow* widget_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<WindowedNSNotificationObserver> waiter(
|
||||
[[WindowedNSNotificationObserver alloc]
|
||||
initForNotification:NSWindowDidBecomeKeyNotification
|
||||
object:widget->GetNativeWindow()]);
|
||||
object:widget_window]);
|
||||
widget->Show();
|
||||
EXPECT_TRUE([waiter wait]);
|
||||
EXPECT_TRUE([widget->GetNativeWindow() isKeyWindow]);
|
||||
EXPECT_TRUE([widget_window isKeyWindow]);
|
||||
}
|
||||
|
||||
NSData* ViewAsTIFF(NSView* view) {
|
||||
@ -190,7 +192,7 @@ TEST_F(NativeWidgetMacInteractiveUITest, ParentWindowTrafficLights) {
|
||||
parent_widget->SetBounds(gfx::Rect(100, 100, 100, 100));
|
||||
ShowKeyWindow(parent_widget);
|
||||
|
||||
NSWindow* parent = parent_widget->GetNativeWindow();
|
||||
NSWindow* parent = parent_widget->GetNativeWindow().GetNativeNSWindow();
|
||||
EXPECT_TRUE([parent isMainWindow]);
|
||||
|
||||
NSButton* button = [parent standardWindowButton:NSWindowCloseButton];
|
||||
@ -244,7 +246,8 @@ TEST_F(NativeWidgetMacInteractiveUITest, BubbleDismiss) {
|
||||
|
||||
// First, test with LeftMouseDown in the parent window.
|
||||
NSEvent* mouse_down = cocoa_test_event_utils::LeftMouseDownAtPointInWindow(
|
||||
NSMakePoint(50, 50), parent_widget->GetNativeWindow());
|
||||
NSMakePoint(50, 50),
|
||||
parent_widget->GetNativeWindow().GetNativeNSWindow());
|
||||
[NSApp sendEvent:mouse_down];
|
||||
EXPECT_TRUE(bubble_widget->IsClosed());
|
||||
|
||||
@ -254,7 +257,8 @@ TEST_F(NativeWidgetMacInteractiveUITest, BubbleDismiss) {
|
||||
|
||||
// Test with RightMouseDown in the parent window.
|
||||
mouse_down = cocoa_test_event_utils::RightMouseDownAtPointInWindow(
|
||||
NSMakePoint(50, 50), parent_widget->GetNativeWindow());
|
||||
NSMakePoint(50, 50),
|
||||
parent_widget->GetNativeWindow().GetNativeNSWindow());
|
||||
[NSApp sendEvent:mouse_down];
|
||||
EXPECT_TRUE(bubble_widget->IsClosed());
|
||||
|
||||
@ -264,7 +268,8 @@ TEST_F(NativeWidgetMacInteractiveUITest, BubbleDismiss) {
|
||||
|
||||
// Test with RightMouseDown in the bubble (bubble should stay open).
|
||||
mouse_down = cocoa_test_event_utils::RightMouseDownAtPointInWindow(
|
||||
NSMakePoint(50, 50), bubble_widget->GetNativeWindow());
|
||||
NSMakePoint(50, 50),
|
||||
bubble_widget->GetNativeWindow().GetNativeNSWindow());
|
||||
[NSApp sendEvent:mouse_down];
|
||||
EXPECT_FALSE(bubble_widget->IsClosed());
|
||||
bubble_widget->CloseNow();
|
||||
@ -276,7 +281,8 @@ TEST_F(NativeWidgetMacInteractiveUITest, BubbleDismiss) {
|
||||
ShowKeyWindow(bubble_widget);
|
||||
|
||||
mouse_down = cocoa_test_event_utils::RightMouseDownAtPointInWindow(
|
||||
NSMakePoint(50, 50), parent_widget->GetNativeWindow());
|
||||
NSMakePoint(50, 50),
|
||||
parent_widget->GetNativeWindow().GetNativeNSWindow());
|
||||
[NSApp sendEvent:mouse_down];
|
||||
EXPECT_FALSE(bubble_widget->IsClosed());
|
||||
|
||||
@ -298,8 +304,8 @@ TEST_F(NativeWidgetMacInteractiveUITest, GlobalNSTextInputContextUpdates) {
|
||||
widget->Show();
|
||||
wait_for_first_active.Wait();
|
||||
}
|
||||
EXPECT_TRUE([widget->GetNativeView() inputContext]);
|
||||
EXPECT_EQ([widget->GetNativeView() inputContext],
|
||||
EXPECT_TRUE([widget->GetNativeView().GetNativeNSView() inputContext]);
|
||||
EXPECT_EQ([widget->GetNativeView().GetNativeNSView() inputContext],
|
||||
[NSTextInputContext currentInputContext]);
|
||||
|
||||
widget->GetContentsView()->RemoveChildView(textfield);
|
||||
@ -308,7 +314,7 @@ TEST_F(NativeWidgetMacInteractiveUITest, GlobalNSTextInputContextUpdates) {
|
||||
// iteration. We just tore out the inputContext, so ensure the raw, weak
|
||||
// global pointer that AppKit likes to keep around has been updated manually.
|
||||
EXPECT_EQ(nil, [NSTextInputContext currentInputContext]);
|
||||
EXPECT_FALSE([widget->GetNativeView() inputContext]);
|
||||
EXPECT_FALSE([widget->GetNativeView().GetNativeNSView() inputContext]);
|
||||
|
||||
// RemoveChildView() doesn't delete the view.
|
||||
delete textfield;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "ui/events/test/event_generator.h"
|
||||
#import "ui/gfx/mac/coordinate_conversion.h"
|
||||
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
|
||||
#include "ui/views/cocoa/bridged_native_widget_host_impl.h"
|
||||
#include "ui/views/controls/button/label_button.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/controls/native/native_view_host.h"
|
||||
@ -93,7 +94,8 @@ namespace test {
|
||||
class BridgedNativeWidgetTestApi {
|
||||
public:
|
||||
explicit BridgedNativeWidgetTestApi(NSWindow* window) {
|
||||
bridge_ = BridgedNativeWidgetImpl::GetFromNativeWindow(window);
|
||||
bridge_ =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow(window)->bridge_impl();
|
||||
}
|
||||
|
||||
// Simulate a frame swap from the compositor.
|
||||
@ -181,7 +183,7 @@ class NativeWidgetMacTest : public WidgetTest {
|
||||
widget->Init(params);
|
||||
widget->Show();
|
||||
*window = base::mac::ObjCCastStrict<NativeWidgetMacTestWindow>(
|
||||
widget->GetNativeWindow());
|
||||
widget->GetNativeWindow().GetNativeNSWindow());
|
||||
EXPECT_TRUE(*window);
|
||||
return widget;
|
||||
}
|
||||
@ -245,7 +247,7 @@ class NativeHostHolder {
|
||||
|
||||
void Detach() { host_->Detach(); }
|
||||
|
||||
gfx::NativeView view() const { return view_.get(); }
|
||||
NSView* view() const { return view_.get(); }
|
||||
NativeViewHost* host() const { return host_.get(); }
|
||||
|
||||
private:
|
||||
@ -292,7 +294,7 @@ class CustomTooltipView : public View {
|
||||
// Test visibility states triggered externally.
|
||||
TEST_F(NativeWidgetMacTest, HideAndShowExternally) {
|
||||
Widget* widget = CreateTopLevelPlatformWidget();
|
||||
NSWindow* ns_window = widget->GetNativeWindow();
|
||||
NSWindow* ns_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
WidgetChangeObserver observer(widget);
|
||||
|
||||
// Should initially be hidden.
|
||||
@ -421,10 +423,11 @@ class PaintCountView : public View {
|
||||
// and state changes that are unavoidably flaky.
|
||||
TEST_F(NativeWidgetMacTest, DISABLED_OrderFrontAfterMiniaturize) {
|
||||
Widget* widget = CreateTopLevelPlatformWidget();
|
||||
NSWindow* ns_window = widget->GetNativeWindow();
|
||||
NSWindow* ns_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
Widget* child_widget = CreateChildPlatformWidget(widget->GetNativeView());
|
||||
NSWindow* child_ns_window = child_widget->GetNativeWindow();
|
||||
NSWindow* child_ns_window =
|
||||
child_widget->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
// Set parent bounds that overlap child.
|
||||
widget->SetBounds(gfx::Rect(100, 100, 300, 300));
|
||||
@ -511,7 +514,7 @@ TEST_F(NativeWidgetMacTest, MiniaturizeExternally) {
|
||||
|
||||
PaintCountView* view = new PaintCountView();
|
||||
widget->GetContentsView()->AddChildView(view);
|
||||
NSWindow* ns_window = widget->GetNativeWindow();
|
||||
NSWindow* ns_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
WidgetChangeObserver observer(widget);
|
||||
|
||||
widget->SetBounds(gfx::Rect(100, 100, 300, 300));
|
||||
@ -595,7 +598,7 @@ TEST_F(NativeWidgetMacTest, MiniaturizeExternally) {
|
||||
|
||||
// Create a widget without a minimize button.
|
||||
widget = CreateTopLevelFramelessPlatformWidget();
|
||||
ns_window = widget->GetNativeWindow();
|
||||
ns_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
widget->SetBounds(gfx::Rect(100, 100, 300, 300));
|
||||
widget->Show();
|
||||
EXPECT_FALSE(widget->IsMinimized());
|
||||
@ -644,6 +647,7 @@ TEST_F(NativeWidgetMacTest, SetCursor) {
|
||||
widget->GetContentsView()->AddChildView(new CursorView(0, hand));
|
||||
widget->GetContentsView()->AddChildView(new CursorView(100, ibeam));
|
||||
widget->Show();
|
||||
NSWindow* widget_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
// Events used to simulate tracking rectangle updates. These are not passed to
|
||||
// toolkit-views, so it only matters whether they are inside or outside the
|
||||
@ -662,29 +666,28 @@ TEST_F(NativeWidgetMacTest, SetCursor) {
|
||||
|
||||
// Use an event generator to ask views code to set the cursor. However, note
|
||||
// that this does not cause Cocoa to generate tracking rectangle updates.
|
||||
ui::test::EventGenerator event_generator(GetContext(),
|
||||
widget->GetNativeWindow());
|
||||
ui::test::EventGenerator event_generator(GetContext(), widget_window);
|
||||
|
||||
// Move the mouse over the first view, then simulate a tracking rectangle
|
||||
// update. Verify that the cursor changed from arrow to hand type.
|
||||
event_generator.MoveMouseTo(gfx::Point(50, 50));
|
||||
[widget->GetNativeWindow() cursorUpdate:event_in_content];
|
||||
[widget_window cursorUpdate:event_in_content];
|
||||
EXPECT_EQ(hand, [NSCursor currentCursor]);
|
||||
|
||||
// A tracking rectangle update not in the content area should forward to
|
||||
// the native NSWindow implementation, which sets the arrow cursor.
|
||||
[widget->GetNativeWindow() cursorUpdate:event_out_of_content];
|
||||
[widget_window cursorUpdate:event_out_of_content];
|
||||
EXPECT_EQ(arrow, [NSCursor currentCursor]);
|
||||
|
||||
// Now move to the second view.
|
||||
event_generator.MoveMouseTo(gfx::Point(150, 50));
|
||||
[widget->GetNativeWindow() cursorUpdate:event_in_content];
|
||||
[widget_window cursorUpdate:event_in_content];
|
||||
EXPECT_EQ(ibeam, [NSCursor currentCursor]);
|
||||
|
||||
// Moving to the third view (but remaining in the content area) should also
|
||||
// forward to the native NSWindow implementation.
|
||||
event_generator.MoveMouseTo(gfx::Point(250, 50));
|
||||
[widget->GetNativeWindow() cursorUpdate:event_in_content];
|
||||
[widget_window cursorUpdate:event_in_content];
|
||||
EXPECT_EQ(arrow, [NSCursor currentCursor]);
|
||||
|
||||
widget->CloseNow();
|
||||
@ -707,7 +710,8 @@ TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
|
||||
NSRect nsrect = gfx::ScreenRectToNSRect(screen_rect);
|
||||
NSPoint midpoint = NSMakePoint(NSMidX(nsrect), NSMidY(nsrect));
|
||||
|
||||
id hit = [widget->GetNativeWindow() accessibilityHitTest:midpoint];
|
||||
id hit = [widget->GetNativeWindow().GetNativeNSWindow()
|
||||
accessibilityHitTest:midpoint];
|
||||
id title = [hit accessibilityAttributeValue:NSAccessibilityValueAttribute];
|
||||
EXPECT_NSEQ(title, @"Green");
|
||||
|
||||
@ -726,7 +730,7 @@ Widget* AttachPopupToNativeParent(NSWindow* native_parent) {
|
||||
// manager.
|
||||
Widget* child = new Widget;
|
||||
Widget::InitParams init_params;
|
||||
init_params.parent = anchor_view;
|
||||
init_params.parent = anchor_view.get();
|
||||
init_params.type = Widget::InitParams::TYPE_POPUP;
|
||||
child->Init(init_params);
|
||||
return child;
|
||||
@ -754,9 +758,13 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
|
||||
EXPECT_NE(child, top_level_widget->GetWidget());
|
||||
|
||||
// To verify the parent, we need to use NativeWidgetMac APIs.
|
||||
BridgedNativeWidgetImpl* bridged_native_widget =
|
||||
BridgedNativeWidgetImpl::GetFromNativeWindow(child->GetNativeWindow());
|
||||
EXPECT_EQ(native_parent, bridged_native_widget->parent()->ns_window());
|
||||
BridgedNativeWidgetHostImpl* bridged_native_widget_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
child->GetNativeWindow());
|
||||
EXPECT_EQ(bridged_native_widget_host->parent()
|
||||
->native_widget_mac()
|
||||
->GetNativeWindow(),
|
||||
native_parent);
|
||||
|
||||
const gfx::Rect child_bounds(50, 50, 200, 100);
|
||||
child->SetBounds(child_bounds);
|
||||
@ -768,7 +776,8 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
|
||||
EXPECT_EQ(1u, [[native_parent childWindows] count]);
|
||||
EXPECT_EQ(child->GetNativeWindow(),
|
||||
[[native_parent childWindows] objectAtIndex:0]);
|
||||
EXPECT_EQ(native_parent, [child->GetNativeWindow() parentWindow]);
|
||||
EXPECT_EQ(native_parent,
|
||||
[child->GetNativeWindow().GetNativeNSWindow() parentWindow]);
|
||||
|
||||
Widget::GetAllChildWidgets([native_parent contentView], &children);
|
||||
ASSERT_EQ(2u, children.size());
|
||||
@ -783,7 +792,10 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
|
||||
NSView* anchor_view = [[native_parent contentView] subviews][0];
|
||||
EXPECT_TRUE(anchor_view);
|
||||
[anchor_view removeFromSuperview];
|
||||
EXPECT_EQ(native_parent, bridged_native_widget->parent()->ns_window());
|
||||
EXPECT_EQ(bridged_native_widget_host->parent()
|
||||
->native_widget_mac()
|
||||
->GetNativeWindow(),
|
||||
native_parent);
|
||||
|
||||
// Closing the parent should close and destroy the child.
|
||||
EXPECT_FALSE(child_observer.widget_closed());
|
||||
@ -804,7 +816,7 @@ TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
||||
Widget* widget = CreateTopLevelPlatformWidget();
|
||||
widget->Show();
|
||||
TestWidgetObserver observer(widget);
|
||||
last_window = widget->GetNativeWindow();
|
||||
last_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
EXPECT_TRUE([[NSApp windows] containsObject:last_window]);
|
||||
Widget::CloseAllSecondaryWidgets();
|
||||
EXPECT_TRUE(observer.widget_closed());
|
||||
@ -825,7 +837,7 @@ TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
||||
Widget* widget = CreateTopLevelPlatformWidget();
|
||||
widget->Show();
|
||||
TestWidgetObserver observer(widget);
|
||||
last_window = [widget->GetNativeWindow() retain];
|
||||
last_window = [widget->GetNativeWindow().GetNativeNSWindow() retain];
|
||||
EXPECT_TRUE([[NSApp windows] containsObject:last_window]);
|
||||
widget->CloseNow();
|
||||
EXPECT_TRUE(observer.widget_closed());
|
||||
@ -857,8 +869,10 @@ TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
||||
TestWidgetObserver parent_observer(parent);
|
||||
TestWidgetObserver child_observer(child);
|
||||
|
||||
EXPECT_TRUE([[NSApp windows] containsObject:parent->GetNativeWindow()]);
|
||||
EXPECT_TRUE([[NSApp windows] containsObject:child->GetNativeWindow()]);
|
||||
EXPECT_TRUE([[NSApp windows]
|
||||
containsObject:parent->GetNativeWindow().GetNativeNSWindow()]);
|
||||
EXPECT_TRUE([[NSApp windows]
|
||||
containsObject:child->GetNativeWindow().GetNativeNSWindow()]);
|
||||
Widget::CloseAllSecondaryWidgets();
|
||||
EXPECT_TRUE(parent_observer.widget_closed());
|
||||
EXPECT_TRUE(child_observer.widget_closed());
|
||||
@ -949,7 +963,7 @@ base::string16 TooltipTextForWidget(Widget* widget) {
|
||||
// view and it fills the window. This just assumes the window is at least big
|
||||
// big enough for a constant coordinate to be within it.
|
||||
NSPoint point = NSMakePoint(30, 30);
|
||||
NSView* view = [widget->GetNativeView() hitTest:point];
|
||||
NSView* view = [widget->GetNativeView().GetNativeNSView() hitTest:point];
|
||||
NSString* text =
|
||||
[view view:view stringForToolTip:0 point:point userData:nullptr];
|
||||
return base::SysNSStringToUTF16(text);
|
||||
@ -1139,7 +1153,8 @@ Widget* ShowChildModalWidgetAndWait(NSWindow* native_parent) {
|
||||
EXPECT_FALSE(modal_dialog_widget->IsVisible());
|
||||
ScopedSwizzleWaiter show_waiter([ConstrainedWindowAnimationShow class]);
|
||||
|
||||
BridgedNativeWidgetTestApi test_api(modal_dialog_widget->GetNativeWindow());
|
||||
BridgedNativeWidgetTestApi test_api(
|
||||
modal_dialog_widget->GetNativeWindow().GetNativeNSWindow());
|
||||
EXPECT_FALSE(test_api.show_animation());
|
||||
|
||||
modal_dialog_widget->Show();
|
||||
@ -1235,7 +1250,8 @@ TEST_F(NativeWidgetMacTest, ShowAnimationControl) {
|
||||
modal_dialog_widget->SetBounds(gfx::Rect(50, 50, 200, 150));
|
||||
EXPECT_FALSE(modal_dialog_widget->IsVisible());
|
||||
|
||||
BridgedNativeWidgetTestApi test_api(modal_dialog_widget->GetNativeWindow());
|
||||
BridgedNativeWidgetTestApi test_api(
|
||||
modal_dialog_widget->GetNativeWindow().GetNativeNSWindow());
|
||||
EXPECT_FALSE(test_api.show_animation());
|
||||
modal_dialog_widget->Show();
|
||||
|
||||
@ -1295,7 +1311,7 @@ TEST_F(NativeWidgetMacTest, WindowModalSheet) {
|
||||
|
||||
// Retain, to run checks after the Widget is torn down.
|
||||
base::scoped_nsobject<NSWindow> sheet_window(
|
||||
[sheet_widget->GetNativeWindow() retain]);
|
||||
[sheet_widget->GetNativeWindow().GetNativeNSWindow() retain]);
|
||||
|
||||
// Although there is no titlebar displayed, sheets need NSTitledWindowMask in
|
||||
// order to properly engage window-modal behavior in AppKit.
|
||||
@ -1387,7 +1403,8 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
||||
|
||||
{
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
EXPECT_TRUE([sheet_widget->GetNativeWindow() isVisible]);
|
||||
EXPECT_TRUE(
|
||||
[sheet_widget->GetNativeWindow().GetNativeNSWindow() isVisible]);
|
||||
|
||||
WidgetChangeObserver widget_observer(sheet_widget);
|
||||
|
||||
@ -1405,12 +1422,13 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
|
||||
// Ensure the sheet wasn't blocked by a previous modal session.
|
||||
EXPECT_TRUE([sheet_widget->GetNativeWindow() isVisible]);
|
||||
EXPECT_TRUE(
|
||||
[sheet_widget->GetNativeWindow().GetNativeNSWindow() isVisible]);
|
||||
|
||||
WidgetChangeObserver widget_observer(sheet_widget);
|
||||
|
||||
// Test native -[NSWindow close] on the sheet. Does not animate.
|
||||
[sheet_widget->GetNativeWindow() close];
|
||||
[sheet_widget->GetNativeWindow().GetNativeNSWindow() close];
|
||||
EXPECT_TRUE(widget_observer.widget_closed());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
@ -1423,7 +1441,8 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
||||
{
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
base::scoped_nsobject<NSWindow> sheet_window(
|
||||
sheet_widget->GetNativeWindow(), base::scoped_policy::RETAIN);
|
||||
sheet_widget->GetNativeWindow().GetNativeNSWindow(),
|
||||
base::scoped_policy::RETAIN);
|
||||
EXPECT_TRUE([sheet_window isVisible]);
|
||||
|
||||
WidgetChangeObserver widget_observer(sheet_widget);
|
||||
@ -1446,7 +1465,8 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
NSWindow* sheet_window = sheet_widget->GetNativeWindow();
|
||||
NSWindow* sheet_window =
|
||||
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
||||
EXPECT_TRUE([sheet_window isVisible]);
|
||||
|
||||
WidgetChangeObserver widget_observer(sheet_widget);
|
||||
@ -1465,7 +1485,8 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
||||
// Test -[NSWindow close] on the parent window.
|
||||
{
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
EXPECT_TRUE([sheet_widget->GetNativeWindow() isVisible]);
|
||||
EXPECT_TRUE(
|
||||
[sheet_widget->GetNativeWindow().GetNativeNSWindow() isVisible]);
|
||||
WidgetChangeObserver widget_observer(sheet_widget);
|
||||
|
||||
[native_parent close];
|
||||
@ -1481,7 +1502,8 @@ TEST_F(NativeWidgetMacTest, CloseWindowModalSheetWithoutSheetParent) {
|
||||
{
|
||||
base::mac::ScopedNSAutoreleasePool pool;
|
||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||
NSWindow* sheet_window = sheet_widget->GetNativeWindow();
|
||||
NSWindow* sheet_window =
|
||||
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
||||
EXPECT_TRUE([sheet_window isVisible]);
|
||||
|
||||
sheet_widget->Close(); // Asynchronous. Can't be called after -close.
|
||||
@ -1525,25 +1547,30 @@ TEST_F(NativeWidgetMacTest, NoopReparentNativeView) {
|
||||
NSWindow* parent = MakeBorderlessNativeParent();
|
||||
Widget* dialog = views::DialogDelegate::CreateDialogWidget(
|
||||
new DialogDelegateView, nullptr, [parent contentView]);
|
||||
BridgedNativeWidgetImpl* bridge =
|
||||
BridgedNativeWidgetImpl::GetFromNativeWindow(dialog->GetNativeWindow());
|
||||
BridgedNativeWidgetHostImpl* bridge_host =
|
||||
BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
dialog->GetNativeWindow());
|
||||
|
||||
EXPECT_EQ(bridge->parent()->ns_window(), parent);
|
||||
EXPECT_EQ(bridge_host->parent()->native_widget_mac()->GetNativeWindow(),
|
||||
parent);
|
||||
Widget::ReparentNativeView(dialog->GetNativeView(), [parent contentView]);
|
||||
EXPECT_EQ(bridge->parent()->ns_window(), parent);
|
||||
EXPECT_EQ(bridge_host->parent()->native_widget_mac()->GetNativeWindow(),
|
||||
parent);
|
||||
|
||||
[parent close];
|
||||
|
||||
Widget* parent_widget = CreateNativeDesktopWidget();
|
||||
parent = parent_widget->GetNativeWindow();
|
||||
parent = parent_widget->GetNativeWindow().GetNativeNSWindow();
|
||||
dialog = views::DialogDelegate::CreateDialogWidget(
|
||||
new DialogDelegateView, nullptr, [parent contentView]);
|
||||
bridge =
|
||||
BridgedNativeWidgetImpl::GetFromNativeWindow(dialog->GetNativeWindow());
|
||||
bridge_host = BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
dialog->GetNativeWindow());
|
||||
|
||||
EXPECT_EQ(bridge->parent()->ns_window(), parent);
|
||||
EXPECT_EQ(bridge_host->parent()->native_widget_mac()->GetNativeWindow(),
|
||||
parent);
|
||||
Widget::ReparentNativeView(dialog->GetNativeView(), [parent contentView]);
|
||||
EXPECT_EQ(bridge->parent()->ns_window(), parent);
|
||||
EXPECT_EQ(bridge_host->parent()->native_widget_mac()->GetNativeWindow(),
|
||||
parent);
|
||||
|
||||
parent_widget->CloseNow();
|
||||
}
|
||||
@ -1567,7 +1594,8 @@ class ParentCloseMonitor : public WidgetObserver {
|
||||
// NSWindow parent/child relationship should be established on Show() and
|
||||
// the parent should have a delegate. Retain the parent since it can't be
|
||||
// retrieved from the child while it is being destroyed.
|
||||
parent_nswindow_.reset([[child->GetNativeWindow() parentWindow] retain]);
|
||||
parent_nswindow_.reset(
|
||||
[[child->GetNativeWindow().GetNativeNSWindow() parentWindow] retain]);
|
||||
EXPECT_TRUE(parent_nswindow_);
|
||||
EXPECT_TRUE([parent_nswindow_ delegate]);
|
||||
}
|
||||
@ -1581,7 +1609,7 @@ class ParentCloseMonitor : public WidgetObserver {
|
||||
// (it's removed just after OnWidgetDestroying() returns). The parent should
|
||||
// still be open (children are always closed first), but not have a delegate
|
||||
// (since it is being torn down).
|
||||
EXPECT_TRUE([child->GetNativeWindow() parentWindow]);
|
||||
EXPECT_TRUE([child->GetNativeWindow().GetNativeNSWindow() parentWindow]);
|
||||
EXPECT_TRUE([parent_nswindow_ isVisible]);
|
||||
EXPECT_FALSE([parent_nswindow_ delegate]);
|
||||
|
||||
@ -1589,7 +1617,7 @@ class ParentCloseMonitor : public WidgetObserver {
|
||||
}
|
||||
|
||||
void OnWidgetDestroyed(Widget* child) override {
|
||||
EXPECT_FALSE([child->GetNativeWindow() parentWindow]);
|
||||
EXPECT_FALSE([child->GetNativeWindow().GetNativeNSWindow() parentWindow]);
|
||||
EXPECT_TRUE([parent_nswindow_ isVisible]);
|
||||
EXPECT_FALSE([parent_nswindow_ delegate]);
|
||||
|
||||
@ -1617,7 +1645,7 @@ TEST_F(NativeWidgetMacTest, NoParentDelegateDuringTeardown) {
|
||||
parent->SetBounds(gfx::Rect(100, 100, 300, 200));
|
||||
parent->Show();
|
||||
ParentCloseMonitor monitor(parent);
|
||||
[parent->GetNativeWindow() close];
|
||||
[parent->GetNativeWindow().GetNativeNSWindow() close];
|
||||
EXPECT_TRUE(monitor.child_closed());
|
||||
}
|
||||
|
||||
@ -1650,37 +1678,48 @@ TEST_F(NativeWidgetMacTest, NoParentDelegateDuringTeardown) {
|
||||
TEST_F(NativeWidgetMacTest, NativeProperties) {
|
||||
// Create a regular widget (TYPE_WINDOW).
|
||||
Widget* regular_widget = CreateNativeDesktopWidget();
|
||||
EXPECT_TRUE([regular_widget->GetNativeWindow() canBecomeKeyWindow]);
|
||||
EXPECT_TRUE([regular_widget->GetNativeWindow() canBecomeMainWindow]);
|
||||
EXPECT_TRUE([regular_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeKeyWindow]);
|
||||
EXPECT_TRUE([regular_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeMainWindow]);
|
||||
|
||||
// Disabling activation should prevent key and main status.
|
||||
regular_widget->widget_delegate()->set_can_activate(false);
|
||||
EXPECT_FALSE([regular_widget->GetNativeWindow() canBecomeKeyWindow]);
|
||||
EXPECT_FALSE([regular_widget->GetNativeWindow() canBecomeMainWindow]);
|
||||
EXPECT_FALSE([regular_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeKeyWindow]);
|
||||
EXPECT_FALSE([regular_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeMainWindow]);
|
||||
|
||||
// Create a dialog widget (also TYPE_WINDOW), but with a DialogDelegate.
|
||||
Widget* dialog_widget = views::DialogDelegate::CreateDialogWidget(
|
||||
new ModalDialogDelegate(ui::MODAL_TYPE_CHILD), nullptr,
|
||||
regular_widget->GetNativeView());
|
||||
EXPECT_TRUE([dialog_widget->GetNativeWindow() canBecomeKeyWindow]);
|
||||
EXPECT_TRUE([dialog_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeKeyWindow]);
|
||||
// Dialogs shouldn't take main status away from their parent.
|
||||
EXPECT_FALSE([dialog_widget->GetNativeWindow() canBecomeMainWindow]);
|
||||
EXPECT_FALSE([dialog_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeMainWindow]);
|
||||
|
||||
// Create a bubble widget with a parent: also shouldn't get main.
|
||||
BubbleDialogDelegateView* bubble_view = new SimpleBubbleView();
|
||||
bubble_view->set_parent_window(regular_widget->GetNativeView());
|
||||
Widget* bubble_widget = BubbleDialogDelegateView::CreateBubble(bubble_view);
|
||||
EXPECT_TRUE([bubble_widget->GetNativeWindow() canBecomeKeyWindow]);
|
||||
EXPECT_FALSE([bubble_widget->GetNativeWindow() canBecomeMainWindow]);
|
||||
EXPECT_TRUE([bubble_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeKeyWindow]);
|
||||
EXPECT_FALSE([bubble_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeMainWindow]);
|
||||
EXPECT_EQ(NSWindowCollectionBehaviorTransient,
|
||||
[bubble_widget->GetNativeWindow() collectionBehavior] &
|
||||
[bubble_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
collectionBehavior] &
|
||||
NSWindowCollectionBehaviorTransient);
|
||||
|
||||
// But a bubble without a parent should still be able to become main.
|
||||
Widget* toplevel_bubble_widget =
|
||||
BubbleDialogDelegateView::CreateBubble(new SimpleBubbleView());
|
||||
EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeKeyWindow]);
|
||||
EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow() canBecomeMainWindow]);
|
||||
EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeKeyWindow]);
|
||||
EXPECT_TRUE([toplevel_bubble_widget->GetNativeWindow().GetNativeNSWindow()
|
||||
canBecomeMainWindow]);
|
||||
|
||||
toplevel_bubble_widget->CloseNow();
|
||||
regular_widget->CloseNow();
|
||||
@ -1744,7 +1783,7 @@ TEST_F(NativeWidgetMacTest, DISABLED_DoesHideTitle) {
|
||||
widget->Init(params);
|
||||
widget->Show();
|
||||
|
||||
NSWindow* ns_window = widget->GetNativeWindow();
|
||||
NSWindow* ns_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
// Disable color correction so we can read unmodified values from the bitmap.
|
||||
[ns_window setColorSpace:[NSColorSpace sRGBColorSpace]];
|
||||
|
||||
@ -1866,7 +1905,7 @@ TEST_F(NativeWidgetMacTest, GetWorkAreaBoundsInScreen) {
|
||||
EXPECT_FALSE(NSIsEmptyRect(actual));
|
||||
EXPECT_NSEQ(expected, actual);
|
||||
|
||||
[widget.GetNativeWindow() close];
|
||||
[widget.GetNativeWindow().GetNativeNSWindow() close];
|
||||
actual = gfx::ScreenRectToNSRect(widget.GetWorkAreaBoundsInScreen());
|
||||
EXPECT_TRUE(NSIsEmptyRect(actual));
|
||||
}
|
||||
@ -1874,7 +1913,7 @@ TEST_F(NativeWidgetMacTest, GetWorkAreaBoundsInScreen) {
|
||||
// Test that Widget opacity can be changed.
|
||||
TEST_F(NativeWidgetMacTest, ChangeOpacity) {
|
||||
Widget* widget = CreateTopLevelPlatformWidget();
|
||||
NSWindow* ns_window = widget->GetNativeWindow();
|
||||
NSWindow* ns_window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
CGFloat old_opacity = [ns_window alphaValue];
|
||||
widget->SetOpacity(.7f);
|
||||
@ -1895,7 +1934,7 @@ TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Titled) {
|
||||
|
||||
// Setup the mock content view for the NSWindow, so that we can intercept
|
||||
// drawRect.
|
||||
NSWindow* window = widget->GetNativeWindow();
|
||||
NSWindow* window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<MockBridgedView> mock_bridged_view(
|
||||
[[MockBridgedView alloc] init]);
|
||||
// Reset drawRect count.
|
||||
@ -1941,7 +1980,7 @@ TEST_F(NativeWidgetMacTest, SchedulePaintInRect_Borderless) {
|
||||
|
||||
// Setup the mock content view for the NSWindow, so that we can intercept
|
||||
// drawRect.
|
||||
NSWindow* window = widget->GetNativeWindow();
|
||||
NSWindow* window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
base::scoped_nsobject<MockBridgedView> mock_bridged_view(
|
||||
[[MockBridgedView alloc] init]);
|
||||
// Reset drawRect count.
|
||||
@ -1983,8 +2022,8 @@ TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) {
|
||||
widget->Show();
|
||||
|
||||
base::scoped_nsobject<NSView> child_view([[FocusableTestNSView alloc]
|
||||
initWithFrame:[widget->GetNativeView() bounds]]);
|
||||
[widget->GetNativeView() addSubview:child_view];
|
||||
initWithFrame:[widget->GetNativeView().GetNativeNSView() bounds]]);
|
||||
[widget->GetNativeView().GetNativeNSView() addSubview:child_view];
|
||||
EXPECT_TRUE([child_view acceptsFirstResponder]);
|
||||
EXPECT_TRUE(widget->GetRootView()->IsFocusable());
|
||||
|
||||
@ -1992,10 +2031,11 @@ TEST_F(NativeWidgetMacTest, ChangeFocusOnChangeFirstResponder) {
|
||||
manager->SetFocusedView(widget->GetRootView());
|
||||
EXPECT_EQ(manager->GetFocusedView(), widget->GetRootView());
|
||||
|
||||
[widget->GetNativeWindow() makeFirstResponder:child_view];
|
||||
[widget->GetNativeWindow().GetNativeNSWindow() makeFirstResponder:child_view];
|
||||
EXPECT_FALSE(manager->GetFocusedView());
|
||||
|
||||
[widget->GetNativeWindow() makeFirstResponder:widget->GetNativeView()];
|
||||
[widget->GetNativeWindow().GetNativeNSWindow()
|
||||
makeFirstResponder:widget->GetNativeView().GetNativeNSView()];
|
||||
EXPECT_EQ(manager->GetFocusedView(), widget->GetRootView());
|
||||
|
||||
widget->CloseNow();
|
||||
@ -2013,7 +2053,7 @@ TEST_F(NativeWidgetMacTest, ReparentNativeViewBounds) {
|
||||
widget->Init(params);
|
||||
widget->SetContentsView(new View);
|
||||
|
||||
NSView* child_view = widget->GetNativeView();
|
||||
NSView* child_view = widget->GetNativeView().GetNativeNSView();
|
||||
Widget::ReparentNativeView(child_view, parent->GetNativeView());
|
||||
|
||||
// Reparented content view has the size of the Widget that created it.
|
||||
@ -2026,13 +2066,13 @@ TEST_F(NativeWidgetMacTest, ReparentNativeViewBounds) {
|
||||
NSRect native_parent_rect = NSMakeRect(50, 100, 200, 70);
|
||||
base::scoped_nsobject<NSView> native_parent(
|
||||
[[NSView alloc] initWithFrame:native_parent_rect]);
|
||||
[parent->GetNativeView() addSubview:native_parent];
|
||||
[parent->GetNativeView().GetNativeNSView() addSubview:native_parent];
|
||||
|
||||
gfx::Rect screen_rect = widget->GetWindowBoundsInScreen();
|
||||
EXPECT_EQ(100, screen_rect.x());
|
||||
EXPECT_EQ(100, screen_rect.y());
|
||||
|
||||
Widget::ReparentNativeView(child_view, native_parent);
|
||||
Widget::ReparentNativeView(child_view, native_parent.get());
|
||||
widget->SetBounds(widget_rect);
|
||||
screen_rect = widget->GetWindowBoundsInScreen();
|
||||
EXPECT_EQ(150, screen_rect.x());
|
||||
@ -2061,21 +2101,21 @@ TEST_F(NativeWidgetMacTest, ReparentNativeViewTypes) {
|
||||
|
||||
Widget::ReparentNativeView(child->GetNativeView(),
|
||||
toplevel1->GetNativeView());
|
||||
EXPECT_EQ([child->GetNativeView() window],
|
||||
[toplevel1->GetNativeView() window]);
|
||||
EXPECT_EQ(0, [child->GetNativeWindow() alphaValue]);
|
||||
EXPECT_EQ([child->GetNativeView().GetNativeNSView() window],
|
||||
[toplevel1->GetNativeView().GetNativeNSView() window]);
|
||||
EXPECT_EQ(0, [child->GetNativeWindow().GetNativeNSWindow() alphaValue]);
|
||||
|
||||
Widget::ReparentNativeView(child->GetNativeView(),
|
||||
toplevel2->GetNativeView());
|
||||
EXPECT_EQ([child->GetNativeView() window],
|
||||
[toplevel2->GetNativeView() window]);
|
||||
EXPECT_EQ(0, [child->GetNativeWindow() alphaValue]);
|
||||
EXPECT_NE(0, [toplevel1->GetNativeWindow() alphaValue]);
|
||||
EXPECT_EQ([child->GetNativeView().GetNativeNSView() window],
|
||||
[toplevel2->GetNativeView().GetNativeNSView() window]);
|
||||
EXPECT_EQ(0, [child->GetNativeWindow().GetNativeNSWindow() alphaValue]);
|
||||
EXPECT_NE(0, [toplevel1->GetNativeWindow().GetNativeNSWindow() alphaValue]);
|
||||
|
||||
Widget::ReparentNativeView(toplevel2->GetNativeView(),
|
||||
toplevel1->GetNativeView());
|
||||
EXPECT_EQ([toplevel2->GetNativeWindow() parentWindow],
|
||||
[toplevel1->GetNativeView() window]);
|
||||
EXPECT_EQ([toplevel2->GetNativeWindow().GetNativeNSWindow() parentWindow],
|
||||
[toplevel1->GetNativeView().GetNativeNSView() window]);
|
||||
}
|
||||
|
||||
// Test class for Full Keyboard Access related tests.
|
||||
@ -2089,8 +2129,9 @@ class NativeWidgetMacFullKeyboardAccessTest : public NativeWidgetMacTest {
|
||||
NativeWidgetMacTest::SetUp();
|
||||
|
||||
widget_ = CreateTopLevelPlatformWidget();
|
||||
bridge_ = BridgedNativeWidgetImpl::GetFromNativeWindow(
|
||||
widget_->GetNativeWindow());
|
||||
bridge_ = BridgedNativeWidgetHostImpl::GetFromNativeWindow(
|
||||
widget_->GetNativeWindow())
|
||||
->bridge_impl();
|
||||
fake_full_keyboard_access_ =
|
||||
ui::test::ScopedFakeFullKeyboardAccess::GetInstance();
|
||||
DCHECK(fake_full_keyboard_access_);
|
||||
@ -2165,7 +2206,8 @@ class NativeWidgetMacViewsOrderTest : public WidgetTest {
|
||||
// It's not a bug if the native view has a different number of subviews,
|
||||
// but the rest of this test assumes it. It may or may not be worth
|
||||
// removing that assumption at some point.
|
||||
ASSERT_EQ(0u, [[widget_->GetNativeView() subviews] count]);
|
||||
ASSERT_EQ(0u,
|
||||
[[widget_->GetNativeView().GetNativeNSView() subviews] count]);
|
||||
|
||||
native_host_parent_ = new View();
|
||||
widget_->GetContentsView()->AddChildView(native_host_parent_);
|
||||
@ -2178,7 +2220,7 @@ class NativeWidgetMacViewsOrderTest : public WidgetTest {
|
||||
hosts_.push_back(std::move(holder));
|
||||
}
|
||||
EXPECT_EQ(kNativeViewCount, native_host_parent_->child_count());
|
||||
EXPECT_NSEQ([widget_->GetNativeView() subviews],
|
||||
EXPECT_NSEQ([widget_->GetNativeView().GetNativeNSView() subviews],
|
||||
(@[ hosts_[0]->view(), hosts_[1]->view(), hosts_[2]->view() ]));
|
||||
}
|
||||
|
||||
@ -2187,7 +2229,9 @@ class NativeWidgetMacViewsOrderTest : public WidgetTest {
|
||||
WidgetTest::TearDown();
|
||||
}
|
||||
|
||||
NSView* GetContentNativeView() { return widget_->GetNativeView(); }
|
||||
NSView* GetContentNativeView() {
|
||||
return widget_->GetNativeView().GetNativeNSView();
|
||||
}
|
||||
|
||||
Widget* widget_ = nullptr;
|
||||
View* native_host_parent_ = nullptr;
|
||||
@ -2253,7 +2297,7 @@ TEST_F(NativeWidgetMacTest, CanClose) {
|
||||
ModalDialogDelegate* delegate = new ModalDialogDelegate(ui::MODAL_TYPE_NONE);
|
||||
Widget* widget =
|
||||
views::DialogDelegate::CreateDialogWidget(delegate, nullptr, nullptr);
|
||||
NSWindow* window = widget->GetNativeWindow();
|
||||
NSWindow* window = widget->GetNativeWindow().GetNativeNSWindow();
|
||||
delegate->set_can_close(false);
|
||||
EXPECT_FALSE([[window delegate] windowShouldClose:window]);
|
||||
delegate->set_can_close(true);
|
||||
@ -2294,7 +2338,9 @@ TEST_F(NativeWidgetMacTest, TouchBar) {
|
||||
ModalDialogDelegate* delegate = new ModalDialogDelegate(ui::MODAL_TYPE_NONE);
|
||||
views::DialogDelegate::CreateDialogWidget(delegate, nullptr, nullptr);
|
||||
DialogClientView* client_view = delegate->GetDialogClientView();
|
||||
NSView* content = [delegate->GetWidget()->GetNativeWindow() contentView];
|
||||
NSView* content =
|
||||
[delegate->GetWidget()->GetNativeWindow().GetNativeNSWindow()
|
||||
contentView];
|
||||
|
||||
NSString* principal = nil;
|
||||
NSObject* old_touch_bar = nil;
|
||||
|
@ -62,7 +62,7 @@ class NativeWidgetTest : public ViewsTestBase {
|
||||
|
||||
TEST_F(NativeWidgetTest, CreateNativeWidget) {
|
||||
ScopedTestWidget widget(CreateNativeWidget());
|
||||
EXPECT_TRUE(widget->GetWidget()->GetNativeView() != NULL);
|
||||
EXPECT_TRUE(widget->GetWidget()->GetNativeView());
|
||||
}
|
||||
|
||||
TEST_F(NativeWidgetTest, GetNativeWidgetForNativeView) {
|
||||
|
@ -1064,7 +1064,7 @@ TEST_F(WidgetTestInteractive, WindowModalWindowDestroyedActivationTest) {
|
||||
|
||||
gfx::NativeView modal_native_view = modal_dialog_widget->GetNativeView();
|
||||
ASSERT_EQ(3u, focus_changes.size());
|
||||
EXPECT_EQ(nullptr, focus_changes[1]);
|
||||
EXPECT_EQ(gfx::kNullNativeView, focus_changes[1]);
|
||||
EXPECT_EQ(modal_native_view, focus_changes[2]);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@ -1078,7 +1078,7 @@ TEST_F(WidgetTestInteractive, WindowModalWindowDestroyedActivationTest) {
|
||||
#endif
|
||||
|
||||
ASSERT_EQ(5u, focus_changes.size());
|
||||
EXPECT_EQ(nullptr, focus_changes[3]);
|
||||
EXPECT_EQ(gfx::kNullNativeView, focus_changes[3]);
|
||||
EXPECT_EQ(top_level_native_view, focus_changes[4]);
|
||||
|
||||
top_level_widget.CloseNow();
|
||||
|
@ -1806,8 +1806,9 @@ TEST_F(WidgetTest, MousePressCausesCapture) {
|
||||
widget->GetRootView()->AddChildView(event_count_view);
|
||||
|
||||
// No capture has been set.
|
||||
EXPECT_EQ(nullptr, internal::NativeWidgetPrivate::GetGlobalCapture(
|
||||
widget->GetNativeView()));
|
||||
EXPECT_EQ(
|
||||
gfx::kNullNativeView,
|
||||
internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView()));
|
||||
|
||||
MousePressEventConsumer consumer;
|
||||
event_count_view->AddPostTargetHandler(&consumer);
|
||||
@ -1867,8 +1868,9 @@ TEST_F(WidgetTest, CaptureDuringMousePressNotOverridden) {
|
||||
event_count_view->SetBounds(0, 0, 300, 300);
|
||||
widget->GetRootView()->AddChildView(event_count_view);
|
||||
|
||||
EXPECT_EQ(nullptr, internal::NativeWidgetPrivate::GetGlobalCapture(
|
||||
widget->GetNativeView()));
|
||||
EXPECT_EQ(
|
||||
gfx::kNullNativeView,
|
||||
internal::NativeWidgetPrivate::GetGlobalCapture(widget->GetNativeView()));
|
||||
|
||||
Widget* widget2 = CreateTopLevelNativeWidget();
|
||||
// Gives explicit capture to |widget2|
|
||||
|
@ -11,7 +11,7 @@ namespace views {
|
||||
gfx::Size GetWindowSizeForClientSize(Widget* widget, const gfx::Size& size) {
|
||||
DCHECK(widget);
|
||||
return BridgedNativeWidgetImpl::GetWindowSizeForClientSize(
|
||||
widget->GetNativeWindow(), size);
|
||||
widget->GetNativeWindow().GetNativeNSWindow(), size);
|
||||
}
|
||||
|
||||
} // namespace views
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user