forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port ash's accessibility focus ring to chromecast.
- Copies ash's AccessibilityFocusRing and friends into chromecast/graphics/accessibility. See patchset chromium#1 for the pure copy operation without modifications. - Modify the above to work without ash: explicit configuration of the CastWindowManagerAura's root window and window activation client (ash has global singletons for these). - Add AccessibilityManager class which delegates to the above, roughly analogous to the equivalent in chromeos. Configured as a browser process singleton in CastBrowserProcess. - Call AccessibilityManager from the accessibilityPrivate extensionsion API, so that ChromeVox can use it. Bug: internal b/73383411 Test: manual test Change-Id: I0019c56e7be84abc2a97b429b3820f8d8f69ffbf Reviewed-on: https://chromium-review.googlesource.com/1071720 Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Alex Sakhartchouk <alexst@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Commit-Queue: Ryan Daum <rdaum@chromium.org> Cr-Commit-Position: refs/heads/master@{#563299}
- Loading branch information
Ryan Daum
authored and
Commit Bot
committed
May 31, 2018
1 parent
9c9cfa0
commit b653982
Showing
32 changed files
with
2,419 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
chromecast/graphics/accessibility/accessibility_cursor_ring_layer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Copied with modifications from ash/accessibility, refactored for use in | ||
// chromecast. | ||
|
||
#include "chromecast/graphics/accessibility/accessibility_cursor_ring_layer.h" | ||
|
||
#include "third_party/skia/include/core/SkPaint.h" | ||
#include "third_party/skia/include/core/SkPath.h" | ||
#include "ui/aura/window.h" | ||
#include "ui/compositor/layer.h" | ||
#include "ui/compositor/paint_recorder.h" | ||
#include "ui/display/display.h" | ||
#include "ui/display/screen.h" | ||
#include "ui/gfx/canvas.h" | ||
#include "ui/wm/core/coordinate_conversion.h" | ||
|
||
namespace chromecast { | ||
|
||
namespace { | ||
|
||
// The number of pixels in the color gradient that fades to transparent. | ||
const int kGradientWidth = 8; | ||
|
||
// The radius of the ring in pixels. | ||
const int kCursorRingRadius = 24; | ||
|
||
// Extra margin to add to the layer in pixels. | ||
const int kLayerMargin = 8; | ||
|
||
} // namespace | ||
|
||
AccessibilityCursorRingLayer::AccessibilityCursorRingLayer( | ||
aura::Window* root_window, | ||
AccessibilityLayerDelegate* delegate, | ||
int red, | ||
int green, | ||
int blue) | ||
: FocusRingLayer(root_window, delegate), | ||
red_(red), | ||
green_(green), | ||
blue_(blue) {} | ||
|
||
AccessibilityCursorRingLayer::~AccessibilityCursorRingLayer() = default; | ||
|
||
void AccessibilityCursorRingLayer::Set(const gfx::Point& location) { | ||
location_ = location; | ||
|
||
gfx::Rect bounds = gfx::Rect(location.x(), location.y(), 0, 0); | ||
int inset = kGradientWidth + kCursorRingRadius + kLayerMargin; | ||
bounds.Inset(-inset, -inset, -inset, -inset); | ||
|
||
DCHECK(root_window()); | ||
display::Display display = | ||
display::Screen::GetScreen()->GetDisplayMatching(bounds); | ||
::wm::ConvertRectFromScreen(root_window(), &bounds); | ||
CreateOrUpdateLayer(root_window(), "AccessibilityCursorRing", bounds); | ||
} | ||
|
||
void AccessibilityCursorRingLayer::OnPaintLayer( | ||
const ui::PaintContext& context) { | ||
ui::PaintRecorder recorder(context, layer()->size()); | ||
|
||
cc::PaintFlags flags; | ||
flags.setAntiAlias(true); | ||
flags.setStyle(cc::PaintFlags::kStroke_Style); | ||
flags.setStrokeWidth(2); | ||
|
||
gfx::Rect r = layer()->bounds(); | ||
r.Offset(-r.OffsetFromOrigin()); | ||
r.Inset(kLayerMargin, kLayerMargin, kLayerMargin, kLayerMargin); | ||
const int w = kGradientWidth; | ||
for (int i = 0; i < w; ++i) { | ||
flags.setColor(SkColorSetARGB(255 * i * i / (w * w), red_, green_, blue_)); | ||
SkPath path; | ||
path.addOval(SkRect::MakeXYWH(r.x(), r.y(), r.width(), r.height())); | ||
r.Inset(1, 1, 1, 1); | ||
recorder.canvas()->DrawPath(path, flags); | ||
} | ||
} | ||
|
||
} // namespace chromecast |
46 changes: 46 additions & 0 deletions
46
chromecast/graphics/accessibility/accessibility_cursor_ring_layer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Copied with modifications from ash/accessibility, refactored for use in | ||
// chromecast. | ||
|
||
#ifndef CHROMECAST_GRAPHICS_ACCESSIBILITY_ACCESSIBILITY_CURSOR_RING_LAYER_H_ | ||
#define CHROMECAST_GRAPHICS_ACCESSIBILITY_ACCESSIBILITY_CURSOR_RING_LAYER_H_ | ||
|
||
#include "chromecast/graphics/accessibility/accessibility_focus_ring.h" | ||
#include "chromecast/graphics/accessibility/focus_ring_layer.h" | ||
|
||
namespace chromecast { | ||
|
||
// A subclass of FocusRingLayer that highlights the mouse cursor while it's | ||
// moving, to make it easier to find visually. | ||
class AccessibilityCursorRingLayer : public FocusRingLayer { | ||
public: | ||
AccessibilityCursorRingLayer(aura::Window* root_window, | ||
AccessibilityLayerDelegate* delegate, | ||
int red, | ||
int green, | ||
int blue); | ||
~AccessibilityCursorRingLayer() override; | ||
|
||
// Create the layer and update its bounds and position in the hierarchy. | ||
void Set(const gfx::Point& location); | ||
|
||
private: | ||
// ui::LayerDelegate overrides: | ||
void OnPaintLayer(const ui::PaintContext& context) override; | ||
|
||
// The current location. | ||
gfx::Point location_; | ||
|
||
int red_; | ||
int green_; | ||
int blue_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AccessibilityCursorRingLayer); | ||
}; | ||
|
||
} // namespace chromecast | ||
|
||
#endif // CHROMECAST_GRAPHICS_ACCESSIBILITY_ACCESSIBILITY_CURSOR_RING_LAYER_H_ |
Oops, something went wrong.