diff options
author | thestig <thestig@chromium.org> | 2015-08-14 22:13:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-15 05:13:40 +0000 |
commit | b2ebd3e75989a75ac356e5560a1fd542481e830d (patch) | |
tree | b91d57b312f63707bbb11fc4b80a18cb630632e7 /pdf | |
parent | a5bc6777ce3398b7d82cbe1da038138cb84593bd (diff) | |
download | chromium_src-b2ebd3e75989a75ac356e5560a1fd542481e830d.zip chromium_src-b2ebd3e75989a75ac356e5560a1fd542481e830d.tar.gz chromium_src-b2ebd3e75989a75ac356e5560a1fd542481e830d.tar.bz2 |
PDF: Use the z-order when there is a link and widget overlaps.
BUG=515837
Review URL: https://codereview.chromium.org/1274413002
Cr-Commit-Position: refs/heads/master@{#343574}
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdfium/pdfium_page.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/pdf/pdfium/pdfium_page.cc b/pdf/pdfium/pdfium_page.cc index 79410c4..93e7645 100644 --- a/pdf/pdfium/pdfium_page.cc +++ b/pdf/pdfium/pdfium_page.cc @@ -263,7 +263,8 @@ PDFiumPage::Area PDFiumPage::GetCharIndex(const pp::Point& point, if (!available_) return NONSELECTABLE_AREA; pp::Point point2 = point - rect_.point(); - double new_x, new_y; + double new_x; + double new_y; FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(), rotation, point2.x(), point2.y(), &new_x, &new_y); @@ -271,15 +272,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 = FPDFPage_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 +295,16 @@ 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, + // launch actions, cross-document links, etc. + // 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) |