| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #include "ui/aura/client/window_tree_client.h" | 60 #include "ui/aura/client/window_tree_client.h" |
| 61 #include "ui/aura/env.h" | 61 #include "ui/aura/env.h" |
| 62 #include "ui/aura/root_window.h" | 62 #include "ui/aura/root_window.h" |
| 63 #include "ui/aura/window.h" | 63 #include "ui/aura/window.h" |
| 64 #include "ui/aura/window_observer.h" | 64 #include "ui/aura/window_observer.h" |
| 65 #include "ui/aura/window_tracker.h" | 65 #include "ui/aura/window_tracker.h" |
| 66 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 66 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 67 #include "ui/base/hit_test.h" | 67 #include "ui/base/hit_test.h" |
| 68 #include "ui/base/ime/input_method.h" | 68 #include "ui/base/ime/input_method.h" |
| 69 #include "ui/base/ui_base_types.h" | 69 #include "ui/base/ui_base_types.h" |
| 70 #include "ui/compositor/compositor_vsync_manager.h" |
| 70 #include "ui/compositor/layer.h" | 71 #include "ui/compositor/layer.h" |
| 71 #include "ui/events/event.h" | 72 #include "ui/events/event.h" |
| 72 #include "ui/events/event_utils.h" | 73 #include "ui/events/event_utils.h" |
| 73 #include "ui/events/gestures/gesture_recognizer.h" | 74 #include "ui/events/gestures/gesture_recognizer.h" |
| 74 #include "ui/gfx/canvas.h" | 75 #include "ui/gfx/canvas.h" |
| 75 #include "ui/gfx/display.h" | 76 #include "ui/gfx/display.h" |
| 76 #include "ui/gfx/rect_conversions.h" | 77 #include "ui/gfx/rect_conversions.h" |
| 77 #include "ui/gfx/screen.h" | 78 #include "ui/gfx/screen.h" |
| 78 #include "ui/gfx/size_conversions.h" | 79 #include "ui/gfx/size_conversions.h" |
| 79 #include "ui/gfx/skia_util.h" | 80 #include "ui/gfx/skia_util.h" |
| (...skipping 3274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3354 active_frame_subscriber_textures_.begin(); | 3355 active_frame_subscriber_textures_.begin(); |
| 3355 it != active_frame_subscriber_textures_.end(); | 3356 it != active_frame_subscriber_textures_.end(); |
| 3356 ++it) { | 3357 ++it) { |
| 3357 (*it)->Destroy(); | 3358 (*it)->Destroy(); |
| 3358 } | 3359 } |
| 3359 active_frame_subscriber_textures_.clear(); | 3360 active_frame_subscriber_textures_.clear(); |
| 3360 | 3361 |
| 3361 #if defined(OS_WIN) | 3362 #if defined(OS_WIN) |
| 3362 legacy_render_widget_host_HWND_.reset(NULL); | 3363 legacy_render_widget_host_HWND_.reset(NULL); |
| 3363 #endif | 3364 #endif |
| 3365 |
| 3366 DCHECK(!vsync_manager_); |
| 3364 } | 3367 } |
| 3365 | 3368 |
| 3366 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 3369 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
| 3367 const gfx::Point screen_point = | 3370 const gfx::Point screen_point = |
| 3368 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); | 3371 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(); |
| 3369 aura::Window* root_window = window_->GetRootWindow(); | 3372 aura::Window* root_window = window_->GetRootWindow(); |
| 3370 if (!root_window) | 3373 if (!root_window) |
| 3371 return; | 3374 return; |
| 3372 | 3375 |
| 3373 gfx::Point root_window_point = screen_point; | 3376 gfx::Point root_window_point = screen_point; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3524 | 3527 |
| 3525 #if defined(OS_WIN) | 3528 #if defined(OS_WIN) |
| 3526 // The parent may have changed here. Ensure that the legacy window is | 3529 // The parent may have changed here. Ensure that the legacy window is |
| 3527 // reparented accordingly. | 3530 // reparented accordingly. |
| 3528 if (legacy_render_widget_host_HWND_) | 3531 if (legacy_render_widget_host_HWND_) |
| 3529 legacy_render_widget_host_HWND_->UpdateParent( | 3532 legacy_render_widget_host_HWND_->UpdateParent( |
| 3530 reinterpret_cast<HWND>(GetNativeViewId())); | 3533 reinterpret_cast<HWND>(GetNativeViewId())); |
| 3531 #endif | 3534 #endif |
| 3532 | 3535 |
| 3533 ui::Compositor* compositor = GetCompositor(); | 3536 ui::Compositor* compositor = GetCompositor(); |
| 3534 if (compositor) | 3537 if (compositor) { |
| 3535 compositor->vsync_manager()->AddObserver(this); | 3538 DCHECK(!vsync_manager_); |
| 3539 vsync_manager_ = compositor->vsync_manager(); |
| 3540 vsync_manager_->AddObserver(this); |
| 3541 } |
| 3536 } | 3542 } |
| 3537 | 3543 |
| 3538 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 3544 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 3539 aura::client::CursorClient* cursor_client = | 3545 aura::client::CursorClient* cursor_client = |
| 3540 aura::client::GetCursorClient(window_->GetRootWindow()); | 3546 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 3541 if (cursor_client) | 3547 if (cursor_client) |
| 3542 cursor_client->RemoveObserver(this); | 3548 cursor_client->RemoveObserver(this); |
| 3543 | 3549 |
| 3544 DetachFromInputMethod(); | 3550 DetachFromInputMethod(); |
| 3545 | 3551 |
| 3546 window_->GetDispatcher()->RemoveRootWindowObserver(this); | 3552 window_->GetDispatcher()->RemoveRootWindowObserver(this); |
| 3547 ui::Compositor* compositor = GetCompositor(); | 3553 ui::Compositor* compositor = GetCompositor(); |
| 3548 if (current_surface_.get()) { | 3554 if (current_surface_.get()) { |
| 3549 // We can't get notification for commits after this point, which would | 3555 // We can't get notification for commits after this point, which would |
| 3550 // guarantee that the compositor isn't using an old texture any more, so | 3556 // guarantee that the compositor isn't using an old texture any more, so |
| 3551 // instead we force the layer to stop using any external resources which | 3557 // instead we force the layer to stop using any external resources which |
| 3552 // synchronizes with the compositor thread, and makes it safe to run the | 3558 // synchronizes with the compositor thread, and makes it safe to run the |
| 3553 // callback. | 3559 // callback. |
| 3554 window_->layer()->SetShowPaintedContent(); | 3560 window_->layer()->SetShowPaintedContent(); |
| 3555 } | 3561 } |
| 3556 RunOnCommitCallbacks(); | 3562 RunOnCommitCallbacks(); |
| 3557 resize_lock_.reset(); | 3563 resize_lock_.reset(); |
| 3558 host_->WasResized(); | 3564 host_->WasResized(); |
| 3559 | 3565 |
| 3560 if (compositor) { | 3566 if (compositor && compositor->HasObserver(this)) |
| 3561 if (compositor->HasObserver(this)) | 3567 compositor->RemoveObserver(this); |
| 3562 compositor->RemoveObserver(this); | |
| 3563 compositor->vsync_manager()->RemoveObserver(this); | |
| 3564 } | |
| 3565 | 3568 |
| 3566 #if defined(OS_WIN) | 3569 #if defined(OS_WIN) |
| 3567 // Update the legacy window's parent temporarily to the desktop window. It | 3570 // Update the legacy window's parent temporarily to the desktop window. It |
| 3568 // will eventually get reparented to the right root. | 3571 // will eventually get reparented to the right root. |
| 3569 if (legacy_render_widget_host_HWND_) | 3572 if (legacy_render_widget_host_HWND_) |
| 3570 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); | 3573 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); |
| 3571 #endif | 3574 #endif |
| 3575 |
| 3576 if (vsync_manager_) { |
| 3577 vsync_manager_->RemoveObserver(this); |
| 3578 vsync_manager_ = NULL; |
| 3579 } |
| 3572 } | 3580 } |
| 3573 | 3581 |
| 3574 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { | 3582 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { |
| 3575 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 3583 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
| 3576 return dispatcher ? dispatcher->host()->compositor() : NULL; | 3584 return dispatcher ? dispatcher->host()->compositor() : NULL; |
| 3577 } | 3585 } |
| 3578 | 3586 |
| 3579 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 3587 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
| 3580 ui::InputMethod* input_method = GetInputMethod(); | 3588 ui::InputMethod* input_method = GetInputMethod(); |
| 3581 if (input_method && input_method->GetTextInputClient() == this) | 3589 if (input_method && input_method->GetTextInputClient() == this) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3600 RenderWidgetHost* widget) { | 3608 RenderWidgetHost* widget) { |
| 3601 return new RenderWidgetHostViewAura(widget); | 3609 return new RenderWidgetHostViewAura(widget); |
| 3602 } | 3610 } |
| 3603 | 3611 |
| 3604 // static | 3612 // static |
| 3605 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3613 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3606 GetScreenInfoForWindow(results, NULL); | 3614 GetScreenInfoForWindow(results, NULL); |
| 3607 } | 3615 } |
| 3608 | 3616 |
| 3609 } // namespace content | 3617 } // namespace content |
| OLD | NEW |