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

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: 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, new_y;
Tom Sepez 2015/08/07 18:19:13 nit: one per line.
Lei Zhang 2015/08/07 23:39:41 Done.
267 FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(), 267 FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(),
268 rotation, point2.x(), point2.y(), &new_x, &new_y); 268 rotation, point2.x(), point2.y(), &new_x, &new_y);
269 269
270 int rv = FPDFText_GetCharIndexAtPos( 270 int rv = FPDFText_GetCharIndexAtPos(
271 GetTextPage(), new_x, new_y, kTolerance, kTolerance); 271 GetTextPage(), new_x, new_y, kTolerance, kTolerance);
272 *char_index = rv; 272 *char_index = rv;
273 273
274 FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y);
274 int control = 275 int control =
275 FPDPage_HasFormFieldAtPoint(engine_->form(), GetPage(), new_x, new_y); 276 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 277
281 FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y); 278 // If there is a control and link at the same point, figure out their z-order
282 if (link) { 279 // to determine which is on top.
280 if (link && control > FPDF_FORMFIELD_UNKNOWN) {
281 int control_z_order = FPDPage_FormFieldZOrderAtPoint(
282 engine_->form(), GetPage(), new_x, new_y);
283 int link_z_order = FPDFLink_GetLinkZOrderAtPoint(GetPage(), new_x, new_y);
284 DCHECK_NE(control_z_order, link_z_order);
285 if (control_z_order > link_z_order) {
286 *form_type = control;
287 return PDFiumPage::NONSELECTABLE_AREA;
288 }
289
283 // We don't handle all possible link types of the PDF. For example, 290 // We don't handle all possible link types of the PDF. For example,
284 // launch actions, cross-document links, etc. 291 // launch actions, cross-document links, etc.
285 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA 292 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA
286 // and we should proceed with area detection. 293 // and we should proceed with area detection.
287 PDFiumPage::Area area = GetLinkTarget(link, target); 294 PDFiumPage::Area area = GetLinkTarget(link, target);
288 if (area != PDFiumPage::NONSELECTABLE_AREA) 295 if (area != PDFiumPage::NONSELECTABLE_AREA)
289 return area; 296 return area;
297 } else if (link) {
298 // We don't handle all possible link types of the PDF. For example,
299 // See identical block above.
300 PDFiumPage::Area area = GetLinkTarget(link, target);
301 if (area != PDFiumPage::NONSELECTABLE_AREA)
302 return area;
303 } else if (control > FPDF_FORMFIELD_UNKNOWN) {
304 *form_type = control;
305 return PDFiumPage::NONSELECTABLE_AREA;
290 } 306 }
291 307
292 if (rv < 0) 308 if (rv < 0)
293 return NONSELECTABLE_AREA; 309 return NONSELECTABLE_AREA;
294 310
295 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA; 311 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA;
Tom Sepez 2015/08/07 18:20:14 nit: seems like a double negative here.
Lei Zhang 2015/08/07 23:39:41 Seems ok to me. "If GetLink() succeeds, it's a web
296 } 312 }
297 313
298 base::char16 PDFiumPage::GetCharAtIndex(int index) { 314 base::char16 PDFiumPage::GetCharAtIndex(int index) {
299 if (!available_) 315 if (!available_)
300 return L'\0'; 316 return L'\0';
301 return static_cast<base::char16>(FPDFText_GetUnicode(GetTextPage(), index)); 317 return static_cast<base::char16>(FPDFText_GetUnicode(GetTextPage(), index));
302 } 318 }
303 319
304 int PDFiumPage::GetCharCount() { 320 int PDFiumPage::GetCharCount() {
305 if (!available_) 321 if (!available_)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 page_->loading_count_--; 524 page_->loading_count_--;
509 } 525 }
510 526
511 PDFiumPage::Link::Link() { 527 PDFiumPage::Link::Link() {
512 } 528 }
513 529
514 PDFiumPage::Link::~Link() { 530 PDFiumPage::Link::~Link() {
515 } 531 }
516 532
517 } // namespace chrome_pdf 533 } // 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