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