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

Side by Side Diff: Source/modules/accessibility/AXMenuListPopup.cpp

Issue 1020473004: Fire an event when a menu list option becomes unselected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 28
29 #include "core/html/HTMLSelectElement.h" 29 #include "core/html/HTMLSelectElement.h"
30 #include "modules/accessibility/AXMenuListOption.h" 30 #include "modules/accessibility/AXMenuListOption.h"
31 #include "modules/accessibility/AXObjectCacheImpl.h" 31 #include "modules/accessibility/AXObjectCacheImpl.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 using namespace HTMLNames; 35 using namespace HTMLNames;
36 36
37 AXMenuListPopup::AXMenuListPopup(AXObjectCacheImpl* axObjectCache) 37 AXMenuListPopup::AXMenuListPopup(AXObjectCacheImpl* axObjectCache)
38 : AXMockObject(axObjectCache) 38 : AXMockObject(axObjectCache), m_activeIndex(-1)
39 { 39 {
40 } 40 }
41 41
42 bool AXMenuListPopup::isVisible() const 42 bool AXMenuListPopup::isVisible() const
43 { 43 {
44 return false; 44 return false;
45 } 45 }
46 46
47 bool AXMenuListPopup::isOffScreen() const 47 bool AXMenuListPopup::isOffScreen() const
48 { 48 {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 { 93 {
94 if (!m_parent) 94 if (!m_parent)
95 return; 95 return;
96 96
97 Node* selectNode = m_parent->node(); 97 Node* selectNode = m_parent->node();
98 if (!selectNode) 98 if (!selectNode)
99 return; 99 return;
100 100
101 m_haveChildren = true; 101 m_haveChildren = true;
102 102
103 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = toHTMLS electElement(selectNode)->listItems(); 103 HTMLSelectElement* htmlSelectElement = toHTMLSelectElement(selectNode);
104 m_activeIndex = htmlSelectElement->selectedIndex();
105 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = htmlSel ectElement->listItems();
104 unsigned length = listItems.size(); 106 unsigned length = listItems.size();
105 for (unsigned i = 0; i < length; i++) { 107 for (unsigned i = 0; i < length; i++) {
106 AXMenuListOption* option = menuListOptionAXObject(listItems[i]); 108 AXMenuListOption* option = menuListOptionAXObject(listItems[i]);
107 if (option) { 109 if (option) {
108 option->setParent(this); 110 option->setParent(this);
109 m_children.append(option); 111 m_children.append(option);
110 } 112 }
111 } 113 }
112 } 114 }
113 115
(...skipping 20 matching lines...) Expand all
134 { 136 {
135 // We defer creation of the children until updating the active option so tha t we don't 137 // We defer creation of the children until updating the active option so tha t we don't
136 // create AXObjects for <option> elements while they're in the middle of rem oval. 138 // create AXObjects for <option> elements while they're in the middle of rem oval.
137 if (!m_haveChildren) 139 if (!m_haveChildren)
138 addChildren(); 140 addChildren();
139 141
140 ASSERT_ARG(optionIndex, optionIndex >= 0); 142 ASSERT_ARG(optionIndex, optionIndex >= 0);
141 ASSERT_ARG(optionIndex, optionIndex < static_cast<int>(m_children.size())); 143 ASSERT_ARG(optionIndex, optionIndex < static_cast<int>(m_children.size()));
142 144
143 AXObjectCacheImpl* cache = axObjectCache(); 145 AXObjectCacheImpl* cache = axObjectCache();
146 if (m_activeIndex >= 0 && m_activeIndex < static_cast<int>(m_children.size() )) {
147 RefPtr<AXObject> previousChild = m_children[m_activeIndex].get();
148 cache->postNotification(previousChild.get(), document(), AXObjectCacheIm pl::AXMenuListItemUnselected, true);
149 }
150
144 RefPtr<AXObject> child = m_children[optionIndex].get(); 151 RefPtr<AXObject> child = m_children[optionIndex].get();
145
146 cache->postNotification(child.get(), document(), AXObjectCacheImpl::AXFocuse dUIElementChanged, true); 152 cache->postNotification(child.get(), document(), AXObjectCacheImpl::AXFocuse dUIElementChanged, true);
147 cache->postNotification(child.get(), document(), AXObjectCacheImpl::AXMenuLi stItemSelected, true); 153 cache->postNotification(child.get(), document(), AXObjectCacheImpl::AXMenuLi stItemSelected, true);
154 m_activeIndex = optionIndex;
148 } 155 }
149 156
150 } // namespace blink 157 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698