Commit ca8e25b9 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Iframe accessible bounding boxes should include border,padding.

We store accessible bounding boxes as relative coordinates, and
normally each element takes its parent's border and padding into
account when exposing its own top/left coordinate. This doesn't
work for the root document node inside an iframe, because it
can't know the owning iframe element's border and padding, so
we need a special case for that.

Bug: 740312
Change-Id: I4c7d7f435eff9c69afa889d666bd09a2dc5716ae
Reviewed-on: https://chromium-review.googlesource.com/775024Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518794}
parent 3ba0b497
......@@ -1195,6 +1195,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
RunHtmlTest(FILE_PATH_LITERAL("iframe-coordinates-cross-process.html"));
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityIframePadding) {
RunHtmlTest(FILE_PATH_LITERAL("iframe-padding.html"));
}
// Flaky on Win7. http://crbug.com/610744
#ifdef OS_WIN
#define MAYBE_AccessibilityIframePresentational DISABLED_AccessibilityIframePresentational
......
rootWebArea pageLocation=(0, 0)
++iframe pageLocation=(0, 0) pageSize=(300, 100)
++++rootWebArea pageLocation=(0, 0) pageSize=(300, 100)
++++++genericContainer pageLocation=(0, 0) pageSize=(300, 100)
++++++++button pageLocation=(25, 25) pageSize=(250, 50) name='Ordinary Button'
++iframe pageLocation=(30, 230) pageSize=(300, 100)
++++rootWebArea pageLocation=(30, 230) pageSize=(300, 100)
++++++genericContainer pageLocation=(30, 230) pageSize=(300, 100)
++++++++button pageLocation=(55, 255) pageSize=(250, 50) name='Ordinary Button'
<!--
@BLINK-ALLOW:pageLocation*
@BLINK-ALLOW:pageSize=(300, 100)
@BLINK-ALLOW:pageSize=(250, 50)
-->
<!DOCTYPE html>
<html>
<body style="padding: 0; margin: 0; width: 800px; height: 800px">
<div>
<iframe width=300 height=100 src="frame/button.html" style="position: absolute; left: 0; top: 0; border: 0; padding: 0; margin: 0;"></iframe>
</div>
<div>
<iframe width=300 height=100 src="frame/button.html" style="position: absolute; left: 0; top: 200px; border: 5px solid #ccf; padding: 25px; margin: 0;"></iframe>
</div>
</body>
</html>
......@@ -46,6 +46,7 @@
#include "core/input/ContextMenuAllowedScope.h"
#include "core/input/EventHandler.h"
#include "core/input_type_names.h"
#include "core/layout/LayoutBox.h"
#include "core/layout/LayoutBoxModelObject.h"
#include "core/layout/LayoutView.h"
#include "core/page/Page.h"
......@@ -1947,6 +1948,14 @@ void AXObject::GetRelativeBounds(AXObject** out_container,
out_bounds_in_container =
layout_object->LocalBoundingBoxRectForAccessibility();
// Frames need to take their border and padding into account so the
// child element's computed position will be correct.
if (layout_object->IsBox() && layout_object->GetNode() &&
layout_object->GetNode()->IsFrameOwnerElement()) {
out_bounds_in_container =
FloatRect(ToLayoutBox(layout_object)->ContentBoxRect());
}
// 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* scrollable_area = container->GetScrollableAreaIfScrollable();
......@@ -1956,11 +1965,13 @@ void AXObject::GetRelativeBounds(AXObject** out_container,
}
// 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.
// object.
TransformationMatrix transform = layout_object->LocalToAncestorTransform(
ToLayoutBoxModelObject(container_layout_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.
if (transform.IsIdentityOr2DTranslation()) {
out_bounds_in_container.Move(transform.To2DTranslation());
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment