OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 809 } |
810 | 810 |
811 WebAXRole WebAXObject::role() const | 811 WebAXRole WebAXObject::role() const |
812 { | 812 { |
813 if (isDetached()) | 813 if (isDetached()) |
814 return WebAXRoleUnknown; | 814 return WebAXRoleUnknown; |
815 | 815 |
816 return static_cast<WebAXRole>(m_private->roleValue()); | 816 return static_cast<WebAXRole>(m_private->roleValue()); |
817 } | 817 } |
818 | 818 |
| 819 void WebAXObject::selection(WebAXObject& anchorObject, int& anchorOffset, |
| 820 WebAXObject& focusObject, int& focusOffset) const |
| 821 { |
| 822 if (isDetached()) { |
| 823 anchorObject = WebAXObject(); |
| 824 anchorOffset = -1; |
| 825 focusObject = WebAXObject(); |
| 826 focusOffset = -1; |
| 827 return; |
| 828 } |
| 829 |
| 830 AXObject::AXRange axSelection = m_private->selection(); |
| 831 anchorObject = WebAXObject(axSelection.anchorObject); |
| 832 anchorOffset = axSelection.anchorOffset; |
| 833 focusObject = WebAXObject(axSelection.focusObject); |
| 834 focusOffset = axSelection.focusOffset; |
| 835 return; |
| 836 } |
| 837 |
| 838 void WebAXObject::setSelection(const WebAXObject& anchorObject, int anchorOffset
, |
| 839 const WebAXObject& focusObject, int focusOffset) const |
| 840 { |
| 841 if (isDetached()) |
| 842 return; |
| 843 |
| 844 AXObject::AXRange axSelection(anchorObject, anchorOffset, |
| 845 focusObject, focusOffset); |
| 846 m_private->setSelection(axSelection); |
| 847 return; |
| 848 } |
| 849 |
819 unsigned WebAXObject::selectionEnd() const | 850 unsigned WebAXObject::selectionEnd() const |
820 { | 851 { |
821 if (isDetached()) | 852 if (isDetached()) |
822 return 0; | 853 return 0; |
823 | 854 |
824 return m_private->selectedTextRange().start + m_private->selectedTextRange()
.length; | 855 AXObject::AXRange axSelection = m_private->selectionUnderObject(); |
| 856 if (axSelection.focusOffset < 0) |
| 857 return 0; |
| 858 |
| 859 return axSelection.focusOffset; |
825 } | 860 } |
826 | 861 |
827 unsigned WebAXObject::selectionStart() const | 862 unsigned WebAXObject::selectionStart() const |
828 { | 863 { |
829 if (isDetached()) | 864 if (isDetached()) |
830 return 0; | 865 return 0; |
831 | 866 |
832 return m_private->selectedTextRange().start; | 867 AXObject::AXRange axSelection = m_private->selectionUnderObject(); |
| 868 if (axSelection.anchorOffset < 0) |
| 869 return 0; |
| 870 |
| 871 return axSelection.anchorOffset; |
833 } | 872 } |
834 | 873 |
835 unsigned WebAXObject::selectionEndLineNumber() const | 874 unsigned WebAXObject::selectionEndLineNumber() const |
836 { | 875 { |
837 if (isDetached()) | 876 if (isDetached()) |
838 return 0; | 877 return 0; |
839 | 878 |
840 VisiblePosition position = m_private->visiblePositionForIndex(selectionEnd()
); | 879 VisiblePosition position = m_private->visiblePositionForIndex(selectionEnd()
); |
841 int lineNumber = m_private->lineForPosition(position); | 880 int lineNumber = m_private->lineForPosition(position); |
842 if (lineNumber < 0) | 881 if (lineNumber < 0) |
843 return 0; | 882 return 0; |
| 883 |
844 return lineNumber; | 884 return lineNumber; |
845 } | 885 } |
846 | 886 |
847 unsigned WebAXObject::selectionStartLineNumber() const | 887 unsigned WebAXObject::selectionStartLineNumber() const |
848 { | 888 { |
849 if (isDetached()) | 889 if (isDetached()) |
850 return 0; | 890 return 0; |
851 | 891 |
852 VisiblePosition position = m_private->visiblePositionForIndex(selectionStart
()); | 892 VisiblePosition position = m_private->visiblePositionForIndex(selectionStart
()); |
853 int lineNumber = m_private->lineForPosition(position); | 893 int lineNumber = m_private->lineForPosition(position); |
854 if (lineNumber < 0) | 894 if (lineNumber < 0) |
855 return 0; | 895 return 0; |
| 896 |
856 return lineNumber; | 897 return lineNumber; |
857 } | 898 } |
858 | 899 |
859 void WebAXObject::setFocused(bool on) const | 900 void WebAXObject::setFocused(bool on) const |
860 { | 901 { |
861 if (!isDetached()) | 902 if (!isDetached()) |
862 m_private->setFocused(on); | 903 m_private->setFocused(on); |
863 } | 904 } |
864 | 905 |
865 void WebAXObject::setSelectedTextRange(int selectionStart, int selectionEnd) con
st | 906 void WebAXObject::setSelectedTextRange(int selectionStart, int selectionEnd) con
st |
866 { | 907 { |
867 if (isDetached()) | 908 if (isDetached()) |
868 return; | 909 return; |
869 | 910 |
870 m_private->setSelectedTextRange(AXObject::PlainTextRange(selectionStart, sel
ectionEnd - selectionStart)); | 911 m_private->setSelection(AXObject::AXRange(selectionStart, selectionEnd)); |
871 } | 912 } |
872 | 913 |
873 void WebAXObject::setValue(WebString value) const | 914 void WebAXObject::setValue(WebString value) const |
874 { | 915 { |
875 if (isDetached()) | 916 if (isDetached()) |
876 return; | 917 return; |
877 | 918 |
878 m_private->setValue(value); | 919 m_private->setValue(value); |
879 } | 920 } |
880 | 921 |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 for (size_t i = 0; i < vectorSize; i++) | 1523 for (size_t i = 0; i < vectorSize; i++) |
1483 offsetsWebVector[i] = offsetsVector[i]; | 1524 offsetsWebVector[i] = offsetsVector[i]; |
1484 offsets.swap(offsetsWebVector); | 1525 offsets.swap(offsetsWebVector); |
1485 } | 1526 } |
1486 | 1527 |
1487 void WebAXObject::wordBoundaries(WebVector<int>& starts, WebVector<int>& ends) c
onst | 1528 void WebAXObject::wordBoundaries(WebVector<int>& starts, WebVector<int>& ends) c
onst |
1488 { | 1529 { |
1489 if (isDetached()) | 1530 if (isDetached()) |
1490 return; | 1531 return; |
1491 | 1532 |
1492 Vector<AXObject::PlainTextRange> words; | 1533 Vector<AXObject::AXRange> wordBoundaries; |
1493 m_private->wordBoundaries(words); | 1534 m_private->wordBoundaries(wordBoundaries); |
1494 | 1535 |
1495 WebVector<int> startsWebVector(words.size()); | 1536 WebVector<int> wordStartOffsets(wordBoundaries.size()); |
1496 WebVector<int> endsWebVector(words.size()); | 1537 WebVector<int> wordEndOffsets(wordBoundaries.size()); |
1497 for (size_t i = 0; i < words.size(); i++) { | 1538 for (size_t i = 0; i < wordBoundaries.size(); ++i) { |
1498 startsWebVector[i] = words[i].start; | 1539 ASSERT(wordBoundaries[i].isSimple()); |
1499 endsWebVector[i] = words[i].start + words[i].length; | 1540 wordStartOffsets[i] = wordBoundaries[i].anchorOffset; |
| 1541 wordEndOffsets[i] = wordBoundaries[i].focusOffset; |
1500 } | 1542 } |
1501 starts.swap(startsWebVector); | 1543 |
1502 ends.swap(endsWebVector); | 1544 starts.swap(wordStartOffsets); |
| 1545 ends.swap(wordEndOffsets); |
1503 } | 1546 } |
1504 | 1547 |
1505 bool WebAXObject::isScrollableContainer() const | 1548 bool WebAXObject::isScrollableContainer() const |
1506 { | 1549 { |
1507 if (isDetached()) | 1550 if (isDetached()) |
1508 return false; | 1551 return false; |
1509 | 1552 |
1510 return m_private->isScrollableContainer(); | 1553 return m_private->isScrollableContainer(); |
1511 } | 1554 } |
1512 | 1555 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 m_private = object; | 1613 m_private = object; |
1571 return *this; | 1614 return *this; |
1572 } | 1615 } |
1573 | 1616 |
1574 WebAXObject::operator PassRefPtrWillBeRawPtr<AXObject>() const | 1617 WebAXObject::operator PassRefPtrWillBeRawPtr<AXObject>() const |
1575 { | 1618 { |
1576 return m_private.get(); | 1619 return m_private.get(); |
1577 } | 1620 } |
1578 | 1621 |
1579 } // namespace blink | 1622 } // namespace blink |
OLD | NEW |