Chromium Code Reviews| 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, |