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; |