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

Side by Side 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: nit 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "pdf/pdfium/pdfium_page.h" 5 #include "pdf/pdfium/pdfium_page.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 256 }
257 257
258 PDFiumPage::Area PDFiumPage::GetCharIndex(const pp::Point& point, 258 PDFiumPage::Area PDFiumPage::GetCharIndex(const pp::Point& point,
259 int rotation, 259 int rotation,
260 int* char_index, 260 int* char_index,
261 int* form_type, 261 int* form_type,
262 LinkTarget* target) { 262 LinkTarget* target) {
263 if (!available_) 263 if (!available_)
264 return NONSELECTABLE_AREA; 264 return NONSELECTABLE_AREA;
265 pp::Point point2 = point - rect_.point(); 265 pp::Point point2 = point - rect_.point();
266 double new_x, new_y; 266 double new_x;
267 double new_y;
267 FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(), 268 FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(),
268 rotation, point2.x(), point2.y(), &new_x, &new_y); 269 rotation, point2.x(), point2.y(), &new_x, &new_y);
269 270
270 int rv = FPDFText_GetCharIndexAtPos( 271 int rv = FPDFText_GetCharIndexAtPos(
271 GetTextPage(), new_x, new_y, kTolerance, kTolerance); 272 GetTextPage(), new_x, new_y, kTolerance, kTolerance);
272 *char_index = rv; 273 *char_index = rv;
273 274
275 FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y);
274 int control = 276 int control =
275 FPDPage_HasFormFieldAtPoint(engine_->form(), GetPage(), new_x, new_y); 277 FPDPage_HasFormFieldAtPoint(engine_->form(), GetPage(), new_x, new_y);
276 if (control > FPDF_FORMFIELD_UNKNOWN) {
277 *form_type = control;
278 return PDFiumPage::NONSELECTABLE_AREA;
279 }
280 278
281 FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y); 279 // If there is a control and link at the same point, figure out their z-order
282 if (link) { 280 // to determine which is on top.
281 if (link && control > FPDF_FORMFIELD_UNKNOWN) {
282 int control_z_order = FPDFPage_FormFieldZOrderAtPoint(
283 engine_->form(), GetPage(), new_x, new_y);
284 int link_z_order = FPDFLink_GetLinkZOrderAtPoint(GetPage(), new_x, new_y);
285 DCHECK_NE(control_z_order, link_z_order);
286 if (control_z_order > link_z_order) {
287 *form_type = control;
288 return PDFiumPage::NONSELECTABLE_AREA;
289 }
290
283 // We don't handle all possible link types of the PDF. For example, 291 // We don't handle all possible link types of the PDF. For example,
284 // launch actions, cross-document links, etc. 292 // launch actions, cross-document links, etc.
285 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA 293 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA
286 // and we should proceed with area detection. 294 // and we should proceed with area detection.
287 PDFiumPage::Area area = GetLinkTarget(link, target); 295 PDFiumPage::Area area = GetLinkTarget(link, target);
288 if (area != PDFiumPage::NONSELECTABLE_AREA) 296 if (area != PDFiumPage::NONSELECTABLE_AREA)
289 return area; 297 return area;
298 } else if (link) {
299 // We don't handle all possible link types of the PDF. For example,
300 // launch actions, cross-document links, etc.
301 // See identical block above.
302 PDFiumPage::Area area = GetLinkTarget(link, target);
303 if (area != PDFiumPage::NONSELECTABLE_AREA)
304 return area;
305 } else if (control > FPDF_FORMFIELD_UNKNOWN) {
306 *form_type = control;
307 return PDFiumPage::NONSELECTABLE_AREA;
290 } 308 }
291 309
292 if (rv < 0) 310 if (rv < 0)
293 return NONSELECTABLE_AREA; 311 return NONSELECTABLE_AREA;
294 312
295 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA; 313 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA;
296 } 314 }
297 315
298 base::char16 PDFiumPage::GetCharAtIndex(int index) { 316 base::char16 PDFiumPage::GetCharAtIndex(int index) {
299 if (!available_) 317 if (!available_)
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 page_->loading_count_--; 526 page_->loading_count_--;
509 } 527 }
510 528
511 PDFiumPage::Link::Link() { 529 PDFiumPage::Link::Link() {
512 } 530 }
513 531
514 PDFiumPage::Link::~Link() { 532 PDFiumPage::Link::~Link() {
515 } 533 }
516 534
517 } // namespace chrome_pdf 535 } // namespace chrome_pdf
OLDNEW
« 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