diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-06-21 15:10:17 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-21 20:40:15 +0000 |
commit | eca45e00c04fea5fa6be10a17f61cbcec6cba131 (patch) | |
tree | 33fed5a67379918ebbd083445accc569bb538843 /core/fpdfdoc/cpdf_occontext.cpp | |
parent | 4e5e6f793c1a04f8257d2ea260ffa693b2c8cfd6 (diff) | |
download | pdfium-eca45e00c04fea5fa6be10a17f61cbcec6cba131.tar.xz |
Fixed optional content not rendered when OCGs array is empty.chromium/3138
At least one nonnull entry needs to be in OCGs for it to be considered
present. See "OCGs" in table 4.49 in the PDF 1.7 spec.
Bug: pdfium:491.
Change-Id: I7eae65ba1fabff9cf1d5cea50d059a04814a3fec
Reviewed-on: https://pdfium-review.googlesource.com/6751
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_occontext.cpp')
-rw-r--r-- | core/fpdfdoc/cpdf_occontext.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp index 66950c9406..7e746e0028 100644 --- a/core/fpdfdoc/cpdf_occontext.cpp +++ b/core/fpdfdoc/cpdf_occontext.cpp @@ -254,18 +254,25 @@ bool CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict) { return true; bool bState = (csP == "AllOn" || csP == "AllOff"); + // At least one entry of OCGs needs to be a valid dictionary for it to be + // considered present. See "OCGs" in table 4.49 in the PDF 1.7 spec. + bool bValidEntrySeen = false; for (size_t i = 0; i < pArray->GetCount(); i++) { bool bItem = true; CPDF_Dictionary* pItemDict = pArray->GetDictAt(i); - if (pItemDict) - bItem = GetOCGVisible(pItemDict); + if (!pItemDict) + continue; + + bValidEntrySeen = true; + bItem = GetOCGVisible(pItemDict); if ((csP == "AnyOn" && bItem) || (csP == "AnyOff" && !bItem)) return true; if ((csP == "AllOn" && !bItem) || (csP == "AllOff" && bItem)) return false; } - return bState; + + return !bValidEntrySeen || bState; } bool CPDF_OCContext::CheckOCGVisible(const CPDF_Dictionary* pOCGDict) { |