summaryrefslogtreecommitdiffstats
path: root/pdf
diff options
context:
space:
mode:
authorn.bansal <n.bansal@samsung.com>2014-09-10 16:25:10 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-10 23:28:00 +0000
commit47ddc0fca1e5944965866ac55844515a28d2d022 (patch)
treec7996832f63a4c090119e52f4a569c79a82d02f0 /pdf
parent0332c191aa02efc6c24d0c87a1d41b7c12d3b8a8 (diff)
downloadchromium_src-47ddc0fca1e5944965866ac55844515a28d2d022.zip
chromium_src-47ddc0fca1e5944965866ac55844515a28d2d022.tar.gz
chromium_src-47ddc0fca1e5944965866ac55844515a28d2d022.tar.bz2
PDF Viewer - Show context menu for links on right click
Currently context menu for page is shown when right clicked on links in the pdf. This happens because an empty string is returned as url to ContextMenuClientImpl::showContextMenu() from plugin. The reason for above is that GetLinkAtPosition() isn't passing a point in page coordinates to GetCharIndex() and GetCharIndex() expects the point to be in page coordinate. This means that when the document is zoomed or scrolled and right click is done then it doesn't work. This patch updates the point passed to GetCharIndex() to be in page coordinates by factoring in current position and zoom level. BUG=148665 Review URL: https://codereview.chromium.org/553453002 Cr-Commit-Position: refs/heads/master@{#294256}
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdfium/pdfium_engine.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index e6713271..f0fe1b2 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -1867,7 +1867,10 @@ std::string PDFiumEngine::GetSelectedText() {
std::string PDFiumEngine::GetLinkAtPosition(const pp::Point& point) {
int temp;
PDFiumPage::LinkTarget target;
- PDFiumPage::Area area = GetCharIndex(point, &temp, &temp, &target);
+ pp::Point point_in_page(
+ static_cast<int>((point.x() + position_.x()) / current_zoom_),
+ static_cast<int>((point.y() + position_.y()) / current_zoom_));
+ PDFiumPage::Area area = GetCharIndex(point_in_page, &temp, &temp, &target);
if (area == PDFiumPage::WEBLINK_AREA)
return target.url;
return std::string();