From 0a0892626d24ce82e7026c32c71b1de036d4bbe1 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 10 May 2017 14:00:53 -0700 Subject: Replace operator bool with HasRef() in classes with a CFX_SharedCopyOnWrite member. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I51e30d298e87b9ae0d5aca83b2f1d6787efce70a Reviewed-on: https://pdfium-review.googlesource.com/5290 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña --- core/fpdfapi/page/cpdf_clippath.h | 2 +- core/fpdfapi/page/cpdf_colorstate.h | 2 +- core/fpdfapi/page/cpdf_contentmark.h | 2 +- core/fpdfapi/page/cpdf_contentparser.cpp | 4 ++-- core/fpdfapi/page/cpdf_generalstate.h | 2 +- core/fpdfapi/page/cpdf_pageobject.cpp | 4 ++-- core/fpdfapi/page/cpdf_path.h | 2 +- core/fpdfapi/page/cpdf_pathobject.cpp | 2 +- core/fpdfapi/page/cpdf_shadingobject.cpp | 6 +++--- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 4 ++-- core/fpdfapi/render/cpdf_imagerenderer.cpp | 2 +- core/fpdfapi/render/cpdf_renderstatus.cpp | 18 +++++++++--------- core/fpdftext/cpdf_textpage.cpp | 6 +++--- 13 files changed, 28 insertions(+), 28 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/page/cpdf_clippath.h b/core/fpdfapi/page/cpdf_clippath.h index dd44cb250e..8493a9ccd9 100644 --- a/core/fpdfapi/page/cpdf_clippath.h +++ b/core/fpdfapi/page/cpdf_clippath.h @@ -28,7 +28,7 @@ class CPDF_ClipPath { void Emplace() { m_Ref.Emplace(); } void SetNull() { m_Ref.SetNull(); } - explicit operator bool() const { return !!m_Ref; } + bool HasRef() const { return !!m_Ref; } bool operator==(const CPDF_ClipPath& that) const { return m_Ref == that.m_Ref; } diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h index f66eac3d81..0862f489bd 100644 --- a/core/fpdfapi/page/cpdf_colorstate.h +++ b/core/fpdfapi/page/cpdf_colorstate.h @@ -44,7 +44,7 @@ class CPDF_ColorState { void SetFillPattern(CPDF_Pattern* pattern, float* pValue, uint32_t nValues); void SetStrokePattern(CPDF_Pattern* pattern, float* pValue, uint32_t nValues); - explicit operator bool() const { return !!m_Ref; } + bool HasRef() const { return !!m_Ref; } private: class ColorData { diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h index 154f19d529..5782addc93 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -35,7 +35,7 @@ class CPDF_ContentMark { bool bDirect); void DeleteLastMark(); - explicit operator bool() const { return !!m_Ref; } + bool HasRef() const { return !!m_Ref; } private: class MarkData { diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp index 96bc7a2221..eeac3c17b1 100644 --- a/core/fpdfapi/page/cpdf_contentparser.cpp +++ b/core/fpdfapi/page/cpdf_contentparser.cpp @@ -102,7 +102,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level); m_pParser->GetCurStates()->m_CTM = form_matrix; m_pParser->GetCurStates()->m_ParentMatrix = form_matrix; - if (ClipPath) { + if (ClipPath.HasRef()) { m_pParser->GetCurStates()->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, true); } @@ -195,7 +195,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) { FXSYS_round(m_pParser->GetType3Data()[5] * 1000); } for (auto& pObj : *m_pObjectHolder->GetPageObjectList()) { - if (!pObj->m_ClipPath) + if (!pObj->m_ClipPath.HasRef()) continue; if (pObj->m_ClipPath.GetPathCount() != 1) continue; diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h index 8de5a36ca6..9305785256 100644 --- a/core/fpdfapi/page/cpdf_generalstate.h +++ b/core/fpdfapi/page/cpdf_generalstate.h @@ -22,7 +22,7 @@ class CPDF_GeneralState { ~CPDF_GeneralState(); void Emplace() { m_Ref.Emplace(); } - explicit operator bool() const { return !!m_Ref; } + bool HasRef() const { return !!m_Ref; } void SetRenderIntent(const CFX_ByteString& ri); diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp index c0e031e7ed..09a98eee7d 100644 --- a/core/fpdfapi/page/cpdf_pageobject.cpp +++ b/core/fpdfapi/page/cpdf_pageobject.cpp @@ -79,13 +79,13 @@ void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) { } void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) { - if (!m_ClipPath) + if (!m_ClipPath.HasRef()) return; m_ClipPath.Transform(matrix); } void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) { - if (!m_GeneralState) + if (!m_GeneralState.HasRef()) return; m_GeneralState.GetMutableMatrix()->Concat(matrix); } diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h index 84b844e798..4bbb4b870e 100644 --- a/core/fpdfapi/page/cpdf_path.h +++ b/core/fpdfapi/page/cpdf_path.h @@ -22,7 +22,7 @@ class CPDF_Path { ~CPDF_Path(); void Emplace() { m_Ref.Emplace(); } - explicit operator bool() const { return !!m_Ref; } + bool HasRef() const { return !!m_Ref; } const std::vector& GetPoints() const; void ClosePath(); diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp index 1dd0a88f78..c4d55bc20f 100644 --- a/core/fpdfapi/page/cpdf_pathobject.cpp +++ b/core/fpdfapi/page/cpdf_pathobject.cpp @@ -32,7 +32,7 @@ const CPDF_PathObject* CPDF_PathObject::AsPath() const { } void CPDF_PathObject::CalcBoundingBox() { - if (!m_Path) + if (!m_Path.HasRef()) return; CFX_FloatRect rect; float width = m_GraphState.GetLineWidth(); diff --git a/core/fpdfapi/page/cpdf_shadingobject.cpp b/core/fpdfapi/page/cpdf_shadingobject.cpp index 928b0af47e..5454380cae 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.cpp +++ b/core/fpdfapi/page/cpdf_shadingobject.cpp @@ -19,11 +19,11 @@ CPDF_PageObject::Type CPDF_ShadingObject::GetType() const { } void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) { - if (m_ClipPath) + if (m_ClipPath.HasRef()) m_ClipPath.Transform(matrix); m_Matrix.Concat(matrix); - if (m_ClipPath) { + if (m_ClipPath.HasRef()) { CalcBoundingBox(); } else { matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); @@ -43,7 +43,7 @@ const CPDF_ShadingObject* CPDF_ShadingObject::AsShading() const { } void CPDF_ShadingObject::CalcBoundingBox() { - if (!m_ClipPath) + if (!m_ClipPath.HasRef()) return; CFX_FloatRect rect = m_ClipPath.GetClipBox(); m_Left = rect.left; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 3e6e75a53e..099ddf6b05 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -838,7 +838,7 @@ void CPDF_StreamContentParser::Handle_MarkPlace_Dictionary() {} void CPDF_StreamContentParser::Handle_EndImage() {} void CPDF_StreamContentParser::Handle_EndMarkedContent() { - if (m_CurContentMark) + if (m_CurContentMark.HasRef()) m_CurContentMark.DeleteLastMark(); } @@ -1121,7 +1121,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() { pObj->m_Matrix = m_pCurStates->m_CTM; pObj->m_Matrix.Concat(m_mtContentToUser); CFX_FloatRect bbox = - pObj->m_ClipPath ? pObj->m_ClipPath.GetClipBox() : m_BBox; + pObj->m_ClipPath.HasRef() ? pObj->m_ClipPath.GetClipBox() : m_BBox; if (pShading->IsMeshShading()) bbox.Intersect(GetShadingBBox(pShading, pObj->m_Matrix)); pObj->m_Left = bbox.left; diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 6562e154fc..dd1044816a 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -133,7 +133,7 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() { if (m_bPatternColor) return DrawPatternImage(m_pObj2Device); - if (m_BitmapAlpha != 255 || !state || !state.GetFillOP() || + if (m_BitmapAlpha != 255 || !state.HasRef() || !state.GetFillOP() || state.GetOPMode() != 0 || state.GetBlendType() != FXDIB_BLEND_NORMAL || state.GetStrokeAlpha() != 1.0f || state.GetFillAlpha() != 1.0f) { return StartDIBSource(); diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 0a288c4b00..44af9a2bac 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1068,7 +1068,7 @@ void CPDF_RenderStatus::RenderSingleObject(CPDF_PageObject* pObj, return; } m_pCurObj = pObj; - if (m_Options.m_pOCContext && pObj->m_ContentMark) { + if (m_Options.m_pOCContext && pObj->m_ContentMark.HasRef()) { if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) { return; } @@ -1097,7 +1097,7 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, } m_pCurObj = pObj; - if (m_Options.m_pOCContext && pObj->m_ContentMark && + if (m_Options.m_pOCContext && pObj->m_ContentMark.HasRef() && !m_Options.m_pOCContext->CheckObjectVisible(pObj)) { return false; } @@ -1315,10 +1315,10 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, if (m_pType3Char && !bType3 && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && - (!*pColorState || pColorState->GetFillColor()->IsNull())))) { + (!pColorState->HasRef() || pColorState->GetFillColor()->IsNull())))) { return m_T3FillColor; } - if (!*pColorState || pColorState->GetFillColor()->IsNull()) + if (!pColorState->HasRef() || pColorState->GetFillColor()->IsNull()) pColorState = &m_InitialStates.m_ColorState; FX_COLORREF rgb = pColorState->GetFillRGB(); @@ -1343,10 +1343,10 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { if (m_pType3Char && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored && - (!*pColorState || pColorState->GetStrokeColor()->IsNull())))) { + (!pColorState->HasRef() || pColorState->GetStrokeColor()->IsNull())))) { return m_T3FillColor; } - if (!*pColorState || pColorState->GetStrokeColor()->IsNull()) + if (!pColorState->HasRef() || pColorState->GetStrokeColor()->IsNull()) pColorState = &m_InitialStates.m_ColorState; FX_COLORREF rgb = pColorState->GetStrokeRGB(); @@ -1368,8 +1368,8 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, const CFX_Matrix* pObj2Device) { - if (!ClipPath) { - if (m_LastClipPath) { + if (!ClipPath.HasRef()) { + if (m_LastClipPath.HasRef()) { m_pDevice->RestoreState(true); m_LastClipPath.SetNull(); } @@ -1477,7 +1477,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, } } bool bTextClip = - (pPageObj->m_ClipPath && pPageObj->m_ClipPath.GetTextCount() && + (pPageObj->m_ClipPath.HasRef() && pPageObj->m_ClipPath.GetTextCount() && m_pDevice->GetDeviceClass() == FXDC_DISPLAY && !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)); if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index c64b8e17ae..5a39281183 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -800,7 +800,7 @@ void CPDF_TextPage::ProcessTextObject( FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { CPDF_TextObject* pTextObj = Obj.m_pTextObj; - if (!pTextObj->m_ContentMark) + if (!pTextObj->m_ContentMark.HasRef()) return FPDFText_MarkedContent::Pass; int nContentMark = pTextObj->m_ContentMark.CountItems(); @@ -825,7 +825,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { if (!bExist) return FPDFText_MarkedContent::Pass; - if (m_pPreTextObj && m_pPreTextObj->m_ContentMark && + if (m_pPreTextObj && m_pPreTextObj->m_ContentMark.HasRef() && m_pPreTextObj->m_ContentMark.CountItems() == n && pDict == m_pPreTextObj->m_ContentMark.GetItem(n - 1).GetParam()) { return FPDFText_MarkedContent::Done; @@ -863,7 +863,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { CPDF_TextObject* pTextObj = Obj.m_pTextObj; - if (!pTextObj->m_ContentMark) + if (!pTextObj->m_ContentMark.HasRef()) return; int nContentMark = pTextObj->m_ContentMark.CountItems(); -- cgit v1.2.3