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

Side by Side Diff: Source/core/accessibility/AccessibilityNodeObject.cpp

Issue 14740025: Simplify and add caching for accessible bounding box calculation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Re-landing with null check fix Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google 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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 if (axObj) { 1287 if (axObj) {
1288 AccessibilityRole role = axObj->roleValue(); 1288 AccessibilityRole role = axObj->roleValue();
1289 if (role != GroupRole && role != UnknownRole) 1289 if (role != GroupRole && role != UnknownRole)
1290 break; 1290 break;
1291 } 1291 }
1292 } 1292 }
1293 1293
1294 return String(); 1294 return String();
1295 } 1295 }
1296 1296
1297 LayoutRect AccessibilityNodeObject::boundingBoxRect() const 1297 LayoutRect AccessibilityNodeObject::elementRect() const
1298 { 1298 {
1299 // AccessibilityNodeObjects have no mechanism yet to return a size or positi on. 1299 // AccessibilityNodeObjects have no mechanism yet to return a size or positi on.
1300 // For now, let's return the position of the ancestor that does have a posit ion, 1300 // For now, let's return the position of the ancestor that does have a posit ion,
1301 // and make it the width of that parent, and about the height of a line of t ext, so that it's clear the object is a child of the parent. 1301 // and make it the width of that parent, and about the height of a line of t ext, so that it's clear the object is a child of the parent.
1302 1302
1303 LayoutRect boundingBox; 1303 LayoutRect boundingBox;
1304 1304
1305 for (AccessibilityObject* positionProvider = parentObject(); positionProvide r; positionProvider = positionProvider->parentObject()) { 1305 for (AccessibilityObject* positionProvider = parentObject(); positionProvide r; positionProvider = positionProvider->parentObject()) {
1306 if (positionProvider->isAccessibilityRenderObject()) { 1306 if (positionProvider->isAccessibilityRenderObject()) {
1307 LayoutRect parentRect = positionProvider->elementRect(); 1307 LayoutRect parentRect = positionProvider->elementRect();
1308 boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::m in(10.0f, parentRect.height().toFloat())))); 1308 boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::m in(10.0f, parentRect.height().toFloat()))));
1309 boundingBox.setLocation(parentRect.location()); 1309 boundingBox.setLocation(parentRect.location());
1310 break; 1310 break;
1311 } 1311 }
1312 } 1312 }
1313 1313
1314 return boundingBox; 1314 return boundingBox;
1315 } 1315 }
1316 1316
1317 LayoutRect AccessibilityNodeObject::elementRect() const
1318 {
1319 return boundingBoxRect();
1320 }
1321
1322 AccessibilityObject* AccessibilityNodeObject::parentObject() const 1317 AccessibilityObject* AccessibilityNodeObject::parentObject() const
1323 { 1318 {
1324 if (!node()) 1319 if (!node())
1325 return 0; 1320 return 0;
1326 1321
1327 Node* parentObj = node()->parentNode(); 1322 Node* parentObj = node()->parentNode();
1328 if (parentObj) 1323 if (parentObj)
1329 return axObjectCache()->getOrCreate(parentObj); 1324 return axObjectCache()->getOrCreate(parentObj);
1330 1325
1331 return 0; 1326 return 0;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 useTextUnderElement = true; 1773 useTextUnderElement = true;
1779 1774
1780 if (useTextUnderElement) { 1775 if (useTextUnderElement) {
1781 String text = textUnderElement(); 1776 String text = textUnderElement();
1782 if (!text.isEmpty()) 1777 if (!text.isEmpty())
1783 textOrder.append(AccessibilityText(text, ChildrenText)); 1778 textOrder.append(AccessibilityText(text, ChildrenText));
1784 } 1779 }
1785 } 1780 }
1786 1781
1787 } // namespace WebCore 1782 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/accessibility/AccessibilityNodeObject.h ('k') | Source/core/accessibility/AccessibilityObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698