MacViews: Fix Child window Visibility, implement Hide()
commitdfb37010ac9cd7235de27c3269ebd12ba708dedd
authortapted <tapted@chromium.org>
Tue, 2 Dec 2014 05:06:09 +0000 (1 21:06 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 2 Dec 2014 05:06:48 +0000 (2 05:06 +0000)
tree4b89a19a0678e289cb9cf8f7ec8275ed57996ef5
parent73ac03596540af49fd3c0e0b064eb44b1d57233a
MacViews: Fix Child window Visibility, implement Hide()

Visibility is managed by BridgedNativeWidget (similar to aura::Window).

BridgedNativeWidget::SetVisible(bool visible, bool activate) is added,
and a `wants_to_be_visible_` tracks the visibility of a child that
is hidden due to having a hidden parent window.

Gets 3 tests passing, and adds 2 new (passing) tests, and regresses 2
tests.
Now passing:
- WidgetTest.TestRootViewHandlersWhenHidden
- WidgetTest.TestWindowVisibilityAfterHide
- WidgetTest.Visibility

InactiveWidgetDoesNotGrabActivation regresses because activation on
desktop properly needs an interactive_ui_test. On linux/win the test
only runs with non-desktop aura windows (which use per-process
wm::IsActiveWindow() rather than desktop_window_tree_host_->
IsActive()).

I need to fix IsActive() anyway, so I'll make sure there is an
equivalent OS-specific test that knows how to wait for activation.
(e.g. Linux uses an X11PropertyChangeWaiter in
desktop_window_tree_host_x11_interactive_uitest).

BubbleDelegateTest.VisibleWhenAnchorWidgetBoundsChanged also regresses.
Bubbles created in BubbleDelegateTest have a parent widget that is never
made visible. But they also have a layer, which IsDrawn().
aura::Window::IsVisible goes

  for (const Window* window = this; window; window = window->parent()) {
    if (!window->visible_)
       return false;
    if (window->layer())
      return window->layer()->IsDrawn();
  }

so returns early when the visible layer is found, before encountering
the non-visible parent. Adding a widget->Show() in BubbleDelegateTest::
CreateTestWidget() would fix it for Mac, and is probably warranted, but
needs more investigation.

BUG=378134
TEST=New/Updated: WidgetObserverTest.ClosingOnHiddenParent,
NativeWidgetMacTest.HideAndShowExternally, WidgetTest.Visibility
views_unittests: 471 tests run. 22 fail. 16 crash.

Review URL: https://codereview.chromium.org/748693002

Cr-Commit-Position: refs/heads/master@{#306349}
ui/views/cocoa/bridged_native_widget.h
ui/views/cocoa/bridged_native_widget.mm
ui/views/cocoa/bridged_native_widget_unittest.mm
ui/views/cocoa/native_widget_mac_nswindow.h [new file with mode: 0644]
ui/views/cocoa/native_widget_mac_nswindow.mm [new file with mode: 0644]
ui/views/cocoa/views_nswindow_delegate.h
ui/views/cocoa/views_nswindow_delegate.mm
ui/views/views.gyp
ui/views/widget/native_widget_mac.mm
ui/views/widget/native_widget_mac_unittest.mm [new file with mode: 0644]
ui/views/widget/widget_unittest.cc