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

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

Issue 23983002: Expose InlineTextBoxes in the accessibility tree. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove platform differences from inline-text-textarea output Created 7 years, 3 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
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 14 matching lines...) Expand all
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/Page.h" 53 #include "core/page/Page.h"
53 #include "core/platform/LocalizedStrings.h" 54 #include "core/platform/LocalizedStrings.h"
54 #include "core/rendering/HitTestResult.h" 55 #include "core/rendering/HitTestResult.h"
56 #include "core/rendering/InlineTextBox.h"
57 #include "core/rendering/RenderFieldset.h"
55 #include "core/rendering/RenderFileUploadControl.h" 58 #include "core/rendering/RenderFileUploadControl.h"
56 #include "core/rendering/RenderHTMLCanvas.h" 59 #include "core/rendering/RenderHTMLCanvas.h"
57 #include "core/rendering/RenderImage.h" 60 #include "core/rendering/RenderImage.h"
58 #include "core/rendering/RenderInline.h" 61 #include "core/rendering/RenderInline.h"
59 #include "core/rendering/RenderLayer.h" 62 #include "core/rendering/RenderLayer.h"
60 #include "core/rendering/RenderListMarker.h" 63 #include "core/rendering/RenderListMarker.h"
61 #include "core/rendering/RenderMenuList.h" 64 #include "core/rendering/RenderMenuList.h"
62 #include "core/rendering/RenderTextControlSingleLine.h" 65 #include "core/rendering/RenderTextControlSingleLine.h"
63 #include "core/rendering/RenderTextFragment.h" 66 #include "core/rendering/RenderTextFragment.h"
64 #include "core/rendering/RenderWidget.h" 67 #include "core/rendering/RenderWidget.h"
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 1462
1460 for (RefPtr<AccessibilityObject> obj = firstChild(); obj; obj = obj->nextSib ling()) 1463 for (RefPtr<AccessibilityObject> obj = firstChild(); obj; obj = obj->nextSib ling())
1461 addChild(obj.get()); 1464 addChild(obj.get());
1462 1465
1463 addHiddenChildren(); 1466 addHiddenChildren();
1464 addAttachmentChildren(); 1467 addAttachmentChildren();
1465 addImageMapChildren(); 1468 addImageMapChildren();
1466 addTextFieldChildren(); 1469 addTextFieldChildren();
1467 addCanvasChildren(); 1470 addCanvasChildren();
1468 addRemoteSVGChildren(); 1471 addRemoteSVGChildren();
1472 addInlineTextBoxChildren();
1469 } 1473 }
1470 1474
1471 bool AccessibilityRenderObject::canHaveChildren() const 1475 bool AccessibilityRenderObject::canHaveChildren() const
1472 { 1476 {
1473 if (!m_renderer) 1477 if (!m_renderer)
1474 return false; 1478 return false;
1475 1479
1476 return AccessibilityNodeObject::canHaveChildren(); 1480 return AccessibilityNodeObject::canHaveChildren();
1477 } 1481 }
1478 1482
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 1729
1726 // Post that the row count changed. 1730 // Post that the row count changed.
1727 if (containerParent) 1731 if (containerParent)
1728 axObjectCache()->postNotification(containerParent, document(), AXObjectC ache::AXRowCountChanged, true); 1732 axObjectCache()->postNotification(containerParent, document(), AXObjectC ache::AXRowCountChanged, true);
1729 1733
1730 // Post that the specific row either collapsed or expanded. 1734 // Post that the specific row either collapsed or expanded.
1731 if (roleValue() == RowRole || roleValue() == TreeItemRole) 1735 if (roleValue() == RowRole || roleValue() == TreeItemRole)
1732 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true); 1736 axObjectCache()->postNotification(this, document(), isExpanded() ? AXObj ectCache::AXRowExpanded : AXObjectCache::AXRowCollapsed, true);
1733 } 1737 }
1734 1738
1739 void AccessibilityRenderObject::textChanged()
1740 {
1741 if (!m_renderer)
1742 return;
1743
1744 if (AXObjectCache::inlineTextBoxAccessibility() && roleValue() == StaticText Role)
1745 childrenChanged();
1746
1747 AccessibilityNodeObject::textChanged();
1748 }
1749
1735 // 1750 //
1736 // Text metrics. Most of these should be deprecated, needs major cleanup. 1751 // Text metrics. Most of these should be deprecated, needs major cleanup.
1737 // 1752 //
1738 1753
1739 // NOTE: Consider providing this utility method as AX API 1754 // NOTE: Consider providing this utility method as AX API
1740 int AccessibilityRenderObject::index(const VisiblePosition& position) const 1755 int AccessibilityRenderObject::index(const VisiblePosition& position) const
1741 { 1756 {
1742 if (position.isNull() || !isTextControl()) 1757 if (position.isNull() || !isTextControl())
1743 return -1; 1758 return -1;
1744 1759
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable AXRole) != node) 1807 if (indexPosition.isNull() || highestEditableRoot(indexPosition, HasEditable AXRole) != node)
1793 return 0; 1808 return 0;
1794 1809
1795 RefPtr<Range> range = Range::create(m_renderer->document()); 1810 RefPtr<Range> range = Range::create(m_renderer->document());
1796 range->setStart(node, 0, IGNORE_EXCEPTION); 1811 range->setStart(node, 0, IGNORE_EXCEPTION);
1797 range->setEnd(indexPosition, IGNORE_EXCEPTION); 1812 range->setEnd(indexPosition, IGNORE_EXCEPTION);
1798 1813
1799 return TextIterator::rangeLength(range.get()); 1814 return TextIterator::rangeLength(range.get());
1800 } 1815 }
1801 1816
1817 void AccessibilityRenderObject::addInlineTextBoxChildren()
1818 {
1819 if (!axObjectCache()->inlineTextBoxAccessibility())
1820 return;
1821
1822 if (!renderer() || !renderer()->isText())
1823 return;
1824
1825 RenderText* renderText = toRenderText(renderer());
1826 if (renderText->needsLayout())
1827 renderText->document().updateLayoutIgnorePendingStylesheets();
1828
1829 for (InlineTextBox* box = renderText->firstTextBox(); box; box = box->nextTe xtBox()) {
1830 AccessibilityObject* axObject = axObjectCache()->getOrCreate(box);
1831 if (!axObject->accessibilityIsIgnored())
1832 m_children.append(axObject);
1833 }
1834 }
1835
1802 void AccessibilityRenderObject::lineBreaks(Vector<int>& lineBreaks) const 1836 void AccessibilityRenderObject::lineBreaks(Vector<int>& lineBreaks) const
1803 { 1837 {
1804 if (!isTextControl()) 1838 if (!isTextControl())
1805 return; 1839 return;
1806 1840
1807 VisiblePosition visiblePos = visiblePositionForIndex(0); 1841 VisiblePosition visiblePos = visiblePositionForIndex(0);
1808 VisiblePosition savedVisiblePos = visiblePos; 1842 VisiblePosition savedVisiblePos = visiblePos;
1809 visiblePos = nextLinePosition(visiblePos, 0); 1843 visiblePos = nextLinePosition(visiblePos, 0);
1810 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { 1844 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) {
1811 lineBreaks.append(indexForVisiblePosition(visiblePos)); 1845 lineBreaks.append(indexForVisiblePosition(visiblePos));
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 if (label && label->renderer()) { 2408 if (label && label->renderer()) {
2375 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2409 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2376 result.unite(labelRect); 2410 result.unite(labelRect);
2377 } 2411 }
2378 } 2412 }
2379 2413
2380 return result; 2414 return result;
2381 } 2415 }
2382 2416
2383 } // namespace WebCore 2417 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698