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/html/HTMLHtmlElement.h" | 45 #include "core/html/HTMLHtmlElement.h" |
45 #include "core/html/HTMLImageElement.h" | 46 #include "core/html/HTMLImageElement.h" |
46 #include "core/html/HTMLLabelElement.h" | 47 #include "core/html/HTMLLabelElement.h" |
47 #include "core/html/HTMLOptionElement.h" | 48 #include "core/html/HTMLOptionElement.h" |
48 #include "core/html/HTMLSelectElement.h" | 49 #include "core/html/HTMLSelectElement.h" |
49 #include "core/html/HTMLTextAreaElement.h" | 50 #include "core/html/HTMLTextAreaElement.h" |
50 #include "core/html/shadow/ShadowElementNames.h" | 51 #include "core/html/shadow/ShadowElementNames.h" |
51 #include "core/loader/ProgressTracker.h" | 52 #include "core/loader/ProgressTracker.h" |
52 #include "core/page/Frame.h" | 53 #include "core/page/Frame.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 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 | 1463 |
1462 for (RefPtr<AccessibilityObject> obj = firstChild(); obj; obj = obj->nextSib
ling()) | 1464 for (RefPtr<AccessibilityObject> obj = firstChild(); obj; obj = obj->nextSib
ling()) |
1463 addChild(obj.get()); | 1465 addChild(obj.get()); |
1464 | 1466 |
1465 addHiddenChildren(); | 1467 addHiddenChildren(); |
1466 addAttachmentChildren(); | 1468 addAttachmentChildren(); |
1467 addImageMapChildren(); | 1469 addImageMapChildren(); |
1468 addTextFieldChildren(); | 1470 addTextFieldChildren(); |
1469 addCanvasChildren(); | 1471 addCanvasChildren(); |
1470 addRemoteSVGChildren(); | 1472 addRemoteSVGChildren(); |
| 1473 addInlineTextBoxChildren(); |
1471 } | 1474 } |
1472 | 1475 |
1473 bool AccessibilityRenderObject::canHaveChildren() const | 1476 bool AccessibilityRenderObject::canHaveChildren() const |
1474 { | 1477 { |
1475 if (!m_renderer) | 1478 if (!m_renderer) |
1476 return false; | 1479 return false; |
1477 | 1480 |
1478 return AccessibilityNodeObject::canHaveChildren(); | 1481 return AccessibilityNodeObject::canHaveChildren(); |
1479 } | 1482 } |
1480 | 1483 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 | 1730 |
1728 // Post that the row count changed. | 1731 // Post that the row count changed. |
1729 if (containerParent) | 1732 if (containerParent) |
1730 axObjectCache()->postNotification(containerParent, document(), AXObjectC
ache::AXRowCountChanged, true); | 1733 axObjectCache()->postNotification(containerParent, document(), AXObjectC
ache::AXRowCountChanged, true); |
1731 | 1734 |
1732 // Post that the specific row either collapsed or expanded. | 1735 // Post that the specific row either collapsed or expanded. |
1733 if (roleValue() == RowRole || roleValue() == TreeItemRole) | 1736 if (roleValue() == RowRole || roleValue() == TreeItemRole) |
1734 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj
ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true); | 1737 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj
ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true); |
1735 } | 1738 } |
1736 | 1739 |
| 1740 void AccessibilityRenderObject::textChanged() |
| 1741 { |
| 1742 if (!m_renderer) |
| 1743 return; |
| 1744 |
| 1745 if (AXObjectCache::inlineTextBoxAccessibility() && roleValue() == StaticText
Role) |
| 1746 childrenChanged(); |
| 1747 |
| 1748 AccessibilityNodeObject::textChanged(); |
| 1749 } |
| 1750 |
1737 // | 1751 // |
1738 // Text metrics. Most of these should be deprecated, needs major cleanup. | 1752 // Text metrics. Most of these should be deprecated, needs major cleanup. |
1739 // | 1753 // |
1740 | 1754 |
1741 // NOTE: Consider providing this utility method as AX API | 1755 // NOTE: Consider providing this utility method as AX API |
1742 int AccessibilityRenderObject::index(const VisiblePosition& position) const | 1756 int AccessibilityRenderObject::index(const VisiblePosition& position) const |
1743 { | 1757 { |
1744 if (position.isNull() || !isTextControl()) | 1758 if (position.isNull() || !isTextControl()) |
1745 return -1; | 1759 return -1; |
1746 | 1760 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable
AXRole) != node) | 1808 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable
AXRole) != node) |
1795 return 0; | 1809 return 0; |
1796 | 1810 |
1797 RefPtr<Range> range = Range::create(m_renderer->document()); | 1811 RefPtr<Range> range = Range::create(m_renderer->document()); |
1798 range->setStart(node, 0, IGNORE_EXCEPTION); | 1812 range->setStart(node, 0, IGNORE_EXCEPTION); |
1799 range->setEnd(indexPosition, IGNORE_EXCEPTION); | 1813 range->setEnd(indexPosition, IGNORE_EXCEPTION); |
1800 | 1814 |
1801 return TextIterator::rangeLength(range.get()); | 1815 return TextIterator::rangeLength(range.get()); |
1802 } | 1816 } |
1803 | 1817 |
| 1818 void AccessibilityRenderObject::addInlineTextBoxChildren() |
| 1819 { |
| 1820 if (!axObjectCache()->inlineTextBoxAccessibility()) |
| 1821 return; |
| 1822 |
| 1823 if (!renderer() || !renderer()->isText()) |
| 1824 return; |
| 1825 |
| 1826 RenderText* renderText = toRenderText(renderer()); |
| 1827 if (renderText->needsLayout()) |
| 1828 renderText->document().updateLayoutIgnorePendingStylesheets(); |
| 1829 |
| 1830 for (RenderText::AbstractInlineTextBox* box = renderText->firstTextBox(); bo
x; box = renderText->nextInlineTextBox(box)) { |
| 1831 AccessibilityObject* axObject = axObjectCache()->getOrCreate(renderText,
box); |
| 1832 if (!axObject->accessibilityIsIgnored()) |
| 1833 m_children.append(axObject); |
| 1834 } |
| 1835 } |
| 1836 |
1804 void AccessibilityRenderObject::lineBreaks(Vector<int>& lineBreaks) const | 1837 void AccessibilityRenderObject::lineBreaks(Vector<int>& lineBreaks) const |
1805 { | 1838 { |
1806 if (!isTextControl()) | 1839 if (!isTextControl()) |
1807 return; | 1840 return; |
1808 | 1841 |
1809 VisiblePosition visiblePos = visiblePositionForIndex(0); | 1842 VisiblePosition visiblePos = visiblePositionForIndex(0); |
1810 VisiblePosition savedVisiblePos = visiblePos; | 1843 VisiblePosition savedVisiblePos = visiblePos; |
1811 visiblePos = nextLinePosition(visiblePos, 0); | 1844 visiblePos = nextLinePosition(visiblePos, 0); |
1812 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { | 1845 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { |
1813 lineBreaks.append(indexForVisiblePosition(visiblePos)); | 1846 lineBreaks.append(indexForVisiblePosition(visiblePos)); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 if (label && label->renderer()) { | 2408 if (label && label->renderer()) { |
2376 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 2409 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
2377 result.unite(labelRect); | 2410 result.unite(labelRect); |
2378 } | 2411 } |
2379 } | 2412 } |
2380 | 2413 |
2381 return result; | 2414 return result; |
2382 } | 2415 } |
2383 | 2416 |
2384 } // namespace WebCore | 2417 } // namespace WebCore |
OLD | NEW |