From 6ce3b34281786c2332fa6de81fe67f7f4b883602 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 10 Aug 2018 21:42:43 +0000 Subject: Minor cleanup in CPDF_ContentParser. Add more asserts and use more constants. Change-Id: I51f1d9d1b501f4e99d9793b6c803676b7221be17 Reviewed-on: https://pdfium-review.googlesource.com/39871 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- core/fpdfapi/page/cpdf_contentparser.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index 2bb376e841..f93cf47eb8 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -6,6 +6,7 @@ #include "core/fpdfapi/page/cpdf_contentparser.h" +#include "constants/page_object.h" #include "core/fpdfapi/font/cpdf_type3char.h" #include "core/fpdfapi/page/cpdf_allstates.h" #include "core/fpdfapi/page/cpdf_form.h" @@ -30,7 +31,8 @@ CPDF_ContentParser::CPDF_ContentParser(CPDF_Page* pPage) return; } - CPDF_Object* pContent = pPage->GetDict()->GetDirectObjectFor("Contents"); + CPDF_Object* pContent = + pPage->GetDict()->GetDirectObjectFor(pdfium::page_object::kContents); if (!pContent) { m_CurrentStage = Stage::kComplete; return; @@ -141,7 +143,10 @@ bool CPDF_ContentParser::Continue(PauseIndicatorIface* pPause) { } CPDF_ContentParser::Stage CPDF_ContentParser::GetContent() { - CPDF_Array* pContent = m_pObjectHolder->GetDict()->GetArrayFor("Contents"); + ASSERT(m_CurrentStage == Stage::kGetContent); + ASSERT(m_pObjectHolder->IsPage()); + CPDF_Array* pContent = + m_pObjectHolder->GetDict()->GetArrayFor(pdfium::page_object::kContents); CPDF_Stream* pStreamObj = ToStream( pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr); m_StreamArray[m_CurrentOffset] = -- cgit v1.2.3