| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014, Google Inc. All rights reserved. | 2 * Copyright (C) 2014, 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (!child->isImageMapLink()) | 142 if (!child->isImageMapLink()) |
| 143 continue; | 143 continue; |
| 144 | 144 |
| 145 if (toAXImageMapLink(child)->areaElement() == areaElement) | 145 if (toAXImageMapLink(child)->areaElement() == areaElement) |
| 146 return child; | 146 return child; |
| 147 } | 147 } |
| 148 | 148 |
| 149 return 0; | 149 return 0; |
| 150 } | 150 } |
| 151 | 151 |
| 152 AXObject* AXObjectCacheImpl::focusedUIElementForPage(const Page* page) | 152 AXObject* AXObjectCacheImpl::focusedObject() |
| 153 { | 153 { |
| 154 if (!page->settings().accessibilityEnabled()) | 154 if (!accessibilityEnabled()) |
| 155 return 0; | 155 return 0; |
| 156 | 156 |
| 157 // Cross-process accessibility is not yet implemented. | 157 // We don't have to return anything if the focused frame is not local; |
| 158 if (!page->focusController().focusedOrMainFrame()->isLocalFrame()) | 158 // the remote frame will have its own AXObjectCacheImpl and the focused |
| 159 // object will be sorted out by the browser process. |
| 160 Page* page = m_document->page(); |
| 161 if (!page->focusController().focusedFrame()) |
| 159 return 0; | 162 return 0; |
| 160 | 163 |
| 161 // get the focused node in the page | 164 // Get the focused node in the page. |
| 162 Document* focusedDocument = toLocalFrame(page->focusController().focusedOrMa
inFrame())->document(); | 165 Document* focusedDocument = page->focusController().focusedFrame()->document
(); |
| 163 Node* focusedNode = focusedDocument->focusedElement(); | 166 Node* focusedNode = focusedDocument->focusedElement(); |
| 164 if (!focusedNode) | 167 if (!focusedNode) |
| 165 focusedNode = focusedDocument; | 168 focusedNode = focusedDocument; |
| 166 | 169 |
| 167 if (isHTMLAreaElement(*focusedNode)) | 170 // If it's an image map, get the focused link within the image map. |
| 171 if (isHTMLAreaElement(focusedNode)) |
| 168 return focusedImageMapUIElement(toHTMLAreaElement(focusedNode)); | 172 return focusedImageMapUIElement(toHTMLAreaElement(focusedNode)); |
| 169 | 173 |
| 174 // See if there's a page popup, for example a calendar picker. |
| 175 Element* adjustedFocusedElement = focusedDocument->adjustedFocusedElement(); |
| 176 if (isHTMLInputElement(adjustedFocusedElement)) { |
| 177 if (AXObject* axPopup = toHTMLInputElement(adjustedFocusedElement)->popu
pRootAXObject()) { |
| 178 if (Element* focusedElementInPopup = axPopup->document()->focusedEle
ment()) |
| 179 focusedNode = focusedElementInPopup; |
| 180 } |
| 181 |
| 182 } |
| 183 |
| 170 AXObject* obj = getOrCreate(focusedNode); | 184 AXObject* obj = getOrCreate(focusedNode); |
| 171 if (!obj) | 185 if (!obj) |
| 172 return 0; | 186 return 0; |
| 173 | 187 |
| 174 if (obj->shouldFocusActiveDescendant()) { | 188 if (obj->shouldFocusActiveDescendant()) { |
| 175 if (AXObject* descendant = obj->activeDescendant()) | 189 if (AXObject* descendant = obj->activeDescendant()) |
| 176 obj = descendant; | 190 obj = descendant; |
| 177 } | 191 } |
| 178 | 192 |
| 179 // the HTML element, for example, is focusable but has an AX object that is
ignored | 193 // the HTML element, for example, is focusable but has an AX object that is
ignored |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 | 1127 |
| 1114 void AXObjectCacheImpl::handleFocusedUIElementChanged(Node* oldFocusedNode, Node
* newFocusedNode) | 1128 void AXObjectCacheImpl::handleFocusedUIElementChanged(Node* oldFocusedNode, Node
* newFocusedNode) |
| 1115 { | 1129 { |
| 1116 if (!newFocusedNode) | 1130 if (!newFocusedNode) |
| 1117 return; | 1131 return; |
| 1118 | 1132 |
| 1119 Page* page = newFocusedNode->document().page(); | 1133 Page* page = newFocusedNode->document().page(); |
| 1120 if (!page) | 1134 if (!page) |
| 1121 return; | 1135 return; |
| 1122 | 1136 |
| 1123 AXObject* focusedObject = focusedUIElementForPage(page); | 1137 AXObject* focusedObject = this->focusedObject(); |
| 1124 if (!focusedObject) | 1138 if (!focusedObject) |
| 1125 return; | 1139 return; |
| 1126 | 1140 |
| 1127 AXObject* oldFocusedObject = get(oldFocusedNode); | 1141 AXObject* oldFocusedObject = get(oldFocusedNode); |
| 1128 | 1142 |
| 1129 postPlatformNotification(oldFocusedObject, AXBlur); | 1143 postPlatformNotification(oldFocusedObject, AXBlur); |
| 1130 postPlatformNotification(focusedObject, AXFocusedUIElementChanged); | 1144 postPlatformNotification(focusedObject, AXFocusedUIElementChanged); |
| 1131 } | 1145 } |
| 1132 | 1146 |
| 1133 void AXObjectCacheImpl::handleInitialFocus() | 1147 void AXObjectCacheImpl::handleInitialFocus() |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 visitor->trace(m_nodeObjectMapping); | 1262 visitor->trace(m_nodeObjectMapping); |
| 1249 #endif | 1263 #endif |
| 1250 | 1264 |
| 1251 visitor->trace(m_objects); | 1265 visitor->trace(m_objects); |
| 1252 visitor->trace(m_notificationsToPost); | 1266 visitor->trace(m_notificationsToPost); |
| 1253 | 1267 |
| 1254 AXObjectCache::trace(visitor); | 1268 AXObjectCache::trace(visitor); |
| 1255 } | 1269 } |
| 1256 | 1270 |
| 1257 } // namespace blink | 1271 } // namespace blink |
| OLD | NEW |