summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-25 16:16:32 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-25 16:16:32 -0700
commit5ce09684216ed6b74836de9bd056b8f15bd66a4e (patch)
tree841e23498e3684f4b83062c958169bb05573af7d /fpdfsdk
parent65be4b1818ab99df2bf5b6265604fc25456db49d (diff)
downloadpdfium-5ce09684216ed6b74836de9bd056b8f15bd66a4e.tar.xz
Remove CFX_PrivateData from CPDF_Document
Replace it with two generic slots for Links and Codec usage. Since the codec is at a lower layer than the document, we don't provide separate get/set methods, since having a document upon which to call these would be a layering violation. Do the same for the Links for simplicity. Review-Url: https://codereview.chromium.org/2005193003
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfdoc.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index 7473cb0671..0f69340821 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -16,8 +16,6 @@
namespace {
-int THISMODULE = 0;
-
CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
CPDF_Bookmark bookmark,
const CFX_WideString& title,
@@ -45,22 +43,15 @@ 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;
+ std::unique_ptr<CPDF_LinkList>* pHolder = pDoc->LinksContext();
+ if (!pHolder->get())
+ pHolder->reset(new CPDF_LinkList);
+ return pHolder->get();
}
} // namespace