Chromium Code Reviews| Index: Source/web/WebAXObject.cpp |
| diff --git a/Source/web/WebAXObject.cpp b/Source/web/WebAXObject.cpp |
| index ef98b5b69d6631c1ed86e7f07808f5f7b3f09631..a04e73f134fa178388980725a84c0767d8e1f2c0 100644 |
| --- a/Source/web/WebAXObject.cpp |
| +++ b/Source/web/WebAXObject.cpp |
| @@ -816,12 +816,44 @@ WebAXRole WebAXObject::role() const |
| return static_cast<WebAXRole>(m_private->roleValue()); |
| } |
| +void WebAXObject::selection(WebAXObject& anchorObject, int& anchorOffset, |
| + WebAXObject& focusObject, int& focusOffset) const |
| +{ |
| + if (isDetached()) { |
| + anchorObject = WebAXObject(); |
| + anchorOffset = -1; |
| + focusObject = WebAXObject(); |
| + focusOffset = -1; |
| + return; |
| + } |
| + |
| + AXObject::AXRange axSelection = m_private->selection(); |
| + anchorObject = WebAXObject(axSelection.anchorObject); |
| + anchorOffset = axSelection.anchorOffset; |
| + focusObject = WebAXObject(axSelection.focusObject); |
| + focusOffset = axSelection.focusOffset; |
| + return; |
| +} |
| + |
| +void WebAXObject::setSelection(const WebAXObject& anchorObject, int anchorOffset, |
| + const WebAXObject& focusObject, int focusOffset) const |
| +{ |
| + if (isDetached()) |
| + return; |
| + |
| + AXObject::AXRange axSelection(anchorObject, anchorOffset, |
| + focusObject, focusOffset); |
| + m_private->setSelection(axSelection); |
| + return; |
| +} |
| + |
| unsigned WebAXObject::selectionEnd() const |
| { |
| if (isDetached()) |
| return 0; |
| - return m_private->selectedTextRange().start + m_private->selectedTextRange().length; |
| + AXObject::AXRange axSelection = m_private->selectionUnderObject(); |
|
dmazzoni
2015/06/24 00:11:01
It seems like this changes the behavior.
Previous
|
| + return axSelection.focusOffset; |
| } |
| unsigned WebAXObject::selectionStart() const |
| @@ -829,7 +861,8 @@ unsigned WebAXObject::selectionStart() const |
| if (isDetached()) |
| return 0; |
| - return m_private->selectedTextRange().start; |
| + AXObject::AXRange axSelection = m_private->selectionUnderObject(); |
| + return axSelection.anchorOffset; |
| } |
| unsigned WebAXObject::selectionEndLineNumber() const |
| @@ -867,7 +900,7 @@ void WebAXObject::setSelectedTextRange(int selectionStart, int selectionEnd) con |
| if (isDetached()) |
| return; |
| - m_private->setSelectedTextRange(AXObject::PlainTextRange(selectionStart, selectionEnd - selectionStart)); |
| + m_private->setSelection(AXObject::AXRange(selectionStart, selectionEnd)); |
| } |
| void WebAXObject::setValue(WebString value) const |
| @@ -1489,17 +1522,18 @@ void WebAXObject::wordBoundaries(WebVector<int>& starts, WebVector<int>& ends) c |
| if (isDetached()) |
| return; |
| - Vector<AXObject::PlainTextRange> words; |
| - m_private->wordBoundaries(words); |
| + Vector<AXObject::AXRange> wordBoundaries; |
| + 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; |
|
dmazzoni
2015/06/24 00:11:01
How about: ASSERT(wordBoundaries[i].isSimple());
|
| + wordEndOffsets[i] = wordBoundaries[i].focusOffset; |
| } |
| - starts.swap(startsWebVector); |
| - ends.swap(endsWebVector); |
| + |
| + starts.swap(wordStartOffsets); |
| + ends.swap(wordEndOffsets); |
| } |
| bool WebAXObject::isScrollableContainer() const |