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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 297 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
298 | 298 |
299 void RenderWidgetHostViewAura::InitAsChild( | 299 void RenderWidgetHostViewAura::InitAsChild( |
300 gfx::NativeView parent_view) { | 300 gfx::NativeView parent_view) { |
301 window_->Init(ui::LAYER_TEXTURED); | 301 window_->Init(ui::LAYER_TEXTURED); |
302 window_->SetName("RenderWidgetHostViewAura"); | 302 window_->SetName("RenderWidgetHostViewAura"); |
303 } | 303 } |
304 | 304 |
305 void RenderWidgetHostViewAura::InitAsPopup( | 305 void RenderWidgetHostViewAura::InitAsPopup( |
306 RenderWidgetHostView* parent_host_view, | 306 RenderWidgetHostView* parent_host_view, |
307 const gfx::Rect& bounds_in_display) { | 307 const gfx::Rect& bounds_in_screen) { |
308 popup_parent_host_view_ = | 308 popup_parent_host_view_ = |
309 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 309 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
310 | 310 |
311 RenderWidgetHostViewAura* old_child = | 311 RenderWidgetHostViewAura* old_child = |
312 popup_parent_host_view_->popup_child_host_view_; | 312 popup_parent_host_view_->popup_child_host_view_; |
313 if (old_child) { | 313 if (old_child) { |
314 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 314 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
315 // similar mechanism to ensure a second popup doesn't cause the first one | 315 // similar mechanism to ensure a second popup doesn't cause the first one |
316 // to never get a chance to filter events. See crbug.com/160589. | 316 // to never get a chance to filter events. See crbug.com/160589. |
317 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 317 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
318 old_child->popup_parent_host_view_ = NULL; | 318 old_child->popup_parent_host_view_ = NULL; |
319 } | 319 } |
320 popup_parent_host_view_->popup_child_host_view_ = this; | 320 popup_parent_host_view_->popup_child_host_view_ = this; |
321 window_->SetType(aura::client::WINDOW_TYPE_MENU); | 321 window_->SetType(aura::client::WINDOW_TYPE_MENU); |
322 window_->Init(ui::LAYER_TEXTURED); | 322 window_->Init(ui::LAYER_TEXTURED); |
323 window_->SetName("RenderWidgetHostViewAura"); | 323 window_->SetName("RenderWidgetHostViewAura"); |
324 | 324 |
325 aura::Window* parent = NULL; | |
326 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); | 325 aura::RootWindow* root = popup_parent_host_view_->window_->GetRootWindow(); |
| 326 aura::Window* parent = aura::client::GetStackingClient()->GetDefaultParent( |
| 327 window_, window_, bounds_in_screen); |
| 328 window_->SetParent(parent); |
| 329 |
327 aura::client::ScreenPositionClient* screen_position_client = | 330 aura::client::ScreenPositionClient* screen_position_client = |
328 aura::client::GetScreenPositionClient(root); | 331 aura::client::GetScreenPositionClient(root); |
329 if (screen_position_client) { | 332 gfx::Point origin_in_parent(bounds_in_screen.origin()); |
330 gfx::Point origin_in_screen(bounds_in_display.origin()); | 333 if (screen_position_client) |
331 screen_position_client->ConvertPointToScreen(root, &origin_in_screen); | 334 screen_position_client->ConvertPointFromScreen(parent, &origin_in_parent); |
332 parent = aura::client::GetStackingClient()->GetDefaultParent( | 335 SetBounds(gfx::Rect(origin_in_parent, bounds_in_screen.size())); |
333 window_, window_, | |
334 gfx::Rect(origin_in_screen, bounds_in_display.size())); | |
335 } | |
336 window_->SetParent(parent); | |
337 SetBounds(bounds_in_display); | |
338 Show(); | 336 Show(); |
339 } | 337 } |
340 | 338 |
341 void RenderWidgetHostViewAura::InitAsFullscreen( | 339 void RenderWidgetHostViewAura::InitAsFullscreen( |
342 RenderWidgetHostView* reference_host_view) { | 340 RenderWidgetHostView* reference_host_view) { |
343 is_fullscreen_ = true; | 341 is_fullscreen_ = true; |
344 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); | 342 window_->SetType(aura::client::WINDOW_TYPE_NORMAL); |
345 window_->Init(ui::LAYER_TEXTURED); | 343 window_->Init(ui::LAYER_TEXTURED); |
346 window_->SetName("RenderWidgetHostViewAura"); | 344 window_->SetName("RenderWidgetHostViewAura"); |
347 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 345 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 RenderWidgetHostViewBase::SetBackground(background); | 1032 RenderWidgetHostViewBase::SetBackground(background); |
1035 host_->SetBackground(background); | 1033 host_->SetBackground(background); |
1036 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 1034 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
1037 } | 1035 } |
1038 | 1036 |
1039 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { | 1037 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { |
1040 GetScreenInfoForWindow(results, window_); | 1038 GetScreenInfoForWindow(results, window_); |
1041 } | 1039 } |
1042 | 1040 |
1043 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { | 1041 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { |
1044 return window_->GetToplevelWindow()->GetBoundsInRootWindow(); | 1042 return window_->GetToplevelWindow()->GetBoundsInScreen(); |
1045 } | 1043 } |
1046 | 1044 |
1047 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( | 1045 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( |
1048 const WebKit::WebTouchEvent& touch_event, | 1046 const WebKit::WebTouchEvent& touch_event, |
1049 bool processed) { | 1047 bool processed) { |
1050 ScopedVector<ui::TouchEvent> events; | 1048 ScopedVector<ui::TouchEvent> events; |
1051 if (!MakeUITouchEventsFromWebTouchEvents(touch_event, &events)) | 1049 if (!MakeUITouchEventsFromWebTouchEvents(touch_event, &events)) |
1052 return; | 1050 return; |
1053 | 1051 |
1054 aura::RootWindow* root = window_->GetRootWindow(); | 1052 aura::RootWindow* root = window_->GetRootWindow(); |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 RenderWidgetHost* widget) { | 1989 RenderWidgetHost* widget) { |
1992 return new RenderWidgetHostViewAura(widget); | 1990 return new RenderWidgetHostViewAura(widget); |
1993 } | 1991 } |
1994 | 1992 |
1995 // static | 1993 // static |
1996 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1994 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
1997 GetScreenInfoForWindow(results, NULL); | 1995 GetScreenInfoForWindow(results, NULL); |
1998 } | 1996 } |
1999 | 1997 |
2000 } // namespace content | 1998 } // namespace content |
OLD | NEW |