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

Side by Side Diff: pdf/pdfium/pdfium_page.cc

Issue 969513002: PDF: Handle hit tests for form controls and links consistently. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « pdf/pdfium/pdfium_page.h ('k') | 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 base::DictionaryValue* node = new base::DictionaryValue(); 251 base::DictionaryValue* node = new base::DictionaryValue();
252 node->SetString(kTextNodeType, kTextNodeTypeURL); 252 node->SetString(kTextNodeType, kTextNodeTypeURL);
253 node->SetString(kTextNodeText, text); 253 node->SetString(kTextNodeText, text);
254 node->SetString(kTextNodeURL, url); 254 node->SetString(kTextNodeURL, url);
255 return node; 255 return node;
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 LinkTarget* target) { 262 LinkTarget* target) {
262 if (!available_) 263 if (!available_)
263 return NONSELECTABLE_AREA; 264 return NONSELECTABLE_AREA;
264 pp::Point point2 = point - rect_.point(); 265 pp::Point point2 = point - rect_.point();
265 double new_x, new_y; 266 double new_x, new_y;
266 FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(), 267 FPDF_DeviceToPage(GetPage(), 0, 0, rect_.width(), rect_.height(),
267 rotation, point2.x(), point2.y(), &new_x, &new_y); 268 rotation, point2.x(), point2.y(), &new_x, &new_y);
268 269
269 int rv = FPDFText_GetCharIndexAtPos( 270 int rv = FPDFText_GetCharIndexAtPos(
270 GetTextPage(), new_x, new_y, kTolerance, kTolerance); 271 GetTextPage(), new_x, new_y, kTolerance, kTolerance);
271 *char_index = rv; 272 *char_index = rv;
272 273
274 int control =
275 FPDPage_HasFormFieldAtPoint(engine_->form(), GetPage(), new_x, new_y);
Lei Zhang 2015/02/28 01:16:14 FPDPage_HasFormFieldAtPoint() and FPDFLink_GetLink
276 if (control > FPDF_FORMFIELD_UNKNOWN) {
277 *form_type = control;
278 return PDFiumPage::NONSELECTABLE_AREA;
279 }
280
273 FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y); 281 FPDF_LINK link = FPDFLink_GetLinkAtPoint(GetPage(), new_x, new_y);
274 if (link) { 282 if (link) {
275 // We don't handle all possible link types of the PDF. For example, 283 // We don't handle all possible link types of the PDF. For example,
276 // launch actions, cross-document links, etc. 284 // launch actions, cross-document links, etc.
277 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA 285 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA
278 // and we should proceed with area detection. 286 // and we should proceed with area detection.
279 PDFiumPage::Area area = GetLinkTarget(link, target); 287 PDFiumPage::Area area = GetLinkTarget(link, target);
280 if (area != PDFiumPage::NONSELECTABLE_AREA) 288 if (area != PDFiumPage::NONSELECTABLE_AREA)
281 return area; 289 return area;
282 } 290 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 page_->loading_count_--; 508 page_->loading_count_--;
501 } 509 }
502 510
503 PDFiumPage::Link::Link() { 511 PDFiumPage::Link::Link() {
504 } 512 }
505 513
506 PDFiumPage::Link::~Link() { 514 PDFiumPage::Link::~Link() {
507 } 515 }
508 516
509 } // namespace chrome_pdf 517 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698