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

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

Issue 300223009: Implement basic parts of hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: exclude clipping region part Created 6 years, 6 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) 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 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 1240
1241 return String(); 1241 return String();
1242 } 1242 }
1243 1243
1244 LayoutRect AXNodeObject::elementRect() const 1244 LayoutRect AXNodeObject::elementRect() const
1245 { 1245 {
1246 // First check if it has a custom rect, for example if this element is tied to a canvas path. 1246 // First check if it has a custom rect, for example if this element is tied to a canvas path.
1247 if (!m_explicitElementRect.isEmpty()) 1247 if (!m_explicitElementRect.isEmpty())
1248 return m_explicitElementRect; 1248 return m_explicitElementRect;
1249 1249
1250 // AXNodeObjects have no mechanism yet to return a size or position. 1250 // FIXME: If there are a lot of elements in the canvas, it will be inefficie nt.
1251 // For now, let's return the position of the ancestor that does have a posit ion, 1251 // We can avoid the inefficient calculations by using AXComputedObjectAttrib uteCache.
1252 if (node()->parentElement()->isInCanvasSubtree()) {
1253 LayoutRect rect;
1254
1255 for (Node* child = node()->firstChild(); child; child = child->nextSibli ng()) {
1256 if (child->isHTMLElement()) {
1257 if (AXObject* obj = axObjectCache()->get(child)) {
1258 if (rect.isEmpty())
1259 rect = obj->elementRect();
1260 else
1261 rect.unite(obj->elementRect());
1262 }
1263 }
1264 }
1265
1266 if (!rect.isEmpty())
1267 return rect;
1268 }
1269
1270 // If this object doesn't have an explicit element rect or computable from i ts children,
1271 // for now, let's return the position of the ancestor that does have a posit ion,
1252 // 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. 1272 // 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.
1253 1273
1254 LayoutRect boundingBox; 1274 LayoutRect boundingBox;
1255 1275
1256 for (AXObject* positionProvider = parentObject(); positionProvider; position Provider = positionProvider->parentObject()) { 1276 for (AXObject* positionProvider = parentObject(); positionProvider; position Provider = positionProvider->parentObject()) {
1257 if (positionProvider->isAXRenderObject()) { 1277 if (positionProvider->isAXRenderObject()) {
1258 LayoutRect parentRect = positionProvider->elementRect(); 1278 LayoutRect parentRect = positionProvider->elementRect();
1259 boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::m in(10.0f, parentRect.height().toFloat())))); 1279 boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::m in(10.0f, parentRect.height().toFloat()))));
1260 boundingBox.setLocation(parentRect.location()); 1280 boundingBox.setLocation(parentRect.location());
1261 break; 1281 break;
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 float range = maxValueForRange() - minValueForRange(); 1701 float range = maxValueForRange() - minValueForRange();
1682 float value = valueForRange(); 1702 float value = valueForRange();
1683 1703
1684 value += range * (percentChange / 100); 1704 value += range * (percentChange / 100);
1685 setValue(String::number(value)); 1705 setValue(String::number(value));
1686 1706
1687 axObjectCache()->postNotification(node(), AXObjectCache::AXValueChanged, tru e); 1707 axObjectCache()->postNotification(node(), AXObjectCache::AXValueChanged, tru e);
1688 } 1708 }
1689 1709
1690 } // namespace WebCore 1710 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698