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