From 9fff1c76c1083a5cc0543911811e36007a38aa3a Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 22 Jun 2018 17:46:05 +0000 Subject: Avoid some duplicate const/non-const getters. Getters should nearly always be const when they return a non-const pointer to an unowned object. Saves a bit of code along the way. Grep for similar occurrences and add "const". Change-Id: I492bf962a7d62452fa40310146226dc0c8ebb753 Reviewed-on: https://pdfium-review.googlesource.com/35890 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- core/fpdfapi/page/cpdf_pattern.h | 3 +-- core/fpdfdoc/cpdf_formfield.h | 6 ++---- fpdfsdk/cpdfsdk_formfillenvironment.h | 2 +- fpdfsdk/formfiller/cffl_formfiller.h | 2 +- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 2 +- fxjs/cfxjse_engine.h | 2 +- fxjs/xfa/cjx_object.h | 4 +--- xfa/fxfa/cxfa_ffdocview.h | 2 +- xfa/fxfa/cxfa_ffnotify.h | 2 +- xfa/fxfa/cxfa_ffwidget.h | 2 +- 10 files changed, 11 insertions(+), 16 deletions(-) diff --git a/core/fpdfapi/page/cpdf_pattern.h b/core/fpdfapi/page/cpdf_pattern.h index f1d98922c7..307c677775 100644 --- a/core/fpdfapi/page/cpdf_pattern.h +++ b/core/fpdfapi/page/cpdf_pattern.h @@ -28,8 +28,7 @@ class CPDF_Pattern { // All the getters that return pointers return non-NULL pointers. CPDF_Document* document() const { return m_pDocument.Get(); } - CPDF_Object* pattern_obj() { return m_pPatternObj.Get(); } - const CPDF_Object* pattern_obj() const { return m_pPatternObj.Get(); } + CPDF_Object* pattern_obj() const { return m_pPatternObj.Get(); } CFX_Matrix* pattern_to_form() { return &m_Pattern2Form; } const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; } diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h index 78ef1798cb..0b570efccf 100644 --- a/core/fpdfdoc/cpdf_formfield.h +++ b/core/fpdfdoc/cpdf_formfield.h @@ -170,10 +170,8 @@ class CPDF_FormField { float GetFontSize() const { return m_FontSize; } CPDF_Font* GetFont() const { return m_pFont.Get(); } - const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } - CPDF_Dictionary* GetDict() { return m_pDict.Get(); } - - const CPDF_InterForm* GetForm() const { return m_pForm.Get(); } + CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } + CPDF_InterForm* GetForm() const { return m_pForm.Get(); } WideString GetCheckValue(bool bDefault) const; diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h index b0512485dd..dacc02f95d 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.h +++ b/fpdfsdk/cpdfsdk_formfillenvironment.h @@ -66,7 +66,7 @@ class CPDFSDK_FormFillEnvironment void RemovePageView(IPDF_Page* pPage); void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); - CPDFSDK_Annot* GetFocusAnnot() { return m_pFocusAnnot.Get(); } + CPDFSDK_Annot* GetFocusAnnot() const { return m_pFocusAnnot.Get(); } bool SetFocusAnnot(CPDFSDK_Annot::ObservedPtr* pAnnot); bool KillFocusAnnot(uint32_t nFlag); void ClearAllFocusedAnnots(); diff --git a/fpdfsdk/formfiller/cffl_formfiller.h b/fpdfsdk/formfiller/cffl_formfiller.h index bad42ecaf4..95f5ac8427 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.h +++ b/fpdfsdk/formfiller/cffl_formfiller.h @@ -143,7 +143,7 @@ class CFFL_FormFiller : public CPWL_Wnd::ProviderIface, CPDFSDK_PageView* GetCurPageView(bool renew); void SetChangeMark(); - CPDFSDK_Annot* GetSDKAnnot() { return m_pWidget.Get(); } + CPDFSDK_Annot* GetSDKAnnot() const { return m_pWidget.Get(); } protected: using CFFL_PageView2PDFWindow = std::map; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index 54b2cac349..45ad447c5a 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -41,7 +41,7 @@ class CPDFXFA_Context : public CPDF_Document::Extension, bool LoadXFADoc(); CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } - CXFA_FFDocView* GetXFADocView() { return m_pXFADocView.Get(); } + CXFA_FFDocView* GetXFADocView() const { return m_pXFADocView.Get(); } FormType GetFormType() const { return m_FormType; } bool ContainsXFAForm() const { return m_FormType == FormType::kXFAFull || diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h index 62de0614c4..0ae16df84e 100644 --- a/fxjs/cfxjse_engine.h +++ b/fxjs/cfxjse_engine.h @@ -56,7 +56,7 @@ class CFXJSE_Engine : public CFX_V8 { ~CFXJSE_Engine() override; void SetEventParam(CXFA_EventParam* param) { m_eventParam = param; } - CXFA_EventParam* GetEventParam() { return m_eventParam.Get(); } + CXFA_EventParam* GetEventParam() const { return m_eventParam.Get(); } bool RunScript(CXFA_Script::Type eScriptType, const WideStringView& wsScript, CFXJSE_Value* pRetValue, diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index 44df6c4c5a..0ee2b66199 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h @@ -60,10 +60,8 @@ class CJX_Object { JS_PROP(className); - CXFA_Object* GetXFAObject() { return object_.Get(); } - const CXFA_Object* GetXFAObject() const { return object_.Get(); } - CXFA_Document* GetDocument() const; + CXFA_Object* GetXFAObject() const { return object_.Get(); } void SetCalcRecursionCount(size_t count) { calc_recursion_count_ = count; } size_t GetCalcRecursionCount() const { return calc_recursion_count_; } diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h index efa504ecd3..c0011c6f01 100644 --- a/xfa/fxfa/cxfa_ffdocview.h +++ b/xfa/fxfa/cxfa_ffdocview.h @@ -47,7 +47,7 @@ class CXFA_FFDocView { explicit CXFA_FFDocView(CXFA_FFDoc* pDoc); ~CXFA_FFDocView(); - CXFA_FFDoc* GetDoc() { return m_pDoc.Get(); } + CXFA_FFDoc* GetDoc() const { return m_pDoc.Get(); } int32_t StartLayout(); int32_t DoLayout(); void StopLayout(); diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h index cdb43b71d2..6715f825ff 100644 --- a/xfa/fxfa/cxfa_ffnotify.h +++ b/xfa/fxfa/cxfa_ffnotify.h @@ -58,7 +58,7 @@ class CXFA_FFNotify { bool bIsFormReady, bool bRecursive); void AddCalcValidate(CXFA_Node* pNode); - CXFA_FFDoc* GetHDOC() { return m_pDoc.Get(); } + CXFA_FFDoc* GetHDOC() const { return m_pDoc.Get(); } IXFA_AppProvider* GetAppProvider(); CXFA_FFWidgetHandler* GetWidgetHandler(); void OpenDropDownList(CXFA_FFWidget* hWidget); diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 9b8402c343..419532d58c 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -148,7 +148,7 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem { uint32_t GetStatus(); void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved); - CXFA_Node* GetNode() { return m_pNode.Get(); } + CXFA_Node* GetNode() const { return m_pNode.Get(); } CXFA_FFDocView* GetDocView(); void SetDocView(CXFA_FFDocView* pDocView); -- cgit v1.2.3