| 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 467 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
| 468 SetOverscrollControllerEnabled(overscroll_enabled); | 468 SetOverscrollControllerEnabled(overscroll_enabled); |
| 469 } | 469 } |
| 470 | 470 |
| 471 //////////////////////////////////////////////////////////////////////////////// | 471 //////////////////////////////////////////////////////////////////////////////// |
| 472 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 472 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
| 473 | 473 |
| 474 void RenderWidgetHostViewAura::InitAsChild( | 474 void RenderWidgetHostViewAura::InitAsChild( |
| 475 gfx::NativeView parent_view) { | 475 gfx::NativeView parent_view) { |
| 476 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 476 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
| 477 window_->Init(aura::WINDOW_LAYER_TEXTURED); | 477 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 478 window_->SetName("RenderWidgetHostViewAura"); | 478 window_->SetName("RenderWidgetHostViewAura"); |
| 479 window_->layer()->SetColor(SK_ColorWHITE); |
| 479 } | 480 } |
| 480 | 481 |
| 481 void RenderWidgetHostViewAura::InitAsPopup( | 482 void RenderWidgetHostViewAura::InitAsPopup( |
| 482 RenderWidgetHostView* parent_host_view, | 483 RenderWidgetHostView* parent_host_view, |
| 483 const gfx::Rect& bounds_in_screen) { | 484 const gfx::Rect& bounds_in_screen) { |
| 484 popup_parent_host_view_ = | 485 popup_parent_host_view_ = |
| 485 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 486 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
| 486 | 487 |
| 487 // TransientWindowClient may be NULL during tests. | 488 // TransientWindowClient may be NULL during tests. |
| 488 aura::client::TransientWindowClient* transient_window_client = | 489 aura::client::TransientWindowClient* transient_window_client = |
| 489 aura::client::GetTransientWindowClient(); | 490 aura::client::GetTransientWindowClient(); |
| 490 RenderWidgetHostViewAura* old_child = | 491 RenderWidgetHostViewAura* old_child = |
| 491 popup_parent_host_view_->popup_child_host_view_; | 492 popup_parent_host_view_->popup_child_host_view_; |
| 492 if (old_child) { | 493 if (old_child) { |
| 493 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 494 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
| 494 // similar mechanism to ensure a second popup doesn't cause the first one | 495 // similar mechanism to ensure a second popup doesn't cause the first one |
| 495 // to never get a chance to filter events. See crbug.com/160589. | 496 // to never get a chance to filter events. See crbug.com/160589. |
| 496 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 497 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
| 497 if (transient_window_client) { | 498 if (transient_window_client) { |
| 498 transient_window_client->RemoveTransientChild( | 499 transient_window_client->RemoveTransientChild( |
| 499 popup_parent_host_view_->window_, old_child->window_); | 500 popup_parent_host_view_->window_, old_child->window_); |
| 500 } | 501 } |
| 501 old_child->popup_parent_host_view_ = NULL; | 502 old_child->popup_parent_host_view_ = NULL; |
| 502 } | 503 } |
| 503 popup_parent_host_view_->popup_child_host_view_ = this; | 504 popup_parent_host_view_->popup_child_host_view_ = this; |
| 504 window_->SetType(ui::wm::WINDOW_TYPE_MENU); | 505 window_->SetType(ui::wm::WINDOW_TYPE_MENU); |
| 505 window_->Init(aura::WINDOW_LAYER_TEXTURED); | 506 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 506 window_->SetName("RenderWidgetHostViewAura"); | 507 window_->SetName("RenderWidgetHostViewAura"); |
| 508 window_->layer()->SetColor(SK_ColorWHITE); |
| 507 | 509 |
| 508 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); | 510 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); |
| 509 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); | 511 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); |
| 510 // Setting the transient child allows for the popup to get mouse events when | 512 // Setting the transient child allows for the popup to get mouse events when |
| 511 // in a system modal dialog. | 513 // in a system modal dialog. |
| 512 // This fixes crbug.com/328593. | 514 // This fixes crbug.com/328593. |
| 513 if (transient_window_client) { | 515 if (transient_window_client) { |
| 514 transient_window_client->AddTransientChild( | 516 transient_window_client->AddTransientChild( |
| 515 popup_parent_host_view_->window_, window_); | 517 popup_parent_host_view_->window_, window_); |
| 516 } | 518 } |
| 517 | 519 |
| 518 SetBounds(bounds_in_screen); | 520 SetBounds(bounds_in_screen); |
| 519 Show(); | 521 Show(); |
| 520 if (NeedsMouseCapture()) | 522 if (NeedsMouseCapture()) |
| 521 window_->SetCapture(); | 523 window_->SetCapture(); |
| 522 | 524 |
| 523 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 525 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
| 524 } | 526 } |
| 525 | 527 |
| 526 void RenderWidgetHostViewAura::InitAsFullscreen( | 528 void RenderWidgetHostViewAura::InitAsFullscreen( |
| 527 RenderWidgetHostView* reference_host_view) { | 529 RenderWidgetHostView* reference_host_view) { |
| 528 is_fullscreen_ = true; | 530 is_fullscreen_ = true; |
| 529 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 531 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 530 window_->Init(aura::WINDOW_LAYER_TEXTURED); | 532 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 531 window_->SetName("RenderWidgetHostViewAura"); | 533 window_->SetName("RenderWidgetHostViewAura"); |
| 532 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 534 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 535 window_->layer()->SetColor(SK_ColorWHITE); |
| 533 | 536 |
| 534 aura::Window* parent = NULL; | 537 aura::Window* parent = NULL; |
| 535 gfx::Rect bounds; | 538 gfx::Rect bounds; |
| 536 if (reference_host_view) { | 539 if (reference_host_view) { |
| 537 aura::Window* reference_window = | 540 aura::Window* reference_window = |
| 538 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; | 541 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; |
| 539 if (reference_window) { | 542 if (reference_window) { |
| 540 host_tracker_.reset(new aura::WindowTracker); | 543 host_tracker_.reset(new aura::WindowTracker); |
| 541 host_tracker_->Add(reference_window); | 544 host_tracker_->Add(reference_window); |
| 542 } | 545 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 } | 800 } |
| 798 | 801 |
| 799 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { | 802 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { |
| 800 return window_->GetBoundsInScreen(); | 803 return window_->GetBoundsInScreen(); |
| 801 } | 804 } |
| 802 | 805 |
| 803 void RenderWidgetHostViewAura::SetBackgroundOpaque(bool opaque) { | 806 void RenderWidgetHostViewAura::SetBackgroundOpaque(bool opaque) { |
| 804 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); | 807 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); |
| 805 host_->SetBackgroundOpaque(opaque); | 808 host_->SetBackgroundOpaque(opaque); |
| 806 window_->layer()->SetFillsBoundsOpaquely(opaque); | 809 window_->layer()->SetFillsBoundsOpaquely(opaque); |
| 810 SkColor background_color = opaque ? SK_ColorWHITE : SK_ColorTRANSPARENT; |
| 811 window_->layer()->SetColor(background_color); |
| 807 } | 812 } |
| 808 | 813 |
| 809 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { | 814 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { |
| 810 gfx::Rect requested_rect(GetRequestedRendererSize()); | 815 gfx::Rect requested_rect(GetRequestedRendererSize()); |
| 811 requested_rect.Inset(insets_); | 816 requested_rect.Inset(insets_); |
| 812 return requested_rect.size(); | 817 return requested_rect.size(); |
| 813 } | 818 } |
| 814 | 819 |
| 815 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { | 820 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { |
| 816 if (insets != insets_) { | 821 if (insets != insets_) { |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 return popup_type_ == blink::WebPopupTypeNone; | 1679 return popup_type_ == blink::WebPopupTypeNone; |
| 1675 } | 1680 } |
| 1676 | 1681 |
| 1677 void RenderWidgetHostViewAura::OnCaptureLost() { | 1682 void RenderWidgetHostViewAura::OnCaptureLost() { |
| 1678 host_->LostCapture(); | 1683 host_->LostCapture(); |
| 1679 if (touch_editing_client_) | 1684 if (touch_editing_client_) |
| 1680 touch_editing_client_->EndTouchEditing(false); | 1685 touch_editing_client_->EndTouchEditing(false); |
| 1681 } | 1686 } |
| 1682 | 1687 |
| 1683 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { | 1688 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { |
| 1684 // For non-opaque windows, we don't draw anything, since we depend on the | 1689 NOTREACHED(); |
| 1685 // canvas coming from the compositor to already be initialized as | |
| 1686 // transparent. | |
| 1687 if (window_->layer()->fills_bounds_opaquely()) | |
| 1688 canvas->DrawColor(SK_ColorWHITE); | |
| 1689 } | 1690 } |
| 1690 | 1691 |
| 1691 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( | 1692 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( |
| 1692 float device_scale_factor) { | 1693 float device_scale_factor) { |
| 1693 if (!host_ || !window_->GetRootWindow()) | 1694 if (!host_ || !window_->GetRootWindow()) |
| 1694 return; | 1695 return; |
| 1695 | 1696 |
| 1696 UpdateScreenInfo(window_); | 1697 UpdateScreenInfo(window_); |
| 1697 | 1698 |
| 1698 const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> | 1699 const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2569 | 2570 |
| 2570 //////////////////////////////////////////////////////////////////////////////// | 2571 //////////////////////////////////////////////////////////////////////////////// |
| 2571 // RenderWidgetHostViewBase, public: | 2572 // RenderWidgetHostViewBase, public: |
| 2572 | 2573 |
| 2573 // static | 2574 // static |
| 2574 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2575 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2575 GetScreenInfoForWindow(results, NULL); | 2576 GetScreenInfoForWindow(results, NULL); |
| 2576 } | 2577 } |
| 2577 | 2578 |
| 2578 } // namespace content | 2579 } // namespace content |
| OLD | NEW |