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 6eb6d63f455602da8572e90be9085fa0fc647fed..de95d6c81a515863fb5ed2dfbbce864ca68e9192 100644 |
| --- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| +++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp |
| @@ -256,6 +256,70 @@ ScrollableArea* AXLayoutObject::getScrollableAreaIfScrollable() const |
| return box->getScrollableArea(); |
| } |
| +void AXLayoutObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBoundsInContainer, SkMatrix44& outContainerTransform) const |
| +{ |
| + *outContainer = nullptr; |
| + outBoundsInContainer = FloatRect(); |
| + outContainerTransform.setIdentity(); |
| + |
| + if (!m_layoutObject) |
|
aboxhall
2016/06/09 23:05:30
Any reason not to do this before the above three l
dmazzoni
2016/06/10 16:55:40
These are all out parameters, I think it's safer t
|
| + 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. |
| + AXObject* container = parentObjectUnignored(); |
| + LayoutObject* containerLayoutObject = nullptr; |
| + while (container) { |
| + containerLayoutObject = container->getLayoutObject(); |
| + if (containerLayoutObject && containerLayoutObject->isBoxModelObject() && m_layoutObject->isDescendantOf(containerLayoutObject)) { |
|
aboxhall
2016/06/09 23:05:30
Under what circumstances would `m_layoutObject->is
dmazzoni
2016/06/10 16:55:39
For example, if you used aria-owns to rearrange th
|
| + if (container->isScrollableContainer() || containerLayoutObject->hasLayer()) |
| + break; |
| + } |
| + |
| + container = container->parentObjectUnignored(); |
| + } |
| + |
| + if (!container) |
| + return; |
| + *outContainer = container; |
| + |
| + // Next get the local bounds of this LayoutObject, which is typically |
| + // a rect at point (0, 0) with the width and height of the LayoutObject. |
| + LayoutRect localBounds; |
|
chrishtr
2016/06/09 22:24:53
Does visualOverflowRect() meet your needs? There i
dmazzoni
2016/06/09 22:45:29
It's in the right coordinate system but it seems t
chrishtr
2016/06/09 23:06:42
For what example? But yes it takes into account ev
|
| + if (m_layoutObject->isText()) { |
| + localBounds = toLayoutText(m_layoutObject)->linesBoundingBox(); |
| + } else if (m_layoutObject->isLayoutInline()) { |
| + localBounds = toLayoutInline(m_layoutObject)->linesBoundingBox(); |
| + } else if (m_layoutObject->isBox()) { |
| + localBounds = LayoutRect(LayoutPoint(), toLayoutBox(m_layoutObject)->size()); |
| + } else if (m_layoutObject->isSVG()) { |
| + localBounds = LayoutRect(m_layoutObject->strokeBoundingBox()); |
| + } else { |
| + DCHECK(false); |
| + } |
| + outBoundsInContainer = FloatRect(localBounds); |
| + |
| + // 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) { |
| + IntPoint scrollPosition = scrollableArea->scrollPosition(); |
| + outBoundsInContainer.move(FloatSize(scrollPosition.x(), scrollPosition.y())); |
| + } |
| + |
| + // Compute the transform between the container's coordinate space and this object. |
| + // If the transform is just a simple translation, apply that to the bounding box, but |
| + // if it's a non-trivial transformation like a rotation, scaling, etc. then return |
| + // the full matrix instead. |
| + TransformationMatrix transform = m_layoutObject->localToAncestorTransform(toLayoutBoxModelObject(containerLayoutObject)); |
| + if (transform.isIdentityOr2DTranslation()) { |
| + outBoundsInContainer.move(transform.to2DTranslation()); |
| + } else { |
| + outContainerTransform = TransformationMatrix::toSkMatrix44(transform); |
| + } |
| +} |
| + |
| static bool isImageOrAltText(LayoutBoxModelObject* box, Node* node) |
| { |
| if (box && box->isImage()) |