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

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

Issue 7966013: Rewrite renderer accessibility to not use WebAccessibilityCache. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « content/renderer/render_view.h ('k') | content/renderer/renderer_accessibility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "content/renderer/mhtml_generator.h" 56 #include "content/renderer/mhtml_generator.h"
57 #include "content/renderer/navigation_state.h" 57 #include "content/renderer/navigation_state.h"
58 #include "content/renderer/notification_provider.h" 58 #include "content/renderer/notification_provider.h"
59 #include "content/renderer/p2p/socket_dispatcher.h" 59 #include "content/renderer/p2p/socket_dispatcher.h"
60 #include "content/renderer/plugin_channel_host.h" 60 #include "content/renderer/plugin_channel_host.h"
61 #include "content/renderer/render_process.h" 61 #include "content/renderer/render_process.h"
62 #include "content/renderer/render_thread.h" 62 #include "content/renderer/render_thread.h"
63 #include "content/renderer/render_view_observer.h" 63 #include "content/renderer/render_view_observer.h"
64 #include "content/renderer/render_view_visitor.h" 64 #include "content/renderer/render_view_visitor.h"
65 #include "content/renderer/render_widget_fullscreen_pepper.h" 65 #include "content/renderer/render_widget_fullscreen_pepper.h"
66 #include "content/renderer/renderer_accessibility.h"
66 #include "content/renderer/renderer_webapplicationcachehost_impl.h" 67 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
67 #include "content/renderer/renderer_webstoragenamespace_impl.h" 68 #include "content/renderer/renderer_webstoragenamespace_impl.h"
68 #include "content/renderer/speech_input_dispatcher.h" 69 #include "content/renderer/speech_input_dispatcher.h"
69 #include "content/renderer/text_input_client_observer.h" 70 #include "content/renderer/text_input_client_observer.h"
70 #include "content/renderer/v8_value_converter.h" 71 #include "content/renderer/v8_value_converter.h"
71 #include "content/renderer/web_ui_bindings.h" 72 #include "content/renderer/web_ui_bindings.h"
72 #include "content/renderer/webplugin_delegate_proxy.h" 73 #include "content/renderer/webplugin_delegate_proxy.h"
73 #include "content/renderer/websharedworker_proxy.h" 74 #include "content/renderer/websharedworker_proxy.h"
74 #include "content/renderer/webworker_proxy.h" 75 #include "content/renderer/webworker_proxy.h"
75 #include "media/base/filter_collection.h" 76 #include "media/base/filter_collection.h"
76 #include "media/base/media_switches.h" 77 #include "media/base/media_switches.h"
77 #include "media/base/message_loop_factory_impl.h" 78 #include "media/base/message_loop_factory_impl.h"
78 #include "net/base/escape.h" 79 #include "net/base/escape.h"
79 #include "net/base/net_errors.h" 80 #include "net/base/net_errors.h"
80 #include "net/http/http_util.h" 81 #include "net/http/http_util.h"
81 #include "ppapi/c/private/ppb_flash_net_connector.h" 82 #include "ppapi/c/private/ppb_flash_net_connector.h"
82 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityCache .h"
83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" 83 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h"
84 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" 84 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
85 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 85 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
86 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 86 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" 87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h"
88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" 89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h"
90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h" 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback s.h"
91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 #include "v8/include/v8.h" 131 #include "v8/include/v8.h"
132 #include "webkit/appcache/web_application_cache_host_impl.h" 132 #include "webkit/appcache/web_application_cache_host_impl.h"
133 #include "webkit/glue/alt_error_page_resource_fetcher.h" 133 #include "webkit/glue/alt_error_page_resource_fetcher.h"
134 #include "webkit/glue/context_menu.h" 134 #include "webkit/glue/context_menu.h"
135 #include "webkit/glue/dom_operations.h" 135 #include "webkit/glue/dom_operations.h"
136 #include "webkit/glue/form_data.h" 136 #include "webkit/glue/form_data.h"
137 #include "webkit/glue/form_field.h" 137 #include "webkit/glue/form_field.h"
138 #include "webkit/glue/glue_serialize.h" 138 #include "webkit/glue/glue_serialize.h"
139 #include "webkit/glue/media/video_renderer_impl.h" 139 #include "webkit/glue/media/video_renderer_impl.h"
140 #include "webkit/glue/password_form_dom_manager.h" 140 #include "webkit/glue/password_form_dom_manager.h"
141 #include "webkit/glue/webaccessibility.h"
142 #include "webkit/glue/webdropdata.h" 141 #include "webkit/glue/webdropdata.h"
143 #include "webkit/glue/webkit_constants.h" 142 #include "webkit/glue/webkit_constants.h"
144 #include "webkit/glue/webkit_glue.h" 143 #include "webkit/glue/webkit_glue.h"
145 #include "webkit/glue/webmediaplayer_impl.h" 144 #include "webkit/glue/webmediaplayer_impl.h"
146 #include "webkit/glue/weburlloader_impl.h" 145 #include "webkit/glue/weburlloader_impl.h"
147 #include "webkit/plugins/npapi/default_plugin_shared.h" 146 #include "webkit/plugins/npapi/default_plugin_shared.h"
148 #include "webkit/plugins/npapi/plugin_list.h" 147 #include "webkit/plugins/npapi/plugin_list.h"
149 #include "webkit/plugins/npapi/webplugin_delegate.h" 148 #include "webkit/plugins/npapi/webplugin_delegate.h"
150 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" 149 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
151 #include "webkit/plugins/npapi/webplugin_impl.h" 150 #include "webkit/plugins/npapi/webplugin_impl.h"
152 #include "webkit/plugins/npapi/webview_plugin.h" 151 #include "webkit/plugins/npapi/webview_plugin.h"
153 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 152 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
154 153
155 #if defined(OS_WIN) 154 #if defined(OS_WIN)
156 // TODO(port): these files are currently Windows only because they concern: 155 // TODO(port): these files are currently Windows only because they concern:
157 // * theming 156 // * theming
158 #include "ui/gfx/native_theme_win.h" 157 #include "ui/gfx/native_theme_win.h"
159 #elif defined(USE_X11) 158 #elif defined(USE_X11)
160 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme. h" 159 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme. h"
161 #include "ui/gfx/native_theme.h" 160 #include "ui/gfx/native_theme.h"
162 #elif defined(OS_MACOSX) 161 #elif defined(OS_MACOSX)
163 #include "skia/ext/skia_utils_mac.h" 162 #include "skia/ext/skia_utils_mac.h"
164 #endif 163 #endif
165 164
166 using WebKit::WebAccessibilityCache;
167 using WebKit::WebAccessibilityNotification; 165 using WebKit::WebAccessibilityNotification;
168 using WebKit::WebAccessibilityObject; 166 using WebKit::WebAccessibilityObject;
169 using WebKit::WebApplicationCacheHost; 167 using WebKit::WebApplicationCacheHost;
170 using WebKit::WebApplicationCacheHostClient; 168 using WebKit::WebApplicationCacheHostClient;
171 using WebKit::WebCString; 169 using WebKit::WebCString;
172 using WebKit::WebColor; 170 using WebKit::WebColor;
173 using WebKit::WebColorName; 171 using WebKit::WebColorName;
174 using WebKit::WebConsoleMessage; 172 using WebKit::WebConsoleMessage;
175 using WebKit::WebContextMenuData; 173 using WebKit::WebContextMenuData;
176 using WebKit::WebCookieJar; 174 using WebKit::WebCookieJar;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 using WebKit::WebWorker; 234 using WebKit::WebWorker;
237 using WebKit::WebWorkerClient; 235 using WebKit::WebWorkerClient;
238 using appcache::WebApplicationCacheHostImpl; 236 using appcache::WebApplicationCacheHostImpl;
239 using base::Time; 237 using base::Time;
240 using base::TimeDelta; 238 using base::TimeDelta;
241 using webkit_glue::AltErrorPageResourceFetcher; 239 using webkit_glue::AltErrorPageResourceFetcher;
242 using webkit_glue::FormField; 240 using webkit_glue::FormField;
243 using webkit_glue::PasswordForm; 241 using webkit_glue::PasswordForm;
244 using webkit_glue::PasswordFormDomManager; 242 using webkit_glue::PasswordFormDomManager;
245 using webkit_glue::ResourceFetcher; 243 using webkit_glue::ResourceFetcher;
246 using webkit_glue::WebAccessibility;
247 244
248 //----------------------------------------------------------------------------- 245 //-----------------------------------------------------------------------------
249 246
250 typedef std::map<WebKit::WebView*, RenderView*> ViewMap; 247 typedef std::map<WebKit::WebView*, RenderView*> ViewMap;
251 static base::LazyInstance<ViewMap> g_view_map(base::LINKER_INITIALIZED); 248 static base::LazyInstance<ViewMap> g_view_map(base::LINKER_INITIALIZED);
252 249
253 // Time, in seconds, we delay before sending content state changes (such as form 250 // Time, in seconds, we delay before sending content state changes (such as form
254 // state and scroll position) to the browser. We delay sending changes to avoid 251 // state and scroll position) to the browser. We delay sending changes to avoid
255 // spamming the browser. 252 // spamming the browser.
256 // To avoid having tab/session restore require sending a message to get the 253 // To avoid having tab/session restore require sending a message to get the
(...skipping 10 matching lines...) Expand all
267 static const float kScalingIncrement = 0.1f; 264 static const float kScalingIncrement = 0.1f;
268 265
269 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { 266 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
270 WebVector<WebURL> urls; 267 WebVector<WebURL> urls;
271 ds->redirectChain(urls); 268 ds->redirectChain(urls);
272 result->reserve(urls.size()); 269 result->reserve(urls.size());
273 for (size_t i = 0; i < urls.size(); ++i) 270 for (size_t i = 0; i < urls.size(); ++i)
274 result->push_back(urls[i]); 271 result->push_back(urls[i]);
275 } 272 }
276 273
277 static bool WebAccessibilityNotificationToViewHostMsg(
278 WebAccessibilityNotification notification,
279 ViewHostMsg_AccEvent::Value* type) {
280 switch (notification) {
281 case WebKit::WebAccessibilityNotificationActiveDescendantChanged:
282 *type = ViewHostMsg_AccEvent::ACTIVE_DESCENDANT_CHANGED;
283 break;
284 case WebKit::WebAccessibilityNotificationCheckedStateChanged:
285 *type = ViewHostMsg_AccEvent::CHECK_STATE_CHANGED;
286 break;
287 case WebKit::WebAccessibilityNotificationChildrenChanged:
288 *type = ViewHostMsg_AccEvent::CHILDREN_CHANGED;
289 break;
290 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged:
291 *type = ViewHostMsg_AccEvent::FOCUS_CHANGED;
292 break;
293 case WebKit::WebAccessibilityNotificationLayoutComplete:
294 *type = ViewHostMsg_AccEvent::LAYOUT_COMPLETE;
295 break;
296 case WebKit::WebAccessibilityNotificationLiveRegionChanged:
297 *type = ViewHostMsg_AccEvent::LIVE_REGION_CHANGED;
298 break;
299 case WebKit::WebAccessibilityNotificationLoadComplete:
300 *type = ViewHostMsg_AccEvent::LOAD_COMPLETE;
301 break;
302 case WebKit::WebAccessibilityNotificationMenuListValueChanged:
303 *type = ViewHostMsg_AccEvent::MENU_LIST_VALUE_CHANGED;
304 break;
305 case WebKit::WebAccessibilityNotificationRowCollapsed:
306 *type = ViewHostMsg_AccEvent::ROW_COLLAPSED;
307 break;
308 case WebKit::WebAccessibilityNotificationRowCountChanged:
309 *type = ViewHostMsg_AccEvent::ROW_COUNT_CHANGED;
310 break;
311 case WebKit::WebAccessibilityNotificationRowExpanded:
312 *type = ViewHostMsg_AccEvent::ROW_EXPANDED;
313 break;
314 case WebKit::WebAccessibilityNotificationScrolledToAnchor:
315 *type = ViewHostMsg_AccEvent::SCROLLED_TO_ANCHOR;
316 break;
317 case WebKit::WebAccessibilityNotificationSelectedChildrenChanged:
318 *type = ViewHostMsg_AccEvent::SELECTED_CHILDREN_CHANGED;
319 break;
320 case WebKit::WebAccessibilityNotificationSelectedTextChanged:
321 *type = ViewHostMsg_AccEvent::SELECTED_TEXT_CHANGED;
322 break;
323 case WebKit::WebAccessibilityNotificationValueChanged:
324 *type = ViewHostMsg_AccEvent::VALUE_CHANGED;
325 break;
326 default:
327 return false;
328 }
329 return true;
330 }
331
332 // If |data_source| is non-null and has a NavigationState associated with it, 274 // If |data_source| is non-null and has a NavigationState associated with it,
333 // the AltErrorPageResourceFetcher is reset. 275 // the AltErrorPageResourceFetcher is reset.
334 static void StopAltErrorPageFetcher(WebDataSource* data_source) { 276 static void StopAltErrorPageFetcher(WebDataSource* data_source) {
335 if (data_source) { 277 if (data_source) {
336 NavigationState* state = NavigationState::FromDataSource(data_source); 278 NavigationState* state = NavigationState::FromDataSource(data_source);
337 if (state) 279 if (state)
338 state->set_alt_error_page_fetcher(NULL); 280 state->set_alt_error_page_fetcher(NULL);
339 } 281 }
340 } 282 }
341 283
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 page_id_(-1), 316 page_id_(-1),
375 last_page_id_sent_to_browser_(-1), 317 last_page_id_sent_to_browser_(-1),
376 history_list_offset_(-1), 318 history_list_offset_(-1),
377 history_list_length_(0), 319 history_list_length_(0),
378 target_url_status_(TARGET_NONE), 320 target_url_status_(TARGET_NONE),
379 cached_is_main_frame_pinned_to_left_(false), 321 cached_is_main_frame_pinned_to_left_(false),
380 cached_is_main_frame_pinned_to_right_(false), 322 cached_is_main_frame_pinned_to_right_(false),
381 cached_has_main_frame_horizontal_scrollbar_(false), 323 cached_has_main_frame_horizontal_scrollbar_(false),
382 cached_has_main_frame_vertical_scrollbar_(false), 324 cached_has_main_frame_vertical_scrollbar_(false),
383 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), 325 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
384 ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)),
385 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 326 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
386 geolocation_dispatcher_(NULL), 327 geolocation_dispatcher_(NULL),
387 speech_input_dispatcher_(NULL), 328 speech_input_dispatcher_(NULL),
388 device_orientation_dispatcher_(NULL), 329 device_orientation_dispatcher_(NULL),
389 accessibility_ack_pending_(false),
390 accessibility_logging_(false),
391 p2p_socket_dispatcher_(NULL), 330 p2p_socket_dispatcher_(NULL),
392 devtools_agent_(NULL), 331 devtools_agent_(NULL),
332 renderer_accessibility_(NULL),
393 session_storage_namespace_id_(session_storage_namespace_id), 333 session_storage_namespace_id_(session_storage_namespace_id),
394 handling_select_range_(false) { 334 handling_select_range_(false) {
395 routing_id_ = routing_id; 335 routing_id_ = routing_id;
396 if (opener_id != MSG_ROUTING_NONE) 336 if (opener_id != MSG_ROUTING_NONE)
397 opener_id_ = opener_id; 337 opener_id_ = opener_id;
398 338
399 webwidget_ = WebView::create(this); 339 webwidget_ = WebView::create(this);
400 340
401 if (counter) { 341 if (counter) {
402 shared_popup_counter_ = counter; 342 shared_popup_counter_ = counter;
(...skipping 25 matching lines...) Expand all
428 if (!frame_name.empty()) 368 if (!frame_name.empty())
429 webview()->mainFrame()->setName(frame_name); 369 webview()->mainFrame()->setName(frame_name);
430 webview()->settings()->setMinimumTimerInterval( 370 webview()->settings()->setMinimumTimerInterval(
431 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : 371 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval :
432 webkit_glue::kForegroundTabTimerInterval); 372 webkit_glue::kForegroundTabTimerInterval);
433 373
434 OnSetRendererPrefs(renderer_prefs); 374 OnSetRendererPrefs(renderer_prefs);
435 375
436 host_window_ = parent_hwnd; 376 host_window_ = parent_hwnd;
437 377
438 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
439 if (command_line.HasSwitch(switches::kEnableAccessibility))
440 WebAccessibilityCache::enableAccessibility();
441 if (command_line.HasSwitch(switches::kEnableAccessibilityLogging))
442 accessibility_logging_ = true;
443
444 #if defined(ENABLE_P2P_APIS) 378 #if defined(ENABLE_P2P_APIS)
445 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); 379 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
446 #endif 380 #endif
447 381
448 new MHTMLGenerator(this); 382 new MHTMLGenerator(this);
449 #if defined(OS_MACOSX) 383 #if defined(OS_MACOSX)
450 new TextInputClientObserver(this); 384 new TextInputClientObserver(this);
451 #endif // defined(OS_MACOSX) 385 #endif // defined(OS_MACOSX)
452 386
453 devtools_agent_ = new DevToolsAgent(this); 387 devtools_agent_ = new DevToolsAgent(this);
454 388
389 renderer_accessibility_ = new RendererAccessibility(this);
390
391 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
455 if (command_line.HasSwitch(switches::kEnableMediaStream)) { 392 if (command_line.HasSwitch(switches::kEnableMediaStream)) {
456 media_stream_impl_ = new MediaStreamImpl( 393 media_stream_impl_ = new MediaStreamImpl(
457 RenderThread::current()->video_capture_impl_manager()); 394 RenderThread::current()->video_capture_impl_manager());
458 } 395 }
459 396
460 content::GetContentClient()->renderer()->RenderViewCreated(this); 397 content::GetContentClient()->renderer()->RenderViewCreated(this);
461 } 398 }
462 399
463 RenderView::~RenderView() { 400 RenderView::~RenderView() {
464 history_page_ids_.clear(); 401 history_page_ids_.clear();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 484
548 void RenderView::AddObserver(RenderViewObserver* observer) { 485 void RenderView::AddObserver(RenderViewObserver* observer) {
549 observers_.AddObserver(observer); 486 observers_.AddObserver(observer);
550 } 487 }
551 488
552 void RenderView::RemoveObserver(RenderViewObserver* observer) { 489 void RenderView::RemoveObserver(RenderViewObserver* observer) {
553 observer->set_render_view(NULL); 490 observer->set_render_view(NULL);
554 observers_.RemoveObserver(observer); 491 observers_.RemoveObserver(observer);
555 } 492 }
556 493
557 bool RenderView::RendererAccessibilityNotification::ShouldIncludeChildren() {
558 typedef ViewHostMsg_AccessibilityNotification_Params params;
559 if (type == WebKit::WebAccessibilityNotificationChildrenChanged ||
560 type == WebKit::WebAccessibilityNotificationLoadComplete ||
561 type == WebKit::WebAccessibilityNotificationLiveRegionChanged) {
562 return true;
563 }
564 return false;
565 }
566
567 WebKit::WebView* RenderView::webview() const { 494 WebKit::WebView* RenderView::webview() const {
568 return static_cast<WebKit::WebView*>(webwidget()); 495 return static_cast<WebKit::WebView*>(webwidget());
569 } 496 }
570 497
571 void RenderView::SetReportLoadProgressEnabled(bool enabled) { 498 void RenderView::SetReportLoadProgressEnabled(bool enabled) {
572 if (!enabled) { 499 if (!enabled) {
573 load_progress_tracker_.reset(NULL); 500 load_progress_tracker_.reset(NULL);
574 return; 501 return;
575 } 502 }
576 if (load_progress_tracker_ == NULL) 503 if (load_progress_tracker_ == NULL)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 #if defined(OS_MACOSX) 649 #if defined(OS_MACOSX)
723 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) 650 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility)
724 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) 651 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged)
725 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, 652 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
726 OnPluginImeCompositionCompleted) 653 OnPluginImeCompositionCompleted)
727 #endif 654 #endif
728 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, 655 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent,
729 OnSetEditCommandsForNextKeyEvent) 656 OnSetEditCommandsForNextKeyEvent)
730 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, 657 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction,
731 OnCustomContextMenuAction) 658 OnCustomContextMenuAction)
732 IPC_MESSAGE_HANDLER(ViewMsg_EnableAccessibility, OnEnableAccessibility)
733 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus)
734 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction,
735 OnAccessibilityDoDefaultAction)
736 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK,
737 OnAccessibilityNotificationsAck)
738 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) 659 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened)
739 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, 660 IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated,
740 OnPpapiBrokerChannelCreated) 661 OnPpapiBrokerChannelCreated)
741 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 662 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
742 OnGetAllSavableResourceLinksForCurrentPage) 663 OnGetAllSavableResourceLinksForCurrentPage)
743 IPC_MESSAGE_HANDLER( 664 IPC_MESSAGE_HANDLER(
744 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 665 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
745 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 666 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
746 #if defined(OS_MACOSX) 667 #if defined(OS_MACOSX)
747 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) 668 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1184
1264 Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); 1185 Send(new ViewHostMsg_FrameNavigate(routing_id_, params));
1265 } 1186 }
1266 1187
1267 last_page_id_sent_to_browser_ = 1188 last_page_id_sent_to_browser_ =
1268 std::max(last_page_id_sent_to_browser_, page_id_); 1189 std::max(last_page_id_sent_to_browser_, page_id_);
1269 1190
1270 // If we end up reusing this WebRequest (for example, due to a #ref click), 1191 // If we end up reusing this WebRequest (for example, due to a #ref click),
1271 // we don't want the transition type to persist. Just clear it. 1192 // we don't want the transition type to persist. Just clear it.
1272 navigation_state->set_transition_type(PageTransition::LINK); 1193 navigation_state->set_transition_type(PageTransition::LINK);
1273
1274 // Check if the navigation was within the same page, in which case we don't
1275 // want to clear the accessibility cache.
1276 if (accessibility_.get() && !navigation_state->was_within_same_page()) {
1277 accessibility_.reset();
1278 pending_accessibility_notifications_.clear();
1279 }
1280 } 1194 }
1281 1195
1282 // Tell the embedding application that the title of the active page has changed 1196 // Tell the embedding application that the title of the active page has changed
1283 void RenderView::UpdateTitle(WebFrame* frame, 1197 void RenderView::UpdateTitle(WebFrame* frame,
1284 const string16& title, 1198 const string16& title,
1285 WebTextDirection title_direction) { 1199 WebTextDirection title_direction) {
1286 // Ignore all but top level navigations. 1200 // Ignore all but top level navigations.
1287 if (frame->parent()) 1201 if (frame->parent())
1288 return; 1202 return;
1289 1203
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 1505
1592 void RenderView::didExecuteCommand(const WebString& command_name) { 1506 void RenderView::didExecuteCommand(const WebString& command_name) {
1593 const std::string& name = UTF16ToUTF8(command_name); 1507 const std::string& name = UTF16ToUTF8(command_name);
1594 if (StartsWithASCII(name, "Move", true) || 1508 if (StartsWithASCII(name, "Move", true) ||
1595 StartsWithASCII(name, "Insert", true) || 1509 StartsWithASCII(name, "Insert", true) ||
1596 StartsWithASCII(name, "Delete", true)) 1510 StartsWithASCII(name, "Delete", true))
1597 return; 1511 return;
1598 RenderThread::RecordUserMetrics(name); 1512 RenderThread::RecordUserMetrics(name);
1599 } 1513 }
1600 1514
1601 void RenderView::SendPendingAccessibilityNotifications() {
1602 if (!accessibility_.get())
1603 return;
1604
1605 if (pending_accessibility_notifications_.empty())
1606 return;
1607
1608 // Send all pending accessibility notifications.
1609 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications;
1610 for (size_t i = 0; i < pending_accessibility_notifications_.size(); i++) {
1611 RendererAccessibilityNotification& notification =
1612 pending_accessibility_notifications_[i];
1613 WebAccessibilityObject obj = accessibility_->getObjectById(notification.id);
1614 if (!obj.isValid())
1615 continue;
1616
1617 ViewHostMsg_AccessibilityNotification_Params param;
1618 WebAccessibilityNotificationToViewHostMsg(
1619 pending_accessibility_notifications_[i].type, &param.notification_type);
1620 param.acc_obj = WebAccessibility(
1621 obj, accessibility_.get(), notification.ShouldIncludeChildren());
1622 notifications.push_back(param);
1623
1624 #ifndef NDEBUG
1625 if (accessibility_logging_) {
1626 LOG(INFO) << "Accessibility update:\n"
1627 << param.acc_obj.DebugString(true,
1628 routing_id_,
1629 pending_accessibility_notifications_[i].type);
1630 }
1631 #endif
1632 }
1633 pending_accessibility_notifications_.clear();
1634 Send(new ViewHostMsg_AccessibilityNotifications(routing_id_, notifications));
1635 accessibility_ack_pending_ = true;
1636 }
1637
1638 bool RenderView::handleCurrentKeyboardEvent() { 1515 bool RenderView::handleCurrentKeyboardEvent() {
1639 if (edit_commands_.empty()) 1516 if (edit_commands_.empty())
1640 return false; 1517 return false;
1641 1518
1642 WebFrame* frame = webview()->focusedFrame(); 1519 WebFrame* frame = webview()->focusedFrame();
1643 if (!frame) 1520 if (!frame)
1644 return false; 1521 return false;
1645 1522
1646 EditCommands::iterator it = edit_commands_.begin(); 1523 EditCommands::iterator it = edit_commands_.begin();
1647 EditCommands::iterator end = edit_commands_.end(); 1524 EditCommands::iterator end = edit_commands_.end();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 Send(new ViewHostMsg_TakeFocus(routing_id_, false)); 1728 Send(new ViewHostMsg_TakeFocus(routing_id_, false));
1852 } 1729 }
1853 1730
1854 void RenderView::focusPrevious() { 1731 void RenderView::focusPrevious() {
1855 Send(new ViewHostMsg_TakeFocus(routing_id_, true)); 1732 Send(new ViewHostMsg_TakeFocus(routing_id_, true));
1856 } 1733 }
1857 1734
1858 void RenderView::focusedNodeChanged(const WebNode& node) { 1735 void RenderView::focusedNodeChanged(const WebNode& node) {
1859 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); 1736 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node)));
1860 1737
1861 if (WebAccessibilityCache::accessibilityEnabled() && node.isNull()) {
1862 // TODO(ctguil): Make WebKit send this notification.
1863 // When focus is cleared notify accessibility that the document is focused.
1864 postAccessibilityNotification(
1865 webview()->accessibilityObject(),
1866 WebKit::WebAccessibilityNotificationFocusedUIElementChanged);
1867 }
1868
1869 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); 1738 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node));
1870 } 1739 }
1871 1740
1872 void RenderView::navigateBackForwardSoon(int offset) { 1741 void RenderView::navigateBackForwardSoon(int offset) {
1873 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); 1742 Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset));
1874 } 1743 }
1875 1744
1876 int RenderView::historyBackListCount() { 1745 int RenderView::historyBackListCount() {
1877 return history_list_offset_ < 0 ? 0 : history_list_offset_; 1746 return history_list_offset_ < 0 ? 0 : history_list_offset_;
1878 } 1747 }
1879 1748
1880 int RenderView::historyForwardListCount() { 1749 int RenderView::historyForwardListCount() {
1881 return history_list_length_ - historyBackListCount() - 1; 1750 return history_list_length_ - historyBackListCount() - 1;
1882 } 1751 }
1883 1752
1753 void RenderView::postAccessibilityNotification(
1754 const WebAccessibilityObject& obj,
1755 WebAccessibilityNotification notification) {
1756 renderer_accessibility_->PostAccessibilityNotification(obj, notification);
1757 }
1758
1884 void RenderView::didUpdateInspectorSetting(const WebString& key, 1759 void RenderView::didUpdateInspectorSetting(const WebString& key,
1885 const WebString& value) { 1760 const WebString& value) {
1886 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, 1761 Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_,
1887 key.utf8(), 1762 key.utf8(),
1888 value.utf8())); 1763 value.utf8()));
1889 } 1764 }
1890 1765
1891 // WebKit::WebWidgetClient ---------------------------------------------------- 1766 // WebKit::WebWidgetClient ----------------------------------------------------
1892 1767
1893 void RenderView::didFocus() { 1768 void RenderView::didFocus() {
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 } 3608 }
3734 #endif 3609 #endif
3735 } 3610 }
3736 3611
3737 void RenderView::OnMediaPlayerActionAt(const gfx::Point& location, 3612 void RenderView::OnMediaPlayerActionAt(const gfx::Point& location,
3738 const WebMediaPlayerAction& action) { 3613 const WebMediaPlayerAction& action) {
3739 if (webview()) 3614 if (webview())
3740 webview()->performMediaPlayerAction(action, location); 3615 webview()->performMediaPlayerAction(action, location);
3741 } 3616 }
3742 3617
3743 void RenderView::OnEnableAccessibility() {
3744 if (WebAccessibilityCache::accessibilityEnabled())
3745 return;
3746
3747 WebAccessibilityCache::enableAccessibility();
3748
3749 if (webview()) {
3750 // It's possible that the webview has already loaded a webpage without
3751 // accessibility being enabled. Initialize the browser's cached
3752 // accessibility tree by sending it a 'load complete' notification.
3753 postAccessibilityNotification(
3754 webview()->accessibilityObject(),
3755 WebKit::WebAccessibilityNotificationLoadComplete);
3756 }
3757 }
3758
3759 void RenderView::OnSetAccessibilityFocus(int acc_obj_id) {
3760 if (!accessibility_.get())
3761 return;
3762
3763 WebAccessibilityObject obj = accessibility_->getObjectById(acc_obj_id);
3764 WebAccessibilityObject root = webview()->accessibilityObject();
3765 if (!obj.isValid() || !root.isValid())
3766 return;
3767
3768 // By convention, calling SetFocus on the root of the tree should clear the
3769 // current focus. Otherwise set the focus to the new node.
3770 if (accessibility_->addOrGetId(obj) == accessibility_->addOrGetId(root))
3771 webview()->clearFocusedNode();
3772 else
3773 obj.setFocused(true);
3774 }
3775
3776 void RenderView::OnAccessibilityDoDefaultAction(int acc_obj_id) {
3777 if (!accessibility_.get())
3778 return;
3779
3780 WebAccessibilityObject obj = accessibility_->getObjectById(acc_obj_id);
3781 if (!obj.isValid())
3782 return;
3783
3784 obj.performDefaultAction();
3785 }
3786
3787 void RenderView::OnAccessibilityNotificationsAck() {
3788 DCHECK(accessibility_ack_pending_);
3789 accessibility_ack_pending_ = false;
3790 SendPendingAccessibilityNotifications();
3791 }
3792
3793 void RenderView::OnGetAllSavableResourceLinksForCurrentPage( 3618 void RenderView::OnGetAllSavableResourceLinksForCurrentPage(
3794 const GURL& page_url) { 3619 const GURL& page_url) {
3795 // Prepare list to storage all savable resource links. 3620 // Prepare list to storage all savable resource links.
3796 std::vector<GURL> resources_list; 3621 std::vector<GURL> resources_list;
3797 std::vector<GURL> referrers_list; 3622 std::vector<GURL> referrers_list;
3798 std::vector<GURL> frames_list; 3623 std::vector<GURL> frames_list;
3799 webkit_glue::SavableResourcesResult result(&resources_list, 3624 webkit_glue::SavableResourcesResult result(&resources_list,
3800 &referrers_list, 3625 &referrers_list,
3801 &frames_list); 3626 &frames_list);
3802 3627
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
4092 // WebPluginDelegateProxy is responsible for figuring out if this event 3917 // WebPluginDelegateProxy is responsible for figuring out if this event
4093 // applies to it or not, so inform all the delegates. 3918 // applies to it or not, so inform all the delegates.
4094 std::set<WebPluginDelegateProxy*>::iterator plugin_it; 3919 std::set<WebPluginDelegateProxy*>::iterator plugin_it;
4095 for (plugin_it = plugin_delegates_.begin(); 3920 for (plugin_it = plugin_delegates_.begin();
4096 plugin_it != plugin_delegates_.end(); ++plugin_it) { 3921 plugin_it != plugin_delegates_.end(); ++plugin_it) {
4097 (*plugin_it)->ImeCompositionCompleted(text, plugin_id); 3922 (*plugin_it)->ImeCompositionCompleted(text, plugin_id);
4098 } 3923 }
4099 } 3924 }
4100 #endif // OS_MACOSX 3925 #endif // OS_MACOSX
4101 3926
4102 void RenderView::postAccessibilityNotification(
4103 const WebAccessibilityObject& obj,
4104 WebAccessibilityNotification notification) {
4105 if (!accessibility_.get() && webview()) {
4106 // Create and initialize our accessibility cache
4107 accessibility_.reset(WebAccessibilityCache::create());
4108 accessibility_->initialize(webview());
4109
4110 // Load complete should be our first notification sent. Send it manually
4111 // in cases where we don't get it first to avoid focus problems.
4112 // TODO(ctguil): Investigate if a different notification is a WebCore bug.
4113 if (notification != WebKit::WebAccessibilityNotificationLoadComplete) {
4114 postAccessibilityNotification(accessibility_->getObjectById(1000),
4115 WebKit::WebAccessibilityNotificationLoadComplete);
4116 }
4117 }
4118
4119 if (!accessibility_->isCached(obj)) {
4120 // The browser doesn't know about objects that are not in the cache. Send a
4121 // children change for the first accestor that actually is in the cache.
4122 WebAccessibilityObject parent = obj;
4123 while (parent.isValid() && !accessibility_->isCached(parent))
4124 parent = parent.parentObject();
4125
4126 DCHECK(parent.isValid() && accessibility_->isCached(parent));
4127 if (!parent.isValid())
4128 return;
4129 postAccessibilityNotification(
4130 parent, WebKit::WebAccessibilityNotificationChildrenChanged);
4131
4132 // The parent's children change takes care of the child's children change.
4133 if (notification == WebKit::WebAccessibilityNotificationChildrenChanged)
4134 return;
4135 }
4136
4137 // Add the accessibility object to our cache and ensure it's valid.
4138 RendererAccessibilityNotification acc_notification;
4139 acc_notification.id = accessibility_->addOrGetId(obj);
4140 acc_notification.type = notification;
4141 if (acc_notification.id < 0)
4142 return;
4143
4144 ViewHostMsg_AccEvent::Value temp;
4145 if (!WebAccessibilityNotificationToViewHostMsg(notification, &temp))
4146 return;
4147
4148 // Discard duplicate accessibility notifications.
4149 for (uint32 i = 0; i < pending_accessibility_notifications_.size(); i++) {
4150 if (pending_accessibility_notifications_[i].id == acc_notification.id &&
4151 pending_accessibility_notifications_[i].type == acc_notification.type) {
4152 return;
4153 }
4154 }
4155 pending_accessibility_notifications_.push_back(acc_notification);
4156
4157 if (!accessibility_ack_pending_ && accessibility_method_factory_.empty()) {
4158 // When no accessibility notifications are in-flight post a task to send
4159 // the notifications to the browser. We use PostTask so that we can queue
4160 // up additional notifications.
4161 MessageLoop::current()->PostTask(
4162 FROM_HERE,
4163 accessibility_method_factory_.NewRunnableMethod(
4164 &RenderView::SendPendingAccessibilityNotifications));
4165 }
4166 }
4167
4168 void RenderView::OnSetEditCommandsForNextKeyEvent( 3927 void RenderView::OnSetEditCommandsForNextKeyEvent(
4169 const EditCommands& edit_commands) { 3928 const EditCommands& edit_commands) {
4170 edit_commands_ = edit_commands; 3929 edit_commands_ = edit_commands;
4171 } 3930 }
4172 3931
4173 void RenderView::Close() { 3932 void RenderView::Close() {
4174 // We need to grab a pointer to the doomed WebView before we destroy it. 3933 // We need to grab a pointer to the doomed WebView before we destroy it.
4175 WebView* doomed = webview(); 3934 WebView* doomed = webview();
4176 RenderWidget::Close(); 3935 RenderWidget::Close();
4177 g_view_map.Get().erase(doomed); 3936 g_view_map.Get().erase(doomed);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
4638 } 4397 }
4639 4398
4640 void RenderView::OnLockMouseACK(bool succeeded) { 4399 void RenderView::OnLockMouseACK(bool succeeded) {
4641 pepper_delegate_.OnLockMouseACK(succeeded); 4400 pepper_delegate_.OnLockMouseACK(succeeded);
4642 } 4401 }
4643 4402
4644 void RenderView::OnMouseLockLost() { 4403 void RenderView::OnMouseLockLost() {
4645 pepper_delegate_.OnMouseLockLost(); 4404 pepper_delegate_.OnMouseLockLost();
4646 } 4405 }
4647 4406
OLDNEW
« no previous file with comments | « content/renderer/render_view.h ('k') | content/renderer/renderer_accessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698