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

Side by Side Diff: views/controls/menu/submenu_view.cc

Issue 3015055: Enable better NVDA support for custom menus.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 | « views/controls/menu/menu_scroll_view_container.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/menu/submenu_view.h" 5 #include "views/controls/menu/submenu_view.h"
6 6
7 #include "gfx/canvas.h" 7 #include "gfx/canvas.h"
8 #include "views/accessibility/view_accessibility.h"
8 #include "views/controls/menu/menu_config.h" 9 #include "views/controls/menu/menu_config.h"
9 #include "views/controls/menu/menu_controller.h" 10 #include "views/controls/menu/menu_controller.h"
10 #include "views/controls/menu/menu_host.h" 11 #include "views/controls/menu/menu_host.h"
11 #include "views/controls/menu/menu_scroll_view_container.h" 12 #include "views/controls/menu/menu_scroll_view_container.h"
12 #include "views/widget/root_view.h" 13 #include "views/widget/root_view.h"
13 14
14 // Height of the drop indicator. This should be an even number. 15 // Height of the drop indicator. This should be an even number.
15 static const int kDropIndicatorHeight = 2; 16 static const int kDropIndicatorHeight = 2;
16 17
17 // Color of the drop indicator. 18 // Color of the drop indicator.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 host_->ShowMenuHost(do_capture); 227 host_->ShowMenuHost(do_capture);
227 return; 228 return;
228 } 229 }
229 230
230 host_ = MenuHost::Create(this); 231 host_ = MenuHost::Create(this);
231 // Force construction of the scroll view container. 232 // Force construction of the scroll view container.
232 GetScrollViewContainer(); 233 GetScrollViewContainer();
233 // Make sure the first row is visible. 234 // Make sure the first row is visible.
234 ScrollRectToVisible(gfx::Rect(gfx::Point(), gfx::Size(1, 1))); 235 ScrollRectToVisible(gfx::Rect(gfx::Point(), gfx::Size(1, 1)));
235 host_->Init(parent, bounds, scroll_view_container_, do_capture); 236 host_->Init(parent, bounds, scroll_view_container_, do_capture);
237
238 GetScrollViewContainer()->NotifyAccessibilityEvent(
239 AccessibilityTypes::EVENT_MENUPOPUPSTART);
236 } 240 }
237 241
238 void SubmenuView::Reposition(const gfx::Rect& bounds) { 242 void SubmenuView::Reposition(const gfx::Rect& bounds) {
239 if (host_) 243 if (host_)
240 host_->SetMenuHostBounds(bounds); 244 host_->SetMenuHostBounds(bounds);
241 } 245 }
242 246
243 void SubmenuView::Close() { 247 void SubmenuView::Close() {
244 if (host_) { 248 if (host_) {
249 GetScrollViewContainer()->NotifyAccessibilityEvent(
250 AccessibilityTypes::EVENT_MENUPOPUPEND);
251
245 host_->DestroyMenuHost(); 252 host_->DestroyMenuHost();
246 host_ = NULL; 253 host_ = NULL;
247 } 254 }
248 } 255 }
249 256
250 void SubmenuView::Hide() { 257 void SubmenuView::Hide() {
251 if (host_) 258 if (host_)
252 host_->HideMenuHost(); 259 host_->HideMenuHost();
253 } 260 }
254 261
(...skipping 23 matching lines...) Expand all
278 // selection if the drop is on the passed in item and the drop position is 285 // selection if the drop is on the passed in item and the drop position is
279 // ON. 286 // ON.
280 return (drop_item_ == item && drop_position_ == MenuDelegate::DROP_ON); 287 return (drop_item_ == item && drop_position_ == MenuDelegate::DROP_ON);
281 } 288 }
282 289
283 MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() { 290 MenuScrollViewContainer* SubmenuView::GetScrollViewContainer() {
284 if (!scroll_view_container_) { 291 if (!scroll_view_container_) {
285 scroll_view_container_ = new MenuScrollViewContainer(this); 292 scroll_view_container_ = new MenuScrollViewContainer(this);
286 // Otherwise MenuHost would delete us. 293 // Otherwise MenuHost would delete us.
287 scroll_view_container_->set_parent_owned(false); 294 scroll_view_container_->set_parent_owned(false);
295
296 // Use the parent menu item accessible name for the menu view.
297 std::wstring accessible_name;
298 GetMenuItem()->GetAccessibleName(&accessible_name);
299 scroll_view_container_->SetAccessibleName(accessible_name);
288 } 300 }
289 return scroll_view_container_; 301 return scroll_view_container_;
290 } 302 }
291 303
292 gfx::NativeWindow SubmenuView::native_window() const { 304 gfx::NativeWindow SubmenuView::native_window() const {
293 return host_ ? host_->GetMenuHostWindow() : NULL; 305 return host_ ? host_->GetMenuHostWindow() : NULL;
294 } 306 }
295 307
296 void SubmenuView::MenuHostDestroyed() { 308 void SubmenuView::MenuHostDestroyed() {
297 host_ = NULL; 309 host_ = NULL;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 item_bounds.set_height(kDropIndicatorHeight); 350 item_bounds.set_height(kDropIndicatorHeight);
339 return item_bounds; 351 return item_bounds;
340 352
341 default: 353 default:
342 // Don't render anything for on. 354 // Don't render anything for on.
343 return gfx::Rect(); 355 return gfx::Rect();
344 } 356 }
345 } 357 }
346 358
347 } // namespace views 359 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/menu_scroll_view_container.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698