| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/frame/Settings.h" | 43 #include "core/frame/Settings.h" |
| 44 #include "core/html/HTMLImageElement.h" | 44 #include "core/html/HTMLImageElement.h" |
| 45 #include "core/html/HTMLLabelElement.h" | 45 #include "core/html/HTMLLabelElement.h" |
| 46 #include "core/html/HTMLOptionElement.h" | 46 #include "core/html/HTMLOptionElement.h" |
| 47 #include "core/html/HTMLSelectElement.h" | 47 #include "core/html/HTMLSelectElement.h" |
| 48 #include "core/html/HTMLTextAreaElement.h" | 48 #include "core/html/HTMLTextAreaElement.h" |
| 49 #include "core/html/shadow/ShadowElementNames.h" | 49 #include "core/html/shadow/ShadowElementNames.h" |
| 50 #include "core/layout/HitTestResult.h" | 50 #include "core/layout/HitTestResult.h" |
| 51 #include "core/layout/Layer.h" | 51 #include "core/layout/Layer.h" |
| 52 #include "core/layout/LayoutImage.h" | 52 #include "core/layout/LayoutImage.h" |
| 53 #include "core/layout/LayoutTextControlSingleLine.h" |
| 53 #include "core/loader/ProgressTracker.h" | 54 #include "core/loader/ProgressTracker.h" |
| 54 #include "core/page/Page.h" | 55 #include "core/page/Page.h" |
| 55 #include "core/rendering/RenderFieldset.h" | 56 #include "core/rendering/RenderFieldset.h" |
| 56 #include "core/rendering/RenderFileUploadControl.h" | 57 #include "core/rendering/RenderFileUploadControl.h" |
| 57 #include "core/rendering/RenderHTMLCanvas.h" | 58 #include "core/rendering/RenderHTMLCanvas.h" |
| 58 #include "core/rendering/RenderInline.h" | 59 #include "core/rendering/RenderInline.h" |
| 59 #include "core/rendering/RenderListMarker.h" | 60 #include "core/rendering/RenderListMarker.h" |
| 60 #include "core/rendering/RenderMenuList.h" | 61 #include "core/rendering/RenderMenuList.h" |
| 61 #include "core/rendering/RenderPart.h" | 62 #include "core/rendering/RenderPart.h" |
| 62 #include "core/rendering/RenderTextControlSingleLine.h" | |
| 63 #include "core/rendering/RenderTextFragment.h" | 63 #include "core/rendering/RenderTextFragment.h" |
| 64 #include "core/rendering/RenderView.h" | 64 #include "core/rendering/RenderView.h" |
| 65 #include "core/svg/SVGDocumentExtensions.h" | 65 #include "core/svg/SVGDocumentExtensions.h" |
| 66 #include "core/svg/SVGSVGElement.h" | 66 #include "core/svg/SVGSVGElement.h" |
| 67 #include "core/svg/graphics/SVGImage.h" | 67 #include "core/svg/graphics/SVGImage.h" |
| 68 #include "modules/accessibility/AXImageMapLink.h" | 68 #include "modules/accessibility/AXImageMapLink.h" |
| 69 #include "modules/accessibility/AXInlineTextBox.h" | 69 #include "modules/accessibility/AXInlineTextBox.h" |
| 70 #include "modules/accessibility/AXObjectCacheImpl.h" | 70 #include "modules/accessibility/AXObjectCacheImpl.h" |
| 71 #include "modules/accessibility/AXSVGRoot.h" | 71 #include "modules/accessibility/AXSVGRoot.h" |
| 72 #include "modules/accessibility/AXSpinButton.h" | 72 #include "modules/accessibility/AXSpinButton.h" |
| (...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 AXObject::PlainTextRange AXRenderObject::selectedTextRange() const | 1658 AXObject::PlainTextRange AXRenderObject::selectedTextRange() const |
| 1659 { | 1659 { |
| 1660 if (!isTextControl()) | 1660 if (!isTextControl()) |
| 1661 return PlainTextRange(); | 1661 return PlainTextRange(); |
| 1662 | 1662 |
| 1663 if (isPasswordFieldAndShouldHideValue()) | 1663 if (isPasswordFieldAndShouldHideValue()) |
| 1664 return PlainTextRange(); | 1664 return PlainTextRange(); |
| 1665 | 1665 |
| 1666 AccessibilityRole ariaRole = ariaRoleAttribute(); | 1666 AccessibilityRole ariaRole = ariaRoleAttribute(); |
| 1667 if (isNativeTextControl() && ariaRole == UnknownRole && m_renderer->isTextCo
ntrol()) { | 1667 if (isNativeTextControl() && ariaRole == UnknownRole && m_renderer->isTextCo
ntrol()) { |
| 1668 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1668 HTMLTextFormControlElement* textControl = toLayoutTextControl(m_renderer
)->textFormControlElement(); |
| 1669 return PlainTextRange(textControl->selectionStart(), textControl->select
ionEnd() - textControl->selectionStart()); | 1669 return PlainTextRange(textControl->selectionStart(), textControl->select
ionEnd() - textControl->selectionStart()); |
| 1670 } | 1670 } |
| 1671 | 1671 |
| 1672 if (ariaRole == UnknownRole) | 1672 if (ariaRole == UnknownRole) |
| 1673 return PlainTextRange(); | 1673 return PlainTextRange(); |
| 1674 | 1674 |
| 1675 return ariaSelectedTextRange(); | 1675 return ariaSelectedTextRange(); |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 VisibleSelection AXRenderObject::selection() const | 1678 VisibleSelection AXRenderObject::selection() const |
| 1679 { | 1679 { |
| 1680 return m_renderer->frame()->selection().selection(); | 1680 return m_renderer->frame()->selection().selection(); |
| 1681 } | 1681 } |
| 1682 | 1682 |
| 1683 // | 1683 // |
| 1684 // Modify or take an action on an object. | 1684 // Modify or take an action on an object. |
| 1685 // | 1685 // |
| 1686 | 1686 |
| 1687 void AXRenderObject::setSelectedTextRange(const PlainTextRange& range) | 1687 void AXRenderObject::setSelectedTextRange(const PlainTextRange& range) |
| 1688 { | 1688 { |
| 1689 if (isNativeTextControl() && m_renderer->isTextControl()) { | 1689 if (isNativeTextControl() && m_renderer->isTextControl()) { |
| 1690 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1690 HTMLTextFormControlElement* textControl = toLayoutTextControl(m_renderer
)->textFormControlElement(); |
| 1691 textControl->setSelectionRange(range.start, range.start + range.length,
SelectionHasNoDirection, NotDispatchSelectEvent); | 1691 textControl->setSelectionRange(range.start, range.start + range.length,
SelectionHasNoDirection, NotDispatchSelectEvent); |
| 1692 return; | 1692 return; |
| 1693 } | 1693 } |
| 1694 | 1694 |
| 1695 Document& document = m_renderer->document(); | 1695 Document& document = m_renderer->document(); |
| 1696 LocalFrame* frame = document.frame(); | 1696 LocalFrame* frame = document.frame(); |
| 1697 if (!frame) | 1697 if (!frame) |
| 1698 return; | 1698 return; |
| 1699 Node* node = m_renderer->node(); | 1699 Node* node = m_renderer->node(); |
| 1700 frame->selection().setSelection(VisibleSelection(Position(node, range.start,
Position::PositionIsOffsetInAnchor), | 1700 frame->selection().setSelection(VisibleSelection(Position(node, range.start,
Position::PositionIsOffsetInAnchor), |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 | 1817 |
| 1818 return -1; | 1818 return -1; |
| 1819 } | 1819 } |
| 1820 | 1820 |
| 1821 VisiblePosition AXRenderObject::visiblePositionForIndex(int index) const | 1821 VisiblePosition AXRenderObject::visiblePositionForIndex(int index) const |
| 1822 { | 1822 { |
| 1823 if (!m_renderer) | 1823 if (!m_renderer) |
| 1824 return VisiblePosition(); | 1824 return VisiblePosition(); |
| 1825 | 1825 |
| 1826 if (isNativeTextControl() && m_renderer->isTextControl()) | 1826 if (isNativeTextControl() && m_renderer->isTextControl()) |
| 1827 return toRenderTextControl(m_renderer)->textFormControlElement()->visibl
ePositionForIndex(index); | 1827 return toLayoutTextControl(m_renderer)->textFormControlElement()->visibl
ePositionForIndex(index); |
| 1828 | 1828 |
| 1829 if (!allowsTextRanges() && !m_renderer->isText()) | 1829 if (!allowsTextRanges() && !m_renderer->isText()) |
| 1830 return VisiblePosition(); | 1830 return VisiblePosition(); |
| 1831 | 1831 |
| 1832 Node* node = m_renderer->node(); | 1832 Node* node = m_renderer->node(); |
| 1833 if (!node) | 1833 if (!node) |
| 1834 return VisiblePosition(); | 1834 return VisiblePosition(); |
| 1835 | 1835 |
| 1836 if (index <= 0) | 1836 if (index <= 0) |
| 1837 return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM); | 1837 return VisiblePosition(firstPositionInOrBeforeNode(node), DOWNSTREAM); |
| 1838 | 1838 |
| 1839 Position start, end; | 1839 Position start, end; |
| 1840 bool selected = Range::selectNodeContents(node, start, end); | 1840 bool selected = Range::selectNodeContents(node, start, end); |
| 1841 if (!selected) | 1841 if (!selected) |
| 1842 return VisiblePosition(); | 1842 return VisiblePosition(); |
| 1843 | 1843 |
| 1844 CharacterIterator it(start, end); | 1844 CharacterIterator it(start, end); |
| 1845 it.advance(index - 1); | 1845 it.advance(index - 1); |
| 1846 return VisiblePosition(Position(it.endContainer(), it.endOffset(), Position:
:PositionIsOffsetInAnchor), UPSTREAM); | 1846 return VisiblePosition(Position(it.endContainer(), it.endOffset(), Position:
:PositionIsOffsetInAnchor), UPSTREAM); |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 int AXRenderObject::indexForVisiblePosition(const VisiblePosition& pos) const | 1849 int AXRenderObject::indexForVisiblePosition(const VisiblePosition& pos) const |
| 1850 { | 1850 { |
| 1851 if (isNativeTextControl() && m_renderer->isTextControl()) { | 1851 if (isNativeTextControl() && m_renderer->isTextControl()) { |
| 1852 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer
)->textFormControlElement(); | 1852 HTMLTextFormControlElement* textControl = toLayoutTextControl(m_renderer
)->textFormControlElement(); |
| 1853 return textControl->indexForVisiblePosition(pos); | 1853 return textControl->indexForVisiblePosition(pos); |
| 1854 } | 1854 } |
| 1855 | 1855 |
| 1856 if (!isTextControl()) | 1856 if (!isTextControl()) |
| 1857 return 0; | 1857 return 0; |
| 1858 | 1858 |
| 1859 Node* node = m_renderer->node(); | 1859 Node* node = m_renderer->node(); |
| 1860 if (!node) | 1860 if (!node) |
| 1861 return 0; | 1861 return 0; |
| 1862 | 1862 |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2411 if (label && label->renderer()) { | 2411 if (label && label->renderer()) { |
| 2412 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 2412 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
| 2413 result.unite(labelRect); | 2413 result.unite(labelRect); |
| 2414 } | 2414 } |
| 2415 } | 2415 } |
| 2416 | 2416 |
| 2417 return result; | 2417 return result; |
| 2418 } | 2418 } |
| 2419 | 2419 |
| 2420 } // namespace blink | 2420 } // namespace blink |
| OLD | NEW |