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/desktop.h" | 14 #include "ui/aura/desktop.h" |
14 #include "ui/aura/event.h" | 15 #include "ui/aura/event.h" |
15 #include "ui/aura/hit_test.h" | 16 #include "ui/aura/hit_test.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
17 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/compositor/layer.h" | 19 #include "ui/gfx/compositor/layer.h" |
20 #include "ui/gfx/screen.h" | |
19 | 21 |
20 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 22 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
21 #include "base/bind.h" | 23 #include "base/bind.h" |
22 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
23 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" | 25 #include "content/browser/renderer_host/accelerated_surface_container_linux.h" |
24 #include "content/common/gpu/gpu_messages.h" | 26 #include "content/common/gpu/gpu_messages.h" |
25 #include "ui/gfx/gl/gl_bindings.h" | 27 #include "ui/gfx/gl/gl_bindings.h" |
26 #endif | 28 #endif |
27 | 29 |
28 using WebKit::WebTouchEvent; | 30 using WebKit::WebTouchEvent; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 void RenderWidgetHostViewAura::Init() { | 89 void RenderWidgetHostViewAura::Init() { |
88 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); | 90 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); |
89 } | 91 } |
90 | 92 |
91 //////////////////////////////////////////////////////////////////////////////// | 93 //////////////////////////////////////////////////////////////////////////////// |
92 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 94 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
93 | 95 |
94 void RenderWidgetHostViewAura::InitAsPopup( | 96 void RenderWidgetHostViewAura::InitAsPopup( |
95 RenderWidgetHostView* parent_host_view, | 97 RenderWidgetHostView* parent_host_view, |
96 const gfx::Rect& pos) { | 98 const gfx::Rect& pos) { |
97 NOTIMPLEMENTED(); | |
98 // TODO(ivankr): there has to be an Init() call, otherwise |window_| | |
99 // is left uninitialized and will eventually crash. | |
100 Init(); | 99 Init(); |
100 window_->SetParent( | |
101 static_cast<RenderWidgetHostViewAura*>(parent_host_view)->window_); | |
Ben Goodger (Google)
2011/10/27 22:56:11
It seems like these should be parented to the menu
Daniel Erat
2011/10/28 00:53:13
Done. I think that it's not a transient since thi
| |
102 SetBounds(pos); | |
103 Show(); | |
101 } | 104 } |
102 | 105 |
103 void RenderWidgetHostViewAura::InitAsFullscreen( | 106 void RenderWidgetHostViewAura::InitAsFullscreen( |
104 RenderWidgetHostView* reference_host_view) { | 107 RenderWidgetHostView* reference_host_view) { |
105 NOTIMPLEMENTED(); | |
106 // TODO(ivankr): there has to be an Init() call, otherwise |window_| | |
107 // is left uninitialized and will eventually crash. | |
108 Init(); | 108 Init(); |
109 window_->SetParent(aura::Desktop::GetInstance()); | |
sadrul
2011/10/27 22:47:20
Shouldn't this be parented to the default containe
Ben Goodger (Google)
2011/10/27 22:56:11
The menu container, to be exact.
Daniel Erat
2011/10/28 00:53:13
I used TYPE_POPUP here, but that just gets treated
| |
110 window_->Fullscreen(); | |
111 Show(); | |
112 Focus(); | |
113 // TODO(derat): The window is visible but it's not being updated. Figure out | |
114 // why. | |
109 } | 115 } |
110 | 116 |
111 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 117 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
112 return host_; | 118 return host_; |
113 } | 119 } |
114 | 120 |
115 void RenderWidgetHostViewAura::DidBecomeSelected() { | 121 void RenderWidgetHostViewAura::DidBecomeSelected() { |
116 host_->WasRestored(); | 122 host_->WasRestored(); |
117 } | 123 } |
118 | 124 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 RenderWidgetHostView::SetBackground(background); | 282 RenderWidgetHostView::SetBackground(background); |
277 host_->SetBackground(background); | 283 host_->SetBackground(background); |
278 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 284 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
279 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); | 285 window_->layer()->SetFillsBoundsOpaquely(background.isOpaque()); |
280 #endif | 286 #endif |
281 } | 287 } |
282 | 288 |
283 #if defined(OS_POSIX) | 289 #if defined(OS_POSIX) |
284 void RenderWidgetHostViewAura::GetDefaultScreenInfo( | 290 void RenderWidgetHostViewAura::GetDefaultScreenInfo( |
285 WebKit::WebScreenInfo* results) { | 291 WebKit::WebScreenInfo* results) { |
286 NOTIMPLEMENTED(); | 292 GetScreenInfo(results); |
287 } | 293 } |
288 | 294 |
289 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { | 295 void RenderWidgetHostViewAura::GetScreenInfo(WebKit::WebScreenInfo* results) { |
290 NOTIMPLEMENTED(); | 296 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
297 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | |
298 results->availableRect = results->rect; | |
299 // TODO(derat): Don't hardcode this? | |
Ben Goodger (Google)
2011/10/27 22:56:11
leave NOTIMPLEMENTED() if there is something here
Daniel Erat
2011/10/28 00:53:13
I'm okay with this being in production. It'd idea
| |
300 results->depth = 24; | |
301 results->depthPerComponent = 8; | |
291 } | 302 } |
292 | 303 |
293 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { | 304 gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { |
294 NOTIMPLEMENTED(); | 305 return aura::Desktop::GetInstance()->bounds(); |
295 return gfx::Rect(); | |
296 } | 306 } |
297 #endif | 307 #endif |
298 | 308 |
299 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color, | 309 void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color, |
300 bool animate) { | 310 bool animate) { |
301 NOTIMPLEMENTED(); | 311 NOTIMPLEMENTED(); |
302 } | 312 } |
303 | 313 |
304 void RenderWidgetHostViewAura::UnhandledWheelEvent( | 314 void RenderWidgetHostViewAura::UnhandledWheelEvent( |
305 const WebKit::WebMouseWheelEvent& event) { | 315 const WebKit::WebMouseWheelEvent& event) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 | 375 |
366 void RenderWidgetHostViewAura::OnFocus() { | 376 void RenderWidgetHostViewAura::OnFocus() { |
367 host_->GotFocus(); | 377 host_->GotFocus(); |
368 } | 378 } |
369 | 379 |
370 void RenderWidgetHostViewAura::OnBlur() { | 380 void RenderWidgetHostViewAura::OnBlur() { |
371 host_->Blur(); | 381 host_->Blur(); |
372 } | 382 } |
373 | 383 |
374 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { | 384 bool RenderWidgetHostViewAura::OnKeyEvent(aura::KeyEvent* event) { |
375 NativeWebKeyboardEvent webkit_event(event); | 385 if (event->key_code() == ui::VKEY_ESCAPE) { |
sadrul
2011/10/27 22:47:20
This is only when 'IsPopup'?
Daniel Erat
2011/10/28 00:53:13
Whoops, yeah (fullscreen, though). Sorry for miss
| |
376 host_->ForwardKeyboardEvent(webkit_event); | 386 host_->Shutdown(); |
Ben Goodger (Google)
2011/10/27 22:56:11
Side note: seems odd to me that the view has to do
Daniel Erat
2011/10/28 00:53:13
It's needed for Pepper Flash.
| |
387 } else { | |
388 NativeWebKeyboardEvent webkit_event(event); | |
389 host_->ForwardKeyboardEvent(webkit_event); | |
390 } | |
377 return true; | 391 return true; |
378 } | 392 } |
379 | 393 |
380 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { | 394 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) { |
381 // TODO(beng): talk to beng before implementing this. | 395 // TODO(beng): talk to beng before implementing this. |
382 //NOTIMPLEMENTED(); | 396 //NOTIMPLEMENTED(); |
383 return gfx::kNullCursor; | 397 return gfx::kNullCursor; |
384 } | 398 } |
385 | 399 |
386 int RenderWidgetHostViewAura::GetNonClientComponent( | 400 int RenderWidgetHostViewAura::GetNonClientComponent( |
387 const gfx::Point& point) const { | 401 const gfx::Point& point) const { |
388 return HTCLIENT; | 402 return HTCLIENT; |
389 } | 403 } |
390 | 404 |
391 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { | 405 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { |
406 // TODO: Mouse clicks don't have the desired effect on <SELECT> popups: | |
407 // clicking on an item closes the popup, but the item doesn't get selected. | |
408 // Figure out why. | |
392 if (event->type() == ui::ET_MOUSEWHEEL) | 409 if (event->type() == ui::ET_MOUSEWHEEL) |
393 host_->ForwardWheelEvent(content::MakeWebMouseWheelEvent(event)); | 410 host_->ForwardWheelEvent(content::MakeWebMouseWheelEvent(event, window_)); |
394 else | 411 else |
395 host_->ForwardMouseEvent(content::MakeWebMouseEvent(event)); | 412 host_->ForwardMouseEvent(content::MakeWebMouseEvent(event, window_)); |
396 | 413 |
397 // Return true so that we receive released/drag events. | 414 // Return true so that we receive released/drag events. |
398 return true; | 415 return true; |
399 } | 416 } |
400 | 417 |
401 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( | 418 ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( |
402 aura::TouchEvent* event) { | 419 aura::TouchEvent* event) { |
403 // Update the touch event first. | 420 // Update the touch event first. |
404 WebKit::WebTouchPoint* point = content::UpdateWebTouchEvent(event, | 421 WebKit::WebTouchPoint* point = content::UpdateWebTouchEvent(event, |
405 &touch_event_); | 422 &touch_event_); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 } | 483 } |
467 #endif | 484 #endif |
468 | 485 |
469 //////////////////////////////////////////////////////////////////////////////// | 486 //////////////////////////////////////////////////////////////////////////////// |
470 // RenderWidgetHostViewAura, private: | 487 // RenderWidgetHostViewAura, private: |
471 | 488 |
472 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 489 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
473 //NOTIMPLEMENTED(); | 490 //NOTIMPLEMENTED(); |
474 // TODO(beng): See RenderWidgetHostViewWin. | 491 // TODO(beng): See RenderWidgetHostViewWin. |
475 } | 492 } |
OLD | NEW |