| OLD | NEW |
| 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/renderer_accessibility.h" | 5 #include "content/renderer/accessibility/renderer_accessibility.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" | 12 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" |
| 12 #include "content/renderer/render_frame_impl.h" | 13 #include "content/renderer/render_frame_impl.h" |
| 13 #include "content/renderer/render_view_impl.h" | 14 #include "content/renderer/render_view_impl.h" |
| 14 #include "third_party/WebKit/public/web/WebAXObject.h" | 15 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 15 #include "third_party/WebKit/public/web/WebDocument.h" | 16 #include "third_party/WebKit/public/web/WebDocument.h" |
| 16 #include "third_party/WebKit/public/web/WebInputElement.h" | 17 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 18 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 18 #include "third_party/WebKit/public/web/WebSettings.h" | 19 #include "third_party/WebKit/public/web/WebSettings.h" |
| 19 #include "third_party/WebKit/public/web/WebView.h" | 20 #include "third_party/WebKit/public/web/WebView.h" |
| 20 | 21 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 bool RendererAccessibility::OnMessageReceived(const IPC::Message& message) { | 65 bool RendererAccessibility::OnMessageReceived(const IPC::Message& message) { |
| 65 bool handled = true; | 66 bool handled = true; |
| 66 IPC_BEGIN_MESSAGE_MAP(RendererAccessibility, message) | 67 IPC_BEGIN_MESSAGE_MAP(RendererAccessibility, message) |
| 67 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetFocus, OnSetFocus) | 68 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetFocus, OnSetFocus) |
| 68 IPC_MESSAGE_HANDLER(AccessibilityMsg_DoDefaultAction, OnDoDefaultAction) | 69 IPC_MESSAGE_HANDLER(AccessibilityMsg_DoDefaultAction, OnDoDefaultAction) |
| 69 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK, OnEventsAck) | 70 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK, OnEventsAck) |
| 70 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible, | 71 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible, |
| 71 OnScrollToMakeVisible) | 72 OnScrollToMakeVisible) |
| 72 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, OnScrollToPoint) | 73 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, OnScrollToPoint) |
| 73 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection, OnSetTextSelection) | 74 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection, OnSetTextSelection) |
| 75 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetValue, OnSetValue) |
| 74 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest) | 76 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest) |
| 75 IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset) | 77 IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset) |
| 76 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError) | 78 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError) |
| 77 IPC_MESSAGE_UNHANDLED(handled = false) | 79 IPC_MESSAGE_UNHANDLED(handled = false) |
| 78 IPC_END_MESSAGE_MAP() | 80 IPC_END_MESSAGE_MAP() |
| 79 return handled; | 81 return handled; |
| 80 } | 82 } |
| 81 | 83 |
| 82 void RendererAccessibility::HandleWebAccessibilityEvent( | 84 void RendererAccessibility::HandleWebAccessibilityEvent( |
| 83 const blink::WebAXObject& obj, blink::WebAXEvent event) { | 85 const blink::WebAXObject& obj, blink::WebAXEvent event) { |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 return; | 420 return; |
| 419 | 421 |
| 420 WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id); | 422 WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id); |
| 421 if (obj.isDetached()) { | 423 if (obj.isDetached()) { |
| 422 #ifndef NDEBUG | 424 #ifndef NDEBUG |
| 423 LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id; | 425 LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id; |
| 424 #endif | 426 #endif |
| 425 return; | 427 return; |
| 426 } | 428 } |
| 427 | 429 |
| 428 // TODO(dmazzoni): support elements other than <input>. | 430 obj.setSelectedTextRange(start_offset, end_offset); |
| 429 blink::WebNode node = obj.node(); | 431 } |
| 430 if (!node.isNull() && node.isElementNode()) { | 432 |
| 431 blink::WebElement element = node.to<blink::WebElement>(); | 433 void RendererAccessibility::OnSetValue( |
| 432 blink::WebInputElement* input_element = | 434 int acc_obj_id, |
| 433 blink::toWebInputElement(&element); | 435 base::string16 value) { |
| 434 if (input_element && input_element->isTextField()) | 436 const WebDocument& document = GetMainDocument(); |
| 435 input_element->setSelectionRange(start_offset, end_offset); | 437 if (document.isNull()) |
| 438 return; |
| 439 |
| 440 WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id); |
| 441 if (obj.isDetached()) { |
| 442 #ifndef NDEBUG |
| 443 LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id; |
| 444 #endif |
| 445 return; |
| 436 } | 446 } |
| 447 |
| 448 obj.setValue(value); |
| 437 } | 449 } |
| 438 | 450 |
| 439 } // namespace content | 451 } // namespace content |
| OLD | NEW |