Chromium Code Reviews| Index: views/widget/native_widget_views.cc |
| diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc |
| index dfeda464575c8795bf2daca44153eed8941a6a9b..58f7c4ef823f46d70b6954bca21a958559be9f27 100644 |
| --- a/views/widget/native_widget_views.cc |
| +++ b/views/widget/native_widget_views.cc |
| @@ -45,6 +45,7 @@ namespace views { |
| NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) |
| : delegate_(delegate), |
| parent_(NULL), |
| + bounds_relative_to_parent_(false), |
| view_(NULL), |
| active_(false), |
| window_state_(ui::SHOW_STATE_DEFAULT), |
| @@ -141,6 +142,8 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { |
| parent_ = params.parent_widget; |
| ownership_ = params.ownership; |
| always_on_top_ = params.keep_on_top; |
| + bounds_relative_to_parent_ = |
| + (params.type == Widget::InitParams::TYPE_CONTROL); |
| View* parent_view = NULL; |
| if (params.parent_widget) { |
| parent_view = params.parent_widget->GetChildViewParent(); |
| @@ -153,8 +156,8 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { |
| parent_view = widget->GetChildViewParent(); |
| } |
| - gfx::Rect bounds = AdjustRectOriginForParentWidget(params.bounds, |
| - parent_); |
| + gfx::Rect bounds = bounds_relative_to_parent_ ? |
| + params.bounds : AdjustRectOriginForParentWidget(params.bounds, parent_); |
| view_ = new internal::NativeWidgetView(this); |
| view_->SetBoundsRect(bounds); |
| view_->SetVisible(params.type == Widget::InitParams::TYPE_CONTROL); |
| @@ -166,7 +169,6 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { |
| // be deleted by its Widget. |
| if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET) |
| view_->set_delete_native_widget(false); |
| - |
| if (parent_view) |
| parent_view->AddChildView(view_); |
| view_->SetPaintToLayer(true); |
| @@ -352,7 +354,10 @@ gfx::Rect NativeWidgetViews::GetRestoredBounds() const { |
| void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) { |
| // |bounds| are supplied in the coordinates of the parent. |
|
sadrul
2011/11/14 17:23:04
Update the comment here explaining that for toplev
|
| - view_->SetBoundsRect(AdjustRectOriginForParentWidget(bounds, parent_)); |
| + if (bounds_relative_to_parent_) |
| + view_->SetBoundsRect(bounds); |
|
sadrul
2011/11/14 17:23:04
Is it sufficient to just check for !GetWidget()->i
|
| + else |
| + view_->SetBoundsRect(AdjustRectOriginForParentWidget(bounds, parent_)); |
| } |
| void NativeWidgetViews::SetSize(const gfx::Size& size) { |