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

Unified Diff: content/renderer/renderer_accessibility.cc

Issue 8770021: Initial implementation of IAccessible2 scrollTo and setTextSelection and (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
Index: content/renderer/renderer_accessibility.cc
===================================================================
--- content/renderer/renderer_accessibility.cc (revision 112482)
+++ content/renderer/renderer_accessibility.cc (working copy)
@@ -18,6 +18,7 @@
using WebKit::WebDocument;
using WebKit::WebFrame;
using WebKit::WebNode;
+using WebKit::WebSize;
using WebKit::WebView;
using webkit_glue::WebAccessibility;
@@ -104,6 +105,10 @@
OnAccessibilityDoDefaultAction)
IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK,
OnAccessibilityNotificationsAck)
+ IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityChangeScrollPosition,
+ OnChangeScrollPosition)
+ IPC_MESSAGE_HANDLER(ViewMsg_AccessibilitySetTextSelection,
+ OnSetTextSelection)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -366,6 +371,61 @@
obj.performDefaultAction();
}
+void RendererAccessibility::OnChangeScrollPosition(
+ int acc_obj_id, int scroll_x, int scroll_y) {
+ if (!WebAccessibilityObject::accessibilityEnabled())
+ return;
+
+ const WebDocument& document = GetMainDocument();
+ if (document.isNull())
+ return;
+
+ WebAccessibilityObject root = document.accessibilityObject();
+
+ // TODO(dmazzoni): Support scrolling of any scrollable container,
+ // not just the main document frame.
+ if (acc_obj_id != root.axID())
+ return;
+
+ WebFrame* frame = document.frame();
+ if (!frame)
+ return;
+
+ WebSize min_offset = frame->minimumScrollOffset();
+ WebSize max_offset = frame->maximumScrollOffset();
+ scroll_x = std::max(min_offset.width, scroll_x);
+ scroll_x = std::min(max_offset.width, scroll_x);
+ scroll_y = std::max(min_offset.height, scroll_y);
+ scroll_y = std::min(max_offset.height, scroll_y);
+
+ frame->setScrollOffset(WebSize(scroll_x, scroll_y));
+ if (frame->view())
+ frame->view()->layout();
+
+ PostAccessibilityNotification(
+ root,
+ WebKit::WebAccessibilityNotificationLayoutComplete);
+}
+
+void RendererAccessibility::OnSetTextSelection(
+ int acc_obj_id, int start_offset, int end_offset) {
+ if (!WebAccessibilityObject::accessibilityEnabled())
+ return;
+
+ const WebDocument& document = GetMainDocument();
+ if (document.isNull())
+ return;
+
+ WebAccessibilityObject obj = document.accessibilityObjectFromID(acc_obj_id);
+ if (!obj.isValid()) {
+#ifndef NDEBUG
+ if (logging_)
+ LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id;
+#endif
+ return;
+ }
+}
+
void RendererAccessibility::OnAccessibilityNotificationsAck() {
DCHECK(ack_pending_);
ack_pending_ = false;

Powered by Google App Engine
This is Rietveld 408576698