Index: pdf/pdfium/pdfium_engine.cc |
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
index c4e703efe65e47a20f9820b1c788d4c4add59681..4105f69b3269d3ea5ee7289e557476e7f569f634 100644 |
--- a/pdf/pdfium/pdfium_engine.cc |
+++ b/pdf/pdfium/pdfium_engine.cc |
@@ -600,7 +600,8 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) |
called_do_document_action_(false), |
render_grayscale_(false), |
progressive_paint_timeout_(0), |
- getting_password_(false) { |
+ getting_password_(false), |
+ last_char_index_(-1) { |
find_factory_.Initialize(this); |
password_factory_.Initialize(this); |
@@ -1693,6 +1694,7 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) { |
return true; |
} |
+ int last_page_index = last_page_mouse_down_; |
if (page_index != -1) { |
last_page_mouse_down_ = page_index; |
double page_x, page_y; |
@@ -1715,6 +1717,15 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) { |
} |
client_->FormTextFieldFocusChange(false); |
+ if (event.GetModifiers() == (PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN | |
+ PP_INPUTEVENT_MODIFIER_SHIFTKEY) && |
+ event.GetClickCount() == 1) { |
+ HandleShiftClick(last_page_index, page_index, char_index); |
+ last_char_index_ = char_index; |
+ return true; |
+ } |
+ |
+ last_char_index_ = char_index; |
if (area != PDFiumPage::TEXT_AREA) |
return true; // Return true so WebKit doesn't do its own highlighting. |
@@ -3469,6 +3480,55 @@ void PDFiumEngine::RotateInternal() { |
} |
} |
+void PDFiumEngine::HandleShiftClick(const int last_page_index, |
+ const int page_index, |
+ const int char_index) { |
+ selecting_ = true; |
+ if (last_page_index == -1 || last_page_index == page_index) { |
+ if (last_char_index_ != -1) { |
+ if (char_index == -1) { |
+ selection_.push_back( |
+ PDFiumRange(pages_[page_index], 0, last_char_index_ + 1)); |
+ } else { |
+ if (char_index > last_char_index_) { |
+ selection_.push_back(PDFiumRange(pages_[page_index], last_char_index_, |
+ char_index - last_char_index_ + 1)); |
+ } else if (char_index < last_char_index_) { |
+ selection_.push_back(PDFiumRange(pages_[page_index], char_index, |
+ last_char_index_ - char_index + 1)); |
+ } |
+ } |
+ } else { |
+ if (char_index != -1) |
+ selection_.push_back( |
+ PDFiumRange(pages_[page_index], 0, char_index + 1)); |
+ } |
+ } else { |
+ if (last_char_index_ != -1 && char_index != -1) { |
+ if (last_page_index < page_index) { |
+ selection_.push_back( |
+ PDFiumRange(pages_[last_page_index], last_char_index_, |
+ pages_[last_page_index]->GetCharCount())); |
+ for (int i = last_page_index + 1; i < page_index; i++) { |
+ selection_.push_back( |
+ PDFiumRange(pages_[i], 0, pages_[i]->GetCharCount())); |
+ } |
+ selection_.push_back( |
+ PDFiumRange(pages_[page_index], 0, char_index + 1)); |
+ } else { |
+ selection_.push_back(PDFiumRange(pages_[page_index], char_index, |
+ pages_[page_index]->GetCharCount())); |
+ for (int i = page_index + 1; i < last_page_index; i++) { |
+ selection_.push_back( |
+ PDFiumRange(pages_[i], 0, pages_[i]->GetCharCount())); |
+ } |
+ selection_.push_back( |
+ PDFiumRange(pages_[last_page_index], 0, last_char_index_ + 1)); |
+ } |
+ } |
+ } |
+} |
+ |
void PDFiumEngine::Form_Invalidate(FPDF_FORMFILLINFO* param, |
FPDF_PAGE page, |
double left, |