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

Side by Side Diff: core/fxcrt/fx_basic_util.cpp

Issue 2016743002: Add back-pointer to "Associated widget" to CFWL_WidgetImp. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@opaque_layout_item
Patch Set: Initialize m_pAssociate. 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 | « no previous file | core/fxcrt/include/fx_basic.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 "core/fxcrt/include/fx_basic.h" 7 #include "core/fxcrt/include/fx_basic.h"
8 #include "core/fxcrt/include/fx_ext.h" 8 #include "core/fxcrt/include/fx_ext.h"
9 9
10 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 10 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
11 #include <dirent.h> 11 #include <dirent.h>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 #else 13 #else
14 #include <direct.h> 14 #include <direct.h>
15 #endif 15 #endif
16 16
17 #include <algorithm> 17 #include <algorithm>
18 #include <cctype> 18 #include <cctype>
19 #include <memory> 19 #include <memory>
20 20
21 #ifdef PDF_ENABLE_XFA
22 CFX_PrivateData::CFX_PrivateData() {}
23
24 CFX_PrivateData::~CFX_PrivateData() {
25 ClearAll();
26 }
27 void FX_PRIVATEDATA::FreeData() {
28 if (!m_pData) {
29 return;
30 }
31 if (m_bSelfDestruct) {
32 delete static_cast<CFX_Deletable*>(m_pData);
33 } else if (m_pCallback) {
34 m_pCallback(m_pData);
35 }
36 }
37 void CFX_PrivateData::AddData(void* pModuleId,
38 void* pData,
39 PD_CALLBACK_FREEDATA callback,
40 FX_BOOL bSelfDestruct) {
41 if (!pModuleId) {
42 return;
43 }
44 FX_PRIVATEDATA* pList = m_DataList.GetData();
45 int count = m_DataList.GetSize();
46 for (int i = 0; i < count; i++) {
47 if (pList[i].m_pModuleId == pModuleId) {
48 pList[i].FreeData();
49 pList[i].m_pData = pData;
50 pList[i].m_pCallback = callback;
51 return;
52 }
53 }
54 FX_PRIVATEDATA data = {pModuleId, pData, callback, bSelfDestruct};
55 m_DataList.Add(data);
56 }
57 void CFX_PrivateData::SetPrivateData(void* pModuleId,
58 void* pData,
59 PD_CALLBACK_FREEDATA callback) {
60 AddData(pModuleId, pData, callback, FALSE);
61 }
62 void CFX_PrivateData::SetPrivateObj(void* pModuleId, CFX_Deletable* pObj) {
63 AddData(pModuleId, pObj, NULL, TRUE);
64 }
65 FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) {
66 if (!pModuleId) {
67 return FALSE;
68 }
69 FX_PRIVATEDATA* pList = m_DataList.GetData();
70 int count = m_DataList.GetSize();
71 for (int i = 0; i < count; i++) {
72 if (pList[i].m_pModuleId == pModuleId) {
73 m_DataList.RemoveAt(i);
74 return TRUE;
75 }
76 }
77 return FALSE;
78 }
79 void* CFX_PrivateData::GetPrivateData(void* pModuleId) {
80 if (!pModuleId) {
81 return NULL;
82 }
83 FX_PRIVATEDATA* pList = m_DataList.GetData();
84 int count = m_DataList.GetSize();
85 for (int i = 0; i < count; i++) {
86 if (pList[i].m_pModuleId == pModuleId) {
87 return pList[i].m_pData;
88 }
89 }
90 return NULL;
91 }
92 void CFX_PrivateData::ClearAll() {
93 FX_PRIVATEDATA* pList = m_DataList.GetData();
94 int count = m_DataList.GetSize();
95 for (int i = 0; i < count; i++) {
96 pList[i].FreeData();
97 }
98 m_DataList.RemoveAll();
99 }
100 #endif // PDF_ENABLE_XFA
101
102 void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) { 21 void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) {
103 if (strc.Find('.') == -1) { 22 if (strc.Find('.') == -1) {
104 bInteger = TRUE; 23 bInteger = TRUE;
105 int cc = 0; 24 int cc = 0;
106 pdfium::base::CheckedNumeric<int> integer = 0; 25 pdfium::base::CheckedNumeric<int> integer = 0;
107 FX_STRSIZE len = strc.GetLength(); 26 FX_STRSIZE len = strc.GetLength();
108 bool bNegative = false; 27 bool bNegative = false;
109 if (strc[0] == '+') { 28 if (strc[0] == '+') {
110 cc++; 29 cc++;
111 } else if (strc[0] == '-') { 30 } else if (strc[0] == '-') {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 dstShift -= 8; 290 dstShift -= 8;
372 result |= *dataPtr++ << dstShift; 291 result |= *dataPtr++ << dstShift;
373 } 292 }
374 if (dstShift > 0) { 293 if (dstShift > 0) {
375 bitShift = 8 - dstShift; 294 bitShift = 8 - dstShift;
376 bitMask = (1 << dstShift) - 1; 295 bitMask = (1 << dstShift) - 1;
377 result |= *dataPtr++ >> bitShift & bitMask; 296 result |= *dataPtr++ >> bitShift & bitMask;
378 } 297 }
379 return result; 298 return result;
380 } 299 }
OLDNEW
« no previous file with comments | « no previous file | core/fxcrt/include/fx_basic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698