Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: xfa/fgas/layout/fgas_textbreak.cpp

Issue 2609423003: Properly ref-count CFGAS_GEFont with CFX_RetainPtr. (Closed)
Patch Set: comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fgas/layout/fgas_textbreak.h" 7 #include "xfa/fgas/layout/fgas_textbreak.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; 105 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0;
106 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; 106 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0;
107 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; 107 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0;
108 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; 108 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0;
109 ResetArabicContext(); 109 ResetArabicContext();
110 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); 110 m_iLineRotation = GetLineRotation(m_dwLayoutStyles);
111 m_iRotation = m_iLineRotation + m_iCharRotation; 111 m_iRotation = m_iLineRotation + m_iCharRotation;
112 m_iRotation %= 4; 112 m_iRotation %= 4;
113 } 113 }
114 114
115 void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) { 115 void CFX_TxtBreak::SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont) {
116 if (!pFont) { 116 if (!pFont || pFont == m_pFont)
117 return; 117 return;
118 } 118
119 if (m_pFont == pFont) {
120 return;
121 }
122 SetBreakStatus(); 119 SetBreakStatus();
123 m_pFont = pFont; 120 m_pFont = pFont;
124 m_iDefChar = 0; 121 m_iDefChar = 0;
125 if (m_wDefChar != 0xFEFF && m_pFont) { 122 if (m_wDefChar != 0xFEFF && m_pFont) {
126 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false); 123 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
127 m_iDefChar *= m_iFontSize; 124 m_iDefChar *= m_iFontSize;
128 } 125 }
129 } 126 }
130 127
131 void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { 128 void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) {
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 CFX_WideString* pWSForms, 1204 CFX_WideString* pWSForms,
1208 FX_AdjustCharDisplayPos pAdjustPos) const { 1205 FX_AdjustCharDisplayPos pAdjustPos) const {
1209 if (!pTxtRun || pTxtRun->iLength < 1) { 1206 if (!pTxtRun || pTxtRun->iLength < 1) {
1210 return 0; 1207 return 0;
1211 } 1208 }
1212 IFX_TxtAccess* pAccess = pTxtRun->pAccess; 1209 IFX_TxtAccess* pAccess = pTxtRun->pAccess;
1213 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; 1210 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity;
1214 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); 1211 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str();
1215 int32_t* pWidths = pTxtRun->pWidths; 1212 int32_t* pWidths = pTxtRun->pWidths;
1216 int32_t iLength = pTxtRun->iLength - 1; 1213 int32_t iLength = pTxtRun->iLength - 1;
1217 CFGAS_GEFont* pFont = pTxtRun->pFont; 1214 CFX_RetainPtr<CFGAS_GEFont> pFont = pTxtRun->pFont;
1218 uint32_t dwStyles = pTxtRun->dwStyles; 1215 uint32_t dwStyles = pTxtRun->dwStyles;
1219 CFX_RectF rtText(*pTxtRun->pRect); 1216 CFX_RectF rtText(*pTxtRun->pRect);
1220 bool bRTLPiece = (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; 1217 bool bRTLPiece = (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0;
1221 bool bArabicNumber = 1218 bool bArabicNumber =
1222 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0; 1219 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0;
1223 bool bArabicComma = 1220 bool bArabicComma =
1224 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0; 1221 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0;
1225 FX_FLOAT fFontSize = pTxtRun->fFontSize; 1222 FX_FLOAT fFontSize = pTxtRun->fFontSize;
1226 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 1223 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
1227 int32_t iAscent = pFont->GetAscent(); 1224 int32_t iAscent = pFont->GetAscent();
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 wPrev = (FX_WCHAR)formChars[0].wch; 1583 wPrev = (FX_WCHAR)formChars[0].wch;
1587 } 1584 }
1588 wLast = wch; 1585 wLast = wch;
1589 } 1586 }
1590 return iCount; 1587 return iCount;
1591 } 1588 }
1592 1589
1593 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, 1590 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun,
1594 CFX_RectFArray& rtArray, 1591 CFX_RectFArray& rtArray,
1595 bool bCharBBox) const { 1592 bool bCharBBox) const {
1596 if (!pTxtRun || pTxtRun->iLength < 1) { 1593 if (!pTxtRun || pTxtRun->iLength < 1)
1597 return 0; 1594 return 0;
1598 } 1595
1599 IFX_TxtAccess* pAccess = pTxtRun->pAccess; 1596 IFX_TxtAccess* pAccess = pTxtRun->pAccess;
1600 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; 1597 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity;
1601 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); 1598 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str();
1602 int32_t* pWidths = pTxtRun->pWidths; 1599 int32_t* pWidths = pTxtRun->pWidths;
1603 int32_t iLength = pTxtRun->iLength; 1600 int32_t iLength = pTxtRun->iLength;
1604 CFX_RectF rect(*pTxtRun->pRect); 1601 CFX_RectF rect(*pTxtRun->pRect);
1605 bool bRTLPiece = (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; 1602 bool bRTLPiece = (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0;
1606 FX_FLOAT fFontSize = pTxtRun->fFontSize; 1603 FX_FLOAT fFontSize = pTxtRun->fFontSize;
1607 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 1604 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
1608 FX_FLOAT fScale = fFontSize / 1000.0f; 1605 FX_FLOAT fScale = fFontSize / 1000.0f;
1609 CFGAS_GEFont* pFont = pTxtRun->pFont; 1606 CFX_RetainPtr<CFGAS_GEFont> pFont = pTxtRun->pFont;
1610 if (!pFont) { 1607 if (!pFont)
1611 bCharBBox = false; 1608 bCharBBox = false;
1612 } 1609
1613 CFX_Rect bbox; 1610 CFX_Rect bbox;
1614 bbox.Set(0, 0, 0, 0); 1611 bbox.Set(0, 0, 0, 0);
1615 if (bCharBBox) { 1612 if (bCharBBox)
1616 bCharBBox = pFont->GetBBox(bbox); 1613 bCharBBox = pFont->GetBBox(bbox);
1617 } 1614
1618 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); 1615 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale);
1619 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); 1616 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale);
1620 rtArray.RemoveAll(); 1617 rtArray.RemoveAll();
1621 rtArray.SetSize(iLength); 1618 rtArray.SetSize(iLength);
1622 bool bVertical = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; 1619 bool bVertical = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0;
1623 bool bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; 1620 bool bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0;
1624 bool bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; 1621 bool bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0;
1625 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; 1622 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar;
1626 int32_t iCharSize; 1623 int32_t iCharSize;
1627 FX_FLOAT fCharSize, fStart; 1624 FX_FLOAT fCharSize, fStart;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) 1734 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize)
1738 : m_pLineChars(new CFX_TxtCharArray), 1735 : m_pLineChars(new CFX_TxtCharArray),
1739 m_pLinePieces(new CFX_TxtPieceArray(16)), 1736 m_pLinePieces(new CFX_TxtPieceArray(16)),
1740 m_iStart(0), 1737 m_iStart(0),
1741 m_iWidth(0), 1738 m_iWidth(0),
1742 m_iArabicChars(0) {} 1739 m_iArabicChars(0) {}
1743 1740
1744 CFX_TxtLine::~CFX_TxtLine() { 1741 CFX_TxtLine::~CFX_TxtLine() {
1745 RemoveAll(); 1742 RemoveAll();
1746 } 1743 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698