Index: pdf/pdfium/pdfium_engine.cc |
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
index 87f8d65dc90e3a09695495146564febe52b6ce6c..29ef475cfb89e8d294fec9ba9d1e2d181ff28857 100644 |
--- a/pdf/pdfium/pdfium_engine.cc |
+++ b/pdf/pdfium/pdfium_engine.cc |
@@ -1863,7 +1863,10 @@ bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) { |
selection_.push_back(PDFiumRange(pages_[page_index], 0, char_index)); |
} else { |
// Selecting into the previous page. |
- selection_[last].SetCharCount(-selection_[last].char_index()); |
+ // The selection's char_index is 0-based, so the character count is one |
+ // more than the index. The character count needs to be negative to |
+ // indicate a backwards selection. |
+ selection_[last].SetCharCount(-(selection_[last].char_index() + 1)); |
// First make sure that there are no gaps in selection, i.e. if mousedown on |
// page three but we only get mousemove over page one, we want page two. |