OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, Google 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 24 matching lines...) Expand all Loading... |
35 #include "core/html/HTMLDListElement.h" | 35 #include "core/html/HTMLDListElement.h" |
36 #include "core/html/HTMLFieldSetElement.h" | 36 #include "core/html/HTMLFieldSetElement.h" |
37 #include "core/html/HTMLFrameElementBase.h" | 37 #include "core/html/HTMLFrameElementBase.h" |
38 #include "core/html/HTMLInputElement.h" | 38 #include "core/html/HTMLInputElement.h" |
39 #include "core/html/HTMLLabelElement.h" | 39 #include "core/html/HTMLLabelElement.h" |
40 #include "core/html/HTMLLegendElement.h" | 40 #include "core/html/HTMLLegendElement.h" |
41 #include "core/html/HTMLMediaElement.h" | 41 #include "core/html/HTMLMediaElement.h" |
42 #include "core/html/HTMLMeterElement.h" | 42 #include "core/html/HTMLMeterElement.h" |
43 #include "core/html/HTMLPlugInElement.h" | 43 #include "core/html/HTMLPlugInElement.h" |
44 #include "core/html/HTMLSelectElement.h" | 44 #include "core/html/HTMLSelectElement.h" |
| 45 #include "core/html/HTMLTableCellElement.h" |
| 46 #include "core/html/HTMLTableElement.h" |
| 47 #include "core/html/HTMLTableRowElement.h" |
| 48 #include "core/html/HTMLTableSectionElement.h" |
45 #include "core/html/HTMLTextAreaElement.h" | 49 #include "core/html/HTMLTextAreaElement.h" |
46 #include "core/html/parser/HTMLParserIdioms.h" | 50 #include "core/html/parser/HTMLParserIdioms.h" |
47 #include "core/html/shadow/MediaControlElements.h" | 51 #include "core/html/shadow/MediaControlElements.h" |
48 #include "core/layout/LayoutObject.h" | 52 #include "core/layout/LayoutObject.h" |
49 #include "modules/accessibility/AXObjectCacheImpl.h" | 53 #include "modules/accessibility/AXObjectCacheImpl.h" |
50 #include "platform/UserGestureIndicator.h" | 54 #include "platform/UserGestureIndicator.h" |
51 #include "wtf/text/StringBuilder.h" | 55 #include "wtf/text/StringBuilder.h" |
52 | 56 |
53 | 57 |
54 namespace blink { | 58 namespace blink { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return true; | 180 return true; |
177 | 181 |
178 // Ignore labels that are already referenced by a control's title UI element
. | 182 // Ignore labels that are already referenced by a control's title UI element
. |
179 AXObject* controlObject = correspondingControlForLabelElement(); | 183 AXObject* controlObject = correspondingControlForLabelElement(); |
180 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec
t->isCheckboxOrRadio()) | 184 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec
t->isCheckboxOrRadio()) |
181 return true; | 185 return true; |
182 | 186 |
183 return m_role == UnknownRole; | 187 return m_role == UnknownRole; |
184 } | 188 } |
185 | 189 |
| 190 static bool isListElement(Node* node) |
| 191 { |
| 192 return isHTMLUListElement(*node) || isHTMLOListElement(*node) || isHTMLDList
Element(*node); |
| 193 } |
| 194 |
| 195 static bool isPresentationRoleInTable(AXObject* parent, Node* child) |
| 196 { |
| 197 Node* parentNode = parent->node(); |
| 198 if (!parentNode || !parentNode->isElementNode()) |
| 199 return false; |
| 200 |
| 201 // AXTable determines the role as checking isTableXXX. |
| 202 // If Table has explicit role including presentation, AXTable doesn't assign
implicit Role |
| 203 // to a whole Table. That's why we should check it based on node. |
| 204 // Normal Table Tree is that |
| 205 // cell(its role)-> tr(tr role)-> tfoot, tbody, thead(ignored role) -> table
(table role). |
| 206 // If table has presentation role, it will be like |
| 207 // cell(group)-> tr(unknown) -> tfoot, tbody, thead(ignored) -> table(presen
tation). |
| 208 if (isHTMLTableCellElement(child) && isHTMLTableRowElement(*parentNode)) |
| 209 return parent->hasInheritedPresentationalRole(); |
| 210 |
| 211 if (isHTMLTableRowElement(child) && isHTMLTableSectionElement(*parentNode))
{ |
| 212 // Because TableSections have ignored role, presentation should be check
ed with its parent node |
| 213 AXObject* tableObject = parent->parentObject(); |
| 214 Node* tableNode = tableObject->node(); |
| 215 return isHTMLTableElement(tableNode) && tableObject->hasInheritedPresent
ationalRole(); |
| 216 } |
| 217 return false; |
| 218 } |
| 219 |
| 220 static bool isRequiredOwnedElement(AXObject* parent, AccessibilityRole childRole
, Node* childNode) |
| 221 { |
| 222 Node* parentNode = parent->node(); |
| 223 if (!parentNode || !parentNode->isElementNode()) |
| 224 return false; |
| 225 |
| 226 if (childRole == ListItemRole) |
| 227 return isListElement(parentNode); |
| 228 if (childRole == ListMarkerRole) |
| 229 return isHTMLLIElement(*parentNode); |
| 230 if (childRole == MenuItemCheckBoxRole || childRole == MenuItemRole || child
Role == MenuItemRadioRole) |
| 231 return isHTMLMenuElement(*parentNode); |
| 232 |
| 233 if (isHTMLTableCellElement(childNode)) |
| 234 return isHTMLTableRowElement(*parentNode); |
| 235 if (isHTMLTableRowElement(childNode)) |
| 236 return isHTMLTableSectionElement(*parentNode); |
| 237 |
| 238 // In case of ListboxRole and it's child, ListBoxOptionRole, |
| 239 // Inheritance of presentation role is handled in AXListBoxOption |
| 240 // Because ListBoxOption Role doesn't have any child. |
| 241 // If it's just ignored because of presentation, we can't see any AX tree re
lated to ListBoxOption. |
| 242 return false; |
| 243 } |
| 244 |
| 245 bool AXNodeObject::computeHasInheritedPresentationalRole() const |
| 246 { |
| 247 // ARIA states if an item can get focus, it should not be presentational. |
| 248 if (canSetFocusAttribute()) |
| 249 return false; |
| 250 |
| 251 if (isPresentational()) |
| 252 return true; |
| 253 |
| 254 // http://www.w3.org/TR/wai-aria/complete#presentation |
| 255 // ARIA spec says that the user agent MUST apply an inherited role of presen
tation |
| 256 // to any owned elements that do not have an explicit role defined. |
| 257 if (ariaRoleAttribute() != UnknownRole) |
| 258 return false; |
| 259 |
| 260 AXObject* parent = parentObject(); |
| 261 if (!parent) |
| 262 return false; |
| 263 |
| 264 Node* curNode = node(); |
| 265 if (!parent->hasInheritedPresentationalRole() |
| 266 && !isPresentationRoleInTable(parent, curNode)) |
| 267 return false; |
| 268 |
| 269 // ARIA spec says that when a parent object is presentational and this objec
t |
| 270 // is a required owned element of that parent, then this object is also pres
entational. |
| 271 return isRequiredOwnedElement(parent, roleValue(), curNode); |
| 272 } |
| 273 |
186 AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil() | 274 AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil() |
187 { | 275 { |
188 if (!node()) | 276 if (!node()) |
189 return UnknownRole; | 277 return UnknownRole; |
190 if (node()->isLink()) | 278 if (node()->isLink()) |
191 return LinkRole; | 279 return LinkRole; |
192 if (isHTMLButtonElement(*node())) | 280 if (isHTMLButtonElement(*node())) |
193 return buttonRoleType(); | 281 return buttonRoleType(); |
194 if (isHTMLDetailsElement(*node())) | 282 if (isHTMLDetailsElement(*node())) |
195 return DetailsRole; | 283 return DetailsRole; |
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 float range = maxValueForRange() - minValueForRange(); | 2085 float range = maxValueForRange() - minValueForRange(); |
1998 float value = valueForRange(); | 2086 float value = valueForRange(); |
1999 | 2087 |
2000 value += range * (percentChange / 100); | 2088 value += range * (percentChange / 100); |
2001 setValue(String::number(value)); | 2089 setValue(String::number(value)); |
2002 | 2090 |
2003 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged)
; | 2091 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged)
; |
2004 } | 2092 } |
2005 | 2093 |
2006 } // namespace blink | 2094 } // namespace blink |
OLD | NEW |