Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 2169273004: Switch all LayoutTests to use new accessibility relative bounding box API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix absolute bounds in AXInlineTextBox::elementRect Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 if (toLabelableElement(htmlElement)->labels() && toLabelableElement(html Element)->labels()->length() > 0) 1758 if (toLabelableElement(htmlElement)->labels() && toLabelableElement(html Element)->labels()->length() > 0)
1759 return true; 1759 return true;
1760 } 1760 }
1761 1761
1762 return false; 1762 return false;
1763 } 1763 }
1764 1764
1765 LayoutRect AXNodeObject::elementRect() const 1765 LayoutRect AXNodeObject::elementRect() const
1766 { 1766 {
1767 // First check if it has a custom rect, for example if this element is tied to a canvas path. 1767 // First check if it has a custom rect, for example if this element is tied to a canvas path.
1768 if (!m_explicitElementRect.isEmpty()) 1768 if (!m_explicitElementRect.isEmpty()) {
1769 return m_explicitElementRect; 1769 LayoutRect bounds = m_explicitElementRect;
1770 AXObject* canvas = axObjectCache().objectFromAXID(m_explicitContainerID) ;
1771 if (canvas)
1772 bounds.moveBy(canvas->elementRect().location());
1773 return bounds;
1774 }
1770 1775
1771 // FIXME: If there are a lot of elements in the canvas, it will be inefficie nt. 1776 // FIXME: If there are a lot of elements in the canvas, it will be inefficie nt.
1772 // We can avoid the inefficient calculations by using AXComputedObjectAttrib uteCache. 1777 // We can avoid the inefficient calculations by using AXComputedObjectAttrib uteCache.
1773 if (getNode()->parentElement()->isInCanvasSubtree()) { 1778 if (getNode()->parentElement()->isInCanvasSubtree()) {
1774 LayoutRect rect; 1779 LayoutRect rect;
1775 1780
1776 for (Node& child : NodeTraversal::childrenOf(*getNode())) { 1781 for (Node& child : NodeTraversal::childrenOf(*getNode())) {
1777 if (child.isHTMLElement()) { 1782 if (child.isHTMLElement()) {
1778 if (AXObject* obj = axObjectCache().get(&child)) { 1783 if (AXObject* obj = axObjectCache().get(&child)) {
1779 if (rect.isEmpty()) 1784 if (rect.isEmpty())
(...skipping 19 matching lines...) Expand all
1799 LayoutRect parentRect = positionProvider->elementRect(); 1804 LayoutRect parentRect = positionProvider->elementRect();
1800 boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::m in(10.0f, parentRect.height().toFloat())))); 1805 boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::m in(10.0f, parentRect.height().toFloat()))));
1801 boundingBox.setLocation(parentRect.location()); 1806 boundingBox.setLocation(parentRect.location());
1802 break; 1807 break;
1803 } 1808 }
1804 } 1809 }
1805 1810
1806 return boundingBox; 1811 return boundingBox;
1807 } 1812 }
1808 1813
1814 void AXNodeObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBoun dsInContainer, SkMatrix44& outContainerTransform) const
1815 {
1816 *outContainer = nullptr;
1817 outBoundsInContainer = FloatRect();
1818 outContainerTransform.setIdentity();
1819
1820 // First check if it has explicit bounds, for example if this element is tie d to a
1821 // canvas path. When explicit coordinates are provided, the ID of the explic it container
1822 // element that the coordinates are relative to must be provided too.
1823 if (!m_explicitElementRect.isEmpty()) {
1824 *outContainer = axObjectCache().objectFromAXID(m_explicitContainerID);
1825 if (*outContainer) {
1826 outBoundsInContainer = FloatRect(m_explicitElementRect);
1827 return;
1828 }
1829 }
1830
1831 // If it's in a canvas but doesn't have an explicit rect, get the bounding r ect of its children.
1832 if (getNode()->parentElement()->isInCanvasSubtree()) {
1833 Vector<FloatRect> rects;
1834 for (Node& child : NodeTraversal::childrenOf(*getNode())) {
1835 if (child.isHTMLElement()) {
1836 if (AXObject* obj = axObjectCache().get(&child)) {
1837 AXObject* container;
1838 FloatRect bounds;
1839 obj->getRelativeBounds(&container, bounds, outContainerTrans form);
1840 if (container) {
1841 *outContainer = container;
1842 rects.append(bounds);
1843 }
1844 }
1845 }
1846 }
1847
1848 if (*outContainer) {
1849 outBoundsInContainer = unionRect(rects);
1850 return;
1851 }
1852 }
1853
1854 // If this object doesn't have an explicit element rect or computable from i ts children,
1855 // for now, let's return the position of the ancestor that does have a posit ion,
1856 // and make it the width of that parent, and about the height of a line of t ext, so that
1857 // it's clear the object is a child of the parent.
1858 for (AXObject* positionProvider = parentObject(); positionProvider; position Provider = positionProvider->parentObject()) {
1859 if (positionProvider->isAXLayoutObject()) {
1860 positionProvider->getRelativeBounds(outContainer, outBoundsInContain er, outContainerTransform);
1861 if (*outContainer)
1862 outBoundsInContainer.setSize(FloatSize(outBoundsInContainer.widt h(), std::min(10.0f, outBoundsInContainer.height())));
1863 break;
1864 }
1865 }
1866 }
1867
1809 static Node* getParentNodeForComputeParent(Node* node) 1868 static Node* getParentNodeForComputeParent(Node* node)
1810 { 1869 {
1811 if (!node) 1870 if (!node)
1812 return nullptr; 1871 return nullptr;
1813 1872
1814 Node* parentNode = nullptr; 1873 Node* parentNode = nullptr;
1815 1874
1816 // Skip over <optgroup> and consider the <select> the immediate parent of an <option>. 1875 // Skip over <optgroup> and consider the <select> the immediate parent of an <option>.
1817 if (isHTMLOptionElement(node)) 1876 if (isHTMLOptionElement(node))
1818 parentNode = toHTMLOptionElement(node)->ownerSelectElement(); 1877 parentNode = toHTMLOptionElement(node)->ownerSelectElement();
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 return placeholder; 2900 return placeholder;
2842 } 2901 }
2843 2902
2844 DEFINE_TRACE(AXNodeObject) 2903 DEFINE_TRACE(AXNodeObject)
2845 { 2904 {
2846 visitor->trace(m_node); 2905 visitor->trace(m_node);
2847 AXObject::trace(visitor); 2906 AXObject::trace(visitor);
2848 } 2907 }
2849 2908
2850 } // namespace blink 2909 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698