| 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/widget/native_widget_mac.h" | 5 #import "ui/views/widget/native_widget_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 // cleared when the child is destroyed. This assumes the child is destroyed via | 1158 // cleared when the child is destroyed. This assumes the child is destroyed via |
| 1159 // destruction of its parent. | 1159 // destruction of its parent. |
| 1160 class ParentCloseMonitor : public WidgetObserver { | 1160 class ParentCloseMonitor : public WidgetObserver { |
| 1161 public: | 1161 public: |
| 1162 explicit ParentCloseMonitor(Widget* parent) { | 1162 explicit ParentCloseMonitor(Widget* parent) { |
| 1163 Widget* child = new Widget(); | 1163 Widget* child = new Widget(); |
| 1164 child->AddObserver(this); | 1164 child->AddObserver(this); |
| 1165 Widget::InitParams init_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 1165 Widget::InitParams init_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 1166 init_params.parent = parent->GetNativeView(); | 1166 init_params.parent = parent->GetNativeView(); |
| 1167 init_params.bounds = gfx::Rect(100, 100, 100, 100); | 1167 init_params.bounds = gfx::Rect(100, 100, 100, 100); |
| 1168 init_params.native_widget = | 1168 init_params.native_widget = CreatePlatformNativeWidgetImpl( |
| 1169 CreatePlatformNativeWidgetImpl(init_params, child, kStubCapture, | 1169 init_params, child, kStubCapture, nullptr); |
| 1170 nullptr); | |
| 1171 child->Init(init_params); | 1170 child->Init(init_params); |
| 1172 child->Show(); | 1171 child->Show(); |
| 1173 | 1172 |
| 1174 // NSWindow parent/child relationship should be established on Show() and | 1173 // NSWindow parent/child relationship should be established on Show() and |
| 1175 // the parent should have a delegate. Retain the parent since it can't be | 1174 // the parent should have a delegate. Retain the parent since it can't be |
| 1176 // retrieved from the child while it is being destroyed. | 1175 // retrieved from the child while it is being destroyed. |
| 1177 parent_nswindow_.reset([[child->GetNativeWindow() parentWindow] retain]); | 1176 parent_nswindow_.reset([[child->GetNativeWindow() parentWindow] retain]); |
| 1178 EXPECT_TRUE(parent_nswindow_); | 1177 EXPECT_TRUE(parent_nswindow_); |
| 1179 EXPECT_TRUE([parent_nswindow_ delegate]); | 1178 EXPECT_TRUE([parent_nswindow_ delegate]); |
| 1180 } | 1179 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 | 1333 |
| 1335 DISALLOW_COPY_AND_ASSIGN(CustomTitleWidgetDelegate); | 1334 DISALLOW_COPY_AND_ASSIGN(CustomTitleWidgetDelegate); |
| 1336 }; | 1335 }; |
| 1337 | 1336 |
| 1338 // Test that undocumented title-hiding API we're using does the job. | 1337 // Test that undocumented title-hiding API we're using does the job. |
| 1339 TEST_F(NativeWidgetMacTest, DoesHideTitle) { | 1338 TEST_F(NativeWidgetMacTest, DoesHideTitle) { |
| 1340 // Same as CreateTopLevelPlatformWidget but with a custom delegate. | 1339 // Same as CreateTopLevelPlatformWidget but with a custom delegate. |
| 1341 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 1340 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 1342 Widget* widget = new Widget; | 1341 Widget* widget = new Widget; |
| 1343 params.native_widget = | 1342 params.native_widget = |
| 1344 CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr); | 1343 CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr); |
| 1345 CustomTitleWidgetDelegate delegate(widget); | 1344 CustomTitleWidgetDelegate delegate(widget); |
| 1346 params.delegate = &delegate; | 1345 params.delegate = &delegate; |
| 1347 params.bounds = gfx::Rect(0, 0, 800, 600); | 1346 params.bounds = gfx::Rect(0, 0, 800, 600); |
| 1348 widget->Init(params); | 1347 widget->Init(params); |
| 1349 widget->Show(); | 1348 widget->Show(); |
| 1350 | 1349 |
| 1351 NSWindow* ns_window = widget->GetNativeWindow(); | 1350 NSWindow* ns_window = widget->GetNativeWindow(); |
| 1352 // Disable color correction so we can read unmodified values from the bitmap. | 1351 // Disable color correction so we can read unmodified values from the bitmap. |
| 1353 [ns_window setColorSpace:[NSColorSpace sRGBColorSpace]]; | 1352 [ns_window setColorSpace:[NSColorSpace sRGBColorSpace]]; |
| 1354 | 1353 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 | 1831 |
| 1833 - (void)dealloc { | 1832 - (void)dealloc { |
| 1834 if (deallocFlag_) { | 1833 if (deallocFlag_) { |
| 1835 DCHECK(!*deallocFlag_); | 1834 DCHECK(!*deallocFlag_); |
| 1836 *deallocFlag_ = true; | 1835 *deallocFlag_ = true; |
| 1837 } | 1836 } |
| 1838 [super dealloc]; | 1837 [super dealloc]; |
| 1839 } | 1838 } |
| 1840 | 1839 |
| 1841 @end | 1840 @end |
| OLD | NEW |