diff options
author | tsepez <tsepez@chromium.org> | 2016-09-21 13:30:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-21 13:30:29 -0700 |
commit | 17103b84ebde9ab2b05dff38d473b5d44f723ff2 (patch) | |
tree | d200ac5050cfbb2454bacbef3a97b2c89c542183 /core/fpdfapi/fpdf_page/cpdf_contentmark.cpp | |
parent | c0f60dc29db66262bbc0082fcd51170a570b0d1f (diff) | |
download | pdfium-17103b84ebde9ab2b05dff38d473b5d44f723ff2.tar.xz |
Make ownership explicit in CPDF_ContentMarkItem.
The old SetParam() method had "maybe take ownership" semanitcs
based upon the type argument.
Make GetParam() handle the None case and simplify callers
based upon that behaviour.
Review-Url: https://codereview.chromium.org/2358043003
Diffstat (limited to 'core/fpdfapi/fpdf_page/cpdf_contentmark.cpp')
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_contentmark.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp index 99a16004cd..1c47f00182 100644 --- a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp @@ -66,11 +66,7 @@ bool CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark, for (int i = 0; i < pData->CountItems(); i++) { const CPDF_ContentMarkItem& item = pData->GetItem(i); if (item.GetName() == mark) { - pDict = nullptr; - if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || - item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { - pDict = item.GetParam(); - } + pDict = item.GetParam(); return true; } } @@ -99,13 +95,9 @@ const CPDF_ContentMarkItem& CPDF_ContentMark::MarkData::GetItem( int CPDF_ContentMark::MarkData::GetMCID() const { for (const auto& mark : m_Marks) { - CPDF_ContentMarkItem::ParamType type = mark.GetParamType(); - if (type == CPDF_ContentMarkItem::PropertiesDict || - type == CPDF_ContentMarkItem::DirectDict) { - CPDF_Dictionary* pDict = mark.GetParam(); - if (pDict->KeyExist("MCID")) - return pDict->GetIntegerFor("MCID"); - } + CPDF_Dictionary* pDict = mark.GetParam(); + if (pDict && pDict->KeyExist("MCID")) + return pDict->GetIntegerFor("MCID"); } return -1; } @@ -117,13 +109,14 @@ void CPDF_ContentMark::MarkData::AddMark(const CFX_ByteString& name, item.SetName(name); if (pDict) { if (bDirect) { - item.SetParam(CPDF_ContentMarkItem::DirectDict, - ToDictionary(pDict->Clone())); + item.SetDirectDict( + std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>( + ToDictionary(pDict->Clone()))); } else { - item.SetParam(CPDF_ContentMarkItem::PropertiesDict, pDict); + item.SetPropertiesDict(pDict); } } - m_Marks.push_back(item); + m_Marks.push_back(std::move(item)); } void CPDF_ContentMark::MarkData::DeleteLastMark() { |