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

Side by Side Diff: xfa/fde/css/fde_csscache.cpp

Issue 1919563002: Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: fix issue from c4 Created 4 years, 7 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 | « fpdfsdk/javascript/global.cpp ('k') | xfa/fde/css/fde_cssdatatable.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/fde/css/fde_csscache.h" 7 #include "xfa/fde/css/fde_csscache.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 FDE_CSSTagCache::FDE_CSSTagCache(FDE_CSSTagCache* parent, 24 FDE_CSSTagCache::FDE_CSSTagCache(FDE_CSSTagCache* parent,
25 CXFA_CSSTagProvider* tag) 25 CXFA_CSSTagProvider* tag)
26 : pTag(tag), 26 : pTag(tag),
27 pParent(parent), 27 pParent(parent),
28 dwIDHash(0), 28 dwIDHash(0),
29 dwTagHash(0), 29 dwTagHash(0),
30 iClassIndex(0), 30 iClassIndex(0),
31 dwClassHashs(1) { 31 dwClassHashs(1) {
32 static const uint32_t s_dwIDHash = FX_HashCode_String_GetW(L"id", 2, TRUE); 32 static const uint32_t s_dwIDHash = FX_HashCode_GetW(L"id", true);
33 static const uint32_t s_dwClassHash = 33 static const uint32_t s_dwClassHash = FX_HashCode_GetW(L"class", true);
34 FX_HashCode_String_GetW(L"class", 5, TRUE); 34 dwTagHash = FX_HashCode_GetW(pTag->GetTagName().AsStringC(), true);
35
36 CFX_WideString wsTag = pTag->GetTagName();
37 dwTagHash = FX_HashCode_String_GetW(wsTag.c_str(), wsTag.GetLength(), TRUE);
38 35
39 for (auto it : *pTag) { 36 for (auto it : *pTag) {
40 CFX_WideString wsValue = it.first; 37 CFX_WideString wsValue = it.first;
41 CFX_WideString wsName = it.second; 38 CFX_WideString wsName = it.second;
42 39 uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringC(), true);
43 uint32_t dwNameHash =
44 FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength(), TRUE);
45
46 if (dwNameHash == s_dwClassHash) { 40 if (dwNameHash == s_dwClassHash) {
47 uint32_t dwHash = 41 uint32_t dwHash = FX_HashCode_GetW(wsValue.AsStringC(), false);
48 FX_HashCode_String_GetW(wsValue.c_str(), wsValue.GetLength());
49 dwClassHashs.Add(dwHash); 42 dwClassHashs.Add(dwHash);
50 } else if (dwNameHash == s_dwIDHash) { 43 } else if (dwNameHash == s_dwIDHash) {
51 dwIDHash = FX_HashCode_String_GetW(wsValue.c_str(), wsValue.GetLength()); 44 dwIDHash = FX_HashCode_GetW(wsValue.AsStringC(), false);
52 } 45 }
53 } 46 }
54 } 47 }
55 48
56 FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it) 49 FDE_CSSTagCache::FDE_CSSTagCache(const FDE_CSSTagCache& it)
57 : pTag(it.pTag), 50 : pTag(it.pTag),
58 pParent(it.pParent), 51 pParent(it.pParent),
59 dwIDHash(it.dwIDHash), 52 dwIDHash(it.dwIDHash),
60 dwTagHash(it.dwTagHash), 53 dwTagHash(it.dwTagHash),
61 iClassIndex(0), 54 iClassIndex(0),
62 dwClassHashs(1) { 55 dwClassHashs(1) {
63 if (it.dwClassHashs.GetSize() > 0) 56 if (it.dwClassHashs.GetSize() > 0)
64 dwClassHashs.Copy(it.dwClassHashs); 57 dwClassHashs.Copy(it.dwClassHashs);
65 } 58 }
66 59
67 void CFDE_CSSAccelerator::OnEnterTag(CXFA_CSSTagProvider* pTag) { 60 void CFDE_CSSAccelerator::OnEnterTag(CXFA_CSSTagProvider* pTag) {
68 FDE_CSSTagCache* pTop = GetTopElement(); 61 FDE_CSSTagCache* pTop = GetTopElement();
69 FDE_CSSTagCache item(pTop, pTag); 62 FDE_CSSTagCache item(pTop, pTag);
70 m_Stack.Push(item); 63 m_Stack.Push(item);
71 } 64 }
72 65
73 void CFDE_CSSAccelerator::OnLeaveTag(CXFA_CSSTagProvider* pTag) { 66 void CFDE_CSSAccelerator::OnLeaveTag(CXFA_CSSTagProvider* pTag) {
74 FXSYS_assert(m_Stack.GetTopElement()); 67 FXSYS_assert(m_Stack.GetTopElement());
75 FXSYS_assert(m_Stack.GetTopElement()->GetTag() == pTag); 68 FXSYS_assert(m_Stack.GetTopElement()->GetTag() == pTag);
76 m_Stack.Pop(); 69 m_Stack.Pop();
77 } 70 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/global.cpp ('k') | xfa/fde/css/fde_cssdatatable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698