| 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 "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/client/tooltip_client.h" | 16 #include "ui/aura/client/tooltip_client.h" |
| 17 #include "ui/aura/desktop.h" | |
| 18 #include "ui/aura/event.h" | 17 #include "ui/aura/event.h" |
| 18 #include "ui/aura/root_window.h" |
| 19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_types.h" | 20 #include "ui/aura/window_types.h" |
| 21 #include "ui/base/hit_test.h" | 21 #include "ui/base/hit_test.h" |
| 22 #include "ui/base/ui_base_types.h" | 22 #include "ui/base/ui_base_types.h" |
| 23 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/compositor/layer.h" | 24 #include "ui/gfx/compositor/layer.h" |
| 25 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
| 26 | 26 |
| 27 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 27 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
| 28 #include "base/bind.h" | 28 #include "base/bind.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 const gfx::Rect& pos) { | 118 const gfx::Rect& pos) { |
| 119 popup_parent_host_view_ = | 119 popup_parent_host_view_ = |
| 120 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 120 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
| 121 window_->SetType(aura::WINDOW_TYPE_MENU); | 121 window_->SetType(aura::WINDOW_TYPE_MENU); |
| 122 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); | 122 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); |
| 123 window_->SetName("RenderWidgetHostViewAura"); | 123 window_->SetName("RenderWidgetHostViewAura"); |
| 124 | 124 |
| 125 window_->SetParent(NULL); | 125 window_->SetParent(NULL); |
| 126 Show(); | 126 Show(); |
| 127 | 127 |
| 128 // |pos| is in desktop coordinates. So convert it to | 128 // |pos| is in root window coordinates. So convert it to |
| 129 // |popup_parent_host_view_|'s coordinates first. | 129 // |popup_parent_host_view_|'s coordinates first. |
| 130 gfx::Point origin = pos.origin(); | 130 gfx::Point origin = pos.origin(); |
| 131 aura::Window::ConvertPointToWindow( | 131 aura::Window::ConvertPointToWindow( |
| 132 aura::Desktop::GetInstance(), | 132 aura::RootWindow::GetInstance(), |
| 133 popup_parent_host_view_->window_, &origin); | 133 popup_parent_host_view_->window_, &origin); |
| 134 SetBounds(gfx::Rect(origin, pos.size())); | 134 SetBounds(gfx::Rect(origin, pos.size())); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void RenderWidgetHostViewAura::InitAsFullscreen( | 137 void RenderWidgetHostViewAura::InitAsFullscreen( |
| 138 RenderWidgetHostView* reference_host_view) { | 138 RenderWidgetHostView* reference_host_view) { |
| 139 is_fullscreen_ = true; | 139 is_fullscreen_ = true; |
| 140 window_->SetType(aura::WINDOW_TYPE_NORMAL); | 140 window_->SetType(aura::WINDOW_TYPE_NORMAL); |
| 141 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); | 141 window_->Init(ui::Layer::LAYER_HAS_TEXTURE); |
| 142 window_->SetName("RenderWidgetHostViewAura"); | 142 window_->SetName("RenderWidgetHostViewAura"); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 UpdateCursorIfOverSelf(); | 266 UpdateCursorIfOverSelf(); |
| 267 Destroy(); | 267 Destroy(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void RenderWidgetHostViewAura::Destroy() { | 270 void RenderWidgetHostViewAura::Destroy() { |
| 271 delete window_; | 271 delete window_; |
| 272 } | 272 } |
| 273 | 273 |
| 274 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { | 274 void RenderWidgetHostViewAura::SetTooltipText(const string16& tooltip_text) { |
| 275 tooltip_ = tooltip_text; | 275 tooltip_ = tooltip_text; |
| 276 void* property = aura::Desktop::GetInstance()->GetProperty( | 276 void* property = aura::RootWindow::GetInstance()->GetProperty( |
| 277 aura::kDesktopTooltipClientKey); | 277 aura::kRootWindowTooltipClientKey); |
| 278 if (property) { | 278 if (property) { |
| 279 aura::TooltipClient* tc = static_cast<aura::TooltipClient*>(property); | 279 aura::TooltipClient* tc = static_cast<aura::TooltipClient*>(property); |
| 280 tc->UpdateTooltip(window_); | 280 tc->UpdateTooltip(window_); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( | 284 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( |
| 285 const gfx::Size& size) { | 285 const gfx::Size& size) { |
| 286 return new BackingStoreSkia(host_, size); | 286 return new BackingStoreSkia(host_, size); |
| 287 } | 287 } |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 on_compositing_ended_callbacks_.clear(); | 588 on_compositing_ended_callbacks_.clear(); |
| 589 compositor->RemoveObserver(this); | 589 compositor->RemoveObserver(this); |
| 590 } | 590 } |
| 591 #endif | 591 #endif |
| 592 | 592 |
| 593 //////////////////////////////////////////////////////////////////////////////// | 593 //////////////////////////////////////////////////////////////////////////////// |
| 594 // RenderWidgetHostViewAura, private: | 594 // RenderWidgetHostViewAura, private: |
| 595 | 595 |
| 596 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 596 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
| 597 const gfx::Point screen_point = gfx::Screen::GetCursorScreenPoint(); | 597 const gfx::Point screen_point = gfx::Screen::GetCursorScreenPoint(); |
| 598 aura::Desktop* desktop = aura::Desktop::GetInstance(); | 598 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
| 599 if (desktop->GetEventHandlerForPoint(screen_point) != window_) | 599 if (root_window->GetEventHandlerForPoint(screen_point) != window_) |
| 600 return; | 600 return; |
| 601 | 601 |
| 602 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor(); | 602 gfx::NativeCursor cursor = current_cursor_.GetNativeCursor(); |
| 603 if (is_loading_ && cursor == aura::kCursorPointer) | 603 if (is_loading_ && cursor == aura::kCursorPointer) |
| 604 cursor = aura::kCursorProgress; | 604 cursor = aura::kCursorProgress; |
| 605 | 605 |
| 606 aura::Desktop::GetInstance()->SetCursor(cursor); | 606 aura::RootWindow::GetInstance()->SetCursor(cursor); |
| 607 } | 607 } |
| 608 | 608 |
| 609 //////////////////////////////////////////////////////////////////////////////// | 609 //////////////////////////////////////////////////////////////////////////////// |
| 610 // RenderWidgetHostView, public: | 610 // RenderWidgetHostView, public: |
| 611 | 611 |
| 612 // static | 612 // static |
| 613 void RenderWidgetHostView::GetDefaultScreenInfo( | 613 void RenderWidgetHostView::GetDefaultScreenInfo( |
| 614 WebKit::WebScreenInfo* results) { | 614 WebKit::WebScreenInfo* results) { |
| 615 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); | 615 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); |
| 616 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); | 616 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); |
| 617 results->availableRect = results->rect; | 617 results->availableRect = results->rect; |
| 618 // TODO(derat): Don't hardcode this? | 618 // TODO(derat): Don't hardcode this? |
| 619 results->depth = 24; | 619 results->depth = 24; |
| 620 results->depthPerComponent = 8; | 620 results->depthPerComponent = 8; |
| 621 } | 621 } |
| OLD | NEW |