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

Unified Diff: fpdfsdk/src/fpdfdoc.cpp

Issue 1278053004: Add new public APIs to find the z-order for links and widgets. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years, 4 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
« no previous file with comments | « core/src/fpdfdoc/doc_link.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdfdoc.cpp
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index bcd401b4c48a300338b7821150321fb9e92f9a51..5d2469c160759f4a6521e8bdb96c0b138affd31d 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -7,11 +7,13 @@
#include "../include/fsdk_define.h"
#include "../../public/fpdf_doc.h"
-static int THISMODULE = 0;
+namespace {
-static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
- CPDF_Bookmark bookmark,
- const CFX_WideString& title) {
+int THISMODULE = 0;
+
+CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
+ CPDF_Bookmark bookmark,
+ const CFX_WideString& title) {
if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
// First check this item
return bookmark;
@@ -28,6 +30,26 @@ static CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
return CPDF_Bookmark();
}
+void ReleaseLinkList(void* data) {
+ delete (CPDF_LinkList*)data;
+}
+
+CPDF_LinkList* GetLinkList(CPDF_Page* page) {
+ if (!page)
+ return nullptr;
+
+ // Link list is stored with the document
+ CPDF_Document* pDoc = page->m_pDocument;
+ CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
+ if (!pLinkList) {
+ pLinkList = new CPDF_LinkList;
+ pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
+ }
+ return pLinkList;
+}
+
+} // namespace
+
DLLEXPORT FPDF_BOOKMARK STDCALL
FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
if (!document)
@@ -161,24 +183,27 @@ DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document,
return dest.GetPageIndex(pDoc);
}
-static void ReleaseLinkList(void* data) {
- delete (CPDF_LinkList*)data;
+DLLEXPORT FPDF_LINK STDCALL
+FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) {
+ CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_LinkList* pLinkList = GetLinkList(pPage);
+ if (!pLinkList)
+ return nullptr;
+
+ return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr)
+ .GetDict();
}
-DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
- double x,
- double y) {
- if (!page)
- return NULL;
+DLLEXPORT int STDCALL
+FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y) {
CPDF_Page* pPage = (CPDF_Page*)page;
- // Link list is stored with the document
- CPDF_Document* pDoc = pPage->m_pDocument;
- CPDF_LinkList* pLinkList = (CPDF_LinkList*)pDoc->GetPrivateData(&THISMODULE);
- if (!pLinkList) {
- pLinkList = new CPDF_LinkList(pDoc);
- pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
- }
- return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDict();
+ CPDF_LinkList* pLinkList = GetLinkList(pPage);
+ if (!pLinkList)
+ return -1;
+
+ int z_order = -1;
+ pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order);
+ return z_order;
}
DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
« no previous file with comments | « core/src/fpdfdoc/doc_link.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698