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 "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/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/renderer_host/backing_store_skia.h" | 8 #include "content/browser/renderer_host/backing_store_skia.h" |
9 #include "content/browser/renderer_host/render_widget_host.h" | 9 #include "content/browser/renderer_host/render_widget_host.h" |
10 #include "content/browser/renderer_host/web_input_event_aura.h" | 10 #include "content/browser/renderer_host/web_input_event_aura.h" |
11 #include "content/public/browser/native_web_keyboard_event.h" | 11 #include "content/public/browser/native_web_keyboard_event.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
13 #include "ui/aura/aura_constants.h" | 14 #include "ui/aura/aura_constants.h" |
14 #include "ui/aura/desktop.h" | 15 #include "ui/aura/desktop.h" |
15 #include "ui/aura/event.h" | 16 #include "ui/aura/event.h" |
16 #include "ui/aura/hit_test.h" | 17 #include "ui/aura/hit_test.h" |
17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_types.h" |
18 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/compositor/layer.h" | 21 #include "ui/gfx/compositor/layer.h" |
| 22 #include "ui/gfx/screen.h" |
20 | 23 |
21 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 24 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
22 #include "base/bind.h" | 25 #include "base/bind.h" |
23 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 26 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
24 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" | 27 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" |
25 #include "content/common/gpu/gpu_messages.h" | 28 #include "content/common/gpu/gpu_messages.h" |
26 #include "ui/gfx/gl/gl_bindings.h" | 29 #include "ui/gfx/gl/gl_bindings.h" |
27 #endif | 30 #endif |
28 | 31 |
29 using WebKit::WebTouchEvent; | 32 using WebKit::WebTouchEvent; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 74 } |
72 | 75 |
73 } // namespace | 76 } // namespace |
74 | 77 |
75 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
76 // RenderWidgetHostViewAura, public: | 79 // RenderWidgetHostViewAura, public: |
77 | 80 |
78 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 81 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
79 : host_(host), | 82 : host_(host), |
80 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 83 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| 84 is_fullscreen_(false), |
| 85 popup_parent_host_view_(NULL), |
81 is_loading_(false) { | 86 is_loading_(false) { |
82 host_->SetView(this); | 87 host_->SetView(this); |
83 window_->SetProperty(aura::kTooltipTextKey, &tooltip_); | 88 window_->SetProperty(aura::kTooltipTextKey, &tooltip_); |
84 } | 89 } |
85 | 90 |
86 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { | 91 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
87 } | 92 } |
88 | 93 |
89 void RenderWidgetHostViewAura::Init() { | 94 void RenderWidgetHostViewAura::Init() { |
90 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); | 95 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); |
91 } | 96 } |
92 | 97 |
93 //////////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////////// |
94 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 99 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
95 | 100 |
96 void RenderWidgetHostViewAura::InitAsPopup( | 101 void RenderWidgetHostViewAura::InitAsPopup( |
97 RenderWidgetHostView* parent_host_view, | 102 RenderWidgetHostView* parent_host_view, |
98 const gfx::Rect& pos) { | 103 const gfx::Rect& pos) { |
99 NOTIMPLEMENTED(); | 104 popup_parent_host_view_ = |
100 // TODO(ivankr): there has to be an Init() call, otherwise |window_| | 105 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
101 // is left uninitialized and will eventually crash. | 106 window_->SetType(aura::WINDOW_TYPE_MENU); |
102 Init(); | 107 Init(); |
| 108 |
| 109 window_->SetParent(NULL); |
| 110 Show(); |
| 111 SetBounds(pos); |
103 } | 112 } |
104 | 113 |
105 void RenderWidgetHostViewAura::InitAsFullscreen( | 114 void RenderWidgetHostViewAura::InitAsFullscreen( |
106 RenderWidgetHostView* reference_host_view) { | 115 RenderWidgetHostView* reference_host_view) { |
107 NOTIMPLEMENTED(); | 116 window_->SetType(aura::WINDOW_TYPE_POPUP); |
108 // TODO(ivankr): there has to be an Init() call, otherwise |window_| | 117 is_fullscreen_ = true; |
109 // is left uninitialized and will eventually crash. | |
110 Init(); | 118 Init(); |
| 119 |
| 120 window_->SetParent(NULL); |
| 121 window_->Fullscreen(); |
| 122 Show(); |
| 123 Focus(); |
| 124 // TODO(derat): The window is visible but it's not being updated. Figure out |
| 125 // why. |
111 } | 126 } |
112 | 127 |
113 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 128 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
114 return host_; | 129 return host_; |
115 } | 130 } |
116 | 131 |
117 void RenderWidgetHostViewAura::DidBecomeSelected() { | 132 void RenderWidgetHostViewAura::DidBecomeSelected() { |
118 host_->WasRestored(); | 133 host_->WasRestored(); |
119 } | 134 } |
120 | 135 |
121 void RenderWidgetHostViewAura::WasHidden() { | 136 void RenderWidgetHostViewAura::WasHidden() { |
122 host_->WasHidden(); | 137 host_->WasHidden(); |
123 } | 138 } |
124 | 139 |
125 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { | 140 void RenderWidgetHostViewAura::SetSize(const gfx::Size& size) { |
126 SetBounds(gfx::Rect(window_->bounds().origin(), size)); | 141 SetBounds(gfx::Rect(window_->bounds().origin(), size)); |
127 } | 142 } |
128 | 143 |
129 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { | 144 void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { |
130 window_->SetBounds(rect); | 145 gfx::Rect adjusted_rect = rect; |
| 146 |
| 147 if (popup_parent_host_view_) { |
| 148 gfx::Point translated_origin = adjusted_rect.origin(); |
| 149 // |rect| is relative to |popup_parent_host_view_|; translate it for the |
| 150 // window's container. |
| 151 aura::Window::ConvertPointToWindow( |
| 152 popup_parent_host_view_->window_, |
| 153 window_->parent(), |
| 154 &translated_origin); |
| 155 adjusted_rect.set_origin(translated_origin); |
| 156 } |
| 157 |
| 158 window_->SetBounds(adjusted_rect); |
131 host_->WasResized(); | 159 host_->WasResized(); |
132 } | 160 } |
133 | 161 |
134 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { | 162 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { |
135 return window_; | 163 return window_; |
136 } | 164 } |
137 | 165 |
138 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { | 166 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { |
139 return static_cast<gfx::NativeViewId>(NULL); | 167 return static_cast<gfx::NativeViewId>(NULL); |
140 } | 168 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 RenderWidgetHostView::SetBackground(background); | 306 RenderWidgetHostView::SetBackground(background); |
279 host_->SetBackground(background); | 307 host_->SetBackground(background); |
280 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 308 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
281 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 309 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
282 #endif | 310 #endif |
283 } | 311 } |
284 | 312 |
285 #if defined(OS_POSIX) | 313 #if defined(OS_POSIX) |
286 void RenderWidgetHostViewAura::GetDefaultScreenInfo( | 314 void RenderWidgetHostViewAura::GetDefaultScreenInfo( |
287 WebKit::WebScreenInfo* results) { | 315 WebKit::WebScreenInfo* results) { |
288 NOTIMPLEMENTED(); | 316 GetScreenInfo(results); |
289 } | 317 } |
290 | 318 |
291 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { | 319 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { |
292 NOTIMPLEMENTED(); | 320 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
| 321 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
| 322 results->availableRect = results->rect; |
| 323 // TODO(derat): Don't hardcode this? |
| 324 results->depth = 24; |
| 325 results->depthPerComponent = 8; |
293 } | 326 } |
294 | 327 |
295 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { | 328 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { |
296 NOTIMPLEMENTED(); | 329 return aura::Desktop::GetInstance()->bounds(); |
297 return gfx::Rect(); | |
298 } | 330 } |
299 #endif | 331 #endif |
300 | 332 |
301 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color, | 333 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color, |
302 bool animate) { | 334 bool animate) { |
303 NOTIMPLEMENTED(); | 335 NOTIMPLEMENTED(); |
304 } | 336 } |
305 | 337 |
306 void RenderWidgetHostViewAura::UnhandledWheelEvent( | 338 void RenderWidgetHostViewAura::UnhandledWheelEvent( |
307 const WebKit::WebMouseWheelEvent& event) { | 339 const WebKit::WebMouseWheelEvent& event) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 399 |
368 void RenderWidgetHostViewAura::OnFocus() { | 400 void RenderWidgetHostViewAura::OnFocus() { |
369 host_->GotFocus(); | 401 host_->GotFocus(); |
370 } | 402 } |
371 | 403 |
372 void RenderWidgetHostViewAura::OnBlur() { | 404 void RenderWidgetHostViewAura::OnBlur() { |
373 host_->Blur(); | 405 host_->Blur(); |
374 } | 406 } |
375 | 407 |
376 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { | 408 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { |
377 NativeWebKeyboardEvent webkit_event(event); | 409 // We need to handle the Escape key for Pepper Flash. |
378 host_->ForwardKeyboardEvent(webkit_event); | 410 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { |
| 411 host_->Shutdown(); |
| 412 } else { |
| 413 NativeWebKeyboardEvent webkit_event(event); |
| 414 host_->ForwardKeyboardEvent(webkit_event); |
| 415 } |
379 return true; | 416 return true; |
380 } | 417 } |
381 | 418 |
382 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { | 419 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { |
383 // TODO(beng): talk to beng before implementing this. | 420 // TODO(beng): talk to beng before implementing this. |
384 //NOTIMPLEMENTED(); | 421 //NOTIMPLEMENTED(); |
385 return gfx::kNullCursor; | 422 return gfx::kNullCursor; |
386 } | 423 } |
387 | 424 |
388 int RenderWidgetHostViewAura::GetNonClientComponent( | 425 int RenderWidgetHostViewAura::GetNonClientComponent( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 } | 505 } |
469 #endif | 506 #endif |
470 | 507 |
471 //////////////////////////////////////////////////////////////////////////////// | 508 //////////////////////////////////////////////////////////////////////////////// |
472 // RenderWidgetHostViewAura, private: | 509 // RenderWidgetHostViewAura, private: |
473 | 510 |
474 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 511 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
475 //NOTIMPLEMENTED(); | 512 //NOTIMPLEMENTED(); |
476 // TODO(beng): See RenderWidgetHostViewWin. | 513 // TODO(beng): See RenderWidgetHostViewWin. |
477 } | 514 } |
OLD | NEW |