Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1026)

Unified Diff: pdf/pdfium/pdfium_page.cc

Issue 1274413002: PDF: Use the z-order when there is a link and widget overlaps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698