AX: Modernize AccessibilityChildrenVector loops
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 18:09:51 +0000 (18:09 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 18:09:51 +0000 (18:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126915

Reviewed by Anders Carlsson.

Change appropriate for loops to use the new style.
Use auto where appropriate.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::focusedImageMapUIElement):
* accessibility/AccessibilityARIAGrid.cpp:
(WebCore::AccessibilityARIAGrid::addRowDescendant):
* accessibility/AccessibilityARIAGridCell.cpp:
(WebCore::AccessibilityARIAGridCell::rowIndexRange):
* accessibility/AccessibilityARIAGridRow.cpp:
(WebCore::AccessibilityARIAGridRow::disclosedRows):
(WebCore::AccessibilityARIAGridRow::disclosedByRow):
(WebCore::AccessibilityARIAGridRow::parentTable):
(WebCore::AccessibilityARIAGridRow::headerObject):
* accessibility/AccessibilityListBox.cpp:
(WebCore::AccessibilityListBox::addChildren):
(WebCore::AccessibilityListBox::setSelectedChildren):
(WebCore::AccessibilityListBox::selectedChildren):
* accessibility/AccessibilityListBoxOption.cpp:
(WebCore::AccessibilityListBoxOption::listBoxOptionIndex):
* accessibility/AccessibilityMenuList.cpp:
(WebCore::AccessibilityMenuList::didUpdateActiveOption):
* accessibility/AccessibilityMenuListPopup.cpp:
(WebCore::AccessibilityMenuListPopup::addChildren):
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::insertChild):
(WebCore::AccessibilityNodeObject::selectedRadioButton):
(WebCore::AccessibilityNodeObject::selectedTabItem):
(WebCore::AccessibilityNodeObject::ariaLabeledByText):
* accessibility/AccessibilityObject.cpp:
(WebCore::appendChildrenToArray):
(WebCore::AccessibilityObject::clearChildren):
(WebCore::AccessibilityObject::ariaTreeRows):
(WebCore::AccessibilityObject::ariaTreeItemContent):
(WebCore::AccessibilityObject::ariaTreeItemDisclosedRows):
(WebCore::AccessibilityObject::elementAccessibilityHitTest):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::addRadioButtonGroupMembers):
(WebCore::AccessibilityRenderObject::ariaFlowToElements):
(WebCore::AccessibilityRenderObject::isTabItemSelected):
(WebCore::AccessibilityRenderObject::setSelectedRows):
(WebCore::AccessibilityRenderObject::ariaOwnsElements):
(WebCore::AccessibilityRenderObject::accessibilityImageMapHitTest):
(WebCore::AccessibilityRenderObject::addRemoteSVGChildren):
(WebCore::AccessibilityRenderObject::updateAttachmentViewParents):
(WebCore::AccessibilityRenderObject::addHiddenChildren):
(WebCore::AccessibilityRenderObject::ariaSelectedRows):
(WebCore::AccessibilityRenderObject::ariaListboxSelectedChildren):
(WebCore::AccessibilityRenderObject::ariaListboxVisibleChildren):
(WebCore::AccessibilityRenderObject::tabChildren):
(WebCore::AccessibilityRenderObject::mathRadicandObject):
(WebCore::AccessibilityRenderObject::mathRootIndexObject):
(WebCore::AccessibilityRenderObject::mathNumeratorObject):
(WebCore::AccessibilityRenderObject::mathDenominatorObject):
(WebCore::AccessibilityRenderObject::mathUnderObject):
(WebCore::AccessibilityRenderObject::mathOverObject):
(WebCore::AccessibilityRenderObject::mathBaseObject):
(WebCore::AccessibilityRenderObject::mathSubscriptObject):
(WebCore::AccessibilityRenderObject::mathSuperscriptObject):
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::columnHeaders):
(WebCore::AccessibilityTable::rowHeaders):
(WebCore::AccessibilityTable::visibleRows):
(WebCore::AccessibilityTable::cells):
(WebCore::AccessibilityTable::cellForColumnAndRow):
* accessibility/AccessibilityTableColumn.cpp:
(WebCore::AccessibilityTableColumn::headerObject):
* accessibility/AccessibilityTableHeaderContainer.cpp:
(WebCore::AccessibilityTableHeaderContainer::addChildren):
* accessibility/AccessibilityTableRow.cpp:
(WebCore::AccessibilityTableRow::headerObject):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilityElementAtIndex:]):
(-[WebAccessibilityObjectWrapper indexOfAccessibilityElement:]):
(-[WebAccessibilityObjectWrapper containsUnnaturallySegmentedChildren]):
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(convertMathPairsToNSArray):
(-[WebAccessibilityObjectWrapperBase accessibilityTitle]):
(-[WebAccessibilityObjectWrapperBase accessibilityDescription]):
(-[WebAccessibilityObjectWrapperBase accessibilityHelpText]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(convertToNSArray):
(convertStringsToNSArray):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
(-[WebAccessibilityObjectWrapper accessibilityIndexOfChild:]):
(-[WebAccessibilityObjectWrapper accessibilityArrayAttributeCount:]):
(-[WebAccessibilityObjectWrapper accessibilityArrayAttributeValues:index:maxCount:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161979 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityARIAGrid.cpp
Source/WebCore/accessibility/AccessibilityARIAGridCell.cpp
Source/WebCore/accessibility/AccessibilityARIAGridRow.cpp
Source/WebCore/accessibility/AccessibilityListBox.cpp
Source/WebCore/accessibility/AccessibilityListBoxOption.cpp
Source/WebCore/accessibility/AccessibilityMenuList.cpp
Source/WebCore/accessibility/AccessibilityMenuListPopup.cpp
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityTable.cpp
Source/WebCore/accessibility/AccessibilityTableColumn.cpp
Source/WebCore/accessibility/AccessibilityTableHeaderContainer.cpp
Source/WebCore/accessibility/AccessibilityTableRow.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index d880de4..14f7ed1 100644 (file)
@@ -1,3 +1,98 @@
+2014-01-13  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Modernize AccessibilityChildrenVector loops
+        https://bugs.webkit.org/show_bug.cgi?id=126915
+
+        Reviewed by Anders Carlsson.
+
+        Change appropriate for loops to use the new style.
+        Use auto where appropriate.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::focusedImageMapUIElement):
+        * accessibility/AccessibilityARIAGrid.cpp:
+        (WebCore::AccessibilityARIAGrid::addRowDescendant):
+        * accessibility/AccessibilityARIAGridCell.cpp:
+        (WebCore::AccessibilityARIAGridCell::rowIndexRange):
+        * accessibility/AccessibilityARIAGridRow.cpp:
+        (WebCore::AccessibilityARIAGridRow::disclosedRows):
+        (WebCore::AccessibilityARIAGridRow::disclosedByRow):
+        (WebCore::AccessibilityARIAGridRow::parentTable):
+        (WebCore::AccessibilityARIAGridRow::headerObject):
+        * accessibility/AccessibilityListBox.cpp:
+        (WebCore::AccessibilityListBox::addChildren):
+        (WebCore::AccessibilityListBox::setSelectedChildren):
+        (WebCore::AccessibilityListBox::selectedChildren):
+        * accessibility/AccessibilityListBoxOption.cpp:
+        (WebCore::AccessibilityListBoxOption::listBoxOptionIndex):
+        * accessibility/AccessibilityMenuList.cpp:
+        (WebCore::AccessibilityMenuList::didUpdateActiveOption):
+        * accessibility/AccessibilityMenuListPopup.cpp:
+        (WebCore::AccessibilityMenuListPopup::addChildren):
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::insertChild):
+        (WebCore::AccessibilityNodeObject::selectedRadioButton):
+        (WebCore::AccessibilityNodeObject::selectedTabItem):
+        (WebCore::AccessibilityNodeObject::ariaLabeledByText):
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::appendChildrenToArray):
+        (WebCore::AccessibilityObject::clearChildren):
+        (WebCore::AccessibilityObject::ariaTreeRows):
+        (WebCore::AccessibilityObject::ariaTreeItemContent):
+        (WebCore::AccessibilityObject::ariaTreeItemDisclosedRows):
+        (WebCore::AccessibilityObject::elementAccessibilityHitTest):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::addRadioButtonGroupMembers):
+        (WebCore::AccessibilityRenderObject::ariaFlowToElements):
+        (WebCore::AccessibilityRenderObject::isTabItemSelected):
+        (WebCore::AccessibilityRenderObject::setSelectedRows):
+        (WebCore::AccessibilityRenderObject::ariaOwnsElements):
+        (WebCore::AccessibilityRenderObject::accessibilityImageMapHitTest):
+        (WebCore::AccessibilityRenderObject::addRemoteSVGChildren):
+        (WebCore::AccessibilityRenderObject::updateAttachmentViewParents):
+        (WebCore::AccessibilityRenderObject::addHiddenChildren):
+        (WebCore::AccessibilityRenderObject::ariaSelectedRows):
+        (WebCore::AccessibilityRenderObject::ariaListboxSelectedChildren):
+        (WebCore::AccessibilityRenderObject::ariaListboxVisibleChildren):
+        (WebCore::AccessibilityRenderObject::tabChildren):
+        (WebCore::AccessibilityRenderObject::mathRadicandObject):
+        (WebCore::AccessibilityRenderObject::mathRootIndexObject):
+        (WebCore::AccessibilityRenderObject::mathNumeratorObject):
+        (WebCore::AccessibilityRenderObject::mathDenominatorObject):
+        (WebCore::AccessibilityRenderObject::mathUnderObject):
+        (WebCore::AccessibilityRenderObject::mathOverObject):
+        (WebCore::AccessibilityRenderObject::mathBaseObject):
+        (WebCore::AccessibilityRenderObject::mathSubscriptObject):
+        (WebCore::AccessibilityRenderObject::mathSuperscriptObject):
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::columnHeaders):
+        (WebCore::AccessibilityTable::rowHeaders):
+        (WebCore::AccessibilityTable::visibleRows):
+        (WebCore::AccessibilityTable::cells):
+        (WebCore::AccessibilityTable::cellForColumnAndRow):
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::headerObject):
+        * accessibility/AccessibilityTableHeaderContainer.cpp:
+        (WebCore::AccessibilityTableHeaderContainer::addChildren):
+        * accessibility/AccessibilityTableRow.cpp:
+        (WebCore::AccessibilityTableRow::headerObject):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityElementAtIndex:]):
+        (-[WebAccessibilityObjectWrapper indexOfAccessibilityElement:]):
+        (-[WebAccessibilityObjectWrapper containsUnnaturallySegmentedChildren]):
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (convertMathPairsToNSArray):
+        (-[WebAccessibilityObjectWrapperBase accessibilityTitle]):
+        (-[WebAccessibilityObjectWrapperBase accessibilityDescription]):
+        (-[WebAccessibilityObjectWrapperBase accessibilityHelpText]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (convertToNSArray):
+        (convertStringsToNSArray):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        (-[WebAccessibilityObjectWrapper accessibilityIndexOfChild:]):
+        (-[WebAccessibilityObjectWrapper accessibilityArrayAttributeCount:]):
+        (-[WebAccessibilityObjectWrapper accessibilityArrayAttributeValues:index:maxCount:]):
+
 2014-01-14  Brent Fulgham  <bfulgham@apple.com>
 
         [WebGL] Invalid range checking in WebGLRenderingContext::validateTexFuncLevel
index e77567f..925ebbb 100644 (file)
@@ -118,12 +118,10 @@ AXObjectCache::~AXObjectCache()
 {
     m_notificationPostTimer.stop();
 
-    HashMap<AXID, RefPtr<AccessibilityObject>>::iterator end = m_objects.end();
-    for (HashMap<AXID, RefPtr<AccessibilityObject>>::iterator it = m_objects.begin(); it != end; ++it) {
-        AccessibilityObject* obj = (*it).value.get();
-        detachWrapper(obj, CacheDestroyed);
-        obj->detach(CacheDestroyed);
-        removeAXID(obj);
+    for (const auto& object : m_objects.values()) {
+        detachWrapper(object.get(), CacheDestroyed);
+        object->detach(CacheDestroyed);
+        removeAXID(object.get());
     }
 }
 
@@ -142,15 +140,12 @@ AccessibilityObject* AXObjectCache::focusedImageMapUIElement(HTMLAreaElement* ar
     if (!axRenderImage)
         return 0;
     
-    const AccessibilityObject::AccessibilityChildrenVector& imageChildren = axRenderImage->children();
-    unsigned count = imageChildren.size();
-    for (unsigned k = 0; k < count; ++k) {
-        AccessibilityObject* child = imageChildren[k].get();
+    for (const auto& child : axRenderImage->children()) {
         if (!child->isImageMapLink())
             continue;
         
-        if (toAccessibilityImageMapLink(child)->areaElement() == areaElement)
-            return child;
+        if (toAccessibilityImageMapLink(child.get())->areaElement() == areaElement)
+            return child.get();
     }    
     
     return 0;
index 3007b1c..acb8370 100644 (file)
@@ -88,10 +88,8 @@ void AccessibilityARIAGrid::addRowDescendant(AccessibilityObject* rowChild, Hash
     if (!rowChild->isTableRow()) {
         // Although a "grid" should have rows as its direct descendants, if this is not a table row,
         // dive deeper into the descendants to try to find a valid row.
-        const AccessibilityChildrenVector& children = rowChild->children();
-        size_t length = children.size();
-        for (size_t i = 0; i < length; ++i)
-            addRowDescendant(children[i].get(), appendedRows, columnCount);
+        for (const auto& child : rowChild->children())
+            addRowDescendant(child.get(), appendedRows, columnCount);
     } else
         addTableCellChild(rowChild, appendedRows, columnCount);
 }
index 4560865..ae4f316 100644 (file)
@@ -84,7 +84,7 @@ void AccessibilityARIAGridCell::rowIndexRange(std::pair<unsigned, unsigned>& row
         if (!columnCount)
             return;
 
-        const AccessibilityChildrenVector& siblings = parent->children();
+        const auto& siblings = parent->children();
         unsigned childrenSize = siblings.size();
         for (unsigned k = 0; k < childrenSize; ++k) {
             if (siblings[k].get() == this) {
index 0f08b5d..60f2ac1 100644 (file)
@@ -73,7 +73,7 @@ void AccessibilityARIAGridRow::disclosedRows(AccessibilityChildrenVector& disclo
         return;
     
     unsigned level = hierarchicalLevel();
-    AccessibilityChildrenVector& allRows = toAccessibilityTable(parent)->rows();
+    auto& allRows = toAccessibilityTable(parent)->rows();
     int rowCount = allRows.size();
     for (int k = index + 1; k < rowCount; ++k) {
         AccessibilityObject* row = allRows[k].get();
@@ -100,7 +100,7 @@ AccessibilityObject* AccessibilityARIAGridRow::disclosedByRow() const
     
     // Search for the previous row that matches the correct level.
     int index = rowIndex();
-    AccessibilityChildrenVector& allRows = toAccessibilityTable(parent)->rows();
+    auto& allRows = toAccessibilityTable(parent)->rows();
     int rowCount = allRows.size();
     if (index >= rowCount)
         return 0;
@@ -111,7 +111,7 @@ AccessibilityObject* AccessibilityARIAGridRow::disclosedByRow() const
             return row;
     }
     
-    return 0;
+    return nullptr;
 }
     
 AccessibilityObject* AccessibilityARIAGridRow::parentTable() const
@@ -124,20 +124,17 @@ AccessibilityObject* AccessibilityARIAGridRow::parentTable() const
             return parent;
     }
     
-    return 0;
+    return nullptr;
 }
 
 AccessibilityObject* AccessibilityARIAGridRow::headerObject()
 {
-    const AccessibilityChildrenVector& rowChildren = children();
-    unsigned childrenCount = rowChildren.size();
-    for (unsigned i = 0; i < childrenCount; ++i) {
-        AccessibilityObject* cell = rowChildren[i].get();
-        if (cell->ariaRoleAttribute() == RowHeaderRole)
-            return cell;
+    for (const auto& child : children()) {
+        if (child->ariaRoleAttribute() == RowHeaderRole)
+            return child.get();
     }
     
-    return 0;
+    return nullptr;
 }
 
 } // namespace WebCore
index 8c044eb..f9bb388 100644 (file)
@@ -72,12 +72,10 @@ void AccessibilityListBox::addChildren()
     
     m_haveChildren = true;
     
-    const Vector<HTMLElement*>& listItems = toHTMLSelectElement(selectNode)->listItems();
-    unsigned length = listItems.size();
-    for (unsigned i = 0; i < length; i++) {
+    for (const auto& listItem : toHTMLSelectElement(selectNode)->listItems()) {
         // The cast to HTMLElement below is safe because the only other possible listItem type
         // would be a WMLElement, but WML builds don't use accessibility features at all.
-        AccessibilityObject* listOption = listBoxOptionAccessibilityObject(listItems[i]);
+        AccessibilityObject* listOption = listBoxOptionAccessibilityObject(listItem);
         if (listOption && !listOption->accessibilityIsIgnored())
             m_children.append(listOption);
     }
@@ -93,20 +91,17 @@ void AccessibilityListBox::setSelectedChildren(const AccessibilityChildrenVector
         return;
     
     // disable any selected options
-    unsigned length = m_children.size();
-    for (unsigned i = 0; i < length; i++) {
-        AccessibilityListBoxOption* listBoxOption = toAccessibilityListBoxOption(m_children[i].get());
+    for (const auto& child : m_children) {
+        AccessibilityListBoxOption* listBoxOption = toAccessibilityListBoxOption(child.get());
         if (listBoxOption->isSelected())
             listBoxOption->setSelected(false);
     }
     
-    length = children.size();
-    for (unsigned i = 0; i < length; i++) {
-        AccessibilityObject* obj = children[i].get();
+    for (const auto& obj : children) {
         if (obj->roleValue() != ListBoxOptionRole)
             continue;
                 
-        toAccessibilityListBoxOption(obj)->setSelected(true);
+        toAccessibilityListBoxOption(obj.get())->setSelected(true);
     }
 }
     
@@ -117,10 +112,9 @@ void AccessibilityListBox::selectedChildren(AccessibilityChildrenVector& result)
     if (!hasChildren())
         addChildren();
         
-    unsigned length = m_children.size();
-    for (unsigned i = 0; i < length; i++) {
-        if (toAccessibilityListBoxOption(m_children[i].get())->isSelected())
-            result.append(m_children[i]);
+    for (const auto& child : m_children) {
+        if (toAccessibilityListBoxOption(child.get())->isSelected())
+            result.append(child.get());
     }    
 }
 
index d2b243c..e403e6c 100644 (file)
@@ -220,7 +220,7 @@ int AccessibilityListBoxOption::listBoxOptionIndex() const
     if (!selectElement) 
         return -1;
     
-    const Vector<HTMLElement*>& listItems = selectElement->listItems();
+    const auto& listItems = selectElement->listItems();
     unsigned length = listItems.size();
     for (unsigned i = 0; i < length; i++)
         if (listItems[i] == m_optionElement)
index 0183d38..bc5364c 100644 (file)
@@ -108,7 +108,7 @@ void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
     Ref<Document> document(m_renderer->document());
     AXObjectCache* cache = document->axObjectCache();
 
-    const AccessibilityChildrenVector& childObjects = children();
+    const auto& childObjects = children();
     if (!childObjects.isEmpty()) {
         ASSERT(childObjects.size() == 1);
         ASSERT(childObjects[0]->isMenuListPopup());
index 921769d..8890752 100644 (file)
@@ -102,10 +102,8 @@ void AccessibilityMenuListPopup::addChildren()
 
     m_haveChildren = true;
 
-    const Vector<HTMLElement*>& listItems = toHTMLSelectElement(selectNode)->listItems();
-    unsigned length = listItems.size();
-    for (unsigned i = 0; i < length; i++) {
-        AccessibilityMenuListOption* option = menuListOptionAccessibilityObject(listItems[i]);
+    for (const auto& listItem : toHTMLSelectElement(selectNode)->listItems()) {
+        AccessibilityMenuListOption* option = menuListOptionAccessibilityObject(listItem);
         if (option) {
             option->setParent(this);
             m_children.append(option);
index 6384193..4747c91 100644 (file)
@@ -335,7 +335,7 @@ void AccessibilityNodeObject::insertChild(AccessibilityObject* child, unsigned i
     child->clearChildren();
     
     if (child->accessibilityIsIgnored()) {
-        const AccessibilityChildrenVector& children = child->children();
+        const auto& children = child->children();
         size_t length = children.size();
         for (size_t i = 0; i < length; ++i)
             m_children.insert(index + i, children[i]);
@@ -909,37 +909,30 @@ bool AccessibilityNodeObject::isGroup() const
 AccessibilityObject* AccessibilityNodeObject::selectedRadioButton()
 {
     if (!isRadioGroup())
-        return 0;
-
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
+        return nullptr;
 
     // Find the child radio button that is selected (ie. the intValue == 1).
-    size_t size = children.size();
-    for (size_t i = 0; i < size; ++i) {
-        AccessibilityObject* object = children[i].get();
-        if (object->roleValue() == RadioButtonRole && object->checkboxOrRadioValue() == ButtonStateOn)
-            return object;
+    for (const auto& child : children()) {
+        if (child->roleValue() == RadioButtonRole && child->checkboxOrRadioValue() == ButtonStateOn)
+            return child.get();
     }
-    return 0;
+    return nullptr;
 }
 
 AccessibilityObject* AccessibilityNodeObject::selectedTabItem()
 {
     if (!isTabList())
-        return 0;
+        return nullptr;
 
     // Find the child tab item that is selected (ie. the intValue == 1).
     AccessibilityObject::AccessibilityChildrenVector tabs;
     tabChildren(tabs);
 
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
-    size_t size = tabs.size();
-    for (size_t i = 0; i < size; ++i) {
-        AccessibilityObject* object = children[i].get();
-        if (object->isTabItem() && object->isChecked())
-            return object;
+    for (const auto& child : children()) {
+        if (child->isTabItem() && child->isChecked())
+            return child.get();
     }
-    return 0;
+    return nullptr;
 }
 
 AccessibilityButtonState AccessibilityNodeObject::checkboxOrRadioValue() const
@@ -1433,9 +1426,8 @@ void AccessibilityNodeObject::ariaLabeledByText(Vector<AccessibilityText>& textO
         ariaLabeledByElements(elements);
         
         Vector<RefPtr<AccessibilityObject>> axElements;
-        unsigned length = elements.size();
-        for (unsigned k = 0; k < length; k++) {
-            RefPtr<AccessibilityObject> axElement = axObjectCache()->getOrCreate(elements[k]);
+        for (const auto& element : elements) {
+            RefPtr<AccessibilityObject> axElement = axObjectCache()->getOrCreate(element);
             axElements.append(axElement);
         }
         
index 30df1a7..e4ac6cd 100644 (file)
@@ -417,7 +417,7 @@ static void appendChildrenToArray(AccessibilityObject* object, bool isForward, A
 {
     // A table's children includes elements whose own children are also the table's children (due to the way the Mac exposes tables).
     // The rows from the table should be queried, since those are direct descendants of the table, and they contain content.
-    const AccessibilityObject::AccessibilityChildrenVector& searchChildren = object->isAccessibilityTable() ? toAccessibilityTable(object)->rows() : object->children();
+    const auto& searchChildren = object->isAccessibilityTable() ? toAccessibilityTable(object)->rows() : object->children();
 
     size_t childrenSize = searchChildren.size();
 
@@ -1277,9 +1277,8 @@ void AccessibilityObject::updateChildrenIfNecessary()
 void AccessibilityObject::clearChildren()
 {
     // Some objects have weak pointers to their parents and those associations need to be detached.
-    size_t length = m_children.size();
-    for (size_t i = 0; i < length; i++)
-        m_children[i]->detachFromParent();
+    for (const auto& child : m_children)
+        child->detachFromParent();
     
     m_children.clear();
     m_haveChildren = false;
@@ -1320,42 +1319,31 @@ AccessibilityObject* AccessibilityObject::headingElementForNode(Node* node)
 
 void AccessibilityObject::ariaTreeRows(AccessibilityChildrenVector& result)
 {
-    const AccessibilityChildrenVector& axChildren = children();
-    unsigned count = axChildren.size();
-    for (unsigned k = 0; k < count; ++k) {
-        AccessibilityObject* obj = axChildren[k].get();
-        
+    for (const auto& child : children()) {
         // Add tree items as the rows.
-        if (obj->roleValue() == TreeItemRole) 
-            result.append(obj);
+        if (child->roleValue() == TreeItemRole)
+            result.append(child);
 
         // Now see if this item also has rows hiding inside of it.
-        obj->ariaTreeRows(result);
+        child->ariaTreeRows(result);
     }
 }
     
 void AccessibilityObject::ariaTreeItemContent(AccessibilityChildrenVector& result)
 {
     // The ARIA tree item content are the item that are not other tree items or their containing groups.
-    const AccessibilityChildrenVector& axChildren = children();
-    unsigned count = axChildren.size();
-    for (unsigned k = 0; k < count; ++k) {
-        AccessibilityObject* obj = axChildren[k].get();
-        AccessibilityRole role = obj->roleValue();
+    for (const auto& child : children()) {
+        AccessibilityRole role = child->roleValue();
         if (role == TreeItemRole || role == GroupRole)
             continue;
         
-        result.append(obj);
+        result.append(child);
     }
 }
 
 void AccessibilityObject::ariaTreeItemDisclosedRows(AccessibilityChildrenVector& result)
 {
-    const AccessibilityChildrenVector& axChildren = children();
-    unsigned count = axChildren.size();
-    for (unsigned k = 0; k < count; ++k) {
-        AccessibilityObject* obj = axChildren[k].get();
-        
+    for (const auto& obj : children()) {
         // Add tree items as the rows.
         if (obj->roleValue() == TreeItemRole)
             result.append(obj);
@@ -1677,10 +1665,9 @@ AccessibilityObject* AccessibilityObject::elementAccessibilityHitTest(const IntP
     }
     
     // Check if there are any mock elements that need to be handled.
-    size_t count = m_children.size();
-    for (size_t k = 0; k < count; k++) {
-        if (m_children[k]->isMockObject() && m_children[k]->elementRect().contains(point))
-            return m_children[k]->elementAccessibilityHitTest(point);
+    for (const auto& child : m_children) {
+        if (child->isMockObject() && child->elementRect().contains(point))
+            return child->elementAccessibilityHitTest(point);
     }
 
     return const_cast<AccessibilityObject*>(this); 
index 1b96cf3..1994551 100644 (file)
@@ -962,10 +962,8 @@ void AccessibilityRenderObject::addRadioButtonGroupMembers(AccessibilityChildren
         Vector<Ref<Element>> formElements;
         input->form()->getNamedElements(input->name(), formElements);
         
-        unsigned len = formElements.size();
-        for (unsigned i = 0; i < len; ++i) {
-            Element& associateElement = formElements[i].get();
-            if (AccessibilityObject* object = axObjectCache()->getOrCreate(&associateElement))
+        for (auto& associateElement : formElements) {
+            if (AccessibilityObject* object = axObjectCache()->getOrCreate(&associateElement.get()))
                 linkedUIElements.append(object);        
         } 
     } else {
@@ -1022,9 +1020,7 @@ void AccessibilityRenderObject::ariaFlowToElements(AccessibilityChildrenVector&
     elementsFromAttribute(elements, aria_flowtoAttr);
     
     AXObjectCache* cache = axObjectCache();
-    unsigned count = elements.size();
-    for (unsigned k = 0; k < count; ++k) {
-        Element* element = elements[k];
+    for (const auto& element : elements) {
         AccessibilityObject* flowToElement = cache->getOrCreate(element);
         if (flowToElement)
             flowTo.append(flowToElement);
@@ -1578,9 +1574,7 @@ bool AccessibilityRenderObject::isTabItemSelected() const
     Vector<Element*> elements;
     elementsFromAttribute(elements, aria_controlsAttr);
     
-    unsigned count = elements.size();
-    for (unsigned k = 0; k < count; ++k) {
-        Element* element = elements[k];
+    for (const auto& element : elements) {
         AccessibilityObject* tabPanel = axObjectCache()->getOrCreate(element);
 
         // A tab item should only control tab panels.
@@ -1653,8 +1647,8 @@ void AccessibilityRenderObject::setSelectedRows(AccessibilityChildrenVector& sel
     if (count > 1 && !isMulti)
         count = 1;
     
-    for (unsigned k = 0; k < count; ++k)
-        selectedRows[k]->setSelected(true);
+    for (const auto& selectedRow : selectedRows)
+        selectedRow->setSelected(true);
 }
     
 void AccessibilityRenderObject::setValue(const String& string)
@@ -1682,9 +1676,8 @@ void AccessibilityRenderObject::ariaOwnsElements(AccessibilityChildrenVector& ax
     Vector<Element*> elements;
     elementsFromAttribute(elements, aria_ownsAttr);
     
-    unsigned count = elements.size();
-    for (unsigned k = 0; k < count; ++k) {
-        RenderObject* render = elements[k]->renderer();
+    for (const auto& element : elements) {
+        RenderObject* render = element->renderer();
         AccessibilityObject* obj = axObjectCache()->getOrCreate(render);
         if (obj)
             axObjects.append(obj);
@@ -2155,12 +2148,9 @@ AccessibilityObject* AccessibilityRenderObject::accessibilityImageMapHitTest(HTM
     if (!parent)
         return 0;
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = parent->children();
-    
-    unsigned count = children.size();
-    for (unsigned k = 0; k < count; ++k) {
-        if (children[k]->elementRect().contains(point))
-            return children[k].get();
+    for (const auto& child : parent->children()) {
+        if (child->elementRect().contains(point))
+            return child.get();
     }
     
     return 0;
@@ -2859,10 +2849,8 @@ void AccessibilityRenderObject::addRemoteSVGChildren()
     root->setParent(this);
     
     if (root->accessibilityIsIgnored()) {
-        const AccessibilityChildrenVector& children = root->children();
-        unsigned length = children.size();
-        for (unsigned i = 0; i < length; ++i)
-            m_children.append(children[i]);
+        for (const auto& child : root->children())
+            m_children.append(child);
     } else
         m_children.append(root);
 }
@@ -2904,10 +2892,9 @@ void AccessibilityRenderObject::updateAttachmentViewParents()
     if (accessibilityIsIgnored())
         return;
     
-    size_t length = m_children.size();
-    for (size_t k = 0; k < length; k++) {
-        if (m_children[k]->isAttachment())
-            m_children[k]->overrideAttachmentParent(this);
+    for (const auto& child : m_children) {
+        if (child->isAttachment())
+            child->overrideAttachmentParent(this);
     }
 }
 #endif
@@ -2941,7 +2928,7 @@ void AccessibilityRenderObject::addHiddenChildren()
             // Find out where the last render sibling is located within m_children.
             AccessibilityObject* childObject = axObjectCache()->get(child->renderer());
             if (childObject && childObject->accessibilityIsIgnored()) {
-                const AccessibilityChildrenVector& children = childObject->children();
+                auto& children = childObject->children();
                 if (children.size())
                     childObject = children.last().get();
                 else
@@ -3068,10 +3055,9 @@ void AccessibilityRenderObject::ariaSelectedRows(AccessibilityChildrenVector& re
             return;
     }
 
-    unsigned count = allRows.size();
-    for (unsigned k = 0; k < count; ++k) {
-        if (allRows[k]->isSelected()) {
-            result.append(allRows[k]);
+    for (const auto& row : allRows) {
+        if (row->isSelected()) {
+            result.append(row);
             if (!isMulti)
                 break;
         }
@@ -3082,11 +3068,8 @@ void AccessibilityRenderObject::ariaListboxSelectedChildren(AccessibilityChildre
 {
     bool isMulti = isMultiSelectable();
 
-    const AccessibilityChildrenVector& childObjects = children();
-    unsigned childrenSize = childObjects.size();
-    for (unsigned k = 0; k < childrenSize; ++k) {
+    for (const auto& child : children()) {
         // Every child should have aria-role option, and if so, check for selected attribute/state.
-        AccessibilityObject* child = childObjects[k].get();
         if (child->isSelected() && child->ariaRoleAttribute() == ListBoxOptionRole) {
             result.append(child);
             if (!isMulti)
@@ -3112,11 +3095,9 @@ void AccessibilityRenderObject::ariaListboxVisibleChildren(AccessibilityChildren
     if (!hasChildren())
         addChildren();
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
-    size_t size = children.size();
-    for (size_t i = 0; i < size; i++) {
-        if (!children[i]->isOffScreen())
-            result.append(children[i]);
+    for (const auto& child : children()) {
+        if (child->isOffScreen())
+            result.append(child);
     }
 }
 
@@ -3136,11 +3117,9 @@ void AccessibilityRenderObject::tabChildren(AccessibilityChildrenVector& result)
 {
     ASSERT(roleValue() == TabListRole);
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
-    size_t size = children.size();
-    for (size_t i = 0; i < size; ++i) {
-        if (children[i]->isTabItem())
-            result.append(children[i]);
+    for (const auto& child : children()) {
+        if (child->isTabItem())
+            result.append(child);
     }
 }
     
@@ -3571,7 +3550,7 @@ AccessibilityObject* AccessibilityRenderObject::mathRadicandObject()
     if (!isMathRoot())
         return 0;
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     if (children.size() < 1)
         return 0;
     
@@ -3584,7 +3563,7 @@ AccessibilityObject* AccessibilityRenderObject::mathRootIndexObject()
     if (!isMathRoot())
         return 0;
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     if (children.size() != 2)
         return 0;
 
@@ -3598,7 +3577,7 @@ AccessibilityObject* AccessibilityRenderObject::mathNumeratorObject()
     if (!isMathFraction())
         return 0;
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     if (children.size() != 2)
         return 0;
     
@@ -3610,7 +3589,7 @@ AccessibilityObject* AccessibilityRenderObject::mathDenominatorObject()
     if (!isMathFraction())
         return 0;
 
-    const AccessibilityObject::AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     if (children.size() != 2)
         return 0;
     
@@ -3622,7 +3601,7 @@ AccessibilityObject* AccessibilityRenderObject::mathUnderObject()
     if (!isMathUnderOver() || !node())
         return 0;
     
-    const AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     if (children.size() < 2)
         return 0;
     
@@ -3637,7 +3616,7 @@ AccessibilityObject* AccessibilityRenderObject::mathOverObject()
     if (!isMathUnderOver() || !node())
         return 0;
     
-    const AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     if (children.size() < 2)
         return 0;
     
@@ -3654,7 +3633,7 @@ AccessibilityObject* AccessibilityRenderObject::mathBaseObject()
     if (!isMathSubscriptSuperscript() && !isMathUnderOver() && !isMathMultiscript())
         return 0;
     
-    const AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     // The base object in question is always the first child.
     if (children.size() > 0)
         return children[0].get();
@@ -3667,7 +3646,7 @@ AccessibilityObject* AccessibilityRenderObject::mathSubscriptObject()
     if (!isMathSubscriptSuperscript() || !node())
         return 0;
     
-    const AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     if (children.size() < 2)
         return 0;
 
@@ -3682,7 +3661,7 @@ AccessibilityObject* AccessibilityRenderObject::mathSuperscriptObject()
     if (!isMathSubscriptSuperscript() || !node())
         return 0;
     
-    const AccessibilityChildrenVector& children = this->children();
+    const auto& children = this->children();
     unsigned count = children.size();
 
     if (count >= 2 && node()->hasTagName(MathMLNames::msupTag))
index 900aa61..ee23f1b 100644 (file)
@@ -124,7 +124,7 @@ bool AccessibilityTable::isDataTable() const
         return true;    
 
     // if there's a colgroup or col element, it's probably a data table.
-    for (auto& child : childrenOfType<Element>(*tableElement)) {
+    for (const auto& child : childrenOfType<Element>(*tableElement)) {
         if (child.hasTagName(colTag) || child.hasTagName(colgroupTag))
             return true;
     }
@@ -428,9 +428,8 @@ void AccessibilityTable::columnHeaders(AccessibilityChildrenVector& headers)
     
     updateChildrenIfNecessary();
     
-    size_t columnCount = m_columns.size();
-    for (size_t i = 0; i < columnCount; ++i) {
-        if (AccessibilityObject* header = toAccessibilityTableColumn(m_columns[i].get())->headerObject())
+    for (const auto& column : m_columns) {
+        if (AccessibilityObject* header = toAccessibilityTableColumn(column.get())->headerObject())
             headers.append(header);
     }
 }
@@ -442,9 +441,8 @@ void AccessibilityTable::rowHeaders(AccessibilityChildrenVector& headers)
     
     updateChildrenIfNecessary();
     
-    size_t rowCount = m_rows.size();
-    for (size_t i = 0; i < rowCount; ++i) {
-        if (AccessibilityObject* header = toAccessibilityTableRow(m_rows[i].get())->headerObject())
+    for (const auto& row : m_rows) {
+        if (AccessibilityObject* header = toAccessibilityTableRow(row.get())->headerObject())
             headers.append(header);
     }
 }
@@ -456,9 +454,7 @@ void AccessibilityTable::visibleRows(AccessibilityChildrenVector& rows)
     
     updateChildrenIfNecessary();
     
-    size_t rowCount = m_rows.size();
-    for (size_t i = 0; i < rowCount; ++i) {
-        AccessibilityObject* row = m_rows[i].get();
+    for (const auto& row : m_rows) {
         if (row && !row->isOffScreen())
             rows.append(row);
     }
@@ -471,8 +467,8 @@ void AccessibilityTable::cells(AccessibilityObject::AccessibilityChildrenVector&
     
     updateChildrenIfNecessary();
     
-    for (size_t row = 0; row < m_rows.size(); ++row)
-        cells.appendVector(m_rows[row]->children());
+    for (const auto& row : m_rows)
+        cells.appendVector(row->children());
 }
     
 unsigned AccessibilityTable::columnCount()
@@ -509,7 +505,7 @@ AccessibilityTableCell* AccessibilityTable::cellForColumnAndRow(unsigned column,
     // Iterate backwards through the rows in case the desired cell has a rowspan and exists in a previous row.
     for (unsigned rowIndexCounter = row + 1; rowIndexCounter > 0; --rowIndexCounter) {
         unsigned rowIndex = rowIndexCounter - 1;
-        const AccessibilityChildrenVector& children = m_rows[rowIndex]->children();
+        const auto& children = m_rows[rowIndex]->children();
         // Since some cells may have colspans, we have to check the actual range of each
         // cell to determine which is the right one.
         for (unsigned colIndexCounter = std::min(static_cast<unsigned>(children.size()), column + 1); colIndexCounter > 0; --colIndexCounter) {
index ffe1353..6791c33 100644 (file)
@@ -80,12 +80,9 @@ AccessibilityObject* AccessibilityTableColumn::headerObject()
     
     AccessibilityTable* parentTable = toAccessibilityTable(m_parent);
     if (parentTable->isAriaTable()) {
-        const AccessibilityChildrenVector& rowChildren = children();
-        unsigned childrenCount = rowChildren.size();
-        for (unsigned i = 0; i < childrenCount; ++i) {
-            AccessibilityObject* cell = rowChildren[i].get();
+        for (const auto& cell : children()) {
             if (cell->ariaRoleAttribute() == ColumnHeaderRole)
-                return cell;
+                return cell.get();
         }
         
         return 0;
index 2375f1a..52a0800 100644 (file)
@@ -75,9 +75,8 @@ void AccessibilityTableHeaderContainer::addChildren()
     
     toAccessibilityTable(m_parent)->columnHeaders(m_children);
     
-    unsigned length = m_children.size();
-    for (unsigned k = 0; k < length; ++k)
-        m_headerRect.unite(m_children[k]->elementRect());
+    for (const auto& child : m_children)
+        m_headerRect.unite(child->elementRect());
 }
 
 } // namespace WebCore
index d9f833e..2d06ce9 100644 (file)
@@ -117,7 +117,7 @@ AccessibilityObject* AccessibilityTableRow::headerObject()
     if (!m_renderer || !m_renderer->isTableRow())
         return 0;
     
-    const AccessibilityChildrenVector& rowChildren = children();
+    const auto& rowChildren = children();
     if (!rowChildren.size())
         return 0;
     
index 766f463..a6a7a86 100644 (file)
@@ -347,7 +347,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
     if ([self isAttachment])
         return [[self attachmentView] accessibilityElementAtIndex:index];
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
+    const auto& children = m_object->children();
     if (static_cast<unsigned>(index) >= children.size())
         return nil;
     
@@ -367,7 +367,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
     if ([self isAttachment])
         return [[self attachmentView] indexOfAccessibilityElement:element];
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
+    const auto& children = m_object->children();
     unsigned count = children.size();
     for (unsigned k = 0; k < count; ++k) {
         AccessibilityObjectWrapper* wrapper = children[k]->wrapper();
@@ -1073,7 +1073,7 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     if (role != LinkRole && role != WebCoreLinkRole)
         return NO;
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
+    const auto& children = m_object->children();
     unsigned childrenSize = children.size();
 
     // If there's only one child, then it doesn't have segmented children. 
index 926a4f9..6db24c7 100644 (file)
@@ -78,11 +78,9 @@ using namespace HTMLNames;
 
 static NSArray *convertMathPairsToNSArray(const AccessibilityObject::AccessibilityMathMultiscriptPairs& pairs, NSString *subscriptKey, NSString *superscriptKey)
 {
-    unsigned length = pairs.size();
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:length];
-    for (unsigned i = 0; i < length; ++i) {
+    NSMutableArray *array = [NSMutableArray arrayWithCapacity:pairs.size()];
+    for (const auto& pair : pairs) {
         NSMutableDictionary *pairDictionary = [NSMutableDictionary dictionary];
-        std::pair<AccessibilityObject*, AccessibilityObject*> pair = pairs[i];
         if (pair.first && pair.first->wrapper() && !pair.first->accessibilityIsIgnored())
             [pairDictionary setObject:pair.first->wrapper() forKey:subscriptKey];
         if (pair.second && pair.second->wrapper() && !pair.second->accessibilityIsIgnored())
@@ -165,10 +163,7 @@ static NSArray *convertMathPairsToNSArray(const AccessibilityObject::Accessibili
     Vector<AccessibilityText> textOrder;
     m_object->accessibilityText(textOrder);
     
-    unsigned length = textOrder.size();
-    for (unsigned k = 0; k < length; k++) {
-        const AccessibilityText& text = textOrder[k];
-        
+    for (const auto& text : textOrder) {
         // If we have alternative text, then we should not expose a title.
         if (text.textSource == AlternativeText)
             break;
@@ -196,11 +191,8 @@ static NSArray *convertMathPairsToNSArray(const AccessibilityObject::Accessibili
     Vector<AccessibilityText> textOrder;
     m_object->accessibilityText(textOrder);
     
-    unsigned length = textOrder.size();
     bool visibleTextAvailable = false;
-    for (unsigned k = 0; k < length; k++) {
-        const AccessibilityText& text = textOrder[k];
-        
+    for (const auto& text : textOrder) {
         if (text.textSource == AlternativeText)
             return text.text;
         
@@ -225,11 +217,8 @@ static NSArray *convertMathPairsToNSArray(const AccessibilityObject::Accessibili
     Vector<AccessibilityText> textOrder;
     m_object->accessibilityText(textOrder);
     
-    unsigned length = textOrder.size();
     bool descriptiveTextAvailable = false;
-    for (unsigned k = 0; k < length; k++) {
-        const AccessibilityText& text = textOrder[k];
-        
+    for (const auto& text : textOrder) {
         if (text.textSource == HelpText || text.textSource == SummaryText)
             return text.text;
         
index 4ce798f..d926844 100644 (file)
@@ -1562,15 +1562,14 @@ static void convertToVector(NSArray* array, AccessibilityObject::AccessibilityCh
 
 static NSMutableArray* convertToNSArray(const AccessibilityObject::AccessibilityChildrenVector& vector)
 {
-    unsigned length = vector.size();
-    NSMutableArray* array = [NSMutableArray arrayWithCapacity: length];
-    for (unsigned i = 0; i < length; ++i) {
-        WebAccessibilityObjectWrapper* wrapper = vector[i]->wrapper();
+    NSMutableArray* array = [NSMutableArray arrayWithCapacity:vector.size()];
+    for (const auto& child : vector) {
+        WebAccessibilityObjectWrapper* wrapper = child->wrapper();
         ASSERT(wrapper);
         if (wrapper) {
             // we want to return the attachment view instead of the object representing the attachment.
             // otherwise, we get palindrome errors in the AX hierarchy
-            if (vector[i]->isAttachment() && [wrapper attachmentView])
+            if (child->isAttachment() && [wrapper attachmentView])
                 [array addObject:[wrapper attachmentView]];
             else
                 [array addObject:wrapper];
@@ -1581,10 +1580,9 @@ static NSMutableArray* convertToNSArray(const AccessibilityObject::Accessibility
 
 static NSMutableArray *convertStringsToNSArray(const Vector<String>& vector)
 {
-    size_t length = vector.size();
-    NSMutableArray *array = [NSMutableArray arrayWithCapacity:length];
-    for (size_t i = 0; i < length; ++i)
-        [array addObject:vector[i]];
+    NSMutableArray *array = [NSMutableArray arrayWithCapacity:vector.size()];
+    for (const auto& string : vector)
+        [array addObject:string];
     return array;
 }
 
@@ -2377,7 +2375,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if ([attributeName isEqualToString:NSAccessibilityContentsAttribute]) {
         // The contents of a tab list are all the children except the tabs.
         if (m_object->isTabList()) {
-            const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
+            const auto& children = m_object->children();
             AccessibilityObject::AccessibilityChildrenVector tabsChildren;
             m_object->tabChildren(tabsChildren);
             
@@ -2389,14 +2387,11 @@ static NSString* roleValueToNSString(AccessibilityRole value)
             }
             return convertToNSArray(contents);
         } else if (m_object->isScrollView()) {
-            const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
-            
             // A scrollView's contents are everything except the scroll bars.
             AccessibilityObject::AccessibilityChildrenVector contents;
-            unsigned childrenSize = children.size();
-            for (unsigned k = 0; k < childrenSize; ++k) {
-                if (!children[k]->isScrollbar())
-                    contents.append(children[k]);
+            for (const auto& child : m_object->children()) {
+                if (!child->isScrollbar())
+                    contents.append(child);
             }
             return convertToNSArray(contents);
         }
@@ -3614,7 +3609,7 @@ static RenderObject* rendererForView(NSView* view)
     if (m_object->isTree())
         return [super accessibilityIndexOfChild:child];
     
-    const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
+    const auto& children = m_object->children();
     
     if (children.isEmpty())
         return [[self renderWidgetChildren] indexOfObject:child];
@@ -3640,7 +3635,7 @@ static RenderObject* rendererForView(NSView* view)
         if (m_object->isTree() || m_object->isTreeItem())
             return [[self accessibilityAttributeValue:NSAccessibilityChildrenAttribute] count];
         
-        const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
+        const auto& children = m_object->children();
         if (children.isEmpty())
             return [[self renderWidgetChildren] count];
         
@@ -3672,7 +3667,7 @@ static RenderObject* rendererForView(NSView* view)
             return [super accessibilityArrayAttributeValues:attribute index:index maxCount:maxCount];
         }
         
-        const AccessibilityObject::AccessibilityChildrenVector& children = m_object->children();
+        const auto& children = m_object->children();
         unsigned childCount = children.size();
         if (index >= childCount)
             return nil;