Title: [170634] trunk/Source/WebCore
- Revision
- 170634
- Author
- [email protected]
- Date
- 2014-07-01 04:29:24 -0700 (Tue, 01 Jul 2014)
Log Message
Remove remaining Vector<> copies in WebCore accessibility code
https://bugs.webkit.org/show_bug.cgi?id=133263
Reviewed by Darin Adler.
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::notificationPostTimerFired): Don't copy the Vector member and
then clear it -- move it into the local variable instead.
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::ariaLabeledByText): Move the axElements Vector into
the AccessibilityText constructor.
(WebCore::AccessibilityNodeObject::stringValue): Create a const reference to the Vector of
HTMLSelectElement's list items instead of copying it.
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityText::AccessibilityText): Take the Vector parameter by non-const
value and move it into the member variable.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::stringValue): Create a const reference to the Vector
of HTMLSelectElement's list items instead of copying it.
(WebCore::AccessibilityRenderObject::ariaSelectedRows): Wrap the AccessibilityChildrenVector
iteration in a lambda. Use it to iterate over either the newly-constructed Vector (in case
the object has the tree role) or the reference to the vector returned by
AccessibilityTable::rows() (in case the object is an AccessibilityTable instance).
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (170633 => 170634)
--- trunk/Source/WebCore/ChangeLog 2014-07-01 09:10:56 UTC (rev 170633)
+++ trunk/Source/WebCore/ChangeLog 2014-07-01 11:29:24 UTC (rev 170634)
@@ -1,3 +1,29 @@
+2014-07-01 Zan Dobersek <[email protected]>
+
+ Remove remaining Vector<> copies in WebCore accessibility code
+ https://bugs.webkit.org/show_bug.cgi?id=133263
+
+ Reviewed by Darin Adler.
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXObjectCache::notificationPostTimerFired): Don't copy the Vector member and
+ then clear it -- move it into the local variable instead.
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::ariaLabeledByText): Move the axElements Vector into
+ the AccessibilityText constructor.
+ (WebCore::AccessibilityNodeObject::stringValue): Create a const reference to the Vector of
+ HTMLSelectElement's list items instead of copying it.
+ * accessibility/AccessibilityObject.h:
+ (WebCore::AccessibilityText::AccessibilityText): Take the Vector parameter by non-const
+ value and move it into the member variable.
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::stringValue): Create a const reference to the Vector
+ of HTMLSelectElement's list items instead of copying it.
+ (WebCore::AccessibilityRenderObject::ariaSelectedRows): Wrap the AccessibilityChildrenVector
+ iteration in a lambda. Use it to iterate over either the newly-constructed Vector (in case
+ the object has the tree role) or the reference to the vector returned by
+ AccessibilityTable::rows() (in case the object is an AccessibilityTable instance).
+
2014-06-30 Commit Queue <[email protected]>
Unreviewed, rolling out r170605.
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (170633 => 170634)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2014-07-01 09:10:56 UTC (rev 170633)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2014-07-01 11:29:24 UTC (rev 170634)
@@ -704,8 +704,7 @@
// In DRT, posting notifications has a tendency to immediately queue up other notifications, which can lead to unexpected behavior
// when the notification list is cleared at the end. Instead copy this list at the start.
- auto notifications = m_notificationsToPost;
- m_notificationsToPost.clear();
+ auto notifications = std::move(m_notificationsToPost);
for (const auto& note : notifications) {
AccessibilityObject* obj = note.first.get();
Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (170633 => 170634)
--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2014-07-01 09:10:56 UTC (rev 170633)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp 2014-07-01 11:29:24 UTC (rev 170634)
@@ -1438,7 +1438,7 @@
axElements.append(axElement);
}
- textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, axElements));
+ textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, std::move(axElements)));
}
}
@@ -1787,7 +1787,7 @@
if (node->hasTagName(selectTag)) {
HTMLSelectElement* selectElement = toHTMLSelectElement(node);
int selectedIndex = selectElement->selectedIndex();
- const Vector<HTMLElement*> listItems = selectElement->listItems();
+ const Vector<HTMLElement*>& listItems = selectElement->listItems();
if (selectedIndex >= 0 && static_cast<size_t>(selectedIndex) < listItems.size()) {
const AtomicString& overriddenDescription = listItems[selectedIndex]->fastGetAttribute(aria_labelAttr);
if (!overriddenDescription.isNull())
Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (170633 => 170634)
--- trunk/Source/WebCore/accessibility/AccessibilityObject.h 2014-07-01 09:10:56 UTC (rev 170633)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h 2014-07-01 11:29:24 UTC (rev 170634)
@@ -230,10 +230,10 @@
, textSource(s)
{ }
- AccessibilityText(const String& t, const AccessibilityTextSource& s, const Vector<RefPtr<AccessibilityObject>> elements)
+ AccessibilityText(const String& t, const AccessibilityTextSource& s, Vector<RefPtr<AccessibilityObject>> elements)
: text(t)
, textSource(s)
- , textElements(elements)
+ , textElements(std::move(elements))
{ }
AccessibilityText(const String& t, const AccessibilityTextSource& s, const RefPtr<AccessibilityObject> element)
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (170633 => 170634)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-07-01 09:10:56 UTC (rev 170633)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-07-01 11:29:24 UTC (rev 170634)
@@ -743,7 +743,7 @@
// This has to be overridden in the case where the selected item has an ARIA label.
HTMLSelectElement* selectElement = toHTMLSelectElement(m_renderer->node());
int selectedIndex = selectElement->selectedIndex();
- const Vector<HTMLElement*> listItems = selectElement->listItems();
+ const Vector<HTMLElement*>& listItems = selectElement->listItems();
if (selectedIndex >= 0 && static_cast<size_t>(selectedIndex) < listItems.size()) {
const AtomicString& overriddenDescription = listItems[selectedIndex]->fastGetAttribute(aria_labelAttr);
if (!overriddenDescription.isNull())
@@ -3108,13 +3108,6 @@
void AccessibilityRenderObject::ariaSelectedRows(AccessibilityChildrenVector& result)
{
- // Get all the rows.
- AccessibilityChildrenVector allRows;
- if (isTree())
- ariaTreeRows(allRows);
- else if (isAccessibilityTable() && toAccessibilityTable(this)->supportsSelectedRows())
- allRows = toAccessibilityTable(this)->rows();
-
// Determine which rows are selected.
bool isMulti = isMultiSelectable();
@@ -3126,13 +3119,22 @@
return;
}
- for (const auto& row : allRows) {
- if (row->isSelected()) {
- result.append(row);
- if (!isMulti)
- break;
+ // Get all the rows.
+ auto rowsIteration = [&](const AccessibilityChildrenVector& rows) {
+ for (auto& row : rows) {
+ if (row->isSelected()) {
+ result.append(row);
+ if (!isMulti)
+ break;
+ }
}
- }
+ };
+ if (isTree()) {
+ AccessibilityChildrenVector allRows;
+ ariaTreeRows(allRows);
+ rowsIteration(allRows);
+ } else if (isAccessibilityTable() && toAccessibilityTable(this)->supportsSelectedRows())
+ rowsIteration(toAccessibilityTable(this)->rows());
}
void AccessibilityRenderObject::ariaListboxSelectedChildren(AccessibilityChildrenVector& result)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes