Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: Source/modules/accessibility/AXLayoutObject.cpp

Issue 991863003: Avoid unnecessary copies of AccessibilityChildrenVector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 if (role != TreeItemRole && role != StaticTextRole) 1933 if (role != TreeItemRole && role != StaticTextRole)
1934 return false; 1934 return false;
1935 } 1935 }
1936 return true; 1936 return true;
1937 } 1937 }
1938 1938
1939 void AXLayoutObject::ariaListboxSelectedChildren(AccessibilityChildrenVector& re sult) 1939 void AXLayoutObject::ariaListboxSelectedChildren(AccessibilityChildrenVector& re sult)
1940 { 1940 {
1941 bool isMulti = isMultiSelectable(); 1941 bool isMulti = isMultiSelectable();
1942 1942
1943 AccessibilityChildrenVector childObjects = children(); 1943 const AccessibilityChildrenVector& childObjects = children();
1944 unsigned childrenSize = childObjects.size(); 1944 unsigned childrenSize = childObjects.size();
1945 for (unsigned k = 0; k < childrenSize; ++k) { 1945 for (unsigned k = 0; k < childrenSize; ++k) {
1946 // Every child should have aria-role option, and if so, check for select ed attribute/state. 1946 // Every child should have aria-role option, and if so, check for select ed attribute/state.
1947 AXObject* child = childObjects[k].get(); 1947 AXObject* child = childObjects[k].get();
1948 if (child->isSelected() && child->ariaRoleAttribute() == ListBoxOptionRo le) { 1948 if (child->isSelected() && child->ariaRoleAttribute() == ListBoxOptionRo le) {
1949 result.append(child); 1949 result.append(child);
1950 if (!isMulti) 1950 if (!isMulti)
1951 return; 1951 return;
1952 } 1952 }
1953 } 1953 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 2024
2025 AXObject* AXLayoutObject::accessibilityImageMapHitTest(HTMLAreaElement* area, co nst IntPoint& point) const 2025 AXObject* AXLayoutObject::accessibilityImageMapHitTest(HTMLAreaElement* area, co nst IntPoint& point) const
2026 { 2026 {
2027 if (!area) 2027 if (!area)
2028 return 0; 2028 return 0;
2029 2029
2030 AXObject* parent = axObjectCache()->getOrCreate(area->imageElement()); 2030 AXObject* parent = axObjectCache()->getOrCreate(area->imageElement());
2031 if (!parent) 2031 if (!parent)
2032 return 0; 2032 return 0;
2033 2033
2034 AXObject::AccessibilityChildrenVector children = parent->children(); 2034 const AccessibilityChildrenVector& children = parent->children();
2035 unsigned count = children.size(); 2035 unsigned count = children.size();
2036 for (unsigned k = 0; k < count; ++k) { 2036 for (unsigned k = 0; k < count; ++k) {
2037 if (children[k]->elementRect().contains(point)) 2037 if (children[k]->elementRect().contains(point))
2038 return children[k].get(); 2038 return children[k].get();
2039 } 2039 }
2040 2040
2041 return 0; 2041 return 0;
2042 } 2042 }
2043 2043
2044 bool AXLayoutObject::layoutObjectIsObservable(LayoutObject* renderer) const 2044 bool AXLayoutObject::layoutObjectIsObservable(LayoutObject* renderer) const
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 return; 2173 return;
2174 2174
2175 // Iterate through all of the children, including those that may have alread y been added, and 2175 // Iterate through all of the children, including those that may have alread y been added, and
2176 // try to insert hidden nodes in the correct place in the DOM order. 2176 // try to insert hidden nodes in the correct place in the DOM order.
2177 unsigned insertionIndex = 0; 2177 unsigned insertionIndex = 0;
2178 for (Node* child = node->firstChild(); child; child = child->nextSibling()) { 2178 for (Node* child = node->firstChild(); child; child = child->nextSibling()) {
2179 if (child->renderer()) { 2179 if (child->renderer()) {
2180 // Find out where the last layout sibling is located within m_childr en. 2180 // Find out where the last layout sibling is located within m_childr en.
2181 AXObject* childObject = axObjectCache()->get(child->renderer()); 2181 AXObject* childObject = axObjectCache()->get(child->renderer());
2182 if (childObject && childObject->accessibilityIsIgnored()) { 2182 if (childObject && childObject->accessibilityIsIgnored()) {
2183 AccessibilityChildrenVector children = childObject->children(); 2183 const AccessibilityChildrenVector& children = childObject->child ren();
2184 if (children.size()) 2184 if (children.size())
2185 childObject = children.last().get(); 2185 childObject = children.last().get();
2186 else 2186 else
2187 childObject = 0; 2187 childObject = 0;
2188 } 2188 }
2189 2189
2190 if (childObject) 2190 if (childObject)
2191 insertionIndex = m_children.find(childObject) + 1; 2191 insertionIndex = m_children.find(childObject) + 1;
2192 continue; 2192 continue;
2193 } 2193 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 2283
2284 void AXLayoutObject::addRemoteSVGChildren() 2284 void AXLayoutObject::addRemoteSVGChildren()
2285 { 2285 {
2286 AXSVGRoot* root = remoteSVGRootElement(); 2286 AXSVGRoot* root = remoteSVGRootElement();
2287 if (!root) 2287 if (!root)
2288 return; 2288 return;
2289 2289
2290 root->setParent(this); 2290 root->setParent(this);
2291 2291
2292 if (root->accessibilityIsIgnored()) { 2292 if (root->accessibilityIsIgnored()) {
2293 AccessibilityChildrenVector children = root->children(); 2293 const AccessibilityChildrenVector& children = root->children();
2294 unsigned length = children.size(); 2294 unsigned length = children.size();
2295 for (unsigned i = 0; i < length; ++i) 2295 for (unsigned i = 0; i < length; ++i)
2296 m_children.append(children[i]); 2296 m_children.append(children[i]);
2297 } else { 2297 } else {
2298 m_children.append(root); 2298 m_children.append(root);
2299 } 2299 }
2300 } 2300 }
2301 2301
2302 void AXLayoutObject::ariaSelectedRows(AccessibilityChildrenVector& result) 2302 void AXLayoutObject::ariaSelectedRows(AccessibilityChildrenVector& result)
2303 { 2303 {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 if (label && label->renderer()) { 2411 if (label && label->renderer()) {
2412 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2412 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2413 result.unite(labelRect); 2413 result.unite(labelRect);
2414 } 2414 }
2415 } 2415 }
2416 2416
2417 return result; 2417 return result;
2418 } 2418 }
2419 2419
2420 } // namespace blink 2420 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXARIAGridRow.cpp ('k') | Source/modules/accessibility/AXNodeObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698