OLD | NEW |
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/fde/css/fde_csscache.h" | 7 #include "xfa/fde/css/fde_csscache.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 dwTagHash(0), | 105 dwTagHash(0), |
106 iClassIndex(0), | 106 iClassIndex(0), |
107 dwClassHashs(1) { | 107 dwClassHashs(1) { |
108 FXSYS_assert(pTag != NULL); | 108 FXSYS_assert(pTag != NULL); |
109 CFX_WideStringC wsValue, wsName = pTag->GetTagName(); | 109 CFX_WideStringC wsValue, wsName = pTag->GetTagName(); |
110 dwTagHash = | 110 dwTagHash = |
111 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE); | 111 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE); |
112 FX_POSITION pos = pTag->GetFirstAttribute(); | 112 FX_POSITION pos = pTag->GetFirstAttribute(); |
113 while (pos != NULL) { | 113 while (pos != NULL) { |
114 pTag->GetNextAttribute(pos, wsName, wsValue); | 114 pTag->GetNextAttribute(pos, wsName, wsValue); |
115 FX_DWORD dwNameHash = | 115 uint32_t dwNameHash = |
116 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE); | 116 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), TRUE); |
117 static const FX_DWORD s_dwIDHash = FX_HashCode_String_GetW(L"id", 2, TRUE); | 117 static const uint32_t s_dwIDHash = FX_HashCode_String_GetW(L"id", 2, TRUE); |
118 static const FX_DWORD s_dwClassHash = | 118 static const uint32_t s_dwClassHash = |
119 FX_HashCode_String_GetW(L"class", 5, TRUE); | 119 FX_HashCode_String_GetW(L"class", 5, TRUE); |
120 if (dwNameHash == s_dwClassHash) { | 120 if (dwNameHash == s_dwClassHash) { |
121 FX_DWORD dwHash = | 121 uint32_t dwHash = |
122 FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); | 122 FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); |
123 dwClassHashs.Add(dwHash); | 123 dwClassHashs.Add(dwHash); |
124 } else if (dwNameHash == s_dwIDHash) { | 124 } else if (dwNameHash == s_dwIDHash) { |
125 dwIDHash = FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); | 125 dwIDHash = FX_HashCode_String_GetW(wsValue.GetPtr(), wsValue.GetLength()); |
126 } | 126 } |
127 } | 127 } |
128 } | 128 } |
129 FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it) | 129 FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it) |
130 : pTag(it.pTag), | 130 : pTag(it.pTag), |
131 pParent(it.pParent), | 131 pParent(it.pParent), |
132 dwIDHash(it.dwIDHash), | 132 dwIDHash(it.dwIDHash), |
133 dwTagHash(it.dwTagHash), | 133 dwTagHash(it.dwTagHash), |
134 iClassIndex(0), | 134 iClassIndex(0), |
135 dwClassHashs(1) { | 135 dwClassHashs(1) { |
136 if (it.dwClassHashs.GetSize() > 0) { | 136 if (it.dwClassHashs.GetSize() > 0) { |
137 dwClassHashs.Copy(it.dwClassHashs); | 137 dwClassHashs.Copy(it.dwClassHashs); |
138 } | 138 } |
139 } | 139 } |
140 void CFDE_CSSAccelerator::OnEnterTag(IFDE_CSSTagProvider* pTag) { | 140 void CFDE_CSSAccelerator::OnEnterTag(IFDE_CSSTagProvider* pTag) { |
141 FDE_CSSTagCache* pTop = GetTopElement(); | 141 FDE_CSSTagCache* pTop = GetTopElement(); |
142 FDE_CSSTagCache item(pTop, pTag); | 142 FDE_CSSTagCache item(pTop, pTag); |
143 m_Stack.Push(item); | 143 m_Stack.Push(item); |
144 } | 144 } |
145 void CFDE_CSSAccelerator::OnLeaveTag(IFDE_CSSTagProvider* pTag) { | 145 void CFDE_CSSAccelerator::OnLeaveTag(IFDE_CSSTagProvider* pTag) { |
146 FXSYS_assert(m_Stack.GetTopElement()); | 146 FXSYS_assert(m_Stack.GetTopElement()); |
147 FXSYS_assert(m_Stack.GetTopElement()->GetTag() == pTag); | 147 FXSYS_assert(m_Stack.GetTopElement()->GetTag() == pTag); |
148 m_Stack.Pop(); | 148 m_Stack.Pop(); |
149 } | 149 } |
OLD | NEW |