| 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_SOLID_COLOR); | 477 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 478 window_->SetName("RenderWidgetHostViewAura"); | 478 window_->SetName("RenderWidgetHostViewAura"); |
| 479 window_->layer()->SetColor(background_color_); | 479 window_->layer()->SetColor(SK_ColorWHITE); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void RenderWidgetHostViewAura::InitAsPopup( | 482 void RenderWidgetHostViewAura::InitAsPopup( |
| 483 RenderWidgetHostView* parent_host_view, | 483 RenderWidgetHostView* parent_host_view, |
| 484 const gfx::Rect& bounds_in_screen) { | 484 const gfx::Rect& bounds_in_screen) { |
| 485 popup_parent_host_view_ = | 485 popup_parent_host_view_ = |
| 486 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 486 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
| 487 | 487 |
| 488 // TransientWindowClient may be NULL during tests. | 488 // TransientWindowClient may be NULL during tests. |
| 489 aura::client::TransientWindowClient* transient_window_client = | 489 aura::client::TransientWindowClient* transient_window_client = |
| 490 aura::client::GetTransientWindowClient(); | 490 aura::client::GetTransientWindowClient(); |
| 491 RenderWidgetHostViewAura* old_child = | 491 RenderWidgetHostViewAura* old_child = |
| 492 popup_parent_host_view_->popup_child_host_view_; | 492 popup_parent_host_view_->popup_child_host_view_; |
| 493 if (old_child) { | 493 if (old_child) { |
| 494 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 494 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
| 495 // 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 |
| 496 // 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. |
| 497 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 497 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
| 498 if (transient_window_client) { | 498 if (transient_window_client) { |
| 499 transient_window_client->RemoveTransientChild( | 499 transient_window_client->RemoveTransientChild( |
| 500 popup_parent_host_view_->window_, old_child->window_); | 500 popup_parent_host_view_->window_, old_child->window_); |
| 501 } | 501 } |
| 502 old_child->popup_parent_host_view_ = NULL; | 502 old_child->popup_parent_host_view_ = NULL; |
| 503 } | 503 } |
| 504 popup_parent_host_view_->popup_child_host_view_ = this; | 504 popup_parent_host_view_->popup_child_host_view_ = this; |
| 505 window_->SetType(ui::wm::WINDOW_TYPE_MENU); | 505 window_->SetType(ui::wm::WINDOW_TYPE_MENU); |
| 506 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 506 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 507 window_->SetName("RenderWidgetHostViewAura"); | 507 window_->SetName("RenderWidgetHostViewAura"); |
| 508 window_->layer()->SetColor(background_color_); | 508 window_->layer()->SetColor(SK_ColorWHITE); |
| 509 | 509 |
| 510 // Setting the transient child allows for the popup to get mouse events when | 510 // Setting the transient child allows for the popup to get mouse events when |
| 511 // in a system modal dialog. Do this before calling ParentWindowWithContext | 511 // in a system modal dialog. Do this before calling ParentWindowWithContext |
| 512 // below so that the transient parent is visible to WindowTreeClient. | 512 // below so that the transient parent is visible to WindowTreeClient. |
| 513 // This fixes crbug.com/328593. | 513 // This fixes crbug.com/328593. |
| 514 if (transient_window_client) { | 514 if (transient_window_client) { |
| 515 transient_window_client->AddTransientChild( | 515 transient_window_client->AddTransientChild( |
| 516 popup_parent_host_view_->window_, window_); | 516 popup_parent_host_view_->window_, window_); |
| 517 } | 517 } |
| 518 | 518 |
| 519 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); | 519 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); |
| 520 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); | 520 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); |
| 521 | 521 |
| 522 SetBounds(bounds_in_screen); | 522 SetBounds(bounds_in_screen); |
| 523 Show(); | 523 Show(); |
| 524 if (NeedsMouseCapture()) | 524 if (NeedsMouseCapture()) |
| 525 window_->SetCapture(); | 525 window_->SetCapture(); |
| 526 | 526 |
| 527 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 527 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
| 528 } | 528 } |
| 529 | 529 |
| 530 void RenderWidgetHostViewAura::InitAsFullscreen( | 530 void RenderWidgetHostViewAura::InitAsFullscreen( |
| 531 RenderWidgetHostView* reference_host_view) { | 531 RenderWidgetHostView* reference_host_view) { |
| 532 is_fullscreen_ = true; | 532 is_fullscreen_ = true; |
| 533 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 533 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 534 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 534 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| 535 window_->SetName("RenderWidgetHostViewAura"); | 535 window_->SetName("RenderWidgetHostViewAura"); |
| 536 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 536 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 537 window_->layer()->SetColor(background_color_); | 537 window_->layer()->SetColor(SK_ColorWHITE); |
| 538 | 538 |
| 539 aura::Window* parent = NULL; | 539 aura::Window* parent = NULL; |
| 540 gfx::Rect bounds; | 540 gfx::Rect bounds; |
| 541 if (reference_host_view) { | 541 if (reference_host_view) { |
| 542 aura::Window* reference_window = | 542 aura::Window* reference_window = |
| 543 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; | 543 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; |
| 544 if (reference_window) { | 544 if (reference_window) { |
| 545 host_tracker_.reset(new aura::WindowTracker); | 545 host_tracker_.reset(new aura::WindowTracker); |
| 546 host_tracker_->Add(reference_window); | 546 host_tracker_->Add(reference_window); |
| 547 } | 547 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 } | 798 } |
| 799 | 799 |
| 800 bool RenderWidgetHostViewAura::IsShowing() { | 800 bool RenderWidgetHostViewAura::IsShowing() { |
| 801 return window_->IsVisible(); | 801 return window_->IsVisible(); |
| 802 } | 802 } |
| 803 | 803 |
| 804 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { | 804 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { |
| 805 return window_->GetBoundsInScreen(); | 805 return window_->GetBoundsInScreen(); |
| 806 } | 806 } |
| 807 | 807 |
| 808 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) { | 808 void RenderWidgetHostViewAura::SetBackgroundOpaque(bool opaque) { |
| 809 RenderWidgetHostViewBase::SetBackgroundColor(color); | 809 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); |
| 810 bool opaque = GetBackgroundOpaque(); | |
| 811 host_->SetBackgroundOpaque(opaque); | 810 host_->SetBackgroundOpaque(opaque); |
| 812 window_->layer()->SetFillsBoundsOpaquely(opaque); | 811 window_->layer()->SetFillsBoundsOpaquely(opaque); |
| 813 window_->layer()->SetColor(color); | 812 SkColor background_color = opaque ? SK_ColorWHITE : SK_ColorTRANSPARENT; |
| 813 window_->layer()->SetColor(background_color); |
| 814 } | 814 } |
| 815 | 815 |
| 816 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { | 816 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { |
| 817 gfx::Rect requested_rect(GetRequestedRendererSize()); | 817 gfx::Rect requested_rect(GetRequestedRendererSize()); |
| 818 requested_rect.Inset(insets_); | 818 requested_rect.Inset(insets_); |
| 819 return requested_rect.size(); | 819 return requested_rect.size(); |
| 820 } | 820 } |
| 821 | 821 |
| 822 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { | 822 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { |
| 823 if (insets != insets_) { | 823 if (insets != insets_) { |
| (...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2579 | 2579 |
| 2580 //////////////////////////////////////////////////////////////////////////////// | 2580 //////////////////////////////////////////////////////////////////////////////// |
| 2581 // RenderWidgetHostViewBase, public: | 2581 // RenderWidgetHostViewBase, public: |
| 2582 | 2582 |
| 2583 // static | 2583 // static |
| 2584 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2584 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2585 GetScreenInfoForWindow(results, NULL); | 2585 GetScreenInfoForWindow(results, NULL); |
| 2586 } | 2586 } |
| 2587 | 2587 |
| 2588 } // namespace content | 2588 } // namespace content |
| OLD | NEW |