• tapted's avatar
    Mac/Linux: Ensure window size constraints propagate to the window server during Init · c0704963
    tapted authored
    Currently fixed-size views dialogs on Mac don't initialize properly.
    (And, e.g., WebDialogBrowserTest.SizeWindow fails because of it).
    Desktop Linux has a similar issue.
    
    On desktop Linux, NativeWidgetPrivate::OnRootViewLayout triggers a call
    to UpdateMinAndMaxSize. OnRootViewLayout happens during Widget::Init()
    but the X11 window is not yet mapped, so this was resulting in a no-op.
    For Linux, fix by explicitly calling UpdateMinAndMaxSize after the
    window is mapped.
    
    Mac needs to do a similar thing during Init. However, Mac was calling
    OnSizeConstraintsChanged() before Widget::Init() had set the non-client
    view, so Widget::GetMinimumSize() returned invalid sizes. For Mac, move
    the OnSizeConstraintsChanged() call to OnRootViewLayout(), similar to
    Linux.
    
    Then, add a cross-platform test. Mac was not clamping to the size
    constraints in SetBounds(), so do that.
    
    For the test itself, collapse the testing WidgetDelegates in
    widget_unittest.cc into one helper class rather than adding yet another
    WidgetDelegate. Then, provide a way to query the OS for the minimum
    window size to fill the gaps required for testing the propagation of
    size constraints to the window server.
    
    BUG=454698, 447086
    
    Review URL: https://codereview.chromium.org/1059853007
    
    Cr-Commit-Position: refs/heads/master@{#325538}
    c0704963
bridged_native_widget.mm 31.1 KB