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 0b5202f5e92b496d8c708be58f2bfe311c08ce4d..ea6a708dbff71b3ce0befca9b7c85bfabde78548 100644 |
--- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
+++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp |
@@ -1792,57 +1792,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(); |