Skip to content

Commit 4014560

Browse files
AX: Clean up AccessibilityRenderObject
https://bugs.webkit.org/show_bug.cgi?id=127838 Reviewed by Chris Fleizach. Reducing some code by implementing ariaElementsFromAttribute. It is used as a helper for other methods. No new tests. Covered by existing ones. * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::ariaElementsFromAttribute): (WebCore::AccessibilityRenderObject::ariaFlowToElements): (WebCore::AccessibilityRenderObject::ariaDescribedByElements): (WebCore::AccessibilityRenderObject::ariaOwnsElements): * accessibility/AccessibilityRenderObject.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@163078 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent c79bcfe commit 4014560

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

Source/WebCore/ChangeLog

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2014-01-30 Krzysztof Czech <[email protected]>
2+
3+
AX: Clean up AccessibilityRenderObject
4+
https://bugs.webkit.org/show_bug.cgi?id=127838
5+
6+
Reviewed by Chris Fleizach.
7+
8+
Reducing some code by implementing ariaElementsFromAttribute.
9+
It is used as a helper for other methods.
10+
11+
No new tests. Covered by existing ones.
12+
13+
* accessibility/AccessibilityRenderObject.cpp:
14+
(WebCore::AccessibilityRenderObject::ariaElementsFromAttribute):
15+
(WebCore::AccessibilityRenderObject::ariaFlowToElements):
16+
(WebCore::AccessibilityRenderObject::ariaDescribedByElements):
17+
(WebCore::AccessibilityRenderObject::ariaOwnsElements):
18+
* accessibility/AccessibilityRenderObject.h:
19+
120
2014-01-29 Commit Queue <[email protected]>
221

322
Unreviewed, rolling out r163048.

Source/WebCore/accessibility/AccessibilityRenderObject.cpp

+14-27
Original file line numberDiff line numberDiff line change
@@ -1010,23 +1010,25 @@ bool AccessibilityRenderObject::ariaHasPopup() const
10101010
return elementAttributeValue(aria_haspopupAttr);
10111011
}
10121012

1013+
void AccessibilityRenderObject::ariaElementsFromAttribute(AccessibilityChildrenVector& children, const QualifiedName& attributeName) const
1014+
{
1015+
Vector<Element*> elements;
1016+
elementsFromAttribute(elements, attributeName);
1017+
AXObjectCache* cache = axObjectCache();
1018+
for (const auto& element : elements) {
1019+
if (AccessibilityObject* axObject = cache->getOrCreate(element))
1020+
children.append(axObject);
1021+
}
1022+
}
1023+
10131024
bool AccessibilityRenderObject::supportsARIAFlowTo() const
10141025
{
10151026
return !getAttribute(aria_flowtoAttr).isEmpty();
10161027
}
10171028

10181029
void AccessibilityRenderObject::ariaFlowToElements(AccessibilityChildrenVector& flowTo) const
10191030
{
1020-
Vector<Element*> elements;
1021-
elementsFromAttribute(elements, aria_flowtoAttr);
1022-
1023-
AXObjectCache* cache = axObjectCache();
1024-
for (const auto& element : elements) {
1025-
AccessibilityObject* flowToElement = cache->getOrCreate(element);
1026-
if (flowToElement)
1027-
flowTo.append(flowToElement);
1028-
}
1029-
1031+
ariaElementsFromAttribute(flowTo, aria_flowtoAttr);
10301032
}
10311033

10321034
bool AccessibilityRenderObject::supportsARIADescribedBy() const
@@ -1036,14 +1038,7 @@ bool AccessibilityRenderObject::supportsARIADescribedBy() const
10361038

10371039
void AccessibilityRenderObject::ariaDescribedByElements(AccessibilityChildrenVector& ariaDescribedBy) const
10381040
{
1039-
Vector<Element*> elements;
1040-
elementsFromAttribute(elements, aria_describedbyAttr);
1041-
1042-
AXObjectCache* cache = axObjectCache();
1043-
for (const auto& element : elements) {
1044-
if (AccessibilityObject* describedByElement = cache->getOrCreate(element))
1045-
ariaDescribedBy.append(describedByElement);
1046-
}
1041+
ariaElementsFromAttribute(ariaDescribedBy, aria_describedbyAttr);
10471042
}
10481043

10491044
bool AccessibilityRenderObject::supportsARIADropping() const
@@ -1687,15 +1682,7 @@ void AccessibilityRenderObject::setValue(const String& string)
16871682

16881683
void AccessibilityRenderObject::ariaOwnsElements(AccessibilityChildrenVector& axObjects) const
16891684
{
1690-
Vector<Element*> elements;
1691-
elementsFromAttribute(elements, aria_ownsAttr);
1692-
1693-
for (const auto& element : elements) {
1694-
RenderObject* render = element->renderer();
1695-
AccessibilityObject* obj = axObjectCache()->getOrCreate(render);
1696-
if (obj)
1697-
axObjects.append(obj);
1698-
}
1685+
ariaElementsFromAttribute(axObjects, aria_ownsAttr);
16991686
}
17001687

17011688
bool AccessibilityRenderObject::supportsARIAOwns() const

Source/WebCore/accessibility/AccessibilityRenderObject.h

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ class AccessibilityRenderObject : public AccessibilityNodeObject {
225225
virtual bool computeAccessibilityIsIgnored() const override;
226226

227227
private:
228+
void ariaElementsFromAttribute(AccessibilityChildrenVector&, const QualifiedName&) const;
228229
void ariaListboxSelectedChildren(AccessibilityChildrenVector&);
229230
void ariaListboxVisibleChildren(AccessibilityChildrenVector&);
230231
bool isAllowedChildOfTree() const;

0 commit comments

Comments
 (0)