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

Unified 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 side-by-side diff with in-line comments
Download patch
« pdf/out_of_process_instance.cc ('K') | « pdf/pdfium/pdfium_page.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_page.cc
diff --git a/pdf/pdfium/pdfium_page.cc b/pdf/pdfium/pdfium_page.cc
index e95296986d823d84491fdd0fd8cdeea7ea80daf2..07694c3351468dc8e757527e62e9faaab7728a4c 100644
--- a/pdf/pdfium/pdfium_page.cc
+++ b/pdf/pdfium/pdfium_page.cc
@@ -73,6 +73,14 @@ bool OverlapsOnYAxis(const pp::FloatRect &a, const pp::FloatRect& b) {
a.bottom() < b.y() || b.bottom() < a.y());
}
+pp::Rect UnionLinkCharRects(const std::vector<pp::Rect>& rects) {
+ pp::Rect result_rect;
+ for (const auto& rect : rects)
+ result_rect = result_rect.Union(rect);
+
+ return result_rect;
+}
+
} // namespace
namespace chrome_pdf {
@@ -371,6 +379,19 @@ int PDFiumPage::GetLink(int char_index, PDFiumPage::LinkTarget* target) {
return -1;
}
+std::vector<pp::Rect> PDFiumPage::GetLinkRects() {
+ std::vector<pp::Rect> link_rects;
+ if (!available_)
+ return link_rects;
+
+ CalculateLinks();
+
+ for (const auto& link : links_)
+ link_rects.push_back(UnionLinkCharRects(link.rects));
+
+ return link_rects;
+}
+
std::vector<int> PDFiumPage::GetLinks(pp::Rect text_area,
std::vector<LinkTarget>* targets) {
std::vector<int> links;
« pdf/out_of_process_instance.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