Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 987733002: MacViews: Fix WidgetTest.WidgetDeleted_InOnMousePressed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/test/event_generator_delegate_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // set at all, the creator of the Widget is expected to call SetBounds() 127 // set at all, the creator of the Widget is expected to call SetBounds()
128 // before calling Widget::Show() to avoid a kWindowSizeDeterminedLater-sized 128 // before calling Widget::Show() to avoid a kWindowSizeDeterminedLater-sized
129 // (i.e. 1x1) window appearing. 129 // (i.e. 1x1) window appearing.
130 if (!params.bounds.IsEmpty()) { 130 if (!params.bounds.IsEmpty()) {
131 SetBounds(params.bounds); 131 SetBounds(params.bounds);
132 } else { 132 } else {
133 // If a position is set, but no size, complain. Otherwise, a 1x1 window 133 // If a position is set, but no size, complain. Otherwise, a 1x1 window
134 // would appear there, which might be unexpected. 134 // would appear there, which might be unexpected.
135 DCHECK(params.bounds.origin().IsOrigin()) 135 DCHECK(params.bounds.origin().IsOrigin())
136 << "Zero-sized windows not supported on Mac."; 136 << "Zero-sized windows not supported on Mac.";
137
138 // Otherwise, bounds is all zeroes. Cocoa will currently have the window at
139 // the bottom left of the screen. To support a client calling SetSize() only
140 // (and for consistency across platforms) put it at the top-left instead.
141 // Read back the current frame: it will be a 1x1 context rect but the frame
142 // size also depends on the window style.
143 NSRect frame_rect = [window_ frame];
144 SetBounds(gfx::Rect(gfx::Point(),
145 gfx::Size(NSWidth(frame_rect), NSHeight(frame_rect))));
137 } 146 }
138 147
139 // Widgets for UI controls (usually layered above web contents) start visible. 148 // Widgets for UI controls (usually layered above web contents) start visible.
140 if (params.type == Widget::InitParams::TYPE_CONTROL) 149 if (params.type == Widget::InitParams::TYPE_CONTROL)
141 SetVisibilityState(SHOW_INACTIVE); 150 SetVisibilityState(SHOW_INACTIVE);
142 } 151 }
143 152
144 void BridgedNativeWidget::SetFocusManager(FocusManager* focus_manager) { 153 void BridgedNativeWidget::SetFocusManager(FocusManager* focus_manager) {
145 if (focus_manager_ == focus_manager) 154 if (focus_manager_ == focus_manager)
146 return; 155 return;
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 window_, &kWindowPropertiesKey); 741 window_, &kWindowPropertiesKey);
733 if (!properties) { 742 if (!properties) {
734 properties = [NSMutableDictionary dictionary]; 743 properties = [NSMutableDictionary dictionary];
735 objc_setAssociatedObject(window_, &kWindowPropertiesKey, 744 objc_setAssociatedObject(window_, &kWindowPropertiesKey,
736 properties, OBJC_ASSOCIATION_RETAIN); 745 properties, OBJC_ASSOCIATION_RETAIN);
737 } 746 }
738 return properties; 747 return properties;
739 } 748 }
740 749
741 } // namespace views 750 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/test/event_generator_delegate_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698