diff options
author | jaepark <jaepark@google.com> | 2016-08-25 13:33:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-25 13:33:34 -0700 |
commit | a1d2111945acb35cb3403226e68a1920910fa23e (patch) | |
tree | f8e0dafb97832a0cad15adc50c9b55c0d5b0c48a | |
parent | d99a833da49272ee487293177f62274f58762033 (diff) | |
download | pdfium-a1d2111945acb35cb3403226e68a1920910fa23e.tar.xz |
CPDF_Annot::GetRect() should return CFX_FloatRect.
Avoid using reference argument and return CFX_FloatRect instead.
Review-Url: https://codereview.chromium.org/2278153005
-rw-r--r-- | core/fpdfdoc/cpdf_annot.cpp | 18 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_annotlist.cpp | 3 | ||||
-rw-r--r-- | core/fpdfdoc/include/cpdf_annot.h | 2 | ||||
-rw-r--r-- | fpdfsdk/cba_annotiterator.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_baannot.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_iformfiller.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/fpdfeditpage.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/fsdk_mgr.cpp | 6 |
10 files changed, 19 insertions, 35 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 76d3f9c6d4..e70ee27a98 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -55,12 +55,13 @@ CFX_ByteString CPDF_Annot::GetSubType() const { return m_sSubtype; } -void CPDF_Annot::GetRect(CFX_FloatRect& rect) const { - if (!m_pAnnotDict) { - return; - } - rect = m_pAnnotDict->GetRectBy("Rect"); +CFX_FloatRect CPDF_Annot::GetRect() const { + if (!m_pAnnotDict) + return CFX_FloatRect(); + + CFX_FloatRect rect = m_pAnnotDict->GetRectBy("Rect"); rect.Normalize(); + return rect; } uint32_t CPDF_Annot::GetFlags() const { @@ -133,9 +134,7 @@ static CPDF_Form* FPDFDOC_Annot_GetMatrix(const CPDF_Page* pPage, CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectBy("BBox"); CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); form_matrix.TransformRect(form_bbox); - CFX_FloatRect arect; - pAnnot->GetRect(arect); - matrix.MatchRect(arect, form_bbox); + matrix.MatchRect(pAnnot->GetRect(), form_bbox); matrix.Concat(*pUser2Device); return pForm; } @@ -272,8 +271,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; } } - CFX_FloatRect rect; - GetRect(rect); + CFX_FloatRect rect = GetRect(); CFX_PathData path; width /= 2; path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 9dc0e9587d..153b25fac4 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -84,8 +84,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, continue; } } - CFX_FloatRect annot_rect_f; - pAnnot->GetRect(annot_rect_f); + CFX_FloatRect annot_rect_f = pAnnot->GetRect(); CFX_Matrix matrix = *pMatrix; if (clip_rect) { annot_rect_f.Transform(&matrix); diff --git a/core/fpdfdoc/include/cpdf_annot.h b/core/fpdfdoc/include/cpdf_annot.h index 4029bba4cc..9f8671633c 100644 --- a/core/fpdfdoc/include/cpdf_annot.h +++ b/core/fpdfdoc/include/cpdf_annot.h @@ -44,7 +44,7 @@ class CPDF_Annot { CFX_ByteString GetSubType() const; uint32_t GetFlags() const; - void GetRect(CFX_FloatRect& rect) const; + CFX_FloatRect GetRect() const; const CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict; } CPDF_Dictionary* GetAnnotDict() { return m_pAnnotDict; } FX_BOOL DrawAppearance(CPDF_Page* pPage, diff --git a/fpdfsdk/cba_annotiterator.cpp b/fpdfsdk/cba_annotiterator.cpp index f07805e6f3..bd68997ad9 100644 --- a/fpdfsdk/cba_annotiterator.cpp +++ b/fpdfsdk/cba_annotiterator.cpp @@ -168,7 +168,5 @@ void CBA_AnnotIterator::GenerateResults() { } CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { - CFX_FloatRect rcAnnot; - pAnnot->GetPDFAnnot()->GetRect(rcAnnot); - return rcAnnot; + return pAnnot->GetPDFAnnot()->GetRect(); } diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp index 6a4ba86d94..99dd2e0538 100644 --- a/fpdfsdk/cpdfsdk_baannot.cpp +++ b/fpdfsdk/cpdfsdk_baannot.cpp @@ -35,9 +35,7 @@ void CPDFSDK_BAAnnot::SetRect(const CFX_FloatRect& rect) { } CFX_FloatRect CPDFSDK_BAAnnot::GetRect() const { - CFX_FloatRect rect; - m_pAnnot->GetRect(rect); - return rect; + return m_pAnnot->GetRect(); } CFX_ByteString CPDFSDK_BAAnnot::GetType() const { diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index a36014c924..dcccf0ce1a 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -1975,8 +1975,7 @@ int32_t CPDFSDK_Widget::GetValueAge() const { FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) { CPDF_Annot* pAnnot = GetPDFAnnot(); - CFX_FloatRect annotRect; - pAnnot->GetRect(annotRect); + CFX_FloatRect annotRect = pAnnot->GetRect(); if (!annotRect.Contains(pageX, pageY)) return FALSE; diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 92e9282a74..0779f261a7 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -419,8 +419,7 @@ CFX_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData) { CFX_Matrix CFFL_FormFiller::GetCurMatrix() { CFX_Matrix mt; - CFX_FloatRect rcDA; - m_pWidget->GetPDFAnnot()->GetRect(rcDA); + CFX_FloatRect rcDA = m_pWidget->GetPDFAnnot()->GetRect(); switch (m_pWidget->GetRotate()) { default: @@ -451,8 +450,7 @@ CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) { } CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const { - CFX_FloatRect rectAnnot; - m_pWidget->GetPDFAnnot()->GetRect(rectAnnot); + CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect(); FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp index 9e252cbd41..1f638444af 100644 --- a/fpdfsdk/formfiller/cffl_iformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp @@ -45,10 +45,7 @@ FX_RECT CFFL_IFormFiller::GetViewBBox(CPDFSDK_PageView* pPageView, ASSERT(pPageView); CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); - CFX_FloatRect rcAnnot; - pPDFAnnot->GetRect(rcAnnot); - - CFX_FloatRect rcWin = CPWL_Utils::InflateRect(rcAnnot, 1); + CFX_FloatRect rcWin = CPWL_Utils::InflateRect(pPDFAnnot->GetRect(), 1); return rcWin.GetOuterRect(); } diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp index 0daa459037..1301018709 100644 --- a/fpdfsdk/fpdfeditpage.cpp +++ b/fpdfsdk/fpdfeditpage.cpp @@ -295,8 +295,7 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, for (size_t i = 0; i < AnnotList.Count(); ++i) { CPDF_Annot* pAnnot = AnnotList.GetAt(i); // transformAnnots Rectangle - CFX_FloatRect rect; - pAnnot->GetRect(rect); + CFX_FloatRect rect = pAnnot->GetRect(); CFX_Matrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, (FX_FLOAT)e, (FX_FLOAT)f); rect.Transform(&matrix); diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index 24efd4077d..9017e20b32 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -576,8 +576,7 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY) { for (const auto& pAnnot : m_pAnnotList->All()) { - CFX_FloatRect annotRect; - pAnnot->GetRect(annotRect); + CFX_FloatRect annotRect = pAnnot->GetRect(); if (annotRect.Contains(pageX, pageY)) return pAnnot.get(); } @@ -588,8 +587,7 @@ const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY) { for (const auto& pAnnot : m_pAnnotList->All()) { if (pAnnot->GetSubType() == "Widget") { - CFX_FloatRect annotRect; - pAnnot->GetRect(annotRect); + CFX_FloatRect annotRect = pAnnot->GetRect(); if (annotRect.Contains(pageX, pageY)) return pAnnot.get(); } |