Changeset 131871 in webkit
- Timestamp:
- Oct 19, 2012 1:01:06 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r131864 r131871 1 2012-10-18 Dominic Mazzoni <dmazzoni@google.com> 2 3 AX: labelForElement is slow when there are a lot of DOM elements 4 https://bugs.webkit.org/show_bug.cgi?id=97825 5 6 Reviewed by Ryosuke Niwa. 7 8 Adds two new tests for titleUIElement that run on both Mac and 9 Chromium. One tests correctness, the other tests speed. 10 11 Fixes one test so that it passes on Chromium. 12 Enables other tests that now pass on Chromium. 13 14 * accessibility/secure-textfield-title-ui.html: 15 * accessibility/title-ui-element-correctness-expected.txt: Added. 16 * accessibility/title-ui-element-correctness.html: Added. 17 * perf/accessibility-title-ui-element-expected.txt: Added. 18 * perf/accessibility-title-ui-element.html: Added. 19 * platform/chromium/TestExpectations: 20 1 21 2012-10-18 Alexander Pavlov <apavlov@chromium.org> 2 22 -
trunk/LayoutTests/accessibility/secure-textfield-title-ui.html
r131124 r131871 22 22 var titleUIElement = accessibilityController.focusedElement.titleUIElement(); 23 23 var titleText = titleUIElement.childAtIndex(0); 24 var pattern = "AXValue: Password"; 25 if (titleText.allAttributes().indexOf(pattern) != -1) { 24 if (titleText.stringValue == "AXValue: Password") { 26 25 result.innerText += "Test passed\n"; 27 26 } -
trunk/LayoutTests/platform/chromium/TestExpectations
r131852 r131871 1403 1403 crbug.com/10322 accessibility/lists.html [ Skip ] 1404 1404 crbug.com/10322 accessibility/media-element.html [ Skip ] 1405 crbug.com/10322 accessibility/non-data-table-cell-title-ui-element.html [ Skip ]1406 1405 crbug.com/10322 accessibility/onclick-handlers.html [ Skip ] 1407 1406 crbug.com/10322 accessibility/placeholder.html [ Skip ] … … 1409 1408 crbug.com/10322 accessibility/radio-button-checkbox-size.html [ Skip ] 1410 1409 crbug.com/10322 accessibility/radio-button-group-members.html [ Skip ] 1411 crbug.com/10322 accessibility/radio-button-title-label.html [ Skip ]1412 crbug.com/10322 accessibility/secure-textfield-title-ui.html [ Skip ]1413 1410 crbug.com/10322 accessibility/table-attributes.html [ Skip ] 1414 1411 crbug.com/10322 accessibility/table-cell-spans.html [ Skip ] … … 1419 1416 crbug.com/10322 accessibility/table-with-aria-role.html [ Skip ] 1420 1417 crbug.com/10322 accessibility/table-with-rules.html [ Skip ] 1421 crbug.com/10322 accessibility/th-as-title-ui.html [ Skip ]1422 1418 crbug.com/10322 accessibility/transformed-element.html [ Skip ] 1423 1419 crbug.com/10322 accessibility/visible-elements.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r131870 r131871 1 2012-10-18 Dominic Mazzoni <dmazzoni@google.com> 2 3 AX: labelForElement is slow when there are a lot of DOM elements 4 https://bugs.webkit.org/show_bug.cgi?id=97825 5 6 Reviewed by Ryosuke Niwa. 7 8 Adds a DocumentOrderedMap to TreeScope that allows accessibility to 9 quickly map from an id to the label for that id. This speeds up 10 AccessibilityNode::labelForElement, which was a bottleneck in Chromium 11 when accessibility was on. 12 13 Tests: accessibility/title-ui-element-correctness.html 14 perf/accessibility-title-ui-element.html 15 16 * accessibility/AccessibilityNodeObject.cpp: 17 (WebCore::AccessibilityNodeObject::labelForElement): 18 * dom/DocumentOrderedMap.cpp: 19 (WebCore::keyMatchesLabelForAttribute): 20 (WebCore): 21 (WebCore::DocumentOrderedMap::get): 22 (WebCore::DocumentOrderedMap::getElementByLabelForAttribute): 23 * dom/DocumentOrderedMap.h: 24 (DocumentOrderedMap): 25 * dom/Element.cpp: 26 (WebCore::Element::insertedInto): 27 (WebCore::Element::removedFrom): 28 (WebCore::Element::updateLabel): 29 (WebCore): 30 (WebCore::Element::willModifyAttribute): 31 * dom/Element.h: 32 (Element): 33 * dom/TreeScope.cpp: 34 (WebCore::TreeScope::TreeScope): 35 (WebCore::TreeScope::destroyTreeScopeData): 36 (WebCore::TreeScope::addLabel): 37 (WebCore): 38 (WebCore::TreeScope::removeLabel): 39 (WebCore::TreeScope::labelElementForId): 40 * dom/TreeScope.h: 41 (WebCore): 42 (TreeScope): 43 (WebCore::TreeScope::shouldCacheLabelsByForAttribute): 44 1 45 2012-10-19 Eugene Klyuchnikov <eustas.bug@gmail.com> 2 46 -
trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp
r131124 r131871 60 60 #include "HitTestRequest.h" 61 61 #include "HitTestResult.h" 62 #include "LabelableElement.h" 62 63 #include "LocalizedStrings.h" 63 64 #include "MathMLNames.h" … … 1002 1003 HTMLLabelElement* AccessibilityNodeObject::labelForElement(Element* element) const 1003 1004 { 1004 RefPtr<NodeList> list = element->document()->getElementsByTagName("label"); 1005 unsigned len = list->length(); 1006 for (unsigned i = 0; i < len; i++) { 1007 if (list->item(i)->hasTagName(labelTag)) { 1008 HTMLLabelElement* label = static_cast<HTMLLabelElement*>(list->item(i)); 1009 if (label->control() == element) 1010 return label; 1011 } 1005 if (!element->isHTMLElement() || !toHTMLElement(element)->isLabelable()) 1006 return 0; 1007 1008 const AtomicString& id = element->getIdAttribute(); 1009 if (!id.isEmpty()) { 1010 if (HTMLLabelElement* label = element->treeScope()->labelElementForId(id)) 1011 return label; 1012 } 1013 1014 for (Element* parent = element->parentElement(); parent; parent = parent->parentElement()) { 1015 if (parent->hasTagName(labelTag)) 1016 return static_cast<HTMLLabelElement*>(parent); 1012 1017 } 1013 1018 -
trunk/Source/WebCore/dom/DocumentOrderedMap.cpp
r131124 r131871 54 54 { 55 55 return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().lower().impl() == key; 56 } 57 58 inline bool keyMatchesLabelForAttribute(AtomicStringImpl* key, Element* element) 59 { 60 return element->hasTagName(labelTag) && element->getAttribute(forAttr).impl() == key; 56 61 } 57 62 … … 150 155 } 151 156 157 Element* DocumentOrderedMap::getElementByLabelForAttribute(AtomicStringImpl* key, const TreeScope* scope) const 158 { 159 return get<keyMatchesLabelForAttribute>(key, scope); 160 } 161 152 162 } // namespace WebCore 153 -
trunk/Source/WebCore/dom/DocumentOrderedMap.h
r131124 r131871 53 53 Element* getElementByMapName(AtomicStringImpl*, const TreeScope*) const; 54 54 Element* getElementByLowercasedMapName(AtomicStringImpl*, const TreeScope*) const; 55 Element* getElementByLabelForAttribute(AtomicStringImpl*, const TreeScope*) const; 55 56 56 57 void checkConsistency() const; … … 81 82 82 83 #endif // DocumentOrderedMap_h 83 -
trunk/Source/WebCore/dom/Element.cpp
r131739 r131871 49 49 #include "HTMLFormCollection.h" 50 50 #include "HTMLFrameOwnerElement.h" 51 #include "HTMLLabelElement.h" 51 52 #include "HTMLNames.h" 52 53 #include "HTMLOptionsCollection.h" … … 960 961 updateName(nullAtom, nameValue); 961 962 963 if (hasTagName(labelTag)) { 964 TreeScope* scope = treeScope(); 965 if (scope->shouldCacheLabelsByForAttribute()) 966 updateLabel(scope, nullAtom, fastGetAttribute(forAttr)); 967 } 968 962 969 return InsertionDone; 963 970 } … … 984 991 if (!nameValue.isNull()) 985 992 updateName(nameValue, nullAtom); 993 994 if (hasTagName(labelTag)) { 995 TreeScope* treeScope = insertionPoint->treeScope(); 996 if (treeScope->shouldCacheLabelsByForAttribute()) 997 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); 998 } 986 999 } 987 1000 … … 2126 2139 #endif 2127 2140 2141 void Element::updateLabel(TreeScope* scope, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue) 2142 { 2143 ASSERT(hasTagName(labelTag)); 2144 2145 if (!inDocument()) 2146 return; 2147 2148 if (oldForAttributeValue == newForAttributeValue) 2149 return; 2150 2151 if (!oldForAttributeValue.isEmpty()) 2152 scope->removeLabel(oldForAttributeValue, static_cast<HTMLLabelElement*>(this)); 2153 if (!newForAttributeValue.isEmpty()) 2154 scope->addLabel(newForAttributeValue, static_cast<HTMLLabelElement*>(this)); 2155 } 2156 2128 2157 void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue) 2129 2158 { … … 2132 2161 else if (name == HTMLNames::nameAttr) 2133 2162 updateName(oldValue, newValue); 2163 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { 2164 TreeScope* scope = treeScope(); 2165 if (scope->shouldCacheLabelsByForAttribute()) 2166 updateLabel(scope, oldValue, newValue); 2167 } 2134 2168 2135 2169 #if ENABLE(MUTATION_OBSERVERS) -
trunk/Source/WebCore/dom/Element.h
r131124 r131871 316 316 void updateId(TreeScope*, const AtomicString& oldId, const AtomicString& newId); 317 317 void updateName(const AtomicString& oldName, const AtomicString& newName); 318 void updateLabel(TreeScope*, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue); 318 319 319 320 void removeCachedHTMLCollection(HTMLCollection*, CollectionType); -
trunk/Source/WebCore/dom/TreeScope.cpp
r131549 r131871 37 37 #include "HTMLAnchorElement.h" 38 38 #include "HTMLFrameOwnerElement.h" 39 #include "HTMLLabelElement.h" 39 40 #include "HTMLMapElement.h" 40 41 #include "HTMLNames.h" … … 56 57 : m_rootNode(rootNode) 57 58 , m_parentTreeScope(0) 59 , m_shouldCacheLabelsByForAttribute(false) 58 60 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) 59 61 { … … 73 75 m_elementsById.clear(); 74 76 m_imageMapsByName.clear(); 77 m_labelsByForAttribute.clear(); 75 78 } 76 79 … … 143 146 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this)); 144 147 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this)); 148 } 149 150 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement* element) 151 { 152 m_labelsByForAttribute.add(forAttributeValue.impl(), element); 153 } 154 155 void TreeScope::removeLabel(const AtomicString& forAttributeValue, HTMLLabelElement* element) 156 { 157 m_labelsByForAttribute.remove(forAttributeValue.impl(), element); 158 } 159 160 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeValue) 161 { 162 if (!m_shouldCacheLabelsByForAttribute) { 163 m_shouldCacheLabelsByForAttribute = true; 164 for (Node* node = rootNode(); node; node = node->traverseNextNode()) { 165 if (node->hasTagName(labelTag)) { 166 HTMLLabelElement* label = static_cast<HTMLLabelElement*>(node); 167 const AtomicString& forValue = label->fastGetAttribute(forAttr); 168 if (!forValue.isEmpty()) 169 addLabel(forValue, label); 170 } 171 } 172 } 173 174 if (forAttributeValue.isEmpty()) 175 return 0; 176 177 return static_cast<HTMLLabelElement*>(m_labelsByForAttribute.getElementByLabelForAttribute(forAttributeValue.impl(), this)); 145 178 } 146 179 -
trunk/Source/WebCore/dom/TreeScope.h
r131124 r131871 36 36 class DOMSelection; 37 37 class Element; 38 class HTMLLabelElement; 38 39 class HTMLMapElement; 39 40 class IdTargetObserverRegistry; … … 62 63 void removeImageMap(HTMLMapElement*); 63 64 HTMLMapElement* getImageMap(const String& url) const; 65 66 // For accessibility. 67 bool shouldCacheLabelsByForAttribute() const { return m_shouldCacheLabelsByForAttribute; } 68 void addLabel(const AtomicString& forAttributeValue, HTMLLabelElement*); 69 void removeLabel(const AtomicString& forAttributeValue, HTMLLabelElement*); 70 HTMLLabelElement* labelElementForId(const AtomicString& forAttributeValue); 64 71 65 72 DOMSelection* getSelection() const; … … 95 102 DocumentOrderedMap m_imageMapsByName; 96 103 104 DocumentOrderedMap m_labelsByForAttribute; 105 bool m_shouldCacheLabelsByForAttribute; 106 97 107 OwnPtr<IdTargetObserverRegistry> m_idTargetObserverRegistry; 98 108 -
trunk/Tools/ChangeLog
r131869 r131871 1 2012-10-18 Dominic Mazzoni <dmazzoni@google.com> 2 3 AX: labelForElement is slow when there are a lot of DOM elements 4 https://bugs.webkit.org/show_bug.cgi?id=97825 5 6 Reviewed by Ryosuke Niwa. 7 8 Implement titleUIElement in the chromium port of DRT, and 9 fix getAccessibleElementById so that it ensures the backing store 10 is up-to-date. 11 12 * DumpRenderTree/chromium/TestRunner/AccessibilityControllerChromium.cpp: 13 (AccessibilityController::getAccessibleElementById): 14 * DumpRenderTree/chromium/TestRunner/AccessibilityUIElementChromium.cpp: 15 (AccessibilityUIElement::titleUIElementCallback): 16 1 17 2012-10-17 Ilya Tikhonovsky <loislo@chromium.org> 2 18 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityControllerChromium.cpp
r131828 r131871 118 118 m_rootElement = m_webView->accessibilityObject(); 119 119 120 if (!m_rootElement.updateBackingStoreAndCheckValidity()) 121 return 0; 122 120 123 return findAccessibleElementByIdRecursive(m_rootElement, WebString::fromUTF8(id.c_str())); 121 124 } -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/AccessibilityUIElementChromium.cpp
r131828 r131871 775 775 void AccessibilityUIElement::titleUIElementCallback(const CppArgumentList&, CppVariant* result) 776 776 { 777 result->setNull(); 777 WebAccessibilityObject obj = accessibilityObject().titleUIElement(); 778 if (obj.isNull()) { 779 result->setNull(); 780 return; 781 } 782 783 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant())); 778 784 } 779 785
Note: See TracChangeset
for help on using the changeset viewer.