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

Side by Side Diff: content/renderer/render_view.cc

Issue 7745035: Add a big grab bag of missing web accessibility functionality... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/render_view.h" 5 #include "content/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { 271 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
272 WebVector<WebURL> urls; 272 WebVector<WebURL> urls;
273 ds->redirectChain(urls); 273 ds->redirectChain(urls);
274 result->reserve(urls.size()); 274 result->reserve(urls.size());
275 for (size_t i = 0; i < urls.size(); ++i) 275 for (size_t i = 0; i < urls.size(); ++i)
276 result->push_back(urls[i]); 276 result->push_back(urls[i]);
277 } 277 }
278 278
279 static bool WebAccessibilityNotificationToViewHostMsg( 279 static bool WebAccessibilityNotificationToViewHostMsg(
280 WebAccessibilityNotification notification, 280 WebAccessibilityNotification notification,
281 ViewHostMsg_AccessibilityNotification_Type::Value* type) { 281 ViewHostMsg_AccEvent::Value* type) {
282 switch (notification) { 282 switch (notification) {
283 case WebKit::WebAccessibilityNotificationActiveDescendantChanged:
284 *type = ViewHostMsg_AccEvent::ACTIVE_DESCENDANT_CHANGED;
285 break;
283 case WebKit::WebAccessibilityNotificationCheckedStateChanged: 286 case WebKit::WebAccessibilityNotificationCheckedStateChanged:
284 *type = ViewHostMsg_AccessibilityNotification_Type:: 287 *type = ViewHostMsg_AccEvent::CHECK_STATE_CHANGED;
285 NOTIFICATION_TYPE_CHECK_STATE_CHANGED;
286 break; 288 break;
287 case WebKit::WebAccessibilityNotificationChildrenChanged: 289 case WebKit::WebAccessibilityNotificationChildrenChanged:
288 *type = ViewHostMsg_AccessibilityNotification_Type:: 290 *type = ViewHostMsg_AccEvent::CHILDREN_CHANGED;
289 NOTIFICATION_TYPE_CHILDREN_CHANGED;
290 break; 291 break;
291 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: 292 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged:
292 *type = ViewHostMsg_AccessibilityNotification_Type:: 293 *type = ViewHostMsg_AccEvent::FOCUS_CHANGED;
293 NOTIFICATION_TYPE_FOCUS_CHANGED; 294 break;
295 case WebKit::WebAccessibilityNotificationLayoutComplete:
296 *type = ViewHostMsg_AccEvent::LAYOUT_COMPLETE;
297 break;
298 case WebKit::WebAccessibilityNotificationLiveRegionChanged:
299 *type = ViewHostMsg_AccEvent::LIVE_REGION_CHANGED;
294 break; 300 break;
295 case WebKit::WebAccessibilityNotificationLoadComplete: 301 case WebKit::WebAccessibilityNotificationLoadComplete:
296 *type = ViewHostMsg_AccessibilityNotification_Type:: 302 *type = ViewHostMsg_AccEvent::LOAD_COMPLETE;
297 NOTIFICATION_TYPE_LOAD_COMPLETE; 303 break;
304 case WebKit::WebAccessibilityNotificationMenuListValueChanged:
305 *type = ViewHostMsg_AccEvent::MENU_LIST_VALUE_CHANGED;
306 break;
307 case WebKit::WebAccessibilityNotificationRowCollapsed:
308 *type = ViewHostMsg_AccEvent::ROW_COLLAPSED;
309 break;
310 case WebKit::WebAccessibilityNotificationRowCountChanged:
311 *type = ViewHostMsg_AccEvent::ROW_COUNT_CHANGED;
312 break;
313 case WebKit::WebAccessibilityNotificationRowExpanded:
314 *type = ViewHostMsg_AccEvent::ROW_EXPANDED;
315 break;
316 case WebKit::WebAccessibilityNotificationScrolledToAnchor:
317 *type = ViewHostMsg_AccEvent::SCROLLED_TO_ANCHOR;
318 break;
319 case WebKit::WebAccessibilityNotificationSelectedChildrenChanged:
320 *type = ViewHostMsg_AccEvent::SELECTED_CHILDREN_CHANGED;
321 break;
322 case WebKit::WebAccessibilityNotificationSelectedTextChanged:
323 *type = ViewHostMsg_AccEvent::SELECTED_TEXT_CHANGED;
298 break; 324 break;
299 case WebKit::WebAccessibilityNotificationValueChanged: 325 case WebKit::WebAccessibilityNotificationValueChanged:
300 *type = ViewHostMsg_AccessibilityNotification_Type:: 326 *type = ViewHostMsg_AccEvent::VALUE_CHANGED;
301 NOTIFICATION_TYPE_VALUE_CHANGED;
302 break;
303 case WebKit::WebAccessibilityNotificationSelectedTextChanged:
304 *type = ViewHostMsg_AccessibilityNotification_Type::
305 NOTIFICATION_TYPE_SELECTED_TEXT_CHANGED;
306 break; 327 break;
307 default: 328 default:
308 // TODO(ctguil): Support additional webkit notifications.
309 return false; 329 return false;
310 } 330 }
311 return true; 331 return true;
312 } 332 }
313 333
314 // If |data_source| is non-null and has a NavigationState associated with it, 334 // If |data_source| is non-null and has a NavigationState associated with it,
315 // the AltErrorPageResourceFetcher is reset. 335 // the AltErrorPageResourceFetcher is reset.
316 static void StopAltErrorPageFetcher(WebDataSource* data_source) { 336 static void StopAltErrorPageFetcher(WebDataSource* data_source) {
317 if (data_source) { 337 if (data_source) {
318 NavigationState* state = NavigationState::FromDataSource(data_source); 338 NavigationState* state = NavigationState::FromDataSource(data_source);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 cached_is_main_frame_pinned_to_right_(false), 382 cached_is_main_frame_pinned_to_right_(false),
363 cached_has_main_frame_horizontal_scrollbar_(false), 383 cached_has_main_frame_horizontal_scrollbar_(false),
364 cached_has_main_frame_vertical_scrollbar_(false), 384 cached_has_main_frame_vertical_scrollbar_(false),
365 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), 385 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
366 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), 386 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)),
367 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 387 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
368 geolocation_dispatcher_(NULL), 388 geolocation_dispatcher_(NULL),
369 speech_input_dispatcher_(NULL), 389 speech_input_dispatcher_(NULL),
370 device_orientation_dispatcher_(NULL), 390 device_orientation_dispatcher_(NULL),
371 accessibility_ack_pending_(false), 391 accessibility_ack_pending_(false),
392 accessibility_logging_(false),
372 p2p_socket_dispatcher_(NULL), 393 p2p_socket_dispatcher_(NULL),
373 devtools_agent_(NULL), 394 devtools_agent_(NULL),
374 session_storage_namespace_id_(session_storage_namespace_id), 395 session_storage_namespace_id_(session_storage_namespace_id),
375 handling_select_range_(false) { 396 handling_select_range_(false) {
376 routing_id_ = routing_id; 397 routing_id_ = routing_id;
377 if (opener_id != MSG_ROUTING_NONE) 398 if (opener_id != MSG_ROUTING_NONE)
378 opener_id_ = opener_id; 399 opener_id_ = opener_id;
379 400
380 webwidget_ = WebView::create(this); 401 webwidget_ = WebView::create(this);
381 402
(...skipping 29 matching lines...) Expand all
411 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : 432 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval :
412 webkit_glue::kForegroundTabTimerInterval); 433 webkit_glue::kForegroundTabTimerInterval);
413 434
414 OnSetRendererPrefs(renderer_prefs); 435 OnSetRendererPrefs(renderer_prefs);
415 436
416 host_window_ = parent_hwnd; 437 host_window_ = parent_hwnd;
417 438
418 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 439 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
419 if (command_line.HasSwitch(switches::kEnableAccessibility)) 440 if (command_line.HasSwitch(switches::kEnableAccessibility))
420 WebAccessibilityCache::enableAccessibility(); 441 WebAccessibilityCache::enableAccessibility();
442 if (command_line.HasSwitch(switches::kEnableAccessibilityLogging))
443 accessibility_logging_ = true;
421 444
422 #if defined(ENABLE_P2P_APIS) 445 #if defined(ENABLE_P2P_APIS)
423 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); 446 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
424 #endif 447 #endif
425 448
426 new MHTMLGenerator(this); 449 new MHTMLGenerator(this);
427 450
428 devtools_agent_ = new DevToolsAgent(this); 451 devtools_agent_ = new DevToolsAgent(this);
429 452
430 if (command_line.HasSwitch(switches::kEnableMediaStream)) { 453 if (command_line.HasSwitch(switches::kEnableMediaStream)) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 548 }
526 549
527 void RenderView::RemoveObserver(RenderViewObserver* observer) { 550 void RenderView::RemoveObserver(RenderViewObserver* observer) {
528 observer->set_render_view(NULL); 551 observer->set_render_view(NULL);
529 observers_.RemoveObserver(observer); 552 observers_.RemoveObserver(observer);
530 } 553 }
531 554
532 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() { 555 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() {
533 typedef ViewHostMsg_AccessibilityNotification_Params params; 556 typedef ViewHostMsg_AccessibilityNotification_Params params;
534 if (type == WebKit::WebAccessibilityNotificationChildrenChanged || 557 if (type == WebKit::WebAccessibilityNotificationChildrenChanged ||
535 type == WebKit::WebAccessibilityNotificationLoadComplete) { 558 type == WebKit::WebAccessibilityNotificationLoadComplete ||
559 type == WebKit::WebAccessibilityNotificationLiveRegionChanged) {
536 return true; 560 return true;
537 } 561 }
538 return false; 562 return false;
539 } 563 }
540 564
541 WebKit::WebView* RenderView::webview() const { 565 WebKit::WebView* RenderView::webview() const {
542 return static_cast<WebKit::WebView*>(webwidget()); 566 return static_cast<WebKit::WebView*>(webwidget());
543 } 567 }
544 568
545 void RenderView::SetReportLoadProgressEnabled(bool enabled) { 569 void RenderView::SetReportLoadProgressEnabled(bool enabled) {
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 return; 1633 return;
1610 1634
1611 if (pending_accessibility_notifications_.empty()) 1635 if (pending_accessibility_notifications_.empty())
1612 return; 1636 return;
1613 1637
1614 // Send all pending accessibility notifications. 1638 // Send all pending accessibility notifications.
1615 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; 1639 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications;
1616 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) { 1640 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) {
1617 RendererAccessibilityNotification& notification = 1641 RendererAccessibilityNotification& notification =
1618 pending_accessibility_notifications_[i]; 1642 pending_accessibility_notifications_[i];
1619 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id); 1643 WebAccessibilityObject obj = accessibility_->getObjectById(
Chris Guillory 2011/08/31 02:14:53 Doesn't this fit without wrapping?
dmazzoni 2011/08/31 22:02:54 You're right, looks like my Windows editor was set
1644 notification.id);
1620 if (!obj.isValid()) 1645 if (!obj.isValid())
1621 continue; 1646 continue;
1622 1647
1623 ViewHostMsg_AccessibilityNotification_Params param; 1648 ViewHostMsg_AccessibilityNotification_Params param;
1624 WebAccessibilityNotificationToViewHostMsg( 1649 WebAccessibilityNotificationToViewHostMsg(
1625 pending_accessibility_notifications_[i].type, &param.notification_type); 1650 pending_accessibility_notifications_[i].type,
Chris Guillory 2011/08/31 02:14:53 Doesn't this fit without wrapping?
1651 &param.notification_type);
1626 param.acc_obj = WebAccessibility( 1652 param.acc_obj = WebAccessibility(
1627 obj, accessibility_.get(), notification.ShouldIncludeChildren()); 1653 obj, accessibility_.get(), notification.ShouldIncludeChildren());
1628 notifications.push_back(param); 1654 notifications.push_back(param);
1655
1656 #ifndef NDEBUG
1657 if (accessibility_logging_) {
1658 LOG(INFO) << "Accessibility update: \n"
1659 << param.acc_obj.DebugString(true);
1660 }
1661 #endif
1629 } 1662 }
1630 pending_accessibility_notifications_.clear(); 1663 pending_accessibility_notifications_.clear();
1631 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications)); 1664 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications));
1632 accessibility_ack_pending_ = true; 1665 accessibility_ack_pending_ = true;
1633 } 1666 }
1634 1667
1635 bool RenderView::handleCurrentKeyboardEvent() { 1668 bool RenderView::handleCurrentKeyboardEvent() {
1636 if (edit_commands_.empty()) 1669 if (edit_commands_.empty())
1637 return false; 1670 return false;
1638 1671
(...skipping 2493 matching lines...) Expand 10 before | Expand all | Expand 10 after
4132 return; 4165 return;
4133 } 4166 }
4134 4167
4135 // Add the accessibility object to our cache and ensure it's valid. 4168 // Add the accessibility object to our cache and ensure it's valid.
4136 RendererAccessibilityNotification acc_notification; 4169 RendererAccessibilityNotification acc_notification;
4137 acc_notification.id = accessibility_->addOrGetId(obj); 4170 acc_notification.id = accessibility_->addOrGetId(obj);
4138 acc_notification.type = notification; 4171 acc_notification.type = notification;
4139 if (acc_notification.id < 0) 4172 if (acc_notification.id < 0)
4140 return; 4173 return;
4141 4174
4142 ViewHostMsg_AccessibilityNotification_Type::Value temp; 4175 ViewHostMsg_AccEvent::Value temp;
4143 if (!WebAccessibilityNotificationToViewHostMsg(notification, &temp)) 4176 if (!WebAccessibilityNotificationToViewHostMsg(notification, &temp))
4144 return; 4177 return;
4145 4178
4146 // Discard duplicate accessibility notifications. 4179 // Discard duplicate accessibility notifications.
4147 for (uint32 i = 0; i < pending_accessibility_notifications_.size(); i++) { 4180 for (uint32 i = 0; i < pending_accessibility_notifications_.size(); i++) {
4148 if (pending_accessibility_notifications_[i].id == acc_notification.id && 4181 if (pending_accessibility_notifications_[i].id == acc_notification.id &&
4149 pending_accessibility_notifications_[i].type == acc_notification.type) { 4182 pending_accessibility_notifications_[i].type == acc_notification.type) {
4150 return; 4183 return;
4151 } 4184 }
4152 } 4185 }
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
4605 } 4638 }
4606 4639
4607 void RenderView::OnEnableViewSourceMode() { 4640 void RenderView::OnEnableViewSourceMode() {
4608 if (!webview()) 4641 if (!webview())
4609 return; 4642 return;
4610 WebFrame* main_frame = webview()->mainFrame(); 4643 WebFrame* main_frame = webview()->mainFrame();
4611 if (!main_frame) 4644 if (!main_frame)
4612 return; 4645 return;
4613 main_frame->enableViewSourceMode(true); 4646 main_frame->enableViewSourceMode(true);
4614 } 4647 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698