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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 IPC_MESSAGE_UNHANDLED(handled = false) | 488 IPC_MESSAGE_UNHANDLED(handled = false) |
489 IPC_END_MESSAGE_MAP() | 489 IPC_END_MESSAGE_MAP() |
490 return handled; | 490 return handled; |
491 } | 491 } |
492 | 492 |
493 void RenderWidgetHostViewAura::InitAsChild( | 493 void RenderWidgetHostViewAura::InitAsChild( |
494 gfx::NativeView parent_view) { | 494 gfx::NativeView parent_view) { |
495 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 495 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
496 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 496 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
497 window_->SetName("RenderWidgetHostViewAura"); | 497 window_->SetName("RenderWidgetHostViewAura"); |
498 window_->layer()->SetColor(SK_ColorWHITE); | 498 window_->layer()->SetColor(background_color_); |
499 } | 499 } |
500 | 500 |
501 void RenderWidgetHostViewAura::InitAsPopup( | 501 void RenderWidgetHostViewAura::InitAsPopup( |
502 RenderWidgetHostView* parent_host_view, | 502 RenderWidgetHostView* parent_host_view, |
503 const gfx::Rect& bounds_in_screen) { | 503 const gfx::Rect& bounds_in_screen) { |
504 popup_parent_host_view_ = | 504 popup_parent_host_view_ = |
505 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 505 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
506 | 506 |
507 // TransientWindowClient may be NULL during tests. | 507 // TransientWindowClient may be NULL during tests. |
508 aura::client::TransientWindowClient* transient_window_client = | 508 aura::client::TransientWindowClient* transient_window_client = |
509 aura::client::GetTransientWindowClient(); | 509 aura::client::GetTransientWindowClient(); |
510 RenderWidgetHostViewAura* old_child = | 510 RenderWidgetHostViewAura* old_child = |
511 popup_parent_host_view_->popup_child_host_view_; | 511 popup_parent_host_view_->popup_child_host_view_; |
512 if (old_child) { | 512 if (old_child) { |
513 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 513 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
514 // similar mechanism to ensure a second popup doesn't cause the first one | 514 // similar mechanism to ensure a second popup doesn't cause the first one |
515 // to never get a chance to filter events. See crbug.com/160589. | 515 // to never get a chance to filter events. See crbug.com/160589. |
516 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 516 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
517 if (transient_window_client) { | 517 if (transient_window_client) { |
518 transient_window_client->RemoveTransientChild( | 518 transient_window_client->RemoveTransientChild( |
519 popup_parent_host_view_->window_, old_child->window_); | 519 popup_parent_host_view_->window_, old_child->window_); |
520 } | 520 } |
521 old_child->popup_parent_host_view_ = NULL; | 521 old_child->popup_parent_host_view_ = NULL; |
522 } | 522 } |
523 popup_parent_host_view_->popup_child_host_view_ = this; | 523 popup_parent_host_view_->popup_child_host_view_ = this; |
524 window_->SetType(ui::wm::WINDOW_TYPE_MENU); | 524 window_->SetType(ui::wm::WINDOW_TYPE_MENU); |
525 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 525 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
526 window_->SetName("RenderWidgetHostViewAura"); | 526 window_->SetName("RenderWidgetHostViewAura"); |
527 window_->layer()->SetColor(SK_ColorWHITE); | 527 window_->layer()->SetColor(background_color_); |
528 | 528 |
529 // Setting the transient child allows for the popup to get mouse events when | 529 // Setting the transient child allows for the popup to get mouse events when |
530 // in a system modal dialog. Do this before calling ParentWindowWithContext | 530 // in a system modal dialog. Do this before calling ParentWindowWithContext |
531 // below so that the transient parent is visible to WindowTreeClient. | 531 // below so that the transient parent is visible to WindowTreeClient. |
532 // This fixes crbug.com/328593. | 532 // This fixes crbug.com/328593. |
533 if (transient_window_client) { | 533 if (transient_window_client) { |
534 transient_window_client->AddTransientChild( | 534 transient_window_client->AddTransientChild( |
535 popup_parent_host_view_->window_, window_); | 535 popup_parent_host_view_->window_, window_); |
536 } | 536 } |
537 | 537 |
538 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); | 538 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); |
539 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); | 539 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); |
540 | 540 |
541 SetBounds(bounds_in_screen); | 541 SetBounds(bounds_in_screen); |
542 Show(); | 542 Show(); |
543 if (NeedsMouseCapture()) | 543 if (NeedsMouseCapture()) |
544 window_->SetCapture(); | 544 window_->SetCapture(); |
545 | 545 |
546 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 546 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
547 } | 547 } |
548 | 548 |
549 void RenderWidgetHostViewAura::InitAsFullscreen( | 549 void RenderWidgetHostViewAura::InitAsFullscreen( |
550 RenderWidgetHostView* reference_host_view) { | 550 RenderWidgetHostView* reference_host_view) { |
551 is_fullscreen_ = true; | 551 is_fullscreen_ = true; |
552 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 552 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
553 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); | 553 window_->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
554 window_->SetName("RenderWidgetHostViewAura"); | 554 window_->SetName("RenderWidgetHostViewAura"); |
555 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 555 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
556 window_->layer()->SetColor(SK_ColorWHITE); | 556 window_->layer()->SetColor(background_color_); |
557 | 557 |
558 aura::Window* parent = NULL; | 558 aura::Window* parent = NULL; |
559 gfx::Rect bounds; | 559 gfx::Rect bounds; |
560 if (reference_host_view) { | 560 if (reference_host_view) { |
561 aura::Window* reference_window = | 561 aura::Window* reference_window = |
562 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; | 562 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; |
563 if (reference_window) { | 563 if (reference_window) { |
564 host_tracker_.reset(new aura::WindowTracker); | 564 host_tracker_.reset(new aura::WindowTracker); |
565 host_tracker_->Add(reference_window); | 565 host_tracker_->Add(reference_window); |
566 } | 566 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 } | 817 } |
818 | 818 |
819 bool RenderWidgetHostViewAura::IsShowing() { | 819 bool RenderWidgetHostViewAura::IsShowing() { |
820 return window_->IsVisible(); | 820 return window_->IsVisible(); |
821 } | 821 } |
822 | 822 |
823 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { | 823 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { |
824 return window_->GetBoundsInScreen(); | 824 return window_->GetBoundsInScreen(); |
825 } | 825 } |
826 | 826 |
827 void RenderWidgetHostViewAura::SetBackgroundOpaque(bool opaque) { | 827 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) { |
828 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); | 828 RenderWidgetHostViewBase::SetBackgroundColor(color); |
| 829 bool opaque = GetBackgroundOpaque(); |
829 host_->SetBackgroundOpaque(opaque); | 830 host_->SetBackgroundOpaque(opaque); |
830 window_->layer()->SetFillsBoundsOpaquely(opaque); | 831 window_->layer()->SetFillsBoundsOpaquely(opaque); |
831 SkColor background_color = opaque ? SK_ColorWHITE : SK_ColorTRANSPARENT; | 832 window_->layer()->SetColor(color); |
832 window_->layer()->SetColor(background_color); | |
833 } | 833 } |
834 | 834 |
835 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { | 835 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { |
836 gfx::Rect requested_rect(GetRequestedRendererSize()); | 836 gfx::Rect requested_rect(GetRequestedRendererSize()); |
837 requested_rect.Inset(insets_); | 837 requested_rect.Inset(insets_); |
838 return requested_rect.size(); | 838 return requested_rect.size(); |
839 } | 839 } |
840 | 840 |
841 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { | 841 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { |
842 if (insets != insets_) { | 842 if (insets != insets_) { |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2615 | 2615 |
2616 //////////////////////////////////////////////////////////////////////////////// | 2616 //////////////////////////////////////////////////////////////////////////////// |
2617 // RenderWidgetHostViewBase, public: | 2617 // RenderWidgetHostViewBase, public: |
2618 | 2618 |
2619 // static | 2619 // static |
2620 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2620 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2621 GetScreenInfoForWindow(results, NULL); | 2621 GetScreenInfoForWindow(results, NULL); |
2622 } | 2622 } |
2623 | 2623 |
2624 } // namespace content | 2624 } // namespace content |
OLD | NEW |