• tapted's avatar
    MacViews: Implement NativeViewHostMac (take 3) · 5ee3db98
    tapted authored
    This is done in a comparable way to NativeViewHostAura, but using a
    ReparentNSView helper function which reparents an NSView to a
    NativeWidgetMac's BridgedContentView (or to `nil`).
    
    Earlier attempts tried to use NativeWidgetPrivate::ReparentNativeView()
    which turns out to be a bad idea, since it's really designed to reparent
    windows (aura::Windows or HWNDs). Mac's child window support is
    insufficient for what toolkit-views expects, and WebContents on Mac are
    managed by an NSView in any case, not an NSWindow.
    
    Along with logic currently in render_widget_host_view_mac.mm and
    web_contents_view_mac.mm, reparenting renderer views needs to be done in
    the native view hierarchy, not the window hierarchy.
    
    This CL no longer tries to enable the current
    native_view_host_unittest.cc (tests there assume ReparentNativeView is
    used), but adds native_view_host_mac_unittest.mm to give test coverage,
    and to inspect properties at the Cocoa layer. Common parts of the 3
    _unittest.* files are refactored into a NativeViewHostTestBase class.
    
    Some other views_unittests are also made passing by implementing a
    NativeViewHost::CreateWrapper that doesn't just return NULL:
    4xFocusTraverslTest and NativeWidgetTest.GetTopLevelNativeWidget2
    
    Before: 455 tests run 22 tests failed 21 tests crashed. After: 458 tests
    run 22 tests failed 16 tests crashed.
    
    BUG=378134, 415024
    
    Review URL: https://codereview.chromium.org/530933002
    
    Cr-Commit-Position: refs/heads/master@{#295618}
    5ee3db98
native_view_host.h 5.17 KB