Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ui/views/cocoa/bridged_native_widget.h" | 5 #import "ui/views/cocoa/bridged_native_widget.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 | 551 |
| 552 void BridgedNativeWidget::SetVisibilityState(WindowVisibilityState new_state) { | 552 void BridgedNativeWidget::SetVisibilityState(WindowVisibilityState new_state) { |
| 553 // Ensure that: | 553 // Ensure that: |
| 554 // - A window with an invisible parent is not made visible. | 554 // - A window with an invisible parent is not made visible. |
| 555 // - A parent changing visibility updates child window visibility. | 555 // - A parent changing visibility updates child window visibility. |
| 556 // * But only when changed via this function - ignore changes via the | 556 // * But only when changed via this function - ignore changes via the |
| 557 // NSWindow API, or changes propagating out from here. | 557 // NSWindow API, or changes propagating out from here. |
| 558 wants_to_be_visible_ = new_state != HIDE_WINDOW; | 558 wants_to_be_visible_ = new_state != HIDE_WINDOW; |
| 559 | 559 |
| 560 if (new_state == HIDE_WINDOW) { | 560 if (new_state == HIDE_WINDOW) { |
| 561 // Calling -orderOut: on a window with an attached sheet encounters broken | |
| 562 // AppKit behavior. The sheet effectively becomes "lost". | |
| 563 // See http://crbug.com/667602. Alternatives: call -setAlphaValue:0 and | |
| 564 // -setIgnoresMouseEvents:YES on the NSWindow, or dismiss the sheet before | |
| 565 // hiding. | |
| 566 DCHECK(![window_ attachedSheet]); | |
|
karandeepb
2016/11/28 05:19:32
Won't this trigger for the case given in issue 667
tapted
2016/11/28 06:15:41
Yes, but only with chrome://flags/#mac-views-nativ
karandeepb
2016/11/28 23:37:57
Acknowledged.
| |
| 567 | |
| 561 [window_ orderOut:nil]; | 568 [window_ orderOut:nil]; |
| 562 DCHECK(!window_visible_); | 569 DCHECK(!window_visible_); |
| 563 return; | 570 return; |
| 564 } | 571 } |
| 565 | 572 |
| 566 DCHECK(wants_to_be_visible_); | 573 DCHECK(wants_to_be_visible_); |
| 567 // If the parent (or an ancestor) is hidden, return and wait for it to become | 574 // If the parent (or an ancestor) is hidden, return and wait for it to become |
| 568 // visible. | 575 // visible. |
| 569 if (parent() && !parent()->IsVisibleParent()) | 576 if (parent() && !parent()->IsVisibleParent()) |
| 570 return; | 577 return; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 820 | 827 |
| 821 window_visible_ = window_visible; | 828 window_visible_ = window_visible; |
| 822 | 829 |
| 823 // If arriving via SetVisible(), |wants_to_be_visible_| should already be set. | 830 // If arriving via SetVisible(), |wants_to_be_visible_| should already be set. |
| 824 // If made visible externally (e.g. Cmd+H), just roll with it. Don't try (yet) | 831 // If made visible externally (e.g. Cmd+H), just roll with it. Don't try (yet) |
| 825 // to distinguish being *hidden* externally from being hidden by a parent | 832 // to distinguish being *hidden* externally from being hidden by a parent |
| 826 // window - we might not need that. | 833 // window - we might not need that. |
| 827 if (window_visible_) { | 834 if (window_visible_) { |
| 828 wants_to_be_visible_ = true; | 835 wants_to_be_visible_ = true; |
| 829 | 836 |
| 830 if (parent_) | 837 // Sheets don't need a parentWindow set, and setting one causes graphical |
| 838 // glitches (http://crbug.com/605098). | |
|
karandeepb
2016/11/28 05:19:32
I can't see it being concluded on issue 605098 tha
tapted
2016/11/28 06:15:41
Yup :). Turns out this was the culprit. It went aw
karandeepb
2016/11/28 23:37:57
Acknowledged. Maybe mention this explicitly in the
tapted
2016/11/29 03:28:51
Done.
| |
| 839 if (parent_ && ![window_ isSheet]) | |
| 831 [parent_->GetNSWindow() addChildWindow:window_ ordered:NSWindowAbove]; | 840 [parent_->GetNSWindow() addChildWindow:window_ ordered:NSWindowAbove]; |
| 832 } else { | 841 } else { |
| 833 ReleaseCapture(); // Capture on hidden windows is not permitted. | 842 ReleaseCapture(); // Capture on hidden windows is not permitted. |
| 834 | 843 |
| 835 // When becoming invisible, remove the entry in any parent's childWindow | 844 // When becoming invisible, remove the entry in any parent's childWindow |
| 836 // list. Cocoa's childWindow management breaks down when child windows are | 845 // list. Cocoa's childWindow management breaks down when child windows are |
| 837 // hidden. | 846 // hidden. |
| 838 if (parent_) | 847 if (parent_) |
| 839 [parent_->GetNSWindow() removeChildWindow:window_]; | 848 [parent_->GetNSWindow() removeChildWindow:window_]; |
| 840 } | 849 } |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1418 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1410 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1419 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1411 // changes. Previously we tried adding an NSView and removing it, but for some | 1420 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1412 // reason it required reposting the mouse-down event, and didn't always work. | 1421 // reason it required reposting the mouse-down event, and didn't always work. |
| 1413 // Calling the below seems to be an effective solution. | 1422 // Calling the below seems to be an effective solution. |
| 1414 [window_ setMovableByWindowBackground:NO]; | 1423 [window_ setMovableByWindowBackground:NO]; |
| 1415 [window_ setMovableByWindowBackground:YES]; | 1424 [window_ setMovableByWindowBackground:YES]; |
| 1416 } | 1425 } |
| 1417 | 1426 |
| 1418 } // namespace views | 1427 } // namespace views |
| OLD | NEW |