OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "views/widget/native_widget_views.h" | 5 #include "views/widget/native_widget_views.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ui/base/hit_test.h" | 8 #include "ui/base/hit_test.h" |
9 #include "ui/gfx/compositor/compositor.h" | 9 #include "ui/gfx/compositor/compositor.h" |
10 #include "ui/gfx/compositor/layer.h" | 10 #include "ui/gfx/compositor/layer.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 parent_view = params.parent_widget->GetChildViewParent(); | 146 parent_view = params.parent_widget->GetChildViewParent(); |
147 } else if (ViewsDelegate::views_delegate && | 147 } else if (ViewsDelegate::views_delegate && |
148 ViewsDelegate::views_delegate->GetDefaultParentView() && | 148 ViewsDelegate::views_delegate->GetDefaultParentView() && |
149 !params.child) { | 149 !params.child) { |
150 parent_view = ViewsDelegate::views_delegate->GetDefaultParentView(); | 150 parent_view = ViewsDelegate::views_delegate->GetDefaultParentView(); |
151 } else if (params.parent) { | 151 } else if (params.parent) { |
152 Widget* widget = Widget::GetWidgetForNativeView(params.parent); | 152 Widget* widget = Widget::GetWidgetForNativeView(params.parent); |
153 parent_view = widget->GetChildViewParent(); | 153 parent_view = widget->GetChildViewParent(); |
154 } | 154 } |
155 | 155 |
156 gfx::Rect bounds = AdjustRectOriginForParentWidget(params.bounds, | 156 gfx::Rect bounds = GetWidget()->is_top_level() ? |
157 parent_); | 157 AdjustRectOriginForParentWidget(params.bounds, parent_) : params.bounds; |
158 view_ = new internal::NativeWidgetView(this); | 158 view_ = new internal::NativeWidgetView(this); |
159 view_->SetBoundsRect(bounds); | 159 view_->SetBoundsRect(bounds); |
160 view_->SetVisible(params.type == Widget::InitParams::TYPE_CONTROL); | 160 view_->SetVisible(params.type == Widget::InitParams::TYPE_CONTROL); |
161 | 161 |
162 // With the default NATIVE_WIDGET_OWNS_WIDGET ownership, the | 162 // With the default NATIVE_WIDGET_OWNS_WIDGET ownership, the |
163 // deletion of either of the NativeWidgetViews or NativeWidgetView | 163 // deletion of either of the NativeWidgetViews or NativeWidgetView |
164 // (e.g. via View hierarchy destruction) will delete the other. | 164 // (e.g. via View hierarchy destruction) will delete the other. |
165 // With WIDGET_OWNS_NATIVE_WIDGET, NativeWidgetViews should only | 165 // With WIDGET_OWNS_NATIVE_WIDGET, NativeWidgetViews should only |
166 // be deleted by its Widget. | 166 // be deleted by its Widget. |
167 if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET) | 167 if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const { | 345 gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const { |
346 return GetWindowScreenBounds(); | 346 return GetWindowScreenBounds(); |
347 } | 347 } |
348 | 348 |
349 gfx::Rect NativeWidgetViews::GetRestoredBounds() const { | 349 gfx::Rect NativeWidgetViews::GetRestoredBounds() const { |
350 return GetWindowScreenBounds(); | 350 return GetWindowScreenBounds(); |
351 } | 351 } |
352 | 352 |
353 void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) { | 353 void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) { |
354 // |bounds| are supplied in the coordinates of the parent. | 354 // |bounds| are supplied in the coordinates of the parent. |
355 view_->SetBoundsRect(AdjustRectOriginForParentWidget(bounds, parent_)); | 355 if (GetWidget()->is_top_level()) |
| 356 view_->SetBoundsRect(AdjustRectOriginForParentWidget(bounds, parent_)); |
| 357 else |
| 358 view_->SetBoundsRect(bounds); |
356 } | 359 } |
357 | 360 |
358 void NativeWidgetViews::SetSize(const gfx::Size& size) { | 361 void NativeWidgetViews::SetSize(const gfx::Size& size) { |
359 view_->SetSize(size); | 362 view_->SetSize(size); |
360 } | 363 } |
361 | 364 |
362 void NativeWidgetViews::MoveAbove(gfx::NativeView native_view) { | 365 void NativeWidgetViews::MoveAbove(gfx::NativeView native_view) { |
363 NOTIMPLEMENTED(); | 366 NOTIMPLEMENTED(); |
364 } | 367 } |
365 | 368 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 } | 639 } |
637 default: | 640 default: |
638 // Everything else falls into standard client event handling. | 641 // Everything else falls into standard client event handling. |
639 break; | 642 break; |
640 } | 643 } |
641 } | 644 } |
642 return false; | 645 return false; |
643 } | 646 } |
644 | 647 |
645 } // namespace views | 648 } // namespace views |
OLD | NEW |