From 7d865b611bf5b029723ec3143180d23c95c907e8 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 10 Apr 2018 19:29:25 +0000 Subject: Remove CFX_Rect. It is rarely used and FX_RECT is the more common integer rect type. Change-Id: I7c5b875321c2d587becedcd058bb3a57fd1f0b61 Reviewed-on: https://pdfium-review.googlesource.com/30053 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- xfa/fgas/font/cfgas_gefont.cpp | 17 +++++++---------- xfa/fgas/font/cfgas_gefont.h | 6 +++--- xfa/fgas/layout/cfx_txtbreak.cpp | 13 ++++++------- 3 files changed, 16 insertions(+), 20 deletions(-) (limited to 'xfa/fgas') diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index 83b7ad68d7..6b2cb0f03b 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -185,7 +185,7 @@ bool CFGAS_GEFont::GetCharWidth(wchar_t wUnicode, int32_t& iWidth) { return iWidth > 0; } -bool CFGAS_GEFont::GetCharBBox(wchar_t wUnicode, CFX_Rect* bbox) { +bool CFGAS_GEFont::GetCharBBox(wchar_t wUnicode, FX_RECT* bbox) { auto it = m_BBoxMap.find(wUnicode); if (it != m_BBoxMap.end()) { *bbox = it->second; @@ -205,21 +205,18 @@ bool CFGAS_GEFont::GetCharBBox(wchar_t wUnicode, CFX_Rect* bbox) { if (!m_pFont->GetGlyphBBox(iGlyph, rtBBox)) return false; - CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); - m_BBoxMap[wUnicode] = rt; - *bbox = rt; + m_BBoxMap[wUnicode] = rtBBox; + *bbox = rtBBox; return true; } -bool CFGAS_GEFont::GetBBox(CFX_Rect* bbox) { - FX_RECT rt(0, 0, 0, 0); +bool CFGAS_GEFont::GetBBox(FX_RECT* bbox) { + // TODO(thestig): Pass directly into GetBBox(). + FX_RECT rt; if (!m_pFont->GetBBox(rt)) return false; - bbox->left = rt.left; - bbox->width = rt.Width(); - bbox->top = rt.bottom; - bbox->height = -rt.Height(); + *bbox = rt; return true; } diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index 646562d9ee..22169d6d3d 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.h @@ -43,8 +43,8 @@ class CFGAS_GEFont : public Retainable { int32_t GetAscent() const; int32_t GetDescent() const; - bool GetCharBBox(wchar_t wUnicode, CFX_Rect* bbox); - bool GetBBox(CFX_Rect* bbox); + bool GetCharBBox(wchar_t wUnicode, FX_RECT* bbox); + bool GetBBox(FX_RECT* bbox); RetainPtr GetSubstFont(int32_t iGlyphIndex); CFX_Font* GetDevFont() const { return m_pFont; } @@ -89,7 +89,7 @@ class CFGAS_GEFont : public Retainable { RetainPtr m_pFileRead; std::unique_ptr m_pFontEncoding; std::map m_CharWidthMap; - std::map m_BBoxMap; + std::map m_BBoxMap; std::vector> m_SubstFonts; std::map> m_FontMapper; }; diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp index 30ed3a6746..c3075b00dc 100644 --- a/xfa/fgas/layout/cfx_txtbreak.cpp +++ b/xfa/fgas/layout/cfx_txtbreak.cpp @@ -851,19 +851,18 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } if (chartype == FX_CHARTYPE_Combination) { - CFX_Rect rtBBox; + FX_RECT rtBBox; if (pFont->GetCharBBox(wForm, &rtBBox)) { pCharPos->m_Origin.y = - fYBase + fFontSize - - fFontSize * (float)rtBBox.height / (float)iMaxHeight; + fYBase + fFontSize - fFontSize * rtBBox.Height() / iMaxHeight; } if (wForm == wch && wLast != 0xFEFF) { uint32_t dwLastProps = FX_GetUnicodeProperties(wLast); if ((dwLastProps & FX_CHARTYPEBITSMASK) == FX_CHARTYPE_Combination) { - CFX_Rect rtBox; + FX_RECT rtBox; if (pFont->GetCharBBox(wLast, &rtBox)) - pCharPos->m_Origin.y -= fFontSize * rtBox.height / iMaxHeight; + pCharPos->m_Origin.y -= fFontSize * rtBox.Height() / iMaxHeight; } } } @@ -915,12 +914,12 @@ std::vector CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, if (!pFont) bCharBBox = false; - CFX_Rect bbox; + FX_RECT bbox; if (bCharBBox) bCharBBox = pFont->GetBBox(&bbox); float fLeft = std::max(0.0f, bbox.left * fScale); - float fHeight = fabs(bbox.height * fScale); + float fHeight = fabs(bbox.Height() * fScale); bool bRTLPiece = !!(pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel); bool bSingleLine = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_SingleLine); bool bCombText = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_CombText); -- cgit v1.2.3