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

Unified Diff: core/fpdfapi/fpdf_page/cpdf_contentmark.cpp

Issue 2358043003: Make ownership explicit in CPDF_ContentMarkItem (Closed)
Patch Set: Not owned Created 4 years, 3 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 | « no previous file | core/fpdfapi/fpdf_page/cpdf_contentmarkitem.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/cpdf_contentmark.cpp
diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp
index 99a16004cd7dd9408ba6d38e59659b37ce2eccd9..1c47f0018265a18f9a189bb534330666d7718ee2 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() {
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/cpdf_contentmarkitem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698