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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 window_->SetBounds(rect); | 332 window_->SetBounds(rect); |
333 host_->WasResized(); | 333 host_->WasResized(); |
334 } | 334 } |
335 | 335 |
336 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { | 336 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { |
337 return window_; | 337 return window_; |
338 } | 338 } |
339 | 339 |
340 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { | 340 gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { |
| 341 #if defined(OS_WIN) |
| 342 HWND window = window_->GetRootWindow()->GetAcceleratedWidget(); |
| 343 return reinterpret_cast<gfx::NativeViewId>(window); |
| 344 #else |
341 return static_cast<gfx::NativeViewId>(NULL); | 345 return static_cast<gfx::NativeViewId>(NULL); |
| 346 #endif |
342 } | 347 } |
343 | 348 |
344 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() { | 349 gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() { |
345 NOTIMPLEMENTED(); | 350 NOTIMPLEMENTED(); |
346 return static_cast<gfx::NativeViewAccessible>(NULL); | 351 return static_cast<gfx::NativeViewAccessible>(NULL); |
347 } | 352 } |
348 | 353 |
349 void RenderWidgetHostViewAura::MovePluginWindows( | 354 void RenderWidgetHostViewAura::MovePluginWindows( |
350 const std::vector<webkit::npapi::WebPluginGeometry>& moves) { | 355 const gfx::Point& scroll_offset, |
351 // We don't support windowed plugins. | 356 const std::vector<webkit::npapi::WebPluginGeometry>& plugin_window_moves) { |
| 357 #if defined(OS_WIN) |
| 358 HWND parent = window_->GetRootWindow()->GetAcceleratedWidget(); |
| 359 gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); |
| 360 std::vector<webkit::npapi::WebPluginGeometry> moves = plugin_window_moves; |
| 361 |
| 362 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(), |
| 363 view_bounds.height()); |
| 364 |
| 365 for (size_t i = 0; i < moves.size(); ++i) { |
| 366 gfx::Rect clip = moves[i].clip_rect; |
| 367 clip.Offset(moves[i].window_rect.origin()); |
| 368 clip.Offset(scroll_offset); |
| 369 clip = clip.Intersect(view_port); |
| 370 clip.Offset(-moves[i].window_rect.x(), -moves[i].window_rect.y()); |
| 371 clip.Offset(-scroll_offset.x(), -scroll_offset.y()); |
| 372 moves[i].clip_rect = clip; |
| 373 |
| 374 moves[i].window_rect.Offset(view_bounds.origin()); |
| 375 } |
| 376 MovePluginWindowsHelper(parent, moves); |
| 377 #endif // defined(OS_WIN) |
352 } | 378 } |
353 | 379 |
354 void RenderWidgetHostViewAura::Focus() { | 380 void RenderWidgetHostViewAura::Focus() { |
355 // Make sure we have a FocusManager before attempting to Focus(). In some | 381 // Make sure we have a FocusManager before attempting to Focus(). In some |
356 // situations we may not yet be in a valid Window hierarchy (such as reloading | 382 // situations we may not yet be in a valid Window hierarchy (such as reloading |
357 // after out of memory discared the tab). | 383 // after out of memory discared the tab). |
358 if (window_->GetFocusManager()) | 384 if (window_->GetFocusManager()) |
359 window_->Focus(); | 385 window_->Focus(); |
360 } | 386 } |
361 | 387 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 472 |
447 if (!scroll_rect.IsEmpty()) | 473 if (!scroll_rect.IsEmpty()) |
448 SchedulePaintIfNotInClip(scroll_rect, clip_rect); | 474 SchedulePaintIfNotInClip(scroll_rect, clip_rect); |
449 | 475 |
450 for (size_t i = 0; i < copy_rects.size(); ++i) { | 476 for (size_t i = 0; i < copy_rects.size(); ++i) { |
451 gfx::Rect rect = copy_rects[i].Subtract(scroll_rect); | 477 gfx::Rect rect = copy_rects[i].Subtract(scroll_rect); |
452 if (rect.IsEmpty()) | 478 if (rect.IsEmpty()) |
453 continue; | 479 continue; |
454 | 480 |
455 SchedulePaintIfNotInClip(rect, clip_rect); | 481 SchedulePaintIfNotInClip(rect, clip_rect); |
| 482 |
| 483 #if defined(OS_WIN) |
| 484 // Send the invalid rect in screen coordinates. |
| 485 gfx::Rect screen_rect = GetViewBounds(); |
| 486 gfx::Rect invalid_screen_rect(rect); |
| 487 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); |
| 488 HWND hwnd = window_->GetRootWindow()->GetAcceleratedWidget(); |
| 489 PaintPluginWindowsHelper(hwnd, invalid_screen_rect); |
| 490 #endif // defined(OS_WIN) |
456 } | 491 } |
457 } | 492 } |
458 | 493 |
459 void RenderWidgetHostViewAura::RenderViewGone(base::TerminationStatus status, | 494 void RenderWidgetHostViewAura::RenderViewGone(base::TerminationStatus status, |
460 int error_code) { | 495 int error_code) { |
461 UpdateCursorIfOverSelf(); | 496 UpdateCursorIfOverSelf(); |
462 Destroy(); | 497 Destroy(); |
463 } | 498 } |
464 | 499 |
465 void RenderWidgetHostViewAura::Destroy() { | 500 void RenderWidgetHostViewAura::Destroy() { |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 RenderWidgetHost* widget) { | 1714 RenderWidgetHost* widget) { |
1680 return new RenderWidgetHostViewAura(widget); | 1715 return new RenderWidgetHostViewAura(widget); |
1681 } | 1716 } |
1682 | 1717 |
1683 // static | 1718 // static |
1684 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1719 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
1685 GetScreenInfoForWindow(results, NULL); | 1720 GetScreenInfoForWindow(results, NULL); |
1686 } | 1721 } |
1687 | 1722 |
1688 } // namespace content | 1723 } // namespace content |
OLD | NEW |