| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/test_runner/web_ax_object_proxy.h" | 5 #include "content/shell/test_runner/web_ax_object_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 return attributes; | 320 return attributes; |
| 321 } | 321 } |
| 322 | 322 |
| 323 // New bounds calculation algorithm. Retrieves the frame-relative bounds | 323 // New bounds calculation algorithm. Retrieves the frame-relative bounds |
| 324 // of an object by calling getRelativeBounds and then applying the offsets | 324 // of an object by calling getRelativeBounds and then applying the offsets |
| 325 // and transforms recursively on each container of this object. | 325 // and transforms recursively on each container of this object. |
| 326 blink::WebFloatRect BoundsForObject(const blink::WebAXObject& object) { | 326 blink::WebFloatRect BoundsForObject(const blink::WebAXObject& object) { |
| 327 blink::WebAXObject container; | 327 blink::WebAXObject container; |
| 328 blink::WebFloatRect bounds; | 328 blink::WebFloatRect bounds; |
| 329 SkMatrix44 matrix; | 329 SkMatrix44 matrix; |
| 330 object.GetRelativeBounds(container, bounds, matrix); | 330 bool is_fixed_positioned; |
| 331 object.GetRelativeBounds(container, bounds, matrix, is_fixed_positioned); |
| 331 gfx::RectF computedBounds(0, 0, bounds.width, bounds.height); | 332 gfx::RectF computedBounds(0, 0, bounds.width, bounds.height); |
| 332 while (!container.IsDetached()) { | 333 while (!container.IsDetached()) { |
| 333 computedBounds.Offset(bounds.x, bounds.y); | 334 computedBounds.Offset(bounds.x, bounds.y); |
| 334 computedBounds.Offset(-container.GetScrollOffset().x, | 335 if (!is_fixed_positioned) { |
| 335 -container.GetScrollOffset().y); | 336 computedBounds.Offset(-container.GetScrollOffset().x, |
| 337 -container.GetScrollOffset().y); |
| 338 } |
| 336 if (!matrix.isIdentity()) { | 339 if (!matrix.isIdentity()) { |
| 337 gfx::Transform transform(matrix); | 340 gfx::Transform transform(matrix); |
| 338 transform.TransformRect(&computedBounds); | 341 transform.TransformRect(&computedBounds); |
| 339 } | 342 } |
| 340 container.GetRelativeBounds(container, bounds, matrix); | 343 container.GetRelativeBounds(container, bounds, matrix, is_fixed_positioned); |
| 341 } | 344 } |
| 342 return blink::WebFloatRect(computedBounds.x(), computedBounds.y(), | 345 return blink::WebFloatRect(computedBounds.x(), computedBounds.y(), |
| 343 computedBounds.width(), computedBounds.height()); | 346 computedBounds.width(), computedBounds.height()); |
| 344 } | 347 } |
| 345 | 348 |
| 346 blink::WebRect BoundsForCharacter(const blink::WebAXObject& object, | 349 blink::WebRect BoundsForCharacter(const blink::WebAXObject& object, |
| 347 int characterIndex) { | 350 int characterIndex) { |
| 348 DCHECK_EQ(object.Role(), blink::kWebAXRoleStaticText); | 351 DCHECK_EQ(object.Role(), blink::kWebAXRoleStaticText); |
| 349 int end = 0; | 352 int end = 0; |
| 350 for (unsigned i = 0; i < object.ChildCount(); i++) { | 353 for (unsigned i = 0; i < object.ChildCount(); i++) { |
| (...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 if (index >= descriptionObjects.size()) | 1806 if (index >= descriptionObjects.size()) |
| 1804 return v8::Local<v8::Object>(); | 1807 return v8::Local<v8::Object>(); |
| 1805 return factory_->GetOrCreate(descriptionObjects[index]); | 1808 return factory_->GetOrCreate(descriptionObjects[index]); |
| 1806 } | 1809 } |
| 1807 | 1810 |
| 1808 v8::Local<v8::Object> WebAXObjectProxy::OffsetContainer() { | 1811 v8::Local<v8::Object> WebAXObjectProxy::OffsetContainer() { |
| 1809 accessibility_object_.UpdateLayoutAndCheckValidity(); | 1812 accessibility_object_.UpdateLayoutAndCheckValidity(); |
| 1810 blink::WebAXObject container; | 1813 blink::WebAXObject container; |
| 1811 blink::WebFloatRect bounds; | 1814 blink::WebFloatRect bounds; |
| 1812 SkMatrix44 matrix; | 1815 SkMatrix44 matrix; |
| 1813 accessibility_object_.GetRelativeBounds(container, bounds, matrix); | 1816 bool is_fixed_positioned; |
| 1817 accessibility_object_.GetRelativeBounds(container, bounds, matrix, |
| 1818 is_fixed_positioned); |
| 1814 return factory_->GetOrCreate(container); | 1819 return factory_->GetOrCreate(container); |
| 1815 } | 1820 } |
| 1816 | 1821 |
| 1817 float WebAXObjectProxy::BoundsInContainerX() { | 1822 float WebAXObjectProxy::BoundsInContainerX() { |
| 1818 accessibility_object_.UpdateLayoutAndCheckValidity(); | 1823 accessibility_object_.UpdateLayoutAndCheckValidity(); |
| 1819 blink::WebAXObject container; | 1824 blink::WebAXObject container; |
| 1820 blink::WebFloatRect bounds; | 1825 blink::WebFloatRect bounds; |
| 1821 SkMatrix44 matrix; | 1826 SkMatrix44 matrix; |
| 1822 accessibility_object_.GetRelativeBounds(container, bounds, matrix); | 1827 bool is_fixed_positioned; |
| 1828 accessibility_object_.GetRelativeBounds(container, bounds, matrix, |
| 1829 is_fixed_positioned); |
| 1823 return bounds.x; | 1830 return bounds.x; |
| 1824 } | 1831 } |
| 1825 | 1832 |
| 1826 float WebAXObjectProxy::BoundsInContainerY() { | 1833 float WebAXObjectProxy::BoundsInContainerY() { |
| 1827 accessibility_object_.UpdateLayoutAndCheckValidity(); | 1834 accessibility_object_.UpdateLayoutAndCheckValidity(); |
| 1828 blink::WebAXObject container; | 1835 blink::WebAXObject container; |
| 1829 blink::WebFloatRect bounds; | 1836 blink::WebFloatRect bounds; |
| 1830 SkMatrix44 matrix; | 1837 SkMatrix44 matrix; |
| 1831 accessibility_object_.GetRelativeBounds(container, bounds, matrix); | 1838 bool is_fixed_positioned; |
| 1839 accessibility_object_.GetRelativeBounds(container, bounds, matrix, |
| 1840 is_fixed_positioned); |
| 1832 return bounds.y; | 1841 return bounds.y; |
| 1833 } | 1842 } |
| 1834 | 1843 |
| 1835 float WebAXObjectProxy::BoundsInContainerWidth() { | 1844 float WebAXObjectProxy::BoundsInContainerWidth() { |
| 1836 accessibility_object_.UpdateLayoutAndCheckValidity(); | 1845 accessibility_object_.UpdateLayoutAndCheckValidity(); |
| 1837 blink::WebAXObject container; | 1846 blink::WebAXObject container; |
| 1838 blink::WebFloatRect bounds; | 1847 blink::WebFloatRect bounds; |
| 1839 SkMatrix44 matrix; | 1848 SkMatrix44 matrix; |
| 1840 accessibility_object_.GetRelativeBounds(container, bounds, matrix); | 1849 bool is_fixed_positioned; |
| 1850 accessibility_object_.GetRelativeBounds(container, bounds, matrix, |
| 1851 is_fixed_positioned); |
| 1841 return bounds.width; | 1852 return bounds.width; |
| 1842 } | 1853 } |
| 1843 | 1854 |
| 1844 float WebAXObjectProxy::BoundsInContainerHeight() { | 1855 float WebAXObjectProxy::BoundsInContainerHeight() { |
| 1845 accessibility_object_.UpdateLayoutAndCheckValidity(); | 1856 accessibility_object_.UpdateLayoutAndCheckValidity(); |
| 1846 blink::WebAXObject container; | 1857 blink::WebAXObject container; |
| 1847 blink::WebFloatRect bounds; | 1858 blink::WebFloatRect bounds; |
| 1848 SkMatrix44 matrix; | 1859 SkMatrix44 matrix; |
| 1849 accessibility_object_.GetRelativeBounds(container, bounds, matrix); | 1860 bool is_fixed_positioned; |
| 1861 accessibility_object_.GetRelativeBounds(container, bounds, matrix, |
| 1862 is_fixed_positioned); |
| 1850 return bounds.height; | 1863 return bounds.height; |
| 1851 } | 1864 } |
| 1852 | 1865 |
| 1853 bool WebAXObjectProxy::HasNonIdentityTransform() { | 1866 bool WebAXObjectProxy::HasNonIdentityTransform() { |
| 1854 accessibility_object_.UpdateLayoutAndCheckValidity(); | 1867 accessibility_object_.UpdateLayoutAndCheckValidity(); |
| 1855 accessibility_object_.UpdateLayoutAndCheckValidity(); | 1868 accessibility_object_.UpdateLayoutAndCheckValidity(); |
| 1856 blink::WebAXObject container; | 1869 blink::WebAXObject container; |
| 1857 blink::WebFloatRect bounds; | 1870 blink::WebFloatRect bounds; |
| 1858 SkMatrix44 matrix; | 1871 SkMatrix44 matrix; |
| 1859 accessibility_object_.GetRelativeBounds(container, bounds, matrix); | 1872 bool is_fixed_positioned; |
| 1873 accessibility_object_.GetRelativeBounds(container, bounds, matrix, |
| 1874 is_fixed_positioned); |
| 1860 return !matrix.isIdentity(); | 1875 return !matrix.isIdentity(); |
| 1861 } | 1876 } |
| 1862 | 1877 |
| 1863 RootWebAXObjectProxy::RootWebAXObjectProxy(const blink::WebAXObject& object, | 1878 RootWebAXObjectProxy::RootWebAXObjectProxy(const blink::WebAXObject& object, |
| 1864 Factory* factory) | 1879 Factory* factory) |
| 1865 : WebAXObjectProxy(object, factory) {} | 1880 : WebAXObjectProxy(object, factory) {} |
| 1866 | 1881 |
| 1867 v8::Local<v8::Object> RootWebAXObjectProxy::GetChildAtIndex(unsigned index) { | 1882 v8::Local<v8::Object> RootWebAXObjectProxy::GetChildAtIndex(unsigned index) { |
| 1868 if (index) | 1883 if (index) |
| 1869 return v8::Local<v8::Object>(); | 1884 return v8::Local<v8::Object>(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 v8::Local<v8::Value> value_handle = | 1933 v8::Local<v8::Value> value_handle = |
| 1919 gin::CreateHandle(isolate, new WebAXObjectProxy(object, this)).ToV8(); | 1934 gin::CreateHandle(isolate, new WebAXObjectProxy(object, this)).ToV8(); |
| 1920 if (value_handle.IsEmpty()) | 1935 if (value_handle.IsEmpty()) |
| 1921 return v8::Local<v8::Object>(); | 1936 return v8::Local<v8::Object>(); |
| 1922 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); | 1937 v8::Local<v8::Object> handle = value_handle->ToObject(isolate); |
| 1923 elements_.Append(handle); | 1938 elements_.Append(handle); |
| 1924 return handle; | 1939 return handle; |
| 1925 } | 1940 } |
| 1926 | 1941 |
| 1927 } // namespace test_runner | 1942 } // namespace test_runner |
| OLD | NEW |