Skip to content

Commit

Permalink
PDF: Improve right click behavior in form fields.
Browse files Browse the repository at this point in the history
Use FORM_OnFocus() to give form fields focus, if needed, before bringing
up the context menu.

BUG=754594

Change-Id: I0ddd0202f73b04b59ba5b7fc9369f9eb38a40945
Reviewed-on: https://chromium-review.googlesource.com/644773
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499095}
  • Loading branch information
leizleiz authored and Commit Bot committed Sep 1, 2017
1 parent e6f52a6 commit 32e93a5
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions pdf/pdfium/pdfium_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1915,32 +1915,28 @@ bool PDFiumEngine::OnRightMouseDown(const pp::MouseInputEvent& event) {

bool is_form_text_area = IsFormTextArea(area, form_type);
bool is_editable_form_text_area = false;

double page_x = -1;
double page_y = -1;
FPDF_PAGE page = nullptr;
if (is_form_text_area) {
DCHECK_NE(page_index, -1);

double page_x;
double page_y;
DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);

FPDF_PAGE page = pages_[page_index]->GetPage();
page = pages_[page_index]->GetPage();
is_editable_form_text_area =
IsPointInEditableFormTextArea(page, page_x, page_y, form_type);
}

// Handle the case when focus starts inside a form text area.
if (in_form_text_area_) {
if (is_form_text_area) {
// TODO(bug_754594): Right now this is a no-op, but what needs to happen
// here is a check to see if this right click occurred in the same text
// area as the currently focused text area. If they are not the same,
// refocus. This requires more state tracking, and a new PDFium API to
// set focus.
return true;
FORM_OnFocus(form_, page, 0, page_x, page_y);
} else {
// Transition out of a form text area.
FORM_ForceToKillFocus(form_);
SetInFormTextArea(false);
}

// Transition out of a form text area.
FORM_ForceToKillFocus(form_);
SetInFormTextArea(false);
return true;
}

Expand All @@ -1952,10 +1948,9 @@ bool PDFiumEngine::OnRightMouseDown(const pp::MouseInputEvent& event) {
selection_.clear();
}

// TODO(bug_754594): This does not actually set focus inside the form area.
// To do so requires a new PDFium API.
SetInFormTextArea(true);
editable_form_text_area_ = is_editable_form_text_area;
FORM_OnFocus(form_, page, 0, page_x, page_y);
return true;
}

Expand Down

0 comments on commit 32e93a5

Please sign in to comment.