OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // to never get a chance to filter events. See crbug.com/160589. | 317 // to never get a chance to filter events. See crbug.com/160589. |
318 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 318 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
319 old_child->popup_parent_host_view_ = NULL; | 319 old_child->popup_parent_host_view_ = NULL; |
320 } | 320 } |
321 popup_parent_host_view_->popup_child_host_view_ = this; | 321 popup_parent_host_view_->popup_child_host_view_ = this; |
322 window_->SetType(aura::client::WINDOW_TYPE_MENU); | 322 window_->SetType(aura::client::WINDOW_TYPE_MENU); |
323 window_->Init(ui::LAYER_TEXTURED); | 323 window_->Init(ui::LAYER_TEXTURED); |
324 window_->SetName("RenderWidgetHostViewAura"); | 324 window_->SetName("RenderWidgetHostViewAura"); |
325 | 325 |
326 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); | 326 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); |
327 aura::Window* parent = aura::client::GetStackingClient()->GetDefaultParent( | 327 window_->SetDefaultParentByRootWindow(root, bounds_in_screen); |
328 window_, window_, bounds_in_screen); | |
329 window_->SetParent(parent); | |
330 | 328 |
| 329 // TODO(erg): While I could make sure details of the StackingClient are |
| 330 // hidden behind aura, hiding the details of the ScreenPositionClient will |
| 331 // take another effort. |
331 aura::client::ScreenPositionClient* screen_position_client = | 332 aura::client::ScreenPositionClient* screen_position_client = |
332 aura::client::GetScreenPositionClient(root); | 333 aura::client::GetScreenPositionClient(root); |
333 gfx::Point origin_in_parent(bounds_in_screen.origin()); | 334 gfx::Point origin_in_parent(bounds_in_screen.origin()); |
334 if (screen_position_client) | 335 if (screen_position_client) { |
335 screen_position_client->ConvertPointFromScreen(parent, &origin_in_parent); | 336 screen_position_client->ConvertPointFromScreen( |
| 337 window_->parent(), &origin_in_parent); |
| 338 } |
336 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size())); | 339 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size())); |
337 Show(); | 340 Show(); |
338 } | 341 } |
339 | 342 |
340 void RenderWidgetHostViewAura::InitAsFullscreen( | 343 void RenderWidgetHostViewAura::InitAsFullscreen( |
341 RenderWidgetHostView* reference_host_view) { | 344 RenderWidgetHostView* reference_host_view) { |
342 is_fullscreen_ = true; | 345 is_fullscreen_ = true; |
343 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); | 346 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); |
344 window_->Init(ui::LAYER_TEXTURED); | 347 window_->Init(ui::LAYER_TEXTURED); |
345 window_->SetName("RenderWidgetHostViewAura"); | 348 window_->SetName("RenderWidgetHostViewAura"); |
346 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 349 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
347 aura::Window* parent = NULL; | 350 |
| 351 aura::RootWindow* parent = NULL; |
| 352 gfx::Rect bounds; |
348 if (reference_host_view) { | 353 if (reference_host_view) { |
349 aura::Window* reference_window = | 354 aura::Window* reference_window = |
350 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; | 355 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; |
351 if (reference_window) { | 356 if (reference_window) { |
352 host_tracker_.reset(new aura::WindowTracker); | 357 host_tracker_.reset(new aura::WindowTracker); |
353 host_tracker_->Add(reference_window); | 358 host_tracker_->Add(reference_window); |
354 } | 359 } |
355 gfx::Display display = gfx::Screen::GetScreenFor(window_)-> | 360 gfx::Display display = gfx::Screen::GetScreenFor(window_)-> |
356 GetDisplayNearestWindow(reference_window); | 361 GetDisplayNearestWindow(reference_window); |
357 aura::client::StackingClient* stacking_client = | 362 parent = reference_window->GetRootWindow(); |
358 aura::client::GetStackingClient(); | 363 bounds = display.bounds(); |
359 if (stacking_client) | |
360 parent = stacking_client->GetDefaultParent( | |
361 window_, window_, display.bounds()); | |
362 } | 364 } |
363 window_->SetParent(parent); | 365 window_->SetDefaultParentByRootWindow(parent, bounds); |
| 366 |
364 Show(); | 367 Show(); |
365 Focus(); | 368 Focus(); |
366 } | 369 } |
367 | 370 |
368 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 371 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
369 return host_; | 372 return host_; |
370 } | 373 } |
371 | 374 |
372 void RenderWidgetHostViewAura::WasShown() { | 375 void RenderWidgetHostViewAura::WasShown() { |
373 if (!host_->is_hidden()) | 376 if (!host_->is_hidden()) |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 RenderWidgetHost* widget) { | 1999 RenderWidgetHost* widget) { |
1997 return new RenderWidgetHostViewAura(widget); | 2000 return new RenderWidgetHostViewAura(widget); |
1998 } | 2001 } |
1999 | 2002 |
2000 // static | 2003 // static |
2001 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 2004 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
2002 GetScreenInfoForWindow(results, NULL); | 2005 GetScreenInfoForWindow(results, NULL); |
2003 } | 2006 } |
2004 | 2007 |
2005 } // namespace content | 2008 } // namespace content |
OLD | NEW |