Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index f71ef7ce71f8b2ccb87dc7e2326c1967ee9fe648..035841b3e273c2344373bac72cbf164dc18a1724 100644 |
| --- a/pdf/pdfium/pdfium_engine.cc |
| +++ b/pdf/pdfium/pdfium_engine.cc |
| @@ -1653,8 +1653,10 @@ void PDFiumEngine::SetFormSelectedText(FPDF_FORMHANDLE form_handle, |
| // selection has changed. If so, set plugin text selection. |
| std::string selected_form_text = selected_form_text_; |
| selected_form_text_ = base::UTF16ToUTF8(selected_form_text16); |
| - if (selected_form_text != selected_form_text_) |
| + if (selected_form_text != selected_form_text_) { |
| + DCHECK(in_form_text_area_); |
| pp::PDF::SetSelectedText(GetPluginInstance(), selected_form_text_.c_str()); |
| + } |
| } |
| void PDFiumEngine::PrintEnd() { |
| @@ -1725,7 +1727,9 @@ bool PDFiumEngine::OnMouseDown(const pp::MouseInputEvent& event) { |
| SetMouseLeftButtonDown(event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT); |
| - SelectionChangeInvalidator selection_invalidator(this); |
| + std::unique_ptr<chrome_pdf::PDFiumEngine::SelectionChangeInvalidator> |
|
Lei Zhang
2017/07/10 23:08:20
Since the return value from base::MakeUnique() (wh
drgage
2017/07/11 17:25:36
Done.
|
| + selection_invalidator = |
| + base::MakeUnique<SelectionChangeInvalidator>(this); |
| selection_.clear(); |
| int page_index = -1; |
| @@ -1754,6 +1758,7 @@ 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::FormTypeToArea(form_type), target); |
| + selection_invalidator.reset(); |
|
Lei Zhang
2017/07/10 23:08:21
Can you add a comment to explain why this has to b
drgage
2017/07/11 17:25:36
Done.
|
| bool is_valid_control = (form_type == FPDF_FORMFIELD_TEXTFIELD || |
| form_type == FPDF_FORMFIELD_COMBOBOX); |
| @@ -3583,6 +3588,7 @@ void PDFiumEngine::GetRegion(const pp::Point& location, |
| } |
| void PDFiumEngine::OnSelectionChanged() { |
| + DCHECK(!in_form_text_area_); |
| pp::PDF::SetSelectedText(GetPluginInstance(), GetSelectedText().c_str()); |
| } |
| @@ -3621,6 +3627,10 @@ void PDFiumEngine::SetSelecting(bool selecting) { |
| } |
| void PDFiumEngine::SetInFormTextArea(bool in_form_text_area) { |
| + // If focus previously in form text area, clear form text selection. |
|
Lei Zhang
2017/07/10 23:08:20
// If focus was previously in the form text area,
drgage
2017/07/11 17:25:37
Otherwise, nothing is cleared; the focus is change
Lei Zhang
2017/07/11 20:37:38
Otherwise, nothing is cleared and if |in_form_text
|
| + if (in_form_text_area_) |
| + pp::PDF::SetSelectedText(GetPluginInstance(), ""); |
| + |
| client_->FormTextFieldFocusChange(in_form_text_area); |
| in_form_text_area_ = in_form_text_area; |
| } |