summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_contentmark.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-07-11 21:19:22 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-11 21:19:22 +0000
commitb4bcf69210719810ca563b9f8c0179719e80d212 (patch)
tree1a809ee9a2c7b20db29e33918b6eecfa0aae8a2b /core/fpdfapi/page/cpdf_contentmark.cpp
parent10a7ddb596f0089ba12d0db29b5752a61919a208 (diff)
downloadpdfium-b4bcf69210719810ca563b9f8c0179719e80d212.tar.xz
Write marked content operators when generating a stream.
The marked content operators are BMC, BDC and EMC. In the case of BDC, it is preceded by a direct dict or a property name. Bug: pdfium:1118 Change-Id: I3ee736ff7be3e7d7dde55ef581af3444a325e887 Reviewed-on: https://pdfium-review.googlesource.com/37470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_contentmark.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp
index 29d1bba210..1ff567d9e6 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmark.cpp
@@ -6,6 +6,7 @@
#include "core/fpdfapi/page/cpdf_contentmark.h"
+#include <algorithm>
#include <utility>
#include "core/fpdfapi/parser/cpdf_dictionary.h"
@@ -79,6 +80,20 @@ void CPDF_ContentMark::DeleteLastMark() {
m_pMarkData.Reset();
}
+size_t CPDF_ContentMark::FindFirstDifference(
+ const CPDF_ContentMark* other) const {
+ if (m_pMarkData == other->m_pMarkData)
+ return CountItems();
+
+ size_t min_len = std::min(CountItems(), other->CountItems());
+
+ for (size_t i = 0; i < min_len; ++i) {
+ if (GetItem(i) != other->GetItem(i))
+ return i;
+ }
+ return min_len;
+}
+
CPDF_ContentMark::MarkData::MarkData() {}
CPDF_ContentMark::MarkData::MarkData(const MarkData& src)