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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 2287433003: Get rid of remaining uses of AXObject::elementRect (Closed)
Patch Set: Rebase Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
index 54970683b0522aa8e9a5a62427f8b8f9c95b936c..6c1c098d4741d97f4c7fa32b7370b8aac6914c10 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
@@ -1801,57 +1801,13 @@ bool AXNodeObject::nameFromLabelElement() const
return false;
}
-LayoutRect AXNodeObject::elementRect() const
+void AXNodeObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBoundsInContainer, SkMatrix44& outContainerTransform) const
{
- // First check if it has a custom rect, for example if this element is tied to a canvas path.
- if (!m_explicitElementRect.isEmpty()) {
- LayoutRect bounds = m_explicitElementRect;
- AXObject* canvas = axObjectCache().objectFromAXID(m_explicitContainerID);
- if (canvas)
- bounds.moveBy(canvas->elementRect().location());
- return bounds;
- }
-
- // FIXME: If there are a lot of elements in the canvas, it will be inefficient.
- // We can avoid the inefficient calculations by using AXComputedObjectAttributeCache.
- if (getNode()->parentElement()->isInCanvasSubtree()) {
- LayoutRect rect;
-
- for (Node& child : NodeTraversal::childrenOf(*getNode())) {
- if (child.isHTMLElement()) {
- if (AXObject* obj = axObjectCache().get(&child)) {
- if (rect.isEmpty())
- rect = obj->elementRect();
- else
- rect.unite(obj->elementRect());
- }
- }
- }
-
- if (!rect.isEmpty())
- return rect;
- }
-
- // If this object doesn't have an explicit element rect or computable from its children,
- // for now, let's return the position of the ancestor that does have a position,
- // and make it the width of that parent, and about the height of a line of text, so that it's clear the object is a child of the parent.
-
- LayoutRect boundingBox;
-
- for (AXObject* positionProvider = parentObject(); positionProvider; positionProvider = positionProvider->parentObject()) {
- if (positionProvider->isAXLayoutObject()) {
- LayoutRect parentRect = positionProvider->elementRect();
- boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::min(10.0f, parentRect.height().toFloat()))));
- boundingBox.setLocation(parentRect.location());
- break;
- }
+ if (layoutObjectForRelativeBounds()) {
+ AXObject::getRelativeBounds(outContainer, outBoundsInContainer, outContainerTransform);
+ return;
}
- return boundingBox;
-}
-
-void AXNodeObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBoundsInContainer, SkMatrix44& outContainerTransform) const
-{
*outContainer = nullptr;
outBoundsInContainer = FloatRect();
outContainerTransform.setIdentity();

Powered by Google App Engine
This is Rietveld 408576698