Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index 37c01618778ebd942421fbab1c4c6f6b8a3affcf..bbff97013890aae12516c396f1f929ab2d0e46c8 100644 |
| --- a/pdf/pdfium/pdfium_engine.cc |
| +++ b/pdf/pdfium/pdfium_engine.cc |
| @@ -1624,6 +1624,25 @@ void PDFiumEngine::FitContentsToPrintableAreaIfRequired( |
| void PDFiumEngine::SaveSelectedFormForPrint() { |
| FORM_ForceToKillFocus(form_); |
| client_->FormTextFieldFocusChange(false); |
| + SetInFormTextField(false); |
| +} |
| + |
| +void PDFiumEngine::SetFormSelectedText(const FPDF_FORMHANDLE& hHandle, |
| + const FPDF_PAGE& page) { |
| + size_t form_sel_text_len = FORM_GetSelectedText(hHandle, page, nullptr, 0); |
| + if (!form_sel_text_len) |
| + return; |
| + |
| + base::string16 selected_form_text16; |
| + PDFiumAPIStringBufferSizeInBytesAdapter<base::string16> string_adapter( |
| + &selected_form_text16, form_sel_text_len, false); |
| + string_adapter.Close(FORM_GetSelectedText( |
| + hHandle, page, string_adapter.GetData(), form_sel_text_len)); |
| + |
| + std::string selected_form_text = UTF16ToUTF8(selected_form_text16); |
| + if (!selected_form_text.empty()) { |
| + pp::PDF::SetSelectedText(GetPluginInstance(), selected_form_text.c_str()); |
| + } |
| } |
| void PDFiumEngine::PrintEnd() { |
| @@ -1720,18 +1739,23 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) { |
| FORM_OnLButtonDown(form_, pages_[page_index]->GetPage(), 0, page_x, page_y); |
| if (form_type > FPDF_FORMFIELD_UNKNOWN) { // returns -1 sometimes... |
| - mouse_down_state_.Set(PDFiumPage::NONSELECTABLE_AREA, target); |
| + mouse_down_state_.Set(PDFiumPage::FORM_TEXT_AREA, target); |
|
Lei Zhang
2017/06/14 07:07:02
If we click on a form widget that is not a form te
drgage
2017/06/14 22:53:39
Probably not - I'll change this so that it only is
drgage
2017/06/14 22:53:39
Done.
|
| bool is_valid_control = (form_type == FPDF_FORMFIELD_TEXTFIELD || |
| form_type == FPDF_FORMFIELD_COMBOBOX); |
| #if defined(PDF_ENABLE_XFA) |
| is_valid_control |= (form_type == FPDF_FORMFIELD_XFA); |
| #endif |
| client_->FormTextFieldFocusChange(is_valid_control); |
| + |
| + // TODO (drgage): come back here and figure out what to do with |
|
Lei Zhang
2017/06/14 07:07:02
I think this is actually correct as is in the non-
drgage
2017/06/14 22:53:39
Done.
|
| + // is_valid_control |
| + SetInFormTextField(is_valid_control); |
| return true; // Return now before we get into the selection code. |
| } |
| } |
| client_->FormTextFieldFocusChange(false); |
| + SetInFormTextField(false); |
| if (area != PDFiumPage::TEXT_AREA) |
| return true; // Return true so WebKit doesn't do its own highlighting. |
| @@ -1807,11 +1831,13 @@ bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) { |
| client_->NavigateTo(target.url, disposition); |
| client_->FormTextFieldFocusChange(false); |
| + SetInFormTextField(false); |
| return true; |
| } |
| if (area == PDFiumPage::DOCLINK_AREA) { |
| client_->ScrollToPage(target.page); |
| client_->FormTextFieldFocusChange(false); |
| + SetInFormTextField(false); |
| return true; |
| } |
| } |
| @@ -1827,6 +1853,10 @@ bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) { |
| FORM_OnLButtonUp(form_, pages_[page_index]->GetPage(), 0, page_x, page_y); |
| } |
| + if (area == PDFiumPage::FORM_TEXT_AREA) { |
| + SetFormSelectedText(form_, pages_[last_page_mouse_down_]->GetPage()); |
| + } |
| + |
| if (!selecting_) |
|
Lei Zhang
2017/06/14 07:07:02
The existing code like this member variable and Se
drgage
2017/06/14 22:53:40
Done. Do you think it's sufficient to add an expla
|
| return false; |
| @@ -1991,6 +2021,12 @@ bool PDFiumEngine::OnKeyUp(const pp::KeyboardInputEvent& event) { |
| if (last_page_mouse_down_ == -1) |
| return false; |
| + if (in_form_text_field_) { |
| + uint32_t modifiers = event.GetModifiers(); |
| + if (modifiers & PP_INPUTEVENT_MODIFIER_SHIFTKEY) |
|
Lei Zhang
2017/06/14 07:07:02
I tried this code out and noticed if I:
1) used th
drgage
2017/06/14 22:53:39
I see what you mean. I hadn't tried this combinati
Lei Zhang
2017/06/15 18:11:28
I don't think you need to actually know how the vi
drgage
2017/06/16 02:12:36
Done.
|
| + SetFormSelectedText(form_, pages_[last_page_mouse_down_]->GetPage()); |
| + } |
| + |
| return !!FORM_OnKeyUp(form_, pages_[last_page_mouse_down_]->GetPage(), |
| event.GetKeyCode(), event.GetModifiers()); |
| } |
| @@ -3552,6 +3588,10 @@ void PDFiumEngine::SetSelecting(bool selecting) { |
| client_->IsSelectingChanged(selecting); |
| } |
| +void PDFiumEngine::SetInFormTextField(bool in_form_text_field) { |
| + in_form_text_field_ = in_form_text_field; |
| +} |
| + |
| void PDFiumEngine::ScheduleTouchTimer(const pp::TouchInputEvent& evt) { |
| touch_timers_[++next_touch_timer_id_] = evt; |
| client_->ScheduleTouchTimerCallback(next_touch_timer_id_, |