Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple 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 14 matching lines...) Expand all Loading... | |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/accessibility/AccessibilityRenderObject.h" | 30 #include "core/accessibility/AccessibilityRenderObject.h" |
| 31 | 31 |
| 32 #include "bindings/v8/ExceptionStatePlaceholder.h" | 32 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 33 #include "core/accessibility/AXObjectCache.h" | 33 #include "core/accessibility/AXObjectCache.h" |
| 34 #include "core/accessibility/AccessibilityImageMapLink.h" | 34 #include "core/accessibility/AccessibilityImageMapLink.h" |
| 35 #include "core/accessibility/AccessibilityInlineTextBox.h" | |
| 35 #include "core/accessibility/AccessibilitySVGRoot.h" | 36 #include "core/accessibility/AccessibilitySVGRoot.h" |
| 36 #include "core/accessibility/AccessibilitySpinButton.h" | 37 #include "core/accessibility/AccessibilitySpinButton.h" |
| 37 #include "core/accessibility/AccessibilityTable.h" | 38 #include "core/accessibility/AccessibilityTable.h" |
| 38 #include "core/dom/ElementTraversal.h" | 39 #include "core/dom/ElementTraversal.h" |
| 39 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
| 40 #include "core/editing/FrameSelection.h" | 41 #include "core/editing/FrameSelection.h" |
| 41 #include "core/editing/RenderedPosition.h" | 42 #include "core/editing/RenderedPosition.h" |
| 42 #include "core/editing/VisibleUnits.h" | 43 #include "core/editing/VisibleUnits.h" |
| 43 #include "core/editing/htmlediting.h" | 44 #include "core/editing/htmlediting.h" |
| 44 #include "core/frame/Frame.h" | 45 #include "core/frame/Frame.h" |
| 45 #include "core/html/HTMLHtmlElement.h" | 46 #include "core/html/HTMLHtmlElement.h" |
| 46 #include "core/html/HTMLImageElement.h" | 47 #include "core/html/HTMLImageElement.h" |
| 47 #include "core/html/HTMLLabelElement.h" | 48 #include "core/html/HTMLLabelElement.h" |
| 48 #include "core/html/HTMLOptionElement.h" | 49 #include "core/html/HTMLOptionElement.h" |
| 49 #include "core/html/HTMLSelectElement.h" | 50 #include "core/html/HTMLSelectElement.h" |
| 50 #include "core/html/HTMLTextAreaElement.h" | 51 #include "core/html/HTMLTextAreaElement.h" |
| 51 #include "core/html/shadow/ShadowElementNames.h" | 52 #include "core/html/shadow/ShadowElementNames.h" |
| 52 #include "core/loader/ProgressTracker.h" | 53 #include "core/loader/ProgressTracker.h" |
| 53 #include "core/page/Page.h" | 54 #include "core/page/Page.h" |
| 54 #include "core/rendering/HitTestResult.h" | 55 #include "core/rendering/HitTestResult.h" |
| 56 #include "core/rendering/RenderFieldset.h" | |
| 55 #include "core/rendering/RenderFileUploadControl.h" | 57 #include "core/rendering/RenderFileUploadControl.h" |
| 56 #include "core/rendering/RenderHTMLCanvas.h" | 58 #include "core/rendering/RenderHTMLCanvas.h" |
| 57 #include "core/rendering/RenderImage.h" | 59 #include "core/rendering/RenderImage.h" |
| 58 #include "core/rendering/RenderInline.h" | 60 #include "core/rendering/RenderInline.h" |
| 59 #include "core/rendering/RenderLayer.h" | 61 #include "core/rendering/RenderLayer.h" |
| 60 #include "core/rendering/RenderListMarker.h" | 62 #include "core/rendering/RenderListMarker.h" |
| 61 #include "core/rendering/RenderMenuList.h" | 63 #include "core/rendering/RenderMenuList.h" |
| 62 #include "core/rendering/RenderTextControlSingleLine.h" | 64 #include "core/rendering/RenderTextControlSingleLine.h" |
| 63 #include "core/rendering/RenderTextFragment.h" | 65 #include "core/rendering/RenderTextFragment.h" |
| 64 #include "core/rendering/RenderView.h" | 66 #include "core/rendering/RenderView.h" |
| (...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1466 | 1468 |
| 1467 for (RefPtr<AccessibilityObject> obj = firstChild(); obj; obj = obj->nextSib ling()) | 1469 for (RefPtr<AccessibilityObject> obj = firstChild(); obj; obj = obj->nextSib ling()) |
| 1468 addChild(obj.get()); | 1470 addChild(obj.get()); |
| 1469 | 1471 |
| 1470 addHiddenChildren(); | 1472 addHiddenChildren(); |
| 1471 addAttachmentChildren(); | 1473 addAttachmentChildren(); |
| 1472 addImageMapChildren(); | 1474 addImageMapChildren(); |
| 1473 addTextFieldChildren(); | 1475 addTextFieldChildren(); |
| 1474 addCanvasChildren(); | 1476 addCanvasChildren(); |
| 1475 addRemoteSVGChildren(); | 1477 addRemoteSVGChildren(); |
| 1478 addInlineTextBoxChildren(); | |
| 1476 } | 1479 } |
| 1477 | 1480 |
| 1478 bool AccessibilityRenderObject::canHaveChildren() const | 1481 bool AccessibilityRenderObject::canHaveChildren() const |
| 1479 { | 1482 { |
| 1480 if (!m_renderer) | 1483 if (!m_renderer) |
| 1481 return false; | 1484 return false; |
| 1482 | 1485 |
| 1483 return AccessibilityNodeObject::canHaveChildren(); | 1486 return AccessibilityNodeObject::canHaveChildren(); |
| 1484 } | 1487 } |
| 1485 | 1488 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1732 | 1735 |
| 1733 // Post that the row count changed. | 1736 // Post that the row count changed. |
| 1734 if (containerParent) | 1737 if (containerParent) |
| 1735 axObjectCache()->postNotification(containerParent, document(), AXObjectC ache::AXRowCountChanged, true); | 1738 axObjectCache()->postNotification(containerParent, document(), AXObjectC ache::AXRowCountChanged, true); |
| 1736 | 1739 |
| 1737 // Post that the specific row either collapsed or expanded. | 1740 // Post that the specific row either collapsed or expanded. |
| 1738 if (roleValue() == RowRole || roleValue() == TreeItemRole) | 1741 if (roleValue() == RowRole || roleValue() == TreeItemRole) |
| 1739 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true); | 1742 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true); |
| 1740 } | 1743 } |
| 1741 | 1744 |
| 1745 void AccessibilityRenderObject::textChanged() | |
| 1746 { | |
| 1747 if (!m_renderer) | |
| 1748 return; | |
| 1749 | |
| 1750 if (AXObjectCache::inlineTextBoxAccessibility() && roleValue() == StaticText Role) | |
| 1751 childrenChanged(); | |
| 1752 | |
| 1753 AccessibilityNodeObject::textChanged(); | |
| 1754 } | |
| 1755 | |
| 1742 // | 1756 // |
| 1743 // Text metrics. Most of these should be deprecated, needs major cleanup. | 1757 // Text metrics. Most of these should be deprecated, needs major cleanup. |
| 1744 // | 1758 // |
| 1745 | 1759 |
| 1746 // NOTE: Consider providing this utility method as AX API | 1760 // NOTE: Consider providing this utility method as AX API |
| 1747 int AccessibilityRenderObject::index(const VisiblePosition& position) const | 1761 int AccessibilityRenderObject::index(const VisiblePosition& position) const |
| 1748 { | 1762 { |
| 1749 if (position.isNull() || !isTextControl()) | 1763 if (position.isNull() || !isTextControl()) |
| 1750 return -1; | 1764 return -1; |
| 1751 | 1765 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1799 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable AXRole) != node) | 1813 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable AXRole) != node) |
| 1800 return 0; | 1814 return 0; |
| 1801 | 1815 |
| 1802 RefPtr<Range> range = Range::create(m_renderer->document()); | 1816 RefPtr<Range> range = Range::create(m_renderer->document()); |
| 1803 range->setStart(node, 0, IGNORE_EXCEPTION); | 1817 range->setStart(node, 0, IGNORE_EXCEPTION); |
| 1804 range->setEnd(indexPosition, IGNORE_EXCEPTION); | 1818 range->setEnd(indexPosition, IGNORE_EXCEPTION); |
| 1805 | 1819 |
| 1806 return TextIterator::rangeLength(range.get()); | 1820 return TextIterator::rangeLength(range.get()); |
| 1807 } | 1821 } |
| 1808 | 1822 |
| 1823 void AccessibilityRenderObject::addInlineTextBoxChildren() | |
| 1824 { | |
| 1825 if (!axObjectCache()->inlineTextBoxAccessibility()) | |
| 1826 return; | |
| 1827 | |
| 1828 if (!renderer() || !renderer()->isText()) | |
| 1829 return; | |
| 1830 | |
| 1831 RenderText* renderText = toRenderText(renderer()); | |
| 1832 if (renderText->needsLayout()) | |
| 1833 renderText->document().updateLayoutIgnorePendingStylesheets(); | |
| 1834 | |
| 1835 for (RefPtr<AbstractInlineTextBox> box = renderText->firstAbstractInlineText Box(); box.get(); box = box->nextInlineTextBox()) { | |
|
eseidel
2013/10/17 18:43:26
This may be alot of mallocs. :) But this looks re
dmazzoni
2013/10/17 20:39:20
As long as it's constant in terms of the total num
| |
| 1836 AccessibilityObject* axObject = axObjectCache()->getOrCreate(box.get()); | |
| 1837 if (!axObject->accessibilityIsIgnored()) | |
| 1838 m_children.append(axObject); | |
| 1839 } | |
| 1840 } | |
| 1841 | |
| 1809 void AccessibilityRenderObject::lineBreaks(Vector<int>& lineBreaks) const | 1842 void AccessibilityRenderObject::lineBreaks(Vector<int>& lineBreaks) const |
| 1810 { | 1843 { |
| 1811 if (!isTextControl()) | 1844 if (!isTextControl()) |
| 1812 return; | 1845 return; |
| 1813 | 1846 |
| 1814 VisiblePosition visiblePos = visiblePositionForIndex(0); | 1847 VisiblePosition visiblePos = visiblePositionForIndex(0); |
| 1815 VisiblePosition savedVisiblePos = visiblePos; | 1848 VisiblePosition savedVisiblePos = visiblePos; |
| 1816 visiblePos = nextLinePosition(visiblePos, 0); | 1849 visiblePos = nextLinePosition(visiblePos, 0); |
| 1817 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { | 1850 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { |
| 1818 lineBreaks.append(indexForVisiblePosition(visiblePos)); | 1851 lineBreaks.append(indexForVisiblePosition(visiblePos)); |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2379 if (label && label->renderer()) { | 2412 if (label && label->renderer()) { |
| 2380 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); | 2413 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); |
| 2381 result.unite(labelRect); | 2414 result.unite(labelRect); |
| 2382 } | 2415 } |
| 2383 } | 2416 } |
| 2384 | 2417 |
| 2385 return result; | 2418 return result; |
| 2386 } | 2419 } |
| 2387 | 2420 |
| 2388 } // namespace WebCore | 2421 } // namespace WebCore |
| OLD | NEW |