Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: ash/system/tray/tray_background_view.cc

Issue 10836227: Fix status area accessability issues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | ash/system/tray/tray_bubble_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_background_view.cc
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 0a2a196561af7ce97d1e7c9b6128cd793c431459..49cc7136d551f082f35580a73f14914ba999b363 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -11,6 +11,8 @@
#include "ash/system/status_area_widget_delegate.h"
#include "ash/system/tray/tray_constants.h"
#include "ui/aura/window.h"
+#include "ui/base/accessibility/accessible_view_state.h"
+#include "ui/compositor/layer_animation_observer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/skia_util.h"
#include "ui/views/background.h"
@@ -32,6 +34,33 @@ const int kTrayContainerHorizontalPaddingVerticalAlignment = 1;
namespace ash {
namespace internal {
+// Observe the tray layer animation and update the anchor when it changes.
+// TODO(stevenjb): Observe or mirror the actual animation, not just the start
+// and end points.
+class TrayLayerAnimationObserver : public ui::LayerAnimationObserver {
+ public:
+ explicit TrayLayerAnimationObserver(TrayBackgroundView* host)
+ : host_(host) {
+ }
+
+ virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) {
+ host_->AnchorUpdated();
+ }
+
+ virtual void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) {
+ host_->AnchorUpdated();
+ }
+
+ virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* sequence) {
+ host_->AnchorUpdated();
+ }
+
+ private:
+ TrayBackgroundView* host_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayLayerAnimationObserver);
+};
+
class TrayBackground : public views::Background {
public:
TrayBackground() : alpha_(kTrayBackgroundAlpha) {}
@@ -144,22 +173,53 @@ TrayBackgroundView::TrayBackgroundView(
}
TrayBackgroundView::~TrayBackgroundView() {
+ GetWidget()->GetNativeView()->layer()->GetAnimator()->RemoveObserver(
+ layer_animation_observer_.get());
+}
+
+void TrayBackgroundView::Initialize() {
+ layer_animation_observer_.reset(new TrayLayerAnimationObserver(this));
+ GetWidget()->GetNativeView()->layer()->GetAnimator()->AddObserver(
+ layer_animation_observer_.get());
+ SetBorder();
}
void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
hover_background_animator_.SetPaintsBackground(true,
internal::BackgroundAnimator::CHANGE_ANIMATE);
+ UpdateShouldShowLauncher();
}
void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) {
hover_background_animator_.SetPaintsBackground(false,
internal::BackgroundAnimator::CHANGE_ANIMATE);
+ UpdateShouldShowLauncher();
}
void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) {
PreferredSizeChanged();
}
+void TrayBackgroundView::OnPaintFocusBorder(gfx::Canvas* canvas) {
+ // The tray itself expands to the right and bottom edge of the screen to make
+ // sure clicking on the edges brings up the popup. However, the focus border
+ // should be only around the container.
+ if (HasFocus() && (focusable() || IsAccessibilityFocusable()))
+ DrawBorder(canvas, GetContentsBounds());
+}
+
+void TrayBackgroundView::GetAccessibleState(ui::AccessibleViewState* state) {
+ state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
+ state->name = GetAccessibleName();
+}
+
+void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) {
+ // Return focus to the login view. See crbug.com/120500.
+ views::View* v = GetNextFocusableView();
+ if (v)
+ v->AboutToRequestFocusFromTabTraversal(reverse);
+}
+
bool TrayBackgroundView::PerformAction(const ui::Event& event) {
return false;
}
@@ -194,9 +254,8 @@ void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
void TrayBackgroundView::SetBorder() {
views::View* parent = status_area_widget_->status_area_widget_delegate();
- int child_count = parent->child_count();
- DCHECK(child_count > 0);
- int on_edge = (this == parent->child_at(child_count-1));
+ // Tray views are laid out right-to-left or bottom-to-top
+ int on_edge = (this == parent->child_at(0));
// Change the border padding for different shelf alignment.
if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
set_border(views::Border::CreateEmptyBorder(
@@ -215,5 +274,9 @@ void TrayBackgroundView::SetBorder() {
}
}
+void TrayBackgroundView::UpdateShouldShowLauncher() {
+ status_area_widget()->UpdateShouldShowLauncher();
+}
+
} // namespace internal
} // namespace ash
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | ash/system/tray/tray_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698