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

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

Issue 2037563002: Replace IFGAS_Font with underlying concrete type (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 6 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
« no previous file with comments | « xfa/fgas/layout/fgas_textbreak.h ('k') | xfa/fgas/layout/fgas_unicode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "core/fxcrt/include/fx_arabic.h" 11 #include "core/fxcrt/include/fx_arabic.h"
12 #include "core/fxcrt/include/fx_arb.h" 12 #include "core/fxcrt/include/fx_arb.h"
13 #include "core/fxcrt/include/fx_memory.h" 13 #include "core/fxcrt/include/fx_memory.h"
14 #include "xfa/fgas/font/fgas_gefont.h"
14 #include "xfa/fgas/layout/fgas_linebreak.h" 15 #include "xfa/fgas/layout/fgas_linebreak.h"
15 #include "xfa/fgas/layout/fgas_unicode.h" 16 #include "xfa/fgas/layout/fgas_unicode.h"
16 17
17 CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies) 18 CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
18 : m_dwPolicies(dwPolicies), 19 : m_dwPolicies(dwPolicies),
19 m_iLineWidth(2000000), 20 m_iLineWidth(2000000),
20 m_dwLayoutStyles(0), 21 m_dwLayoutStyles(0),
21 m_bVertical(FALSE), 22 m_bVertical(FALSE),
22 m_bArabicContext(FALSE), 23 m_bArabicContext(FALSE),
23 m_bArabicShapes(FALSE), 24 m_bArabicShapes(FALSE),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 m_bArabicContext = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicContext) != 0; 87 m_bArabicContext = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicContext) != 0;
87 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; 88 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0;
88 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; 89 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0;
89 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; 90 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0;
90 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; 91 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0;
91 ResetArabicContext(); 92 ResetArabicContext();
92 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); 93 m_iLineRotation = GetLineRotation(m_dwLayoutStyles);
93 m_iRotation = m_iLineRotation + m_iCharRotation; 94 m_iRotation = m_iLineRotation + m_iCharRotation;
94 m_iRotation %= 4; 95 m_iRotation %= 4;
95 } 96 }
96 void CFX_TxtBreak::SetFont(IFGAS_Font* pFont) { 97 void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) {
97 if (pFont == NULL) { 98 if (pFont == NULL) {
98 return; 99 return;
99 } 100 }
100 if (m_pFont == pFont) { 101 if (m_pFont == pFont) {
101 return; 102 return;
102 } 103 }
103 SetBreakStatus(); 104 SetBreakStatus();
104 m_pFont = pFont; 105 m_pFont = pFont;
105 m_iDefChar = 0; 106 m_iDefChar = 0;
106 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { 107 if (m_wDefChar != 0xFEFF && m_pFont != NULL) {
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 CFX_WideString* pWSForms, 1168 CFX_WideString* pWSForms,
1168 FX_AdjustCharDisplayPos pAdjustPos) const { 1169 FX_AdjustCharDisplayPos pAdjustPos) const {
1169 if (pTxtRun == NULL || pTxtRun->iLength < 1) { 1170 if (pTxtRun == NULL || pTxtRun->iLength < 1) {
1170 return 0; 1171 return 0;
1171 } 1172 }
1172 IFX_TxtAccess* pAccess = pTxtRun->pAccess; 1173 IFX_TxtAccess* pAccess = pTxtRun->pAccess;
1173 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; 1174 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity;
1174 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); 1175 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str();
1175 int32_t* pWidths = pTxtRun->pWidths; 1176 int32_t* pWidths = pTxtRun->pWidths;
1176 int32_t iLength = pTxtRun->iLength - 1; 1177 int32_t iLength = pTxtRun->iLength - 1;
1177 IFGAS_Font* pFont = pTxtRun->pFont; 1178 CFGAS_GEFont* pFont = pTxtRun->pFont;
1178 uint32_t dwStyles = pTxtRun->dwStyles; 1179 uint32_t dwStyles = pTxtRun->dwStyles;
1179 CFX_RectF rtText(*pTxtRun->pRect); 1180 CFX_RectF rtText(*pTxtRun->pRect);
1180 FX_BOOL bRTLPiece = 1181 FX_BOOL bRTLPiece =
1181 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; 1182 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0;
1182 FX_BOOL bArabicNumber = 1183 FX_BOOL bArabicNumber =
1183 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0; 1184 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicNumber) != 0;
1184 FX_BOOL bArabicComma = 1185 FX_BOOL bArabicComma =
1185 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0; 1186 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_ArabicComma) != 0;
1186 FX_FLOAT fFontSize = pTxtRun->fFontSize; 1187 FX_FLOAT fFontSize = pTxtRun->fFontSize;
1187 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 1188 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; 1559 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity;
1559 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); 1560 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str();
1560 int32_t* pWidths = pTxtRun->pWidths; 1561 int32_t* pWidths = pTxtRun->pWidths;
1561 int32_t iLength = pTxtRun->iLength; 1562 int32_t iLength = pTxtRun->iLength;
1562 CFX_RectF rect(*pTxtRun->pRect); 1563 CFX_RectF rect(*pTxtRun->pRect);
1563 FX_BOOL bRTLPiece = 1564 FX_BOOL bRTLPiece =
1564 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; 1565 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0;
1565 FX_FLOAT fFontSize = pTxtRun->fFontSize; 1566 FX_FLOAT fFontSize = pTxtRun->fFontSize;
1566 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 1567 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
1567 FX_FLOAT fScale = fFontSize / 1000.0f; 1568 FX_FLOAT fScale = fFontSize / 1000.0f;
1568 IFGAS_Font* pFont = pTxtRun->pFont; 1569 CFGAS_GEFont* pFont = pTxtRun->pFont;
1569 if (pFont == NULL) { 1570 if (pFont == NULL) {
1570 bCharBBox = FALSE; 1571 bCharBBox = FALSE;
1571 } 1572 }
1572 CFX_Rect bbox; 1573 CFX_Rect bbox;
1573 bbox.Set(0, 0, 0, 0); 1574 bbox.Set(0, 0, 0, 0);
1574 if (bCharBBox) { 1575 if (bCharBBox) {
1575 bCharBBox = pFont->GetBBox(bbox); 1576 bCharBBox = pFont->GetBBox(bbox);
1576 } 1577 }
1577 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); 1578 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale);
1578 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); 1579 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 rtBBoxF.height = fHeight; 1653 rtBBoxF.height = fHeight;
1653 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); 1654 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f);
1654 } 1655 }
1655 rtArray.SetAt(i, rtBBoxF); 1656 rtArray.SetAt(i, rtBBoxF);
1656 continue; 1657 continue;
1657 } 1658 }
1658 rtArray.SetAt(i, rect); 1659 rtArray.SetAt(i, rect);
1659 } 1660 }
1660 return iLength; 1661 return iLength;
1661 } 1662 }
OLDNEW
« no previous file with comments | « xfa/fgas/layout/fgas_textbreak.h ('k') | xfa/fgas/layout/fgas_unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698