summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-07-23 14:36:34 -0700
committerTom Sepez <tsepez@chromium.org>2015-07-23 14:36:34 -0700
commit90144588255a87dea9e261bd909f2eece31a97b9 (patch)
tree975b465936fecaed1c6fd20fa8b37c816a591784 /core
parentf1e7c461dfabbff6b65a072f24f6711b34159361 (diff)
downloadpdfium-90144588255a87dea9e261bd909f2eece31a97b9.tar.xz
FX_BOOL not always 0 or 1 in CPDF_PageObjects::m_ParserState
This fixes part of the failure encountered at 320b2313d198. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1257503002 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_page.h47
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp38
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp16
-rw-r--r--core/src/fpdfapi/fpdf_page/pageint.h10
4 files changed, 38 insertions, 73 deletions
diff --git a/core/include/fpdfapi/fpdf_page.h b/core/include/fpdfapi/fpdf_page.h
index 7aed626fae..bd8b5c9878 100644
--- a/core/include/fpdfapi/fpdf_page.h
+++ b/core/include/fpdfapi/fpdf_page.h
@@ -24,37 +24,20 @@ class CPDF_StreamContentParser;
#define PDFTRANS_GROUP 0x0100
#define PDFTRANS_ISOLATED 0x0200
#define PDFTRANS_KNOCKOUT 0x0400
-#define PDF_CONTENT_NOT_PARSED 0
-#define PDF_CONTENT_PARSING 1
-#define PDF_CONTENT_PARSED 2
+
class CPDF_PageObjects
{
public:
-
CPDF_PageObjects(FX_BOOL bReleaseMembers = TRUE);
-
~CPDF_PageObjects();
-
-
-
void ContinueParse(IFX_Pause* pPause);
- int GetParseState() const
- {
- return m_ParseState;
- }
-
FX_BOOL IsParsed() const
{
- return m_ParseState == PDF_CONTENT_PARSED;
+ return m_ParseState == CONTENT_PARSED;
}
- int EstimateParseProgress() const;
-
-
-
-
FX_POSITION GetFirstObjectPosition() const
{
return m_ObjectList.GetHeadPosition();
@@ -89,10 +72,6 @@ public:
CPDF_PageObject* GetObjectByIndex(int index) const;
-
-
-
-
FX_POSITION InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject);
void Transform(const CFX_AffineMatrix& matrix);
@@ -105,17 +84,11 @@ public:
CFX_FloatRect CalcBoundingBox() const;
CPDF_Dictionary* m_pFormDict;
-
CPDF_Stream* m_pFormStream;
-
CPDF_Document* m_pDocument;
-
CPDF_Dictionary* m_pPageResources;
-
CPDF_Dictionary* m_pResources;
-
CFX_FloatRect m_BBox;
-
int m_Transparency;
protected:
@@ -123,18 +96,22 @@ protected:
friend class CPDF_StreamContentParser;
friend class CPDF_AllStates;
- CFX_PtrList m_ObjectList;
-
- FX_BOOL m_bBackgroundAlphaNeeded;
+ enum ParseState {
+ CONTENT_NOT_PARSED,
+ CONTENT_PARSING,
+ CONTENT_PARSED
+ };
- FX_BOOL m_bReleaseMembers;
void LoadTransInfo();
void ClearCacheObjects();
+ CFX_PtrList m_ObjectList;
+ FX_BOOL m_bBackgroundAlphaNeeded;
+ FX_BOOL m_bReleaseMembers;
CPDF_ContentParser* m_pParser;
-
- FX_BOOL m_ParseState;
+ ParseState m_ParseState;
};
+
class CPDF_Page : public CPDF_PageObjects, public CFX_PrivateData
{
public:
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index c0cdb228f4..f404352318 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -720,14 +720,19 @@ void CPDF_FormObject::CalcBoundingBox()
m_Right = form_rect.right;
m_Top = form_rect.top;
}
-CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers) : m_ObjectList(128)
+CPDF_PageObjects::CPDF_PageObjects(FX_BOOL bReleaseMembers)
+ : m_pFormDict(nullptr),
+ m_pFormStream(nullptr),
+ m_pDocument(nullptr),
+ m_pPageResources(nullptr),
+ m_pResources(nullptr),
+ m_Transparency(0),
+ m_ObjectList(128),
+ m_bBackgroundAlphaNeeded(FALSE),
+ m_bReleaseMembers(bReleaseMembers),
+ m_pParser(nullptr),
+ m_ParseState(CONTENT_NOT_PARSED)
{
- m_bBackgroundAlphaNeeded = FALSE;
- m_bReleaseMembers = bReleaseMembers;
- m_ParseState = PDF_CONTENT_NOT_PARSED;
- m_pParser = NULL;
- m_pFormStream = NULL;
- m_pResources = NULL;
}
CPDF_PageObjects::~CPDF_PageObjects()
{
@@ -747,18 +752,11 @@ void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause)
}
m_pParser->Continue(pPause);
if (m_pParser->GetStatus() == CPDF_ContentParser::Done) {
- m_ParseState = PDF_CONTENT_PARSED;
+ m_ParseState = CONTENT_PARSED;
delete m_pParser;
m_pParser = NULL;
}
}
-int CPDF_PageObjects::EstimateParseProgress() const
-{
- if (!m_pParser) {
- return m_ParseState == PDF_CONTENT_PARSED ? 100 : 0;
- }
- return m_pParser->EstimateProgress();
-}
FX_POSITION CPDF_PageObjects::InsertObject(FX_POSITION posInsertAfter, CPDF_PageObject* pNewObject)
{
if (!posInsertAfter) {
@@ -843,7 +841,7 @@ void CPDF_PageObjects::LoadTransInfo()
}
void CPDF_PageObjects::ClearCacheObjects()
{
- m_ParseState = PDF_CONTENT_NOT_PARSED;
+ m_ParseState = CONTENT_NOT_PARSED;
delete m_pParser;
m_pParser = NULL;
if (m_bReleaseMembers) {
@@ -930,12 +928,12 @@ void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions, FX_BOOL bReParse)
if (bReParse) {
ClearCacheObjects();
}
- if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSING) {
+ if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) {
return;
}
m_pParser = new CPDF_ContentParser;
m_pParser->Start(this, pOptions);
- m_ParseState = PDF_CONTENT_PARSING;
+ m_ParseState = CONTENT_PARSING;
}
void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions, FX_BOOL bReParse)
{
@@ -994,12 +992,12 @@ CPDF_Form::~CPDF_Form()
void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level)
{
- if (m_ParseState == PDF_CONTENT_PARSED || m_ParseState == PDF_CONTENT_PARSING) {
+ if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) {
return;
}
m_pParser = new CPDF_ContentParser;
m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, pOptions, level);
- m_ParseState = PDF_CONTENT_PARSING;
+ m_ParseState = CONTENT_PARSING;
}
void CPDF_Form::ParseContent(CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level)
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 37ffea9742..b2cfce73d9 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -1133,19 +1133,3 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause)
}
}
}
-int CPDF_ContentParser::EstimateProgress()
-{
- if (m_Status == Ready) {
- return 0;
- }
- if (m_Status == Done) {
- return 100;
- }
- if (m_InternalStage == PAGEPARSE_STAGE_GETCONTENT) {
- return 10;
- }
- if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) {
- return 90;
- }
- return 10 + 80 * m_CurrentOffset / m_Size;
-}
diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h
index cf1fe47c0d..8cd393cf32 100644
--- a/core/src/fpdfapi/fpdf_page/pageint.h
+++ b/core/src/fpdfapi/fpdf_page/pageint.h
@@ -309,9 +309,15 @@ protected:
class CPDF_ContentParser
{
public:
+ enum ParseStatus {
+ Ready,
+ ToBeContinued,
+ Done
+ };
+
CPDF_ContentParser();
~CPDF_ContentParser();
- typedef enum { Ready, ToBeContinued, Done } ParseStatus;
+
ParseStatus GetStatus()
{
return m_Status;
@@ -320,7 +326,7 @@ public:
void Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix,
CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level);
void Continue(IFX_Pause* pPause);
- int EstimateProgress();
+
protected:
void Clear();
ParseStatus m_Status;