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

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

Issue 2924343005: Add functionality for copying text within form text fields and form combobox text fields (Closed)
Patch Set: Add FormTypeToArea helper, style changes Created 3 years, 6 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
« pdf/pdfium/pdfium_page.h ('K') | « 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 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 // If there is a control and link at the same point, figure out their z-order 258 // If there is a control and link at the same point, figure out their z-order
259 // to determine which is on top. 259 // to determine which is on top.
260 if (link && control > FPDF_FORMFIELD_UNKNOWN) { 260 if (link && control > FPDF_FORMFIELD_UNKNOWN) {
261 int control_z_order = FPDFPage_FormFieldZOrderAtPoint( 261 int control_z_order = FPDFPage_FormFieldZOrderAtPoint(
262 engine_->form(), GetPage(), new_x, new_y); 262 engine_->form(), GetPage(), new_x, new_y);
263 int link_z_order = FPDFLink_GetLinkZOrderAtPoint(GetPage(), new_x, new_y); 263 int link_z_order = FPDFLink_GetLinkZOrderAtPoint(GetPage(), new_x, new_y);
264 DCHECK_NE(control_z_order, link_z_order); 264 DCHECK_NE(control_z_order, link_z_order);
265 if (control_z_order > link_z_order) { 265 if (control_z_order > link_z_order) {
266 *form_type = control; 266 *form_type = control;
267 return PDFiumPage::NONSELECTABLE_AREA; 267 return FormTypeToArea(*form_type);
268 } 268 }
269 269
270 // We don't handle all possible link types of the PDF. For example, 270 // We don't handle all possible link types of the PDF. For example,
271 // launch actions, cross-document links, etc. 271 // launch actions, cross-document links, etc.
272 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA 272 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA
273 // and we should proceed with area detection. 273 // and we should proceed with area detection.
274 PDFiumPage::Area area = GetLinkTarget(link, target); 274 PDFiumPage::Area area = GetLinkTarget(link, target);
275 if (area != PDFiumPage::NONSELECTABLE_AREA) 275 if (area != PDFiumPage::NONSELECTABLE_AREA)
276 return area; 276 return area;
277 } else if (link) { 277 } else if (link) {
278 // We don't handle all possible link types of the PDF. For example, 278 // We don't handle all possible link types of the PDF. For example,
279 // launch actions, cross-document links, etc. 279 // launch actions, cross-document links, etc.
280 // See identical block above. 280 // See identical block above.
281 PDFiumPage::Area area = GetLinkTarget(link, target); 281 PDFiumPage::Area area = GetLinkTarget(link, target);
282 if (area != PDFiumPage::NONSELECTABLE_AREA) 282 if (area != PDFiumPage::NONSELECTABLE_AREA)
283 return area; 283 return area;
284 } else if (control > FPDF_FORMFIELD_UNKNOWN) { 284 } else if (control > FPDF_FORMFIELD_UNKNOWN) {
285 *form_type = control; 285 *form_type = control;
286 return PDFiumPage::NONSELECTABLE_AREA; 286 return FormTypeToArea(*form_type);
287 } 287 }
288 288
289 if (rv < 0) 289 if (rv < 0)
290 return NONSELECTABLE_AREA; 290 return NONSELECTABLE_AREA;
291 291
292 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA; 292 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA;
293 } 293 }
294 294
295 PDFiumPage::Area PDFiumPage::FormTypeToArea(int form_type) {
Lei Zhang 2017/06/21 00:19:46 If we make this a static method, we like to make a
drgage 2017/06/21 01:30:24 Done.
296 switch (form_type) {
297 case FPDF_FORMFIELD_TEXTFIELD:
298 return PDFiumPage::FORM_TEXT_AREA;
Lei Zhang 2017/06/21 00:19:45 We can omit this return and just let it fall throu
drgage 2017/06/21 01:30:24 Done.
299 case FPDF_FORMFIELD_COMBOBOX:
Lei Zhang 2017/06/21 00:19:45 Let's put this value first, since it appears earli
drgage 2017/06/21 01:30:24 Done.
300 return PDFiumPage::FORM_TEXT_AREA;
301 default:
302 return PDFiumPage::NONSELECTABLE_AREA;
303 }
304 }
305
295 base::char16 PDFiumPage::GetCharAtIndex(int index) { 306 base::char16 PDFiumPage::GetCharAtIndex(int index) {
296 if (!available_) 307 if (!available_)
297 return L'\0'; 308 return L'\0';
298 return static_cast<base::char16>(FPDFText_GetUnicode(GetTextPage(), index)); 309 return static_cast<base::char16>(FPDFText_GetUnicode(GetTextPage(), index));
299 } 310 }
300 311
301 int PDFiumPage::GetCharCount() { 312 int PDFiumPage::GetCharCount() {
302 if (!available_) 313 if (!available_)
303 return 0; 314 return 0;
304 return FPDFText_CountChars(GetTextPage()); 315 return FPDFText_CountChars(GetTextPage());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 page_->loading_count_--; 533 page_->loading_count_--;
523 } 534 }
524 535
525 PDFiumPage::Link::Link() = default; 536 PDFiumPage::Link::Link() = default;
526 537
527 PDFiumPage::Link::Link(const Link& that) = default; 538 PDFiumPage::Link::Link(const Link& that) = default;
528 539
529 PDFiumPage::Link::~Link() = default; 540 PDFiumPage::Link::~Link() = default;
530 541
531 } // namespace chrome_pdf 542 } // namespace chrome_pdf
OLDNEW
« pdf/pdfium/pdfium_page.h ('K') | « pdf/pdfium/pdfium_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698