From 47ddc0fca1e5944965866ac55844515a28d2d022 Mon Sep 17 00:00:00 2001 From: "n.bansal" Date: Wed, 10 Sep 2014 16:25:10 -0700 Subject: 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} --- pdf/pdfium/pdfium_engine.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pdf') 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((point.x() + position_.x()) / current_zoom_), + static_cast((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(); -- cgit v1.1