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 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 if (getNode()->isHTMLElement()) | 1785 if (getNode()->isHTMLElement()) |
1786 htmlElement = toHTMLElement(getNode()); | 1786 htmlElement = toHTMLElement(getNode()); |
1787 if (htmlElement && isLabelableElement(htmlElement)) { | 1787 if (htmlElement && isLabelableElement(htmlElement)) { |
1788 if (toLabelableElement(htmlElement)->labels() && toLabelableElement(html
Element)->labels()->length() > 0) | 1788 if (toLabelableElement(htmlElement)->labels() && toLabelableElement(html
Element)->labels()->length() > 0) |
1789 return true; | 1789 return true; |
1790 } | 1790 } |
1791 | 1791 |
1792 return false; | 1792 return false; |
1793 } | 1793 } |
1794 | 1794 |
1795 LayoutRect AXNodeObject::elementRect() const | |
1796 { | |
1797 // First check if it has a custom rect, for example if this element is tied
to a canvas path. | |
1798 if (!m_explicitElementRect.isEmpty()) { | |
1799 LayoutRect bounds = m_explicitElementRect; | |
1800 AXObject* canvas = axObjectCache().objectFromAXID(m_explicitContainerID)
; | |
1801 if (canvas) | |
1802 bounds.moveBy(canvas->elementRect().location()); | |
1803 return bounds; | |
1804 } | |
1805 | |
1806 // FIXME: If there are a lot of elements in the canvas, it will be inefficie
nt. | |
1807 // We can avoid the inefficient calculations by using AXComputedObjectAttrib
uteCache. | |
1808 if (getNode()->parentElement()->isInCanvasSubtree()) { | |
1809 LayoutRect rect; | |
1810 | |
1811 for (Node& child : NodeTraversal::childrenOf(*getNode())) { | |
1812 if (child.isHTMLElement()) { | |
1813 if (AXObject* obj = axObjectCache().get(&child)) { | |
1814 if (rect.isEmpty()) | |
1815 rect = obj->elementRect(); | |
1816 else | |
1817 rect.unite(obj->elementRect()); | |
1818 } | |
1819 } | |
1820 } | |
1821 | |
1822 if (!rect.isEmpty()) | |
1823 return rect; | |
1824 } | |
1825 | |
1826 // If this object doesn't have an explicit element rect or computable from i
ts children, | |
1827 // for now, let's return the position of the ancestor that does have a posit
ion, | |
1828 // and make it the width of that parent, and about the height of a line of t
ext, so that it's clear the object is a child of the parent. | |
1829 | |
1830 LayoutRect boundingBox; | |
1831 | |
1832 for (AXObject* positionProvider = parentObject(); positionProvider; position
Provider = positionProvider->parentObject()) { | |
1833 if (positionProvider->isAXLayoutObject()) { | |
1834 LayoutRect parentRect = positionProvider->elementRect(); | |
1835 boundingBox.setSize(LayoutSize(parentRect.width(), LayoutUnit(std::m
in(10.0f, parentRect.height().toFloat())))); | |
1836 boundingBox.setLocation(parentRect.location()); | |
1837 break; | |
1838 } | |
1839 } | |
1840 | |
1841 return boundingBox; | |
1842 } | |
1843 | |
1844 void AXNodeObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBoun
dsInContainer, SkMatrix44& outContainerTransform) const | 1795 void AXNodeObject::getRelativeBounds(AXObject** outContainer, FloatRect& outBoun
dsInContainer, SkMatrix44& outContainerTransform) const |
1845 { | 1796 { |
| 1797 if (layoutObjectForRelativeBounds()) { |
| 1798 AXObject::getRelativeBounds(outContainer, outBoundsInContainer, outConta
inerTransform); |
| 1799 return; |
| 1800 } |
| 1801 |
1846 *outContainer = nullptr; | 1802 *outContainer = nullptr; |
1847 outBoundsInContainer = FloatRect(); | 1803 outBoundsInContainer = FloatRect(); |
1848 outContainerTransform.setIdentity(); | 1804 outContainerTransform.setIdentity(); |
1849 | 1805 |
1850 // First check if it has explicit bounds, for example if this element is tie
d to a | 1806 // First check if it has explicit bounds, for example if this element is tie
d to a |
1851 // canvas path. When explicit coordinates are provided, the ID of the explic
it container | 1807 // canvas path. When explicit coordinates are provided, the ID of the explic
it container |
1852 // element that the coordinates are relative to must be provided too. | 1808 // element that the coordinates are relative to must be provided too. |
1853 if (!m_explicitElementRect.isEmpty()) { | 1809 if (!m_explicitElementRect.isEmpty()) { |
1854 *outContainer = axObjectCache().objectFromAXID(m_explicitContainerID); | 1810 *outContainer = axObjectCache().objectFromAXID(m_explicitContainerID); |
1855 if (*outContainer) { | 1811 if (*outContainer) { |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2929 return placeholder; | 2885 return placeholder; |
2930 } | 2886 } |
2931 | 2887 |
2932 DEFINE_TRACE(AXNodeObject) | 2888 DEFINE_TRACE(AXNodeObject) |
2933 { | 2889 { |
2934 visitor->trace(m_node); | 2890 visitor->trace(m_node); |
2935 AXObject::trace(visitor); | 2891 AXObject::trace(visitor); |
2936 } | 2892 } |
2937 | 2893 |
2938 } // namespace blink | 2894 } // namespace blink |
OLD | NEW |