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

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: 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/pdfium/pdfium_page.h ('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..4a1fa6c485bb5c00bb0f532836ede438e28fd7f3 100644
--- a/pdf/pdfium/pdfium_page.cc
+++ b/pdf/pdfium/pdfium_page.cc
@@ -371,6 +371,32 @@ int PDFiumPage::GetLink(int char_index, PDFiumPage::LinkTarget* target) {
return -1;
}
+std::vector<pp::Rect> PDFiumPage::GetLinkRects() {
+ if (!available_)
+ return std::vector<pp::Rect>();
+
+ CalculateLinks();
+
+ std::vector<pp::Rect> link_rects;
+ for (size_t i = 0; i < links_.size(); ++i) {
Lei Zhang 2016/07/08 18:02:36 nit: You can also do a range-based for loop here.
jaepark 2016/07/08 20:58:16 Done.
+ pp::Rect rect = UnionLinkCharRects(links_[i].rects);
Lei Zhang 2016/07/08 18:02:36 nit: No need for |rect| ?
jaepark 2016/07/08 20:58:16 Done.
+ link_rects.push_back(rect);
+ }
+
+ return link_rects;
+}
+
+pp::Rect PDFiumPage::UnionLinkCharRects(const std::vector<pp::Rect> rects) {
+ if (rects.empty())
Lei Zhang 2016/07/08 18:02:36 Can't you skip this check and get the same result?
jaepark 2016/07/08 20:58:16 Done.
+ return pp::Rect();
+
+ pp::Rect result_rect;
+ for (const auto& rect : rects)
+ result_rect = result_rect.Union(rect);
+
+ return result_rect;
+}
+
std::vector<int> PDFiumPage::GetLinks(pp::Rect text_area,
std::vector<LinkTarget>* targets) {
std::vector<int> links;
« 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