Chromium Code Reviews| Index: Source/web/WebAXObject.cpp |
| diff --git a/Source/web/WebAXObject.cpp b/Source/web/WebAXObject.cpp |
| index 3b89c72dc2c5143a3c90fe5b2882c0a317d755f2..535286182655e018fead921c389eb0f4d7677961 100644 |
| --- a/Source/web/WebAXObject.cpp |
| +++ b/Source/web/WebAXObject.cpp |
| @@ -832,12 +832,32 @@ WebAXRole WebAXObject::role() const |
| return static_cast<WebAXRole>(m_private->roleValue()); |
| } |
| +void WebAXObject::selection(unsigned* anchorId, unsigned* anchorOffset, |
| + unsigned* focusId, unsigned* focusOffset) const |
| +{ |
| + if (isDetached()) { |
| + *anchorId = 0; |
| + *anchorOffset = 0; |
| + *focusId = 0; |
| + *focusOffset = 0; |
| + return; |
| + } |
| + |
| + AXObject::AXSelection axSelection = m_private->selection(); |
| + *anchorId = axSelection.anchorId; |
| + *anchorOffset = axSelection.anchorOffset; |
| + *focusId = axSelection.focusId; |
| + *focusOffset = axSelection.focusOffset; |
| + return; |
| +} |
| + |
| unsigned WebAXObject::selectionEnd() const |
| { |
| if (isDetached()) |
| return 0; |
| - return m_private->selectedTextRange().start + m_private->selectedTextRange().length; |
| + AXObject::AXSelection axSelection = m_private->selectionUnderObject(); |
| + return axSelection.focusOffset; |
| } |
| unsigned WebAXObject::selectionStart() const |
| @@ -845,7 +865,8 @@ unsigned WebAXObject::selectionStart() const |
| if (isDetached()) |
| return 0; |
| - return m_private->selectedTextRange().start; |
| + AXObject::AXSelection axSelection = m_private->selectionUnderObject(); |
| + return axSelection.anchorOffset; |
| } |
| unsigned WebAXObject::selectionEndLineNumber() const |
| @@ -883,7 +904,7 @@ void WebAXObject::setSelectedTextRange(int selectionStart, int selectionEnd) con |
| if (isDetached()) |
| return; |
| - m_private->setSelectedTextRange(AXObject::PlainTextRange(selectionStart, selectionEnd - selectionStart)); |
| + m_private->setSelection(AXObject::AXSelection(selectionStart, selectionEnd)); |
| } |
| void WebAXObject::setValue(WebString value) const |
| @@ -1513,17 +1534,18 @@ void WebAXObject::wordBoundaries(WebVector<int>& starts, WebVector<int>& ends) c |
| if (isDetached()) |
| return; |
| - Vector<AXObject::PlainTextRange> words; |
| - m_private->wordBoundaries(words); |
| + Vector<AXObject::AXSelection> wordBoundaries; |
|
dmazzoni
2015/06/16 17:24:04
Switching this to use AXSelection doesn't make sen
|
| + m_private->wordBoundaries(wordBoundaries); |
| - WebVector<int> startsWebVector(words.size()); |
| - WebVector<int> endsWebVector(words.size()); |
| - for (size_t i = 0; i < words.size(); i++) { |
| - startsWebVector[i] = words[i].start; |
| - endsWebVector[i] = words[i].start + words[i].length; |
| + WebVector<int> wordStartOffsets(wordBoundaries.size()); |
| + WebVector<int> wordEndOffsets(wordBoundaries.size()); |
| + for (size_t i = 0; i < wordBoundaries.size(); ++i) { |
| + wordStartOffsets[i] = wordBoundaries[i].anchorOffset; |
| + wordEndOffsets[i] = wordBoundaries[i].focusOffset; |
| } |
| - starts.swap(startsWebVector); |
| - ends.swap(endsWebVector); |
| + |
| + starts.swap(wordStartOffsets); |
| + ends.swap(wordEndOffsets); |
| } |
| bool WebAXObject::isScrollableContainer() const |