| Index: ui/accessibility/ax_range.h
|
| diff --git a/ui/accessibility/ax_range.h b/ui/accessibility/ax_range.h
|
| index 7235c0623d4ead598c4826ed8e3f2c7526c6ef1b..914f350d3a74d292ccaa90ca4531dc0c6c3739c5 100644
|
| --- a/ui/accessibility/ax_range.h
|
| +++ b/ui/accessibility/ax_range.h
|
| @@ -39,7 +39,7 @@ class AXRange {
|
|
|
| AXRange(const AXRange& other) = delete;
|
|
|
| - AXRange(const AXRange&& other) : AXRange() {
|
| + AXRange(AXRange&& other) : AXRange() {
|
| anchor_.swap(other.anchor_);
|
| focus_.swap(other.focus_);
|
| }
|
| @@ -78,21 +78,32 @@ class AXRange {
|
| if (IsNull())
|
| return text;
|
|
|
| - std::unique_ptr<AXPositionType> first, second;
|
| - if (*anchor_ <= *focus_) {
|
| - first = anchor_->AsLeafTextPosition();
|
| - second = focus_->AsLeafTextPosition();
|
| + std::unique_ptr<AXPositionType> start, end;
|
| + if (*anchor_ < *focus_) {
|
| + start = anchor_->AsLeafTextPosition();
|
| + end = focus_->AsLeafTextPosition();
|
| } else {
|
| - first = focus_->AsLeafTextPosition();
|
| - second = anchor_->AsLeafTextPosition();
|
| + start = focus_->AsLeafTextPosition();
|
| + end = anchor_->AsLeafTextPosition();
|
| }
|
|
|
| + int start_offset = start->text_offset();
|
| + DCHECK_GE(start_offset, 0);
|
| + int end_offset = end->text_offset();
|
| + DCHECK_GE(end_offset, 0);
|
| +
|
| do {
|
| - text += first->GetInnerText();
|
| - first = first->CreateNextTextAnchorPosition();
|
| - } while (*first <= *second);
|
| + text += start->GetInnerText();
|
| + start = start->CreateNextTextAnchorPosition();
|
| + } while (!start->IsNullPosition() && *start <= *end);
|
| +
|
| + if (static_cast<size_t>(start_offset) > text.length())
|
| + return base::string16();
|
|
|
| - return text;
|
| + text = text.substr(start_offset, base::string16::npos);
|
| + size_t text_length = text.length() - end->GetInnerText().length() +
|
| + static_cast<size_t>(end_offset);
|
| + return text.substr(0, text_length);
|
| }
|
|
|
| private:
|
|
|