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

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

Issue 316233002: Fix some links in PDFs not working. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 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 | Annotate | Revision Log
« 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 void PDFiumPage::CalculateLinks() { 381 void PDFiumPage::CalculateLinks() {
382 if (calculated_links_) 382 if (calculated_links_)
383 return; 383 return;
384 384
385 calculated_links_ = true; 385 calculated_links_ = true;
386 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage()); 386 FPDF_PAGELINK links = FPDFLink_LoadWebLinks(GetTextPage());
387 int count = FPDFLink_CountWebLinks(links); 387 int count = FPDFLink_CountWebLinks(links);
388 for (int i = 0; i < count; ++i) { 388 for (int i = 0; i < count; ++i) {
389 base::string16 url; 389 base::string16 url;
390 int url_length = FPDFLink_GetURL(links, i, NULL, 0); 390 int url_length = FPDFLink_GetURL(links, i, NULL, 0);
391 if (url_length > 0) { 391 if (url_length > 0) {
Lei Zhang 2014/06/05 22:26:21 This needs to be url_length > 1 because WriteInto(
jam 2014/06/06 01:17:51 actually, i looked more and the bug is in pdfium.
jam 2014/06/06 03:19:04 Done.
392 unsigned short* data = 392 unsigned short* data =
393 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length + 1)); 393 reinterpret_cast<unsigned short*>(WriteInto(&url, url_length));
394 FPDFLink_GetURL(links, i, data, url_length); 394 FPDFLink_GetURL(links, i, data, url_length);
395 } 395 }
396 Link link; 396 Link link;
397 link.url = base::UTF16ToUTF8(url); 397 link.url = base::UTF16ToUTF8(url);
398 398
399 // If the link cannot be converted to a pp::Var, then it is not possible to 399 // If the link cannot be converted to a pp::Var, then it is not possible to
400 // pass it to JS. In this case, ignore the link like other PDF viewers. 400 // pass it to JS. In this case, ignore the link like other PDF viewers.
401 // See http://crbug.com/312882 for an example. 401 // See http://crbug.com/312882 for an example.
402 pp::Var link_var(link.url); 402 pp::Var link_var(link.url);
403 if (!link_var.is_string()) 403 if (!link_var.is_string())
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 new_left, new_top, new_right - new_left + 1, new_bottom - new_top + 1); 469 new_left, new_top, new_right - new_left + 1, new_bottom - new_top + 1);
470 } 470 }
471 471
472 PDFiumPage::Link::Link() { 472 PDFiumPage::Link::Link() {
473 } 473 }
474 474
475 PDFiumPage::Link::~Link() { 475 PDFiumPage::Link::~Link() {
476 } 476 }
477 477
478 } // namespace chrome_pdf 478 } // 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