diff options
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmark.cpp | 15 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmark.h | 1 |
2 files changed, 16 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) diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h index 33180333af..8bbae52418 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -35,6 +35,7 @@ class CPDF_ContentMark { CPDF_Dictionary* pDict, const ByteString& property_name); void DeleteLastMark(); + size_t FindFirstDifference(const CPDF_ContentMark* other) const; private: class MarkData : public Retainable { |