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

Side by Side Diff: xfa/fxfa/app/xfa_fftext.cpp

Issue 2631703003: Avoid endless loop deleting CFGAS_GEFont. (Closed)
Patch Set: rebase 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
« no previous file with comments | « xfa/fxfa/app/cxfa_textlayout.cpp ('k') | xfa/fxfa/app/xfa_textpiece.cpp » ('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/fxfa/app/xfa_fftext.h" 7 #include "xfa/fxfa/app/xfa_fftext.h"
8 8
9 #include "xfa/fwl/fwl_widgetdef.h" 9 #include "xfa/fwl/fwl_widgetdef.h"
10 #include "xfa/fwl/fwl_widgethit.h" 10 #include "xfa/fwl/fwl_widgethit.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 CFX_RectF rtBox; 146 CFX_RectF rtBox;
147 GetRectWithoutRotate(rtBox); 147 GetRectWithoutRotate(rtBox);
148 if (!rtBox.Contains(fx, fy)) 148 if (!rtBox.Contains(fx, fy))
149 return FWL_WidgetHit::Unknown; 149 return FWL_WidgetHit::Unknown;
150 if (!GetLinkURLAtPoint(fx, fy)) 150 if (!GetLinkURLAtPoint(fx, fy))
151 return FWL_WidgetHit::Unknown; 151 return FWL_WidgetHit::Unknown;
152 return FWL_WidgetHit::HyperLink; 152 return FWL_WidgetHit::HyperLink;
153 } 153 }
154 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) { 154 const FX_WCHAR* CXFA_FFText::GetLinkURLAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
155 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout(); 155 CXFA_TextLayout* pTextLayout = m_pDataAcc->GetTextLayout();
156 if (!pTextLayout) { 156 if (!pTextLayout)
157 return nullptr; 157 return nullptr;
158 } 158
159 FX_FLOAT x(fx), y(fy); 159 FX_FLOAT x(fx);
160 FX_FLOAT y(fy);
160 FWLToClient(x, y); 161 FWLToClient(x, y);
161 const CFX_ArrayTemplate<CXFA_PieceLine*>* pPieceLines = 162
162 pTextLayout->GetPieceLines(); 163 for (const auto& pPieceLine : *pTextLayout->GetPieceLines()) {
163 int32_t iCount = pPieceLines->GetSize(); 164 for (const auto& pPiece : pPieceLine->m_textPieces) {
164 for (int32_t i = 0; i < iCount; i++) { 165 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y))
165 CXFA_PieceLine* pPieceLine = pPieceLines->GetAt(i);
166 int32_t iPieces = pPieceLine->m_textPieces.GetSize();
167 for (int32_t j = 0; j < iPieces; j++) {
168 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j);
169 if (pPiece->pLinkData && pPiece->rtPiece.Contains(x, y)) {
170 return pPiece->pLinkData->GetLinkURL(); 166 return pPiece->pLinkData->GetLinkURL();
171 }
172 } 167 }
173 } 168 }
174 return nullptr; 169 return nullptr;
175 } 170 }
176 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { 171 void CXFA_FFText::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) {
177 CFX_RectF rtWidget; 172 CFX_RectF rtWidget;
178 GetRectWithoutRotate(rtWidget); 173 GetRectWithoutRotate(rtWidget);
179 fx -= rtWidget.left; 174 fx -= rtWidget.left;
180 fy -= rtWidget.top; 175 fy -= rtWidget.top;
181 } 176 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/cxfa_textlayout.cpp ('k') | xfa/fxfa/app/xfa_textpiece.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698