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

Side by Side Diff: Source/core/accessibility/AccessibilityListBoxOption.cpp

Issue 19510005: [oilpan] Completely move HTMLFormControlElement's hierarchy to the managed heap Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 5 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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return false; 78 return false;
79 79
80 if (!m_optionElement->hasTagName(optionTag)) 80 if (!m_optionElement->hasTagName(optionTag))
81 return false; 81 return false;
82 82
83 return static_cast<HTMLOptionElement*>(m_optionElement)->selected(); 83 return static_cast<HTMLOptionElement*>(m_optionElement)->selected();
84 } 84 }
85 85
86 bool AccessibilityListBoxOption::isSelectedOptionActive() const 86 bool AccessibilityListBoxOption::isSelectedOptionActive() const
87 { 87 {
88 HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode(); 88 Handle<HTMLSelectElement> listBoxParentNode = listBoxOptionParentNode();
89 if (!listBoxParentNode) 89 if (!listBoxParentNode)
90 return false; 90 return false;
91 91
92 return listBoxParentNode->activeSelectionEndListIndex() == listBoxOptionInde x(); 92 return listBoxParentNode->activeSelectionEndListIndex() == listBoxOptionInde x();
93 } 93 }
94 94
95 LayoutRect AccessibilityListBoxOption::elementRect() const 95 LayoutRect AccessibilityListBoxOption::elementRect() const
96 { 96 {
97 LayoutRect rect; 97 LayoutRect rect;
98 if (!m_optionElement) 98 if (!m_optionElement)
99 return rect; 99 return rect;
100 100
101 HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode(); 101 Handle<HTMLSelectElement> listBoxParentNode = listBoxOptionParentNode();
102 if (!listBoxParentNode) 102 if (!listBoxParentNode)
103 return rect; 103 return rect;
104 104
105 RenderObject* listBoxRenderer = listBoxParentNode->renderer(); 105 RenderObject* listBoxRenderer = listBoxParentNode->renderer();
106 if (!listBoxRenderer) 106 if (!listBoxRenderer)
107 return rect; 107 return rect;
108 108
109 LayoutRect parentRect = listBoxRenderer->document()->axObjectCache()->getOrC reate(listBoxRenderer)->boundingBoxRect(); 109 LayoutRect parentRect = listBoxRenderer->document()->axObjectCache()->getOrC reate(listBoxRenderer)->boundingBoxRect();
110 int index = listBoxOptionIndex(); 110 int index = listBoxOptionIndex();
111 if (index != -1) 111 if (index != -1)
(...skipping 17 matching lines...) Expand all
129 { 129 {
130 if (!m_optionElement) 130 if (!m_optionElement)
131 return false; 131 return false;
132 132
133 if (!m_optionElement->hasTagName(optionTag)) 133 if (!m_optionElement->hasTagName(optionTag))
134 return false; 134 return false;
135 135
136 if (m_optionElement->isDisabledFormControl()) 136 if (m_optionElement->isDisabledFormControl())
137 return false; 137 return false;
138 138
139 HTMLSelectElement* selectElement = listBoxOptionParentNode(); 139 Handle<HTMLSelectElement> selectElement = listBoxOptionParentNode();
140 if (selectElement && selectElement->isDisabledFormControl()) 140 if (selectElement && selectElement->isDisabledFormControl())
141 return false; 141 return false;
142 142
143 return true; 143 return true;
144 } 144 }
145 145
146 String AccessibilityListBoxOption::stringValue() const 146 String AccessibilityListBoxOption::stringValue() const
147 { 147 {
148 if (!m_optionElement) 148 if (!m_optionElement)
149 return String(); 149 return String();
(...skipping 11 matching lines...) Expand all
161 return String(); 161 return String();
162 } 162 }
163 163
164 Element* AccessibilityListBoxOption::actionElement() const 164 Element* AccessibilityListBoxOption::actionElement() const
165 { 165 {
166 return m_optionElement; 166 return m_optionElement;
167 } 167 }
168 168
169 AccessibilityObject* AccessibilityListBoxOption::parentObject() const 169 AccessibilityObject* AccessibilityListBoxOption::parentObject() const
170 { 170 {
171 HTMLSelectElement* parentNode = listBoxOptionParentNode(); 171 Handle<HTMLSelectElement> parentNode = listBoxOptionParentNode();
172 if (!parentNode) 172 if (!parentNode)
173 return 0; 173 return 0;
174 174
175 return m_optionElement->document()->axObjectCache()->getOrCreate(parentNode) ; 175 return m_optionElement->document()->axObjectCache()->getOrCreate(parentNode. raw());
176 } 176 }
177 177
178 void AccessibilityListBoxOption::setSelected(bool selected) 178 void AccessibilityListBoxOption::setSelected(bool selected)
179 { 179 {
180 HTMLSelectElement* selectElement = listBoxOptionParentNode(); 180 Handle<HTMLSelectElement> selectElement = listBoxOptionParentNode();
181 if (!selectElement) 181 if (!selectElement)
182 return; 182 return;
183 183
184 if (!canSetSelectedAttribute()) 184 if (!canSetSelectedAttribute())
185 return; 185 return;
186 186
187 bool isOptionSelected = isSelected(); 187 bool isOptionSelected = isSelected();
188 if ((isOptionSelected && selected) || (!isOptionSelected && !selected)) 188 if ((isOptionSelected && selected) || (!isOptionSelected && !selected))
189 return; 189 return;
190 190
191 // Convert from the entire list index to the option index. 191 // Convert from the entire list index to the option index.
192 int optionIndex = selectElement->listToOptionIndex(listBoxOptionIndex()); 192 int optionIndex = selectElement->listToOptionIndex(listBoxOptionIndex());
193 selectElement->accessKeySetSelectedIndex(optionIndex); 193 selectElement->accessKeySetSelectedIndex(optionIndex);
194 } 194 }
195 195
196 HTMLSelectElement* AccessibilityListBoxOption::listBoxOptionParentNode() const 196 Result<HTMLSelectElement> AccessibilityListBoxOption::listBoxOptionParentNode() const
197 { 197 {
198 if (!m_optionElement) 198 if (!m_optionElement)
199 return 0; 199 return nullptr;
200 200
201 if (m_optionElement->hasTagName(optionTag)) 201 if (m_optionElement->hasTagName(optionTag))
202 return static_cast<HTMLOptionElement*>(m_optionElement)->ownerSelectElem ent(); 202 return static_cast<HTMLOptionElement*>(m_optionElement)->ownerSelectElem ent();
203 203
204 if (m_optionElement->hasTagName(optgroupTag)) 204 if (m_optionElement->hasTagName(optgroupTag))
205 return static_cast<HTMLOptGroupElement*>(m_optionElement)->ownerSelectEl ement(); 205 return static_cast<HTMLOptGroupElement*>(m_optionElement)->ownerSelectEl ement();
206 206
207 return 0; 207 return nullptr;
208 } 208 }
209 209
210 int AccessibilityListBoxOption::listBoxOptionIndex() const 210 int AccessibilityListBoxOption::listBoxOptionIndex() const
211 { 211 {
212 if (!m_optionElement) 212 if (!m_optionElement)
213 return -1; 213 return -1;
214 214
215 HTMLSelectElement* selectElement = listBoxOptionParentNode(); 215 Handle<HTMLSelectElement> selectElement = listBoxOptionParentNode();
216 if (!selectElement) 216 if (!selectElement)
217 return -1; 217 return -1;
218 218
219 const Vector<HTMLElement*>& listItems = selectElement->listItems(); 219 const Vector<HTMLElement*>& listItems = selectElement->listItems();
220 unsigned length = listItems.size(); 220 unsigned length = listItems.size();
221 for (unsigned i = 0; i < length; i++) 221 for (unsigned i = 0; i < length; i++)
222 if (listItems[i] == m_optionElement) 222 if (listItems[i] == m_optionElement)
223 return i; 223 return i;
224 224
225 return -1; 225 return -1;
226 } 226 }
227 227
228 } // namespace WebCore 228 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/accessibility/AccessibilityListBoxOption.h ('k') | Source/core/accessibility/AccessibilityNodeObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698