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

Side by Side Diff: Source/core/accessibility/AXRenderObject.cpp

Issue 23983002: Expose InlineTextBoxes in the accessibility tree. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/accessibility/AXRenderObject.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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/AXRenderObject.h" 30 #include "core/accessibility/AXRenderObject.h"
31 31
32 #include "bindings/v8/ExceptionStatePlaceholder.h" 32 #include "bindings/v8/ExceptionStatePlaceholder.h"
33 #include "core/accessibility/AXImageMapLink.h" 33 #include "core/accessibility/AXImageMapLink.h"
34 #include "core/accessibility/AXInlineTextBox.h"
34 #include "core/accessibility/AXObjectCache.h" 35 #include "core/accessibility/AXObjectCache.h"
35 #include "core/accessibility/AXSVGRoot.h" 36 #include "core/accessibility/AXSVGRoot.h"
36 #include "core/accessibility/AXSpinButton.h" 37 #include "core/accessibility/AXSpinButton.h"
37 #include "core/accessibility/AXTable.h" 38 #include "core/accessibility/AXTable.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 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 1467
1466 for (RefPtr<AXObject> obj = firstChild(); obj; obj = obj->nextSibling()) 1468 for (RefPtr<AXObject> obj = firstChild(); obj; obj = obj->nextSibling())
1467 addChild(obj.get()); 1469 addChild(obj.get());
1468 1470
1469 addHiddenChildren(); 1471 addHiddenChildren();
1470 addAttachmentChildren(); 1472 addAttachmentChildren();
1471 addImageMapChildren(); 1473 addImageMapChildren();
1472 addTextFieldChildren(); 1474 addTextFieldChildren();
1473 addCanvasChildren(); 1475 addCanvasChildren();
1474 addRemoteSVGChildren(); 1476 addRemoteSVGChildren();
1477 addInlineTextBoxChildren();
1475 } 1478 }
1476 1479
1477 bool AXRenderObject::canHaveChildren() const 1480 bool AXRenderObject::canHaveChildren() const
1478 { 1481 {
1479 if (!m_renderer) 1482 if (!m_renderer)
1480 return false; 1483 return false;
1481 1484
1482 return AXNodeObject::canHaveChildren(); 1485 return AXNodeObject::canHaveChildren();
1483 } 1486 }
1484 1487
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 1731
1729 // Post that the row count changed. 1732 // Post that the row count changed.
1730 if (containerParent) 1733 if (containerParent)
1731 axObjectCache()->postNotification(containerParent, document(), AXObjectC ache::AXRowCountChanged, true); 1734 axObjectCache()->postNotification(containerParent, document(), AXObjectC ache::AXRowCountChanged, true);
1732 1735
1733 // Post that the specific row either collapsed or expanded. 1736 // Post that the specific row either collapsed or expanded.
1734 if (roleValue() == RowRole || roleValue() == TreeItemRole) 1737 if (roleValue() == RowRole || roleValue() == TreeItemRole)
1735 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true); 1738 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true);
1736 } 1739 }
1737 1740
1741 void AXRenderObject::textChanged()
1742 {
1743 if (!m_renderer)
1744 return;
1745
1746 if (AXObjectCache::inlineTextBoxAccessibility() && roleValue() == StaticText Role)
1747 childrenChanged();
1748
1749 // Do this last - AXNodeObject::textChanged posts live region announcements,
1750 // and we should update the inline text boxes first.
1751 AXNodeObject::textChanged();
1752 }
1753
1738 // 1754 //
1739 // Text metrics. Most of these should be deprecated, needs major cleanup. 1755 // Text metrics. Most of these should be deprecated, needs major cleanup.
1740 // 1756 //
1741 1757
1742 // NOTE: Consider providing this utility method as AX API 1758 // NOTE: Consider providing this utility method as AX API
1743 int AXRenderObject::index(const VisiblePosition& position) const 1759 int AXRenderObject::index(const VisiblePosition& position) const
1744 { 1760 {
1745 if (position.isNull() || !isTextControl()) 1761 if (position.isNull() || !isTextControl())
1746 return -1; 1762 return -1;
1747 1763
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable AXRole) != node) 1811 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable AXRole) != node)
1796 return 0; 1812 return 0;
1797 1813
1798 RefPtr<Range> range = Range::create(m_renderer->document()); 1814 RefPtr<Range> range = Range::create(m_renderer->document());
1799 range->setStart(node, 0, IGNORE_EXCEPTION); 1815 range->setStart(node, 0, IGNORE_EXCEPTION);
1800 range->setEnd(indexPosition, IGNORE_EXCEPTION); 1816 range->setEnd(indexPosition, IGNORE_EXCEPTION);
1801 1817
1802 return TextIterator::rangeLength(range.get()); 1818 return TextIterator::rangeLength(range.get());
1803 } 1819 }
1804 1820
1821 void AXRenderObject::addInlineTextBoxChildren()
1822 {
1823 if (!axObjectCache()->inlineTextBoxAccessibility())
1824 return;
1825
1826 if (!renderer() || !renderer()->isText())
1827 return;
1828
1829 RenderText* renderText = toRenderText(renderer());
1830 if (renderText->needsLayout())
1831 renderText->document().updateLayoutIgnorePendingStylesheets();
1832
1833 for (RefPtr<AbstractInlineTextBox> box = renderText->firstAbstractInlineText Box(); box.get(); box = box->nextInlineTextBox()) {
1834 AXObject* axObject = axObjectCache()->getOrCreate(box.get());
1835 if (!axObject->accessibilityIsIgnored())
1836 m_children.append(axObject);
1837 }
1838 }
1839
1805 void AXRenderObject::lineBreaks(Vector<int>& lineBreaks) const 1840 void AXRenderObject::lineBreaks(Vector<int>& lineBreaks) const
1806 { 1841 {
1807 if (!isTextControl()) 1842 if (!isTextControl())
1808 return; 1843 return;
1809 1844
1810 VisiblePosition visiblePos = visiblePositionForIndex(0); 1845 VisiblePosition visiblePos = visiblePositionForIndex(0);
1811 VisiblePosition savedVisiblePos = visiblePos; 1846 VisiblePosition savedVisiblePos = visiblePos;
1812 visiblePos = nextLinePosition(visiblePos, 0); 1847 visiblePos = nextLinePosition(visiblePos, 0);
1813 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { 1848 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) {
1814 lineBreaks.append(indexForVisiblePosition(visiblePos)); 1849 lineBreaks.append(indexForVisiblePosition(visiblePos));
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 if (label && label->renderer()) { 2410 if (label && label->renderer()) {
2376 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2411 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2377 result.unite(labelRect); 2412 result.unite(labelRect);
2378 } 2413 }
2379 } 2414 }
2380 2415
2381 return result; 2416 return result;
2382 } 2417 }
2383 2418
2384 } // namespace WebCore 2419 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/accessibility/AXRenderObject.h ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698