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 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 return PlainTextRange(); | 1564 return PlainTextRange(); |
1565 | 1565 |
1566 return ariaSelectedTextRange(); | 1566 return ariaSelectedTextRange(); |
1567 } | 1567 } |
1568 | 1568 |
1569 VisibleSelection AXRenderObject::selection() const | 1569 VisibleSelection AXRenderObject::selection() const |
1570 { | 1570 { |
1571 return m_renderer->frame()->selection().selection(); | 1571 return m_renderer->frame()->selection().selection(); |
1572 } | 1572 } |
1573 | 1573 |
1574 String AXRenderObject::selectedText() const | |
1575 { | |
1576 ASSERT(isTextControl()); | |
1577 | |
1578 if (isPasswordField()) | |
1579 return String(); // need to return something distinct from empty string | |
1580 | |
1581 if (isNativeTextControl() && m_renderer->isTextControl()) { | |
1582 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | |
1583 return textControl->selectedText(); | |
1584 } | |
1585 | |
1586 if (ariaRoleAttribute() == UnknownRole) | |
1587 return String(); | |
1588 | |
1589 return stringForRange(ariaSelectedTextRange()); | |
1590 } | |
1591 | |
1592 // | 1574 // |
1593 // Modify or take an action on an object. | 1575 // Modify or take an action on an object. |
1594 // | 1576 // |
1595 | 1577 |
1596 void AXRenderObject::setSelectedTextRange(const PlainTextRange& range) | 1578 void AXRenderObject::setSelectedTextRange(const PlainTextRange& range) |
1597 { | 1579 { |
1598 if (isNativeTextControl() && m_renderer->isTextControl()) { | 1580 if (isNativeTextControl() && m_renderer->isTextControl()) { |
1599 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1581 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); |
1600 textControl->setSelectionRange(range.start, range.start + range.length); | 1582 textControl->setSelectionRange(range.start, range.start + range.length); |
1601 return; | 1583 return; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 VisiblePosition visiblePos = visiblePositionForIndex(0); | 1779 VisiblePosition visiblePos = visiblePositionForIndex(0); |
1798 VisiblePosition savedVisiblePos = visiblePos; | 1780 VisiblePosition savedVisiblePos = visiblePos; |
1799 visiblePos = nextLinePosition(visiblePos, 0); | 1781 visiblePos = nextLinePosition(visiblePos, 0); |
1800 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { | 1782 while (!visiblePos.isNull() && visiblePos != savedVisiblePos) { |
1801 lineBreaks.append(indexForVisiblePosition(visiblePos)); | 1783 lineBreaks.append(indexForVisiblePosition(visiblePos)); |
1802 savedVisiblePos = visiblePos; | 1784 savedVisiblePos = visiblePos; |
1803 visiblePos = nextLinePosition(visiblePos, 0); | 1785 visiblePos = nextLinePosition(visiblePos, 0); |
1804 } | 1786 } |
1805 } | 1787 } |
1806 | 1788 |
1807 // A substring of the text associated with this accessibility object that is | |
1808 // specified by the given character range. | |
1809 String AXRenderObject::stringForRange(const PlainTextRange& range) const | |
1810 { | |
1811 if (!range.length) | |
1812 return String(); | |
1813 | |
1814 if (!isTextControl()) | |
1815 return String(); | |
1816 | |
1817 String elementText = isPasswordField() ? String() : text(); | |
1818 if (range.start + range.length > elementText.length()) | |
1819 return String(); | |
1820 | |
1821 return elementText.substring(range.start, range.length); | |
1822 } | |
1823 | |
1824 // | 1789 // |
1825 // Private. | 1790 // Private. |
1826 // | 1791 // |
1827 | 1792 |
1828 bool AXRenderObject::isAllowedChildOfTree() const | 1793 bool AXRenderObject::isAllowedChildOfTree() const |
1829 { | 1794 { |
1830 // Determine if this is in a tree. If so, we apply special behavior to make
it work like an AXOutline. | 1795 // Determine if this is in a tree. If so, we apply special behavior to make
it work like an AXOutline. |
1831 AXObject* axObj = parentObject(); | 1796 AXObject* axObj = parentObject(); |
1832 bool isInTree = false; | 1797 bool isInTree = false; |
1833 while (axObj) { | 1798 while (axObj) { |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 if (label && label->renderer()) { | 2327 if (label && label->renderer()) { |
2363 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 2328 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
2364 result.unite(labelRect); | 2329 result.unite(labelRect); |
2365 } | 2330 } |
2366 } | 2331 } |
2367 | 2332 |
2368 return result; | 2333 return result; |
2369 } | 2334 } |
2370 | 2335 |
2371 } // namespace WebCore | 2336 } // namespace WebCore |
OLD | NEW |