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

Side by Side Diff: content/renderer/accessibility/render_accessibility_impl.cc

Issue 2581483002: Add support for faster, more limited accessibility modes. (Closed)
Patch Set: Disable tests that can't pass on Android with TODO Created 4 years 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 unified diff | Download patch
OLDNEW
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 "content/renderer/accessibility/render_accessibility_impl.h" 5 #include "content/renderer/accessibility/render_accessibility_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 DCHECK(render_frame); 61 DCHECK(render_frame);
62 DCHECK(response); 62 DCHECK(response);
63 if (!render_frame->GetWebFrame()) 63 if (!render_frame->GetWebFrame())
64 return; 64 return;
65 65
66 WebDocument document = render_frame->GetWebFrame()->document(); 66 WebDocument document = render_frame->GetWebFrame()->document();
67 WebScopedAXContext context(document); 67 WebScopedAXContext context(document);
68 WebAXObject root = context.root(); 68 WebAXObject root = context.root();
69 if (!root.updateLayoutAndCheckValidity()) 69 if (!root.updateLayoutAndCheckValidity())
70 return; 70 return;
71 BlinkAXTreeSource tree_source(render_frame); 71 BlinkAXTreeSource tree_source(render_frame, ACCESSIBILITY_MODE_COMPLETE);
72 tree_source.SetRoot(root); 72 tree_source.SetRoot(root);
73 ScopedFreezeBlinkAXTreeSource freeze(&tree_source); 73 ScopedFreezeBlinkAXTreeSource freeze(&tree_source);
74 BlinkAXTreeSerializer serializer(&tree_source); 74 BlinkAXTreeSerializer serializer(&tree_source);
75 serializer.set_max_node_count(kMaxSnapshotNodeCount); 75 serializer.set_max_node_count(kMaxSnapshotNodeCount);
76 serializer.SerializeChanges(context.root(), response); 76 serializer.SerializeChanges(context.root(), response);
77 } 77 }
78 78
79 RenderAccessibilityImpl::RenderAccessibilityImpl(RenderFrameImpl* render_frame) 79 RenderAccessibilityImpl::RenderAccessibilityImpl(RenderFrameImpl* render_frame,
80 AccessibilityMode mode)
80 : RenderFrameObserver(render_frame), 81 : RenderFrameObserver(render_frame),
81 render_frame_(render_frame), 82 render_frame_(render_frame),
82 tree_source_(render_frame), 83 tree_source_(render_frame, mode),
83 serializer_(&tree_source_), 84 serializer_(&tree_source_),
84 plugin_tree_source_(nullptr), 85 plugin_tree_source_(nullptr),
85 last_scroll_offset_(gfx::Size()), 86 last_scroll_offset_(gfx::Size()),
86 ack_pending_(false), 87 ack_pending_(false),
87 reset_token_(0), 88 reset_token_(0),
88 during_action_(false), 89 during_action_(false),
89 weak_factory_(this) { 90 weak_factory_(this) {
90 ack_token_ = g_next_ack_token++; 91 ack_token_ = g_next_ack_token++;
91 WebView* web_view = render_frame_->GetRenderView()->GetWebView(); 92 WebView* web_view = render_frame_->GetRenderView()->GetWebView();
92 WebSettings* settings = web_view->settings(); 93 WebSettings* settings = web_view->settings();
93 settings->setAccessibilityEnabled(true); 94 settings->setAccessibilityEnabled(true);
94 95
95 #if defined(OS_ANDROID) 96 #if defined(OS_ANDROID)
96 // Password values are only passed through on Android. 97 // Password values are only passed through on Android.
97 settings->setAccessibilityPasswordValuesEnabled(true); 98 settings->setAccessibilityPasswordValuesEnabled(true);
98 #endif 99 #endif
99 100
100 #if !defined(OS_ANDROID) 101 #if !defined(OS_ANDROID)
101 // Inline text boxes are enabled for all nodes on all except Android. 102 // Inline text boxes can be enabled globally on all except Android.
102 settings->setInlineTextBoxAccessibilityEnabled(true); 103 // On Android they can be requested for just a specific node.
104 if (mode & ACCESSIBILITY_MODE_FLAG_INLINE_TEXT_BOXES)
105 settings->setInlineTextBoxAccessibilityEnabled(true);
103 #endif 106 #endif
104 107
105 const WebDocument& document = GetMainDocument(); 108 const WebDocument& document = GetMainDocument();
106 if (!document.isNull()) { 109 if (!document.isNull()) {
107 // It's possible that the webview has already loaded a webpage without 110 // It's possible that the webview has already loaded a webpage without
108 // accessibility being enabled. Initialize the browser's cached 111 // accessibility being enabled. Initialize the browser's cached
109 // accessibility tree by sending it a notification. 112 // accessibility tree by sending it a notification.
110 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_LAYOUT_COMPLETE); 113 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_LAYOUT_COMPLETE);
111 } 114 }
112 } 115 }
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 661
659 const WebDocument& document = GetMainDocument(); 662 const WebDocument& document = GetMainDocument();
660 if (document.isNull()) 663 if (document.isNull())
661 return; 664 return;
662 665
663 document.accessibilityObject().scrollToMakeVisibleWithSubFocus( 666 document.accessibilityObject().scrollToMakeVisibleWithSubFocus(
664 WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height())); 667 WebRect(bounds.x(), bounds.y(), bounds.width(), bounds.height()));
665 } 668 }
666 669
667 } // namespace content 670 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698