Chromium Code Reviews| 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 "chrome/browser/ui/views/infobars/infobar_view.h" | 5 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 78 |
| 79 InfoBarView::InfoBarView(scoped_ptr<infobars::InfoBarDelegate> delegate) | 79 InfoBarView::InfoBarView(scoped_ptr<infobars::InfoBarDelegate> delegate) |
| 80 : infobars::InfoBar(std::move(delegate)), | 80 : infobars::InfoBar(std::move(delegate)), |
| 81 views::ExternalFocusTracker(this, nullptr), | 81 views::ExternalFocusTracker(this, nullptr), |
| 82 child_container_(new views::View()), | 82 child_container_(new views::View()), |
| 83 icon_(nullptr), | 83 icon_(nullptr), |
| 84 close_button_(nullptr) { | 84 close_button_(nullptr) { |
| 85 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. | 85 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. |
| 86 set_background( | 86 set_background( |
| 87 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType())); | 87 new InfoBarBackground(infobars::InfoBar::delegate()->GetInfoBarType())); |
| 88 SetEventTargeter(make_scoped_ptr(new views::ViewTargeter(this))); | |
| 88 | 89 |
| 89 AddChildView(child_container_); | 90 AddChildView(child_container_); |
| 90 | 91 |
| 91 if (ui::MaterialDesignController::IsModeMaterial()) { | 92 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 93 SetPaintToLayer(true); | |
| 94 layer()->SetFillsBoundsOpaquely(false); | |
| 95 | |
| 92 child_container_->SetPaintToLayer(true); | 96 child_container_->SetPaintToLayer(true); |
| 93 child_container_->layer()->SetMasksToBounds(true); | 97 child_container_->layer()->SetMasksToBounds(true); |
| 94 // Since MD doesn't use a gradient, we can set a solid bg color. | 98 // Since MD doesn't use a gradient, we can set a solid bg color. |
| 95 child_container_->set_background( | 99 child_container_->set_background( |
| 96 views::Background::CreateSolidBackground(infobars::InfoBar::GetTopColor( | 100 views::Background::CreateSolidBackground(infobars::InfoBar::GetTopColor( |
| 97 infobars::InfoBar::delegate()->GetInfoBarType()))); | 101 infobars::InfoBar::delegate()->GetInfoBarType()))); |
| 98 } | 102 } |
| 99 } | 103 } |
| 100 | 104 |
| 101 InfoBarView::~InfoBarView() { | 105 InfoBarView::~InfoBarView() { |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 422 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
| 419 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); | 423 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); |
| 420 | 424 |
| 421 // This will trigger some screen readers to read the entire contents of this | 425 // This will trigger some screen readers to read the entire contents of this |
| 422 // infobar. | 426 // infobar. |
| 423 if (focused_before && focused_now && !Contains(focused_before) && | 427 if (focused_before && focused_now && !Contains(focused_before) && |
| 424 Contains(focused_now)) { | 428 Contains(focused_now)) { |
| 425 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 429 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 426 } | 430 } |
| 427 } | 431 } |
| 432 | |
| 433 bool InfoBarView::DoesIntersectRect(const View* target, | |
| 434 const gfx::Rect& rect) const { | |
| 435 DCHECK_EQ(this, target); | |
| 436 // Only events that intersect the portion below the arrow are interesting. | |
| 437 gfx::Rect non_arrow_bounds = GetLocalBounds(); | |
| 438 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); | |
| 439 return rect.Intersects(non_arrow_bounds); | |
|
Evan Stade
2016/03/14 23:23:47
turns out Intersects is required to fix bug 593640
| |
| 440 } | |
| OLD | NEW |