| Index: pdf/pdfium/pdfium_page.cc
|
| diff --git a/pdf/pdfium/pdfium_page.cc b/pdf/pdfium/pdfium_page.cc
|
| index a7912a6e344bf60ebe8f3382be9f9620444d0cec..4d7a7beaf82d57fa1f2245ee2dcb9b4adb729e15 100644
|
| --- a/pdf/pdfium/pdfium_page.cc
|
| +++ b/pdf/pdfium/pdfium_page.cc
|
| @@ -271,15 +271,22 @@ PDFiumPage::Area PDFiumPage::GetCharIndex(const pp::Point& point,
|
| GetTextPage(), new_x, new_y, kTolerance, kTolerance);
|
| *char_index = rv;
|
|
|
| + FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y);
|
| int control =
|
| FPDPage_HasFormFieldAtPoint(engine_->form(), GetPage(), new_x, new_y);
|
| - if (control > FPDF_FORMFIELD_UNKNOWN) {
|
| - *form_type = control;
|
| - return PDFiumPage::NONSELECTABLE_AREA;
|
| - }
|
|
|
| - FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y);
|
| - if (link) {
|
| + // If there is a control and link at the same point, figure out their z-order
|
| + // to determine which is on top.
|
| + if (link && control > FPDF_FORMFIELD_UNKNOWN) {
|
| + int control_z_order = FPDPage_FormFieldZOrderAtPoint(
|
| + engine_->form(), GetPage(), new_x, new_y);
|
| + int link_z_order = FPDFLink_GetLinkZOrderAtPoint(GetPage(), new_x, new_y);
|
| + DCHECK_NE(control_z_order, link_z_order);
|
| + if (control_z_order > link_z_order) {
|
| + *form_type = control;
|
| + return PDFiumPage::NONSELECTABLE_AREA;
|
| + }
|
| +
|
| // We don't handle all possible link types of the PDF. For example,
|
| // launch actions, cross-document links, etc.
|
| // In that case, GetLinkTarget() will return NONSELECTABLE_AREA
|
| @@ -287,6 +294,15 @@ PDFiumPage::Area PDFiumPage::GetCharIndex(const pp::Point& point,
|
| PDFiumPage::Area area = GetLinkTarget(link, target);
|
| if (area != PDFiumPage::NONSELECTABLE_AREA)
|
| return area;
|
| + } else if (link) {
|
| + // We don't handle all possible link types of the PDF. For example,
|
| + // See identical block above.
|
| + PDFiumPage::Area area = GetLinkTarget(link, target);
|
| + if (area != PDFiumPage::NONSELECTABLE_AREA)
|
| + return area;
|
| + } else if (control > FPDF_FORMFIELD_UNKNOWN) {
|
| + *form_type = control;
|
| + return PDFiumPage::NONSELECTABLE_AREA;
|
| }
|
|
|
| if (rv < 0)
|
|
|