Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 a custom rect, for example if this element is tied to a canvas path. | |
| 1821 if (!m_explicitElementRect.isEmpty()) { | |
| 1822 *outContainer = axObjectCache().objectFromAXID(m_explicitContainerID); | |
| 1823 if (*outContainer) { | |
| 1824 outBoundsInContainer = FloatRect(m_explicitElementRect); | |
| 1825 return; | |
| 1826 } | |
| 1827 } | |
| 1828 | |
| 1829 // If it's in a canvas but doesn't have an explicit rect, get the bounding r ect of its children. | |
| 1830 if (getNode()->parentElement()->isInCanvasSubtree()) { | |
| 1831 Vector<FloatRect> rects; | |
| 1832 for (Node& child : NodeTraversal::childrenOf(*getNode())) { | |
| 1833 if (child.isHTMLElement()) { | |
| 1834 if (AXObject* obj = axObjectCache().get(&child)) { | |
| 1835 AXObject* container; | |
| 1836 FloatRect bounds; | |
| 1837 obj->getRelativeBounds(&container, bounds, outContainerTrans form); | |
| 1838 if (container) { | |
| 1839 *outContainer = container; | |
| 1840 rects.append(bounds); | |
| 1841 } | |
| 1842 } | |
| 1843 } | |
| 1844 } | |
| 1845 | |
| 1846 if (*outContainer) { | |
| 1847 outBoundsInContainer = unionRect(rects); | |
| 1848 return; | |
| 1849 } | |
| 1850 } | |
| 1851 | |
| 1852 // If this object doesn't have an explicit element rect or computable from i ts children, | |
| 1853 // for now, let's return the position of the ancestor that does have a posit ion, | |
| 1854 // and make it the width of that parent, and about the height of a line of t ext, so that | |
| 1855 // it's clear the object is a child of the parent. | |
| 1856 for (AXObject* positionProvider = parentObject(); positionProvider; position Provider = positionProvider->parentObject()) { | |
| 1857 if (positionProvider->isAXLayoutObject()) { | |
| 1858 positionProvider->getRelativeBounds(outContainer, outBoundsInContain er, outContainerTransform); | |
| 1859 if (*outContainer) | |
| 1860 outBoundsInContainer.setSize(FloatSize(outBoundsInContainer.widt h(), std::min(10.0f, outBoundsInContainer.height()))); | |
|
aboxhall
2016/07/28 18:40:43
Is there a test for this behaviour?
dmazzoni
2016/07/28 21:43:16
Yes, this was covered by existing canvas accessibi
| |
| 1861 break; | |
| 1862 } | |
| 1863 } | |
| 1864 } | |
| 1865 | |
| 1809 static Node* getParentNodeForComputeParent(Node* node) | 1866 static Node* getParentNodeForComputeParent(Node* node) |
| 1810 { | 1867 { |
| 1811 if (!node) | 1868 if (!node) |
| 1812 return nullptr; | 1869 return nullptr; |
| 1813 | 1870 |
| 1814 Node* parentNode = nullptr; | 1871 Node* parentNode = nullptr; |
| 1815 | 1872 |
| 1816 // Skip over <optgroup> and consider the <select> the immediate parent of an <option>. | 1873 // Skip over <optgroup> and consider the <select> the immediate parent of an <option>. |
| 1817 if (isHTMLOptionElement(node)) | 1874 if (isHTMLOptionElement(node)) |
| 1818 parentNode = toHTMLOptionElement(node)->ownerSelectElement(); | 1875 parentNode = toHTMLOptionElement(node)->ownerSelectElement(); |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2841 return placeholder; | 2898 return placeholder; |
| 2842 } | 2899 } |
| 2843 | 2900 |
| 2844 DEFINE_TRACE(AXNodeObject) | 2901 DEFINE_TRACE(AXNodeObject) |
| 2845 { | 2902 { |
| 2846 visitor->trace(m_node); | 2903 visitor->trace(m_node); |
| 2847 AXObject::trace(visitor); | 2904 AXObject::trace(visitor); |
| 2848 } | 2905 } |
| 2849 | 2906 |
| 2850 } // namespace blink | 2907 } // namespace blink |
| OLD | NEW |