summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_streamcontentparser.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-07-05 15:39:59 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-05 15:39:59 +0000
commit86b4f67d40c351ea8e67ba7b7dcc9d8dd7ad371e (patch)
tree54881ef1ca024cd369862cff584b5fd434c1a183 /core/fpdfapi/page/cpdf_streamcontentparser.cpp
parentd774a73b59ac36d533064041196d051c032eee6b (diff)
downloadpdfium-86b4f67d40c351ea8e67ba7b7dcc9d8dd7ad371e.tar.xz
Replace SharedCopyOnWrite<MarkData> with RetainPtr
A RetainPtr is already used inside SharedCopyOnWrite, and the API that CPDF_ContentMark offers is not intuitive. AddMark() and RemoveLastMark() currently copy the MarkData. The new API does not perform these copies, but rather leaves it to the client code. This is the first step to make CPDF_ContentMarkItems modifiable. As long as they are inside a SharedCopyOnWrite, they cannot be changed. Bug: pdfium:1037 Change-Id: I0cd6334b0b8db62070b4412f1d6d1c88bce9891f Reviewed-on: https://pdfium-review.googlesource.com/37132 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_streamcontentparser.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 0a03ed1949..b2ac553191 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -258,6 +258,7 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
m_ParamStartPos(0),
m_ParamCount(0),
m_pCurStates(pdfium::MakeUnique<CPDF_AllStates>()),
+ m_pCurContentMark(pdfium::MakeUnique<CPDF_ContentMark>()),
m_DefFontSize(0),
m_PathStartX(0.0f),
m_PathStartY(0.0f),
@@ -434,7 +435,7 @@ void CPDF_StreamContentParser::SetGraphicStates(CPDF_PageObject* pObj,
bool bGraph) {
pObj->m_GeneralState = m_pCurStates->m_GeneralState;
pObj->m_ClipPath = m_pCurStates->m_ClipPath;
- pObj->m_ContentMark = m_CurContentMark;
+ pObj->m_ContentMark = *m_pCurContentMark;
if (bColor) {
pObj->m_ColorState = m_pCurStates->m_ColorState;
}
@@ -606,8 +607,10 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
return;
bDirect = false;
}
- if (const CPDF_Dictionary* pDict = pProperty->AsDictionary())
- m_CurContentMark.AddMark(std::move(tag), pDict, bDirect);
+ if (const CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
+ m_pCurContentMark = m_pCurContentMark->Clone();
+ m_pCurContentMark->AddMark(std::move(tag), pDict, bDirect);
+ }
}
void CPDF_StreamContentParser::Handle_BeginImage() {
@@ -671,7 +674,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
- m_CurContentMark.AddMark(GetString(0), nullptr, false);
+ m_pCurContentMark = m_pCurContentMark->Clone();
+ m_pCurContentMark->AddMark(GetString(0), nullptr, false);
}
void CPDF_StreamContentParser::Handle_BeginText() {
@@ -864,8 +868,10 @@ void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() {}
void CPDF_StreamContentParser::Handle_EndImage() {}
void CPDF_StreamContentParser::Handle_EndMarkedContent() {
- if (m_CurContentMark.HasRef())
- m_CurContentMark.DeleteLastMark();
+ if (m_pCurContentMark->HasRef()) {
+ m_pCurContentMark = m_pCurContentMark->Clone();
+ m_pCurContentMark->DeleteLastMark();
+ }
}
void CPDF_StreamContentParser::Handle_EndText() {