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

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: 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
Index: fpdfsdk/src/fpdfdoc.cpp
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index bcd401b4c48a300338b7821150321fb9e92f9a51..dabb8ca70138a41da5ea426911ef84d5596a0e6a 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -169,16 +169,37 @@ DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
double x,
double y) {
if (!page)
- return NULL;
+ return nullptr;
+
+ 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->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
+ }
+ return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, nullptr)
+ .GetDict();
+}
+
+DLLEXPORT int STDCALL FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page,
+ double x,
+ double y) {
+ if (!page)
+ return -1;
+
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);
Tom Sepez 2015/08/07 18:14:06 nit: Is this the only place we do "get or create"?
Lei Zhang 2015/08/07 23:03:41 I consolidated.
if (!pLinkList) {
- pLinkList = new CPDF_LinkList(pDoc);
+ pLinkList = new CPDF_LinkList;
pDoc->SetPrivateData(&THISMODULE, pLinkList, ReleaseLinkList);
}
- return pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y).GetDict();
+ int z_order = -1;
+ pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order);
Tom Sepez 2015/08/07 18:14:06 nit: maybe (void) to indicate result not used?
Lei Zhang 2015/08/07 23:03:41 Done.
+ return z_order;
}
DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,

Powered by Google App Engine
This is Rietveld 408576698