Chromium Code Reviews| Index: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| diff --git a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| index 1585354fce6f6cde6b69deb1aa9c78284951f5d8..40ec82afc8fe99ad2125f5acae276b444ee85687 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| @@ -199,8 +199,13 @@ AXLayoutObject::~AXLayoutObject() |
| LayoutRect AXLayoutObject::elementRect() const |
| { |
| - if (!m_explicitElementRect.isEmpty()) |
| - return m_explicitElementRect; |
| + if (!m_explicitElementRect.isEmpty()) { |
| + LayoutRect bounds = m_explicitElementRect; |
| + AXObject* canvas = axObjectCache().objectFromAXID(m_explicitContainerID); |
| + if (canvas) |
| + bounds.moveBy(canvas->elementRect().location()); |
| + return bounds; |
| + } |
| // FIXME(dmazzoni): use relative bounds instead since this is a bottleneck. |
| // http://crbug.com/618120 |
| @@ -252,9 +257,23 @@ void AXLayoutObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBo |
| outBoundsInContainer = FloatRect(); |
| outContainerTransform.setIdentity(); |
| + if (!m_explicitElementRect.isEmpty()) { |
|
aboxhall
2016/07/28 18:40:43
Can you add a comment explaining the logic here?
dmazzoni
2016/07/28 21:43:16
Done.
|
| + *outContainer = axObjectCache().objectFromAXID(m_explicitContainerID); |
| + if (*outContainer) { |
| + outBoundsInContainer = FloatRect(m_explicitElementRect); |
| + return; |
| + } |
| + } |
| + |
| if (!m_layoutObject) |
| return; |
| + if (isWebArea()) { |
| + if (m_layoutObject->frame()->view()) |
| + outBoundsInContainer.setSize(FloatSize(m_layoutObject->frame()->view()->contentsSize())); |
| + return; |
| + } |
| + |
| // First compute the container. The container must be an ancestor in the accessibility tree, and |
| // its LayoutObject must be an ancestor in the layout tree. Get the first such ancestor that's |
| // either scrollable or has a paint layer. |
| @@ -278,9 +297,14 @@ void AXLayoutObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBo |
| // a rect at point (0, 0) with the width and height of the LayoutObject. |
| LayoutRect localBounds; |
| if (m_layoutObject->isText()) { |
| - localBounds = toLayoutText(m_layoutObject)->linesBoundingBox(); |
| + Vector<FloatQuad> quads; |
| + toLayoutText(m_layoutObject)->quads(quads, LayoutText::ClipToEllipsis, LayoutText::LocalQuads); |
| + for (const FloatQuad& quad : quads) |
| + localBounds.unite(LayoutRect(quad.boundingBox())); |
| } else if (m_layoutObject->isLayoutInline()) { |
| - localBounds = toLayoutInline(m_layoutObject)->linesBoundingBox(); |
| + Vector<LayoutRect> rects; |
| + toLayoutInline(m_layoutObject)->addOutlineRects(rects, LayoutPoint(), LayoutObject::IncludeBlockVisualOverflow); |
| + localBounds = unionRect(rects); |
| } else if (m_layoutObject->isBox()) { |
| localBounds = LayoutRect(LayoutPoint(), toLayoutBox(m_layoutObject)->size()); |
| } else if (m_layoutObject->isSVG()) { |
| @@ -293,7 +317,7 @@ void AXLayoutObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBo |
| // If the container has a scroll offset, subtract that out because we want our |
| // bounds to be relative to the *unscrolled* position of the container object. |
| ScrollableArea* scrollableArea = container->getScrollableAreaIfScrollable(); |
| - if (scrollableArea) { |
| + if (scrollableArea && !container->isWebArea()) { |
| IntPoint scrollPosition = scrollableArea->scrollPosition(); |
| outBoundsInContainer.move(FloatSize(scrollPosition.x(), scrollPosition.y())); |
| } |
| @@ -2538,7 +2562,7 @@ LayoutRect AXLayoutObject::computeElementRect() const |
| LayoutRect result; |
| if (obj->isText()) { |
| Vector<FloatQuad> quads; |
| - toLayoutText(obj)->absoluteQuads(quads, LayoutText::ClipToEllipsis); |
| + toLayoutText(obj)->quads(quads, LayoutText::ClipToEllipsis, LayoutText::AbsoluteQuads); |
| result = LayoutRect(boundingBoxForQuads(obj, quads)); |
| } else if (isWebArea() || obj->isSVGRoot()) { |
| result = LayoutRect(obj->absoluteBoundingBoxRect()); |