Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 268 if (*form_type == FPDF_FORMFIELD_TEXTFIELD || | |
| 269 *form_type == FPDF_FORMFIELD_COMBOBOX) | |
|
dsinclair
2017/06/20 15:21:44
This and the one below should have {}s as the cond
drgage
2017/06/20 23:14:27
Done - I actually created a helper to convert from
| |
| 270 return PDFiumPage::FORM_TEXT_AREA; | |
| 271 | |
| 267 return PDFiumPage::NONSELECTABLE_AREA; | 272 return PDFiumPage::NONSELECTABLE_AREA; |
| 268 } | 273 } |
| 269 | 274 |
| 270 // We don't handle all possible link types of the PDF. For example, | 275 // We don't handle all possible link types of the PDF. For example, |
| 271 // launch actions, cross-document links, etc. | 276 // launch actions, cross-document links, etc. |
| 272 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA | 277 // In that case, GetLinkTarget() will return NONSELECTABLE_AREA |
| 273 // and we should proceed with area detection. | 278 // and we should proceed with area detection. |
| 274 PDFiumPage::Area area = GetLinkTarget(link, target); | 279 PDFiumPage::Area area = GetLinkTarget(link, target); |
| 275 if (area != PDFiumPage::NONSELECTABLE_AREA) | 280 if (area != PDFiumPage::NONSELECTABLE_AREA) |
| 276 return area; | 281 return area; |
| 277 } else if (link) { | 282 } else if (link) { |
| 278 // 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, |
| 279 // launch actions, cross-document links, etc. | 284 // launch actions, cross-document links, etc. |
| 280 // See identical block above. | 285 // See identical block above. |
| 281 PDFiumPage::Area area = GetLinkTarget(link, target); | 286 PDFiumPage::Area area = GetLinkTarget(link, target); |
| 282 if (area != PDFiumPage::NONSELECTABLE_AREA) | 287 if (area != PDFiumPage::NONSELECTABLE_AREA) |
| 283 return area; | 288 return area; |
| 284 } else if (control > FPDF_FORMFIELD_UNKNOWN) { | 289 } else if (control > FPDF_FORMFIELD_UNKNOWN) { |
| 285 *form_type = control; | 290 *form_type = control; |
| 291 | |
| 292 if (*form_type == FPDF_FORMFIELD_TEXTFIELD || | |
| 293 *form_type == FPDF_FORMFIELD_COMBOBOX) | |
| 294 return PDFiumPage::FORM_TEXT_AREA; | |
| 295 | |
| 286 return PDFiumPage::NONSELECTABLE_AREA; | 296 return PDFiumPage::NONSELECTABLE_AREA; |
| 287 } | 297 } |
| 288 | 298 |
| 289 if (rv < 0) | 299 if (rv < 0) |
| 290 return NONSELECTABLE_AREA; | 300 return NONSELECTABLE_AREA; |
| 291 | 301 |
| 292 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA; | 302 return GetLink(*char_index, target) != -1 ? WEBLINK_AREA : TEXT_AREA; |
| 293 } | 303 } |
| 294 | 304 |
| 295 base::char16 PDFiumPage::GetCharAtIndex(int index) { | 305 base::char16 PDFiumPage::GetCharAtIndex(int index) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 page_->loading_count_--; | 532 page_->loading_count_--; |
| 523 } | 533 } |
| 524 | 534 |
| 525 PDFiumPage::Link::Link() = default; | 535 PDFiumPage::Link::Link() = default; |
| 526 | 536 |
| 527 PDFiumPage::Link::Link(const Link& that) = default; | 537 PDFiumPage::Link::Link(const Link& that) = default; |
| 528 | 538 |
| 529 PDFiumPage::Link::~Link() = default; | 539 PDFiumPage::Link::~Link() = default; |
| 530 | 540 |
| 531 } // namespace chrome_pdf | 541 } // namespace chrome_pdf |
| OLD | NEW |