| Index: components/test_runner/web_ax_object_proxy.cc
|
| diff --git a/components/test_runner/web_ax_object_proxy.cc b/components/test_runner/web_ax_object_proxy.cc
|
| index c9803b4ec5af2c2d7b3db29abeb6f378eeb0dd73..1e3de2563968680d7a3af6a0e8e3fd6e3b93531e 100644
|
| --- a/components/test_runner/web_ax_object_proxy.cc
|
| +++ b/components/test_runner/web_ax_object_proxy.cc
|
| @@ -9,11 +9,15 @@
|
| #include "base/macros.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "gin/handle.h"
|
| +#include "third_party/WebKit/public/platform/WebFloatRect.h"
|
| #include "third_party/WebKit/public/platform/WebPoint.h"
|
| #include "third_party/WebKit/public/platform/WebRect.h"
|
| #include "third_party/WebKit/public/platform/WebString.h"
|
| #include "third_party/WebKit/public/web/WebFrame.h"
|
| #include "third_party/WebKit/public/web/WebKit.h"
|
| +#include "third_party/skia/include/core/SkMatrix44.h"
|
| +#include "ui/gfx/geometry/rect_f.h"
|
| +#include "ui/gfx/transform.h"
|
|
|
| namespace test_runner {
|
|
|
| @@ -310,6 +314,31 @@ std::string GetAttributes(const blink::WebAXObject& object) {
|
| return attributes;
|
| }
|
|
|
| +// New bounds calculation algorithm. Retrieves the frame-relative bounds
|
| +// of an object by calling getRelativeBounds and then applying the offsets
|
| +// and transforms recursively on each container of this object.
|
| +blink::WebFloatRect BoundsForObject(const blink::WebAXObject& object) {
|
| + blink::WebAXObject container;
|
| + blink::WebFloatRect bounds;
|
| + SkMatrix44 matrix;
|
| + object.getRelativeBounds(container, bounds, matrix);
|
| + gfx::RectF computedBounds(0, 0, bounds.width, bounds.height);
|
| + while (!container.isDetached()) {
|
| + computedBounds.Offset(bounds.x, bounds.y);
|
| + computedBounds.Offset(
|
| + -container.scrollOffset().x, -container.scrollOffset().y);
|
| + if (!matrix.isIdentity()) {
|
| + gfx::Transform transform(matrix);
|
| + transform.TransformRect(&computedBounds);
|
| + }
|
| + container.getRelativeBounds(container, bounds, matrix);
|
| + }
|
| + return blink::WebFloatRect(computedBounds.x(),
|
| + computedBounds.y(),
|
| + computedBounds.width(),
|
| + computedBounds.height());
|
| +}
|
| +
|
| blink::WebRect BoundsForCharacter(const blink::WebAXObject& object,
|
| int characterIndex) {
|
| DCHECK_EQ(object.role(), blink::WebAXRoleStaticText);
|
| @@ -551,6 +580,13 @@ WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) {
|
| .SetProperty("columnHeadersCount", &WebAXObjectProxy::ColumnHeadersCount)
|
| .SetProperty("isClickable", &WebAXObjectProxy::IsClickable)
|
| .SetProperty("isButtonStateMixed", &WebAXObjectProxy::IsButtonStateMixed)
|
| + //
|
| + // NEW bounding rect calculation - high-level interface
|
| + //
|
| + .SetProperty("boundsX", &WebAXObjectProxy::BoundsX)
|
| + .SetProperty("boundsY", &WebAXObjectProxy::BoundsY)
|
| + .SetProperty("boundsWidth", &WebAXObjectProxy::BoundsWidth)
|
| + .SetProperty("boundsHeight", &WebAXObjectProxy::BoundsHeight)
|
| .SetMethod("allAttributes", &WebAXObjectProxy::AllAttributes)
|
| .SetMethod("attributesOfChildren",
|
| &WebAXObjectProxy::AttributesOfChildren)
|
| @@ -596,6 +632,8 @@ WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) {
|
| .SetMethod("scrollToMakeVisibleWithSubFocus",
|
| &WebAXObjectProxy::ScrollToMakeVisibleWithSubFocus)
|
| .SetMethod("scrollToGlobalPoint", &WebAXObjectProxy::ScrollToGlobalPoint)
|
| + .SetMethod("scrollX", &WebAXObjectProxy::ScrollX)
|
| + .SetMethod("scrollY", &WebAXObjectProxy::ScrollY)
|
| .SetMethod("wordStart", &WebAXObjectProxy::WordStart)
|
| .SetMethod("wordEnd", &WebAXObjectProxy::WordEnd)
|
| .SetMethod("nextOnLine", &WebAXObjectProxy::NextOnLine)
|
| @@ -619,7 +657,22 @@ WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) {
|
| .SetMethod("descriptionElementCount",
|
| &WebAXObjectProxy::DescriptionElementCount)
|
| .SetMethod("descriptionElementAtIndex",
|
| - &WebAXObjectProxy::DescriptionElementAtIndex);
|
| + &WebAXObjectProxy::DescriptionElementAtIndex)
|
| + //
|
| + // NEW bounding rect calculation - low-level interface
|
| + //
|
| + .SetMethod("offsetContainer",
|
| + &WebAXObjectProxy::OffsetContainer)
|
| + .SetMethod("boundsInContainerX",
|
| + &WebAXObjectProxy::BoundsInContainerX)
|
| + .SetMethod("boundsInContainerY",
|
| + &WebAXObjectProxy::BoundsInContainerY)
|
| + .SetMethod("boundsInContainerWidth",
|
| + &WebAXObjectProxy::BoundsInContainerWidth)
|
| + .SetMethod("boundsInContainerHeight",
|
| + &WebAXObjectProxy::BoundsInContainerHeight)
|
| + .SetMethod("hasNonIdentityTransform",
|
| + &WebAXObjectProxy::HasNonIdentityTransform);
|
| }
|
|
|
| v8::Local<v8::Object> WebAXObjectProxy::GetChildAtIndex(unsigned index) {
|
| @@ -1290,6 +1343,32 @@ void WebAXObjectProxy::ScrollToGlobalPoint(int x, int y) {
|
| accessibility_object_.scrollToGlobalPoint(blink::WebPoint(x, y));
|
| }
|
|
|
| +int WebAXObjectProxy::ScrollX() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + return accessibility_object_.scrollOffset().x;
|
| +}
|
| +
|
| +int WebAXObjectProxy::ScrollY() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + return accessibility_object_.scrollOffset().y;
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsX() {
|
| + return BoundsForObject(accessibility_object_).x;
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsY() {
|
| + return BoundsForObject(accessibility_object_).y;
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsWidth() {
|
| + return BoundsForObject(accessibility_object_).width;
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsHeight() {
|
| + return BoundsForObject(accessibility_object_).height;
|
| +}
|
| +
|
| int WebAXObjectProxy::WordStart(int character_index) {
|
| accessibility_object_.updateLayoutAndCheckValidity();
|
| if (accessibility_object_.role() != blink::WebAXRoleStaticText)
|
| @@ -1458,6 +1537,61 @@ v8::Local<v8::Object> WebAXObjectProxy::DescriptionElementAtIndex(
|
| return factory_->GetOrCreate(descriptionObjects[index]);
|
| }
|
|
|
| +v8::Local<v8::Object> WebAXObjectProxy::OffsetContainer() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + blink::WebAXObject container;
|
| + blink::WebFloatRect bounds;
|
| + SkMatrix44 matrix;
|
| + accessibility_object_.getRelativeBounds(container, bounds, matrix);
|
| + return factory_->GetOrCreate(container);
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsInContainerX() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + blink::WebAXObject container;
|
| + blink::WebFloatRect bounds;
|
| + SkMatrix44 matrix;
|
| + accessibility_object_.getRelativeBounds(container, bounds, matrix);
|
| + return bounds.x;
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsInContainerY() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + blink::WebAXObject container;
|
| + blink::WebFloatRect bounds;
|
| + SkMatrix44 matrix;
|
| + accessibility_object_.getRelativeBounds(container, bounds, matrix);
|
| + return bounds.y;
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsInContainerWidth() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + blink::WebAXObject container;
|
| + blink::WebFloatRect bounds;
|
| + SkMatrix44 matrix;
|
| + accessibility_object_.getRelativeBounds(container, bounds, matrix);
|
| + return bounds.width;
|
| +}
|
| +
|
| +float WebAXObjectProxy::BoundsInContainerHeight() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + blink::WebAXObject container;
|
| + blink::WebFloatRect bounds;
|
| + SkMatrix44 matrix;
|
| + accessibility_object_.getRelativeBounds(container, bounds, matrix);
|
| + return bounds.height;
|
| +}
|
| +
|
| +bool WebAXObjectProxy::HasNonIdentityTransform() {
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + accessibility_object_.updateLayoutAndCheckValidity();
|
| + blink::WebAXObject container;
|
| + blink::WebFloatRect bounds;
|
| + SkMatrix44 matrix;
|
| + accessibility_object_.getRelativeBounds(container, bounds, matrix);
|
| + return !matrix.isIdentity();
|
| +}
|
| +
|
| RootWebAXObjectProxy::RootWebAXObjectProxy(
|
| const blink::WebAXObject &object, Factory *factory)
|
| : WebAXObjectProxy(object, factory) {
|
|
|