Commit 82f6f988 authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Disable accessibility when VoiceOver is turned off.

(Depends on: https://codereview.chromium.org/606703003/)

BUG=251382

Review URL: https://codereview.chromium.org/602133002

Cr-Commit-Position: refs/heads/master@{#300583}
parent 0615525b
...@@ -538,9 +538,14 @@ void SwizzleInit() { ...@@ -538,9 +538,14 @@ void SwizzleInit() {
} }
- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute {
if ([attribute isEqualToString:@"AXEnhancedUserInterface"] && // This is an undocument attribute that's set when VoiceOver is turned on/off.
[value intValue] == 1) { if ([attribute isEqualToString:@"AXEnhancedUserInterface"]) {
content::BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); content::BrowserAccessibilityState* accessibility_state =
content::BrowserAccessibilityState::GetInstance();
if ([value intValue] == 1)
accessibility_state->OnScreenReaderDetected();
else
accessibility_state->DisableAccessibility();
} }
return [super accessibilitySetValue:value forAttribute:attribute]; return [super accessibilitySetValue:value forAttribute:attribute];
} }
......
...@@ -60,6 +60,11 @@ class CONTENT_EXPORT RendererAccessibility : public RenderFrameObserver { ...@@ -60,6 +60,11 @@ class CONTENT_EXPORT RendererAccessibility : public RenderFrameObserver {
// testing. // testing.
virtual RendererAccessibilityType GetType() = 0; virtual RendererAccessibilityType GetType() = 0;
// This can be called before deleting a RendererAccessibility instance due
// to the accessibility mode changing, as opposed to during frame destruction
// (when there'd be no point).
virtual void DisableAccessibility() {}
protected: protected:
// Returns the main top-level document for this page, or NULL if there's // Returns the main top-level document for this page, or NULL if there's
// no view or frame. // no view or frame.
......
...@@ -98,6 +98,22 @@ void RendererAccessibilityComplete::FocusedNodeChanged(const WebNode& node) { ...@@ -98,6 +98,22 @@ void RendererAccessibilityComplete::FocusedNodeChanged(const WebNode& node) {
} }
} }
void RendererAccessibilityComplete::DisableAccessibility() {
RenderView* render_view = render_frame_->GetRenderView();
if (!render_view)
return;
WebView* web_view = render_view->GetWebView();
if (!web_view)
return;
WebSettings* settings = web_view->settings();
if (!settings)
return;
settings->setAccessibilityEnabled(false);
}
void RendererAccessibilityComplete::HandleWebAccessibilityEvent( void RendererAccessibilityComplete::HandleWebAccessibilityEvent(
const blink::WebAXObject& obj, blink::WebAXEvent event) { const blink::WebAXObject& obj, blink::WebAXEvent event) {
HandleAXEvent(obj, AXEventFromBlink(event)); HandleAXEvent(obj, AXEventFromBlink(event));
......
...@@ -47,6 +47,7 @@ class CONTENT_EXPORT RendererAccessibilityComplete ...@@ -47,6 +47,7 @@ class CONTENT_EXPORT RendererAccessibilityComplete
blink::WebAXEvent event) override; blink::WebAXEvent event) override;
RendererAccessibilityType GetType() override; RendererAccessibilityType GetType() override;
void FocusedNodeChanged(const blink::WebNode& node) override; void FocusedNodeChanged(const blink::WebNode& node) override;
virtual void DisableAccessibility() override;
void HandleAXEvent(const blink::WebAXObject& obj, ui::AXEvent event); void HandleAXEvent(const blink::WebAXObject& obj, ui::AXEvent event);
......
...@@ -1360,6 +1360,11 @@ void RenderFrameImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { ...@@ -1360,6 +1360,11 @@ void RenderFrameImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) {
return; return;
accessibility_mode_ = new_mode; accessibility_mode_ = new_mode;
if (renderer_accessibility_) { if (renderer_accessibility_) {
// Note: this isn't called automatically by the destructor because
// there'd be no point in calling it in frame teardown, only if there's
// an accessibility mode change but the frame is persisting.
renderer_accessibility_->DisableAccessibility();
delete renderer_accessibility_; delete renderer_accessibility_;
renderer_accessibility_ = NULL; renderer_accessibility_ = NULL;
} }
......
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