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

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

Issue 2127383002: Open hyperlinks in PDF in a new tab when middle mouse clicking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Open hyperlinks in PDF in a new tab when middle mouse clicking. Created 4 years, 5 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_engine.cc ('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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 std::swap(top, bottom); 66 std::swap(top, bottom);
67 pp::FloatRect page_coords(left, top, right - left, bottom - top); 67 pp::FloatRect page_coords(left, top, right - left, bottom - top);
68 return FloatPageRectToPixelRect(page, page_coords); 68 return FloatPageRectToPixelRect(page, page_coords);
69 } 69 }
70 70
71 bool OverlapsOnYAxis(const pp::FloatRect &a, const pp::FloatRect& b) { 71 bool OverlapsOnYAxis(const pp::FloatRect &a, const pp::FloatRect& b) {
72 return !(a.IsEmpty() || b.IsEmpty() || 72 return !(a.IsEmpty() || b.IsEmpty() ||
73 a.bottom() < b.y() || b.bottom() < a.y()); 73 a.bottom() < b.y() || b.bottom() < a.y());
74 } 74 }
75 75
76 pp::Rect UnionLinkCharRects(const std::vector<pp::Rect>& rects) {
77 pp::Rect result_rect;
78 for (const auto& rect : rects)
79 result_rect = result_rect.Union(rect);
80
81 return result_rect;
82 }
83
76 } // namespace 84 } // namespace
77 85
78 namespace chrome_pdf { 86 namespace chrome_pdf {
79 87
80 PDFiumPage::PDFiumPage(PDFiumEngine* engine, 88 PDFiumPage::PDFiumPage(PDFiumEngine* engine,
81 int i, 89 int i,
82 const pp::Rect& r, 90 const pp::Rect& r,
83 bool available) 91 bool available)
84 : engine_(engine), 92 : engine_(engine),
85 page_(NULL), 93 page_(NULL),
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (rect.Contains(origin)) { 372 if (rect.Contains(origin)) {
365 if (target) 373 if (target)
366 target->url = links_[i].url; 374 target->url = links_[i].url;
367 return i; 375 return i;
368 } 376 }
369 } 377 }
370 } 378 }
371 return -1; 379 return -1;
372 } 380 }
373 381
382 std::vector<pp::Rect> PDFiumPage::GetLinkRects() {
383 std::vector<pp::Rect> link_rects;
384 if (!available_)
385 return link_rects;
386
387 CalculateLinks();
388
389 for (const auto& link : links_)
390 link_rects.push_back(UnionLinkCharRects(link.rects));
391
392 return link_rects;
393 }
394
374 std::vector<int> PDFiumPage::GetLinks(pp::Rect text_area, 395 std::vector<int> PDFiumPage::GetLinks(pp::Rect text_area,
375 std::vector<LinkTarget>* targets) { 396 std::vector<LinkTarget>* targets) {
376 std::vector<int> links; 397 std::vector<int> links;
377 if (!available_) 398 if (!available_)
378 return links; 399 return links;
379 400
380 CalculateLinks(); 401 CalculateLinks();
381 402
382 for (size_t i = 0; i < links_.size(); ++i) { 403 for (size_t i = 0; i < links_.size(); ++i) {
383 for (const auto& rect : links_[i].rects) { 404 for (const auto& rect : links_[i].rects) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 page_->loading_count_--; 518 page_->loading_count_--;
498 } 519 }
499 520
500 PDFiumPage::Link::Link() { 521 PDFiumPage::Link::Link() {
501 } 522 }
502 523
503 PDFiumPage::Link::~Link() { 524 PDFiumPage::Link::~Link() {
504 } 525 }
505 526
506 } // namespace chrome_pdf 527 } // namespace chrome_pdf
OLDNEW
« pdf/pdfium/pdfium_engine.cc ('K') | « pdf/pdfium/pdfium_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698