Commit b3474bd3 authored by Josiah K's avatar Josiah K Committed by Commit Bot

Add accessibilityPrivate.onMagnifierBoundsChanged API

(For use in Accessibility Common, to enable Magnifier Panning Improvements including Keyboard Panning)

AX-Relnotes: n/a
Change-Id: I751e8b319488c4dcd0d9e28775a3990ef93cdf10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2491601
Commit-Queue: Josiah Krutz <josiahk@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820433}
parent 976b47b4
...@@ -1526,6 +1526,12 @@ void AccessibilityControllerImpl::RequestAutoclickScrollableBoundsForPoint( ...@@ -1526,6 +1526,12 @@ void AccessibilityControllerImpl::RequestAutoclickScrollableBoundsForPoint(
client_->RequestAutoclickScrollableBoundsForPoint(point_in_screen); client_->RequestAutoclickScrollableBoundsForPoint(point_in_screen);
} }
void AccessibilityControllerImpl::MagnifierBoundsChanged(
const gfx::Rect& bounds_in_screen) {
if (client_)
client_->MagnifierBoundsChanged(bounds_in_screen);
}
void AccessibilityControllerImpl::UpdateAutoclickMenuBoundsIfNeeded() { void AccessibilityControllerImpl::UpdateAutoclickMenuBoundsIfNeeded() {
Shell::Get()->autoclick_controller()->UpdateAutoclickMenuBoundsIfNeeded(); Shell::Get()->autoclick_controller()->UpdateAutoclickMenuBoundsIfNeeded();
} }
......
...@@ -197,6 +197,7 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController, ...@@ -197,6 +197,7 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
void SetAutoclickMenuPosition(FloatingMenuPosition position); void SetAutoclickMenuPosition(FloatingMenuPosition position);
FloatingMenuPosition GetAutoclickMenuPosition(); FloatingMenuPosition GetAutoclickMenuPosition();
void RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen); void RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen);
void MagnifierBoundsChanged(const gfx::Rect& bounds_in_screen);
void SetFloatingMenuPosition(FloatingMenuPosition position); void SetFloatingMenuPosition(FloatingMenuPosition position);
FloatingMenuPosition GetFloatingMenuPosition(); FloatingMenuPosition GetFloatingMenuPosition();
......
...@@ -70,6 +70,9 @@ void TestAccessibilityControllerClient::RequestSelectToSpeakStateChange() { ...@@ -70,6 +70,9 @@ void TestAccessibilityControllerClient::RequestSelectToSpeakStateChange() {
void TestAccessibilityControllerClient:: void TestAccessibilityControllerClient::
RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen) {} RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen) {}
void TestAccessibilityControllerClient::MagnifierBoundsChanged(
const gfx::Rect& bounds_in_screen) {}
void TestAccessibilityControllerClient::OnSwitchAccessDisabled() {} void TestAccessibilityControllerClient::OnSwitchAccessDisabled() {}
int32_t TestAccessibilityControllerClient::GetPlayedEarconAndReset() { int32_t TestAccessibilityControllerClient::GetPlayedEarconAndReset() {
......
...@@ -40,6 +40,7 @@ class TestAccessibilityControllerClient : public AccessibilityControllerClient { ...@@ -40,6 +40,7 @@ class TestAccessibilityControllerClient : public AccessibilityControllerClient {
void RequestSelectToSpeakStateChange() override; void RequestSelectToSpeakStateChange() override;
void RequestAutoclickScrollableBoundsForPoint( void RequestAutoclickScrollableBoundsForPoint(
gfx::Point& point_in_screen) override; gfx::Point& point_in_screen) override;
void MagnifierBoundsChanged(const gfx::Rect& bounds_in_screen) override;
void OnSwitchAccessDisabled() override; void OnSwitchAccessDisabled() override;
int32_t GetPlayedEarconAndReset(); int32_t GetPlayedEarconAndReset();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <vector> #include <vector>
#include "ash/accelerators/accelerator_controller_impl.h" #include "ash/accelerators/accelerator_controller_impl.h"
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/accessibility/accessibility_delegate.h" #include "ash/accessibility/accessibility_delegate.h"
#include "ash/display/root_window_transformers.h" #include "ash/display/root_window_transformers.h"
#include "ash/host/ash_window_tree_host.h" #include "ash/host/ash_window_tree_host.h"
...@@ -701,6 +702,9 @@ bool MagnificationController::RedrawDIP(const gfx::PointF& position_in_dip, ...@@ -701,6 +702,9 @@ bool MagnificationController::RedrawDIP(const gfx::PointF& position_in_dip,
if (duration_in_ms > 0) if (duration_in_ms > 0)
is_on_animation_ = true; is_on_animation_ = true;
Shell::Get()->accessibility_controller()->MagnifierBoundsChanged(
GetViewportRect());
return true; return true;
} }
......
...@@ -17,6 +17,7 @@ enum class Gesture; ...@@ -17,6 +17,7 @@ enum class Gesture;
namespace gfx { namespace gfx {
class Point; class Point;
class PointF; class PointF;
class Rect;
} // namespace gfx } // namespace gfx
namespace ash { namespace ash {
...@@ -82,6 +83,10 @@ class ASH_PUBLIC_EXPORT AccessibilityControllerClient { ...@@ -82,6 +83,10 @@ class ASH_PUBLIC_EXPORT AccessibilityControllerClient {
virtual void RequestAutoclickScrollableBoundsForPoint( virtual void RequestAutoclickScrollableBoundsForPoint(
gfx::Point& point_in_screen) = 0; gfx::Point& point_in_screen) = 0;
// Dispatches update to Accessibility Common extension when magnifier bounds
// have changed.
virtual void MagnifierBoundsChanged(const gfx::Rect& bounds_in_screen) = 0;
// Called when Switch Access is fully disabled by the user accepting the // Called when Switch Access is fully disabled by the user accepting the
// disable dialog. Switch Access must be left running when the pref changes // disable dialog. Switch Access must be left running when the pref changes
// and before the disable dialog is accepted, so that users can use Switch // and before the disable dialog is accepted, so that users can use Switch
......
...@@ -531,11 +531,11 @@ bool AccessibilityManager::PlayEarcon(int sound_key, PlaySoundOption option) { ...@@ -531,11 +531,11 @@ bool AccessibilityManager::PlayEarcon(int sound_key, PlaySoundOption option) {
} }
void AccessibilityManager::OnTwoFingerTouchStart() { void AccessibilityManager::OnTwoFingerTouchStart() {
if (!profile()) if (!profile_)
return; return;
extensions::EventRouter* event_router = extensions::EventRouter* event_router =
extensions::EventRouter::Get(profile()); extensions::EventRouter::Get(profile_);
auto event_args = std::make_unique<base::ListValue>(); auto event_args = std::make_unique<base::ListValue>();
auto event = std::make_unique<extensions::Event>( auto event = std::make_unique<extensions::Event>(
...@@ -546,11 +546,11 @@ void AccessibilityManager::OnTwoFingerTouchStart() { ...@@ -546,11 +546,11 @@ void AccessibilityManager::OnTwoFingerTouchStart() {
} }
void AccessibilityManager::OnTwoFingerTouchStop() { void AccessibilityManager::OnTwoFingerTouchStop() {
if (!profile()) if (!profile_)
return; return;
extensions::EventRouter* event_router = extensions::EventRouter* event_router =
extensions::EventRouter::Get(profile()); extensions::EventRouter::Get(profile_);
auto event_args = std::make_unique<base::ListValue>(); auto event_args = std::make_unique<base::ListValue>();
auto event = std::make_unique<extensions::Event>( auto event = std::make_unique<extensions::Event>(
...@@ -599,7 +599,7 @@ void AccessibilityManager::HandleAccessibilityGesture( ...@@ -599,7 +599,7 @@ void AccessibilityManager::HandleAccessibilityGesture(
ax::mojom::Gesture gesture, ax::mojom::Gesture gesture,
gfx::PointF location) { gfx::PointF location) {
extensions::EventRouter* event_router = extensions::EventRouter* event_router =
extensions::EventRouter::Get(profile()); extensions::EventRouter::Get(profile_);
std::unique_ptr<base::ListValue> event_args = std::unique_ptr<base::ListValue> event_args =
std::make_unique<base::ListValue>(); std::make_unique<base::ListValue>();
...@@ -688,6 +688,35 @@ void AccessibilityManager::RequestAutoclickScrollableBoundsForPoint( ...@@ -688,6 +688,35 @@ void AccessibilityManager::RequestAutoclickScrollableBoundsForPoint(
extension_misc::kAccessibilityCommonExtensionId, std::move(event)); extension_misc::kAccessibilityCommonExtensionId, std::move(event));
} }
void AccessibilityManager::MagnifierBoundsChanged(
const gfx::Rect& bounds_in_screen) {
if (!profile_)
return;
extensions::EventRouter* event_router =
extensions::EventRouter::Get(profile_);
auto magnifier_bounds =
std::make_unique<extensions::api::accessibility_private::ScreenRect>();
magnifier_bounds->left = bounds_in_screen.x();
magnifier_bounds->top = bounds_in_screen.y();
magnifier_bounds->width = bounds_in_screen.width();
magnifier_bounds->height = bounds_in_screen.height();
auto event_args =
extensions::api::accessibility_private::OnMagnifierBoundsChanged::Create(
*magnifier_bounds.get());
auto event = std::make_unique<extensions::Event>(
extensions::events::ACCESSIBILITY_PRIVATE_ON_MAGNIFIER_BOUNDS_CHANGED,
extensions::api::accessibility_private::OnMagnifierBoundsChanged::
kEventName,
std::move(event_args));
event_router->DispatchEventWithLazyListener(
extension_misc::kAccessibilityCommonExtensionId, std::move(event));
}
void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { void AccessibilityManager::EnableVirtualKeyboard(bool enabled) {
if (!profile_) if (!profile_)
return; return;
......
...@@ -158,6 +158,10 @@ class AccessibilityManager ...@@ -158,6 +158,10 @@ class AccessibilityManager
// ancestor to the point in the screen, as given in screen coordinates. // ancestor to the point in the screen, as given in screen coordinates.
void RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen); void RequestAutoclickScrollableBoundsForPoint(gfx::Point& point_in_screen);
// Dispatches magnifier bounds update to Magnifier (through Accessibility
// Common extension).
void MagnifierBoundsChanged(const gfx::Rect& bounds_in_screen);
// Enables or disables the virtual keyboard. // Enables or disables the virtual keyboard.
void EnableVirtualKeyboard(bool enabled); void EnableVirtualKeyboard(bool enabled);
// Returns true if the virtual keyboard is enabled, otherwise false. // Returns true if the virtual keyboard is enabled, otherwise false.
......
...@@ -150,6 +150,12 @@ void AccessibilityControllerClient::RequestAutoclickScrollableBoundsForPoint( ...@@ -150,6 +150,12 @@ void AccessibilityControllerClient::RequestAutoclickScrollableBoundsForPoint(
->RequestAutoclickScrollableBoundsForPoint(point_in_screen); ->RequestAutoclickScrollableBoundsForPoint(point_in_screen);
} }
void AccessibilityControllerClient::MagnifierBoundsChanged(
const gfx::Rect& bounds_in_screen) {
chromeos::AccessibilityManager::Get()->MagnifierBoundsChanged(
bounds_in_screen);
}
void AccessibilityControllerClient::OnSwitchAccessDisabled() { void AccessibilityControllerClient::OnSwitchAccessDisabled() {
chromeos::AccessibilityManager::Get()->OnSwitchAccessDisabled(); chromeos::AccessibilityManager::Get()->OnSwitchAccessDisabled();
} }
...@@ -32,6 +32,7 @@ class AccessibilityControllerClient ...@@ -32,6 +32,7 @@ class AccessibilityControllerClient
void RequestSelectToSpeakStateChange() override; void RequestSelectToSpeakStateChange() override;
void RequestAutoclickScrollableBoundsForPoint( void RequestAutoclickScrollableBoundsForPoint(
gfx::Point& point_in_screen) override; gfx::Point& point_in_screen) override;
void MagnifierBoundsChanged(const gfx::Rect& bounds_in_screen) override;
void OnSwitchAccessDisabled() override; void OnSwitchAccessDisabled() override;
private: private:
......
...@@ -565,6 +565,19 @@ ...@@ -565,6 +565,19 @@
], ],
"platforms": ["chromeos"] "platforms": ["chromeos"]
}, },
{
"name": "onMagnifierBoundsChanged",
"type": "function",
"description": "Fired when Chrome OS magnifier bounds are updated.",
"parameters": [
{
"name": "magnifierBounds",
"$ref": "ScreenRect",
"description": "Updated bounds of magnifier viewport."
}
],
"platforms": ["chromeos"]
},
{ {
"name": "onCustomSpokenFeedbackToggled", "name": "onCustomSpokenFeedbackToggled",
"type": "function", "type": "function",
......
...@@ -483,6 +483,7 @@ enum HistogramValue { ...@@ -483,6 +483,7 @@ enum HistogramValue {
WINDOWS_ON_BOUNDS_CHANGED = 461, WINDOWS_ON_BOUNDS_CHANGED = 461,
WALLPAPER_PRIVATE_ON_CLOSE_PREVIEW_WALLPAPER = 462, WALLPAPER_PRIVATE_ON_CLOSE_PREVIEW_WALLPAPER = 462,
PASSWORDS_PRIVATE_ON_WEAK_CREDENTIALS_CHANGED = 463, PASSWORDS_PRIVATE_ON_WEAK_CREDENTIALS_CHANGED = 463,
ACCESSIBILITY_PRIVATE_ON_MAGNIFIER_BOUNDS_CHANGED = 464,
// Last entry: Add new entries above, then run: // Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py // python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -274,7 +274,7 @@ chrome.accessibilityPrivate.forwardKeyEventsToSwitchAccess = function(shouldForw ...@@ -274,7 +274,7 @@ chrome.accessibilityPrivate.forwardKeyEventsToSwitchAccess = function(shouldForw
chrome.accessibilityPrivate.updateSwitchAccessBubble = function(bubble, show, anchor, actions) {}; chrome.accessibilityPrivate.updateSwitchAccessBubble = function(bubble, show, anchor, actions) {};
/** /**
* Enable point scanning in Switch Access. * Enables or disables point scanning in Switch Access.
* @param {boolean} enabled True for start point scanning, false for end point * @param {boolean} enabled True for start point scanning, false for end point
* scanning. * scanning.
*/ */
...@@ -417,6 +417,12 @@ chrome.accessibilityPrivate.onAnnounceForAccessibility; ...@@ -417,6 +417,12 @@ chrome.accessibilityPrivate.onAnnounceForAccessibility;
*/ */
chrome.accessibilityPrivate.onScrollableBoundsForPointRequested; chrome.accessibilityPrivate.onScrollableBoundsForPointRequested;
/**
* Fired when Chrome OS magnifier bounds are updated.
* @type {!ChromeEvent}
*/
chrome.accessibilityPrivate.onMagnifierBoundsChanged;
/** /**
* Fired when a custom spoken feedback on the active window gets enabled or * Fired when a custom spoken feedback on the active window gets enabled or
* disabled. Called from ARC++ accessibility. * disabled. Called from ARC++ accessibility.
......
...@@ -23524,6 +23524,7 @@ Called by update_extension_histograms.py.--> ...@@ -23524,6 +23524,7 @@ Called by update_extension_histograms.py.-->
<int value="461" label="WINDOWS_ON_BOUNDS_CHANGED"/> <int value="461" label="WINDOWS_ON_BOUNDS_CHANGED"/>
<int value="462" label="WALLPAPER_PRIVATE_ON_CLOSE_PREVIEW_WALLPAPER"/> <int value="462" label="WALLPAPER_PRIVATE_ON_CLOSE_PREVIEW_WALLPAPER"/>
<int value="463" label="PASSWORDS_PRIVATE_ON_WEAK_CREDENTIALS_CHANGED"/> <int value="463" label="PASSWORDS_PRIVATE_ON_WEAK_CREDENTIALS_CHANGED"/>
<int value="464" label="ACCESSIBILITY_PRIVATE_ON_MAGNIFIER_BOUNDS_CHANGED"/>
</enum> </enum>
<enum name="ExtensionFileWriteResult"> <enum name="ExtensionFileWriteResult">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment