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_cssstylesheet.h" | 7 #include "xfa/fde/css/fde_cssstylesheet.h" |
8 | 8 |
9 #include "xfa/fde/css/fde_cssdatatable.h" | 9 #include "xfa/fde/css/fde_cssdatatable.h" |
10 #include "xfa/fde/css/fde_csssyntax.h" | 10 #include "xfa/fde/css/fde_csssyntax.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 L"base}rbc{display:ruby-base-group}rtc{display:ruby-text-group}" | 41 L"base}rbc{display:ruby-base-group}rtc{display:ruby-text-group}" |
42 L"q:before{content:open-quote}q:after{content:close-quote}" | 42 L"q:before{content:open-quote}q:after{content:close-quote}" |
43 L"rp{display:none}"; | 43 L"rp{display:none}"; |
44 return IFDE_CSSStyleSheet::LoadFromBuffer( | 44 return IFDE_CSSStyleSheet::LoadFromBuffer( |
45 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); | 45 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); |
46 } | 46 } |
47 | 47 |
48 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream( | 48 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream( |
49 const CFX_WideString& szUrl, | 49 const CFX_WideString& szUrl, |
50 IFX_Stream* pStream, | 50 IFX_Stream* pStream, |
51 FX_WORD wCodePage, | 51 uint16_t wCodePage, |
52 FX_DWORD dwMediaList) { | 52 FX_DWORD dwMediaList) { |
53 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); | 53 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); |
54 if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) { | 54 if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) { |
55 pStyleSheet->Release(); | 55 pStyleSheet->Release(); |
56 pStyleSheet = NULL; | 56 pStyleSheet = NULL; |
57 } | 57 } |
58 return pStyleSheet; | 58 return pStyleSheet; |
59 } | 59 } |
60 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( | 60 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( |
61 const CFX_WideString& szUrl, | 61 const CFX_WideString& szUrl, |
62 const FX_WCHAR* pBuffer, | 62 const FX_WCHAR* pBuffer, |
63 int32_t iBufSize, | 63 int32_t iBufSize, |
64 FX_WORD wCodePage, | 64 uint16_t wCodePage, |
65 FX_DWORD dwMediaList) { | 65 FX_DWORD dwMediaList) { |
66 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); | 66 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); |
67 if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) { | 67 if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) { |
68 pStyleSheet->Release(); | 68 pStyleSheet->Release(); |
69 pStyleSheet = NULL; | 69 pStyleSheet = NULL; |
70 } | 70 } |
71 return pStyleSheet; | 71 return pStyleSheet; |
72 } | 72 } |
73 CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(FX_DWORD dwMediaList) | 73 CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(FX_DWORD dwMediaList) |
74 : m_wCodePage(FX_CODEPAGE_UTF8), | 74 : m_wCodePage(FX_CODEPAGE_UTF8), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 return dwRefCount; | 117 return dwRefCount; |
118 } | 118 } |
119 int32_t CFDE_CSSStyleSheet::CountRules() const { | 119 int32_t CFDE_CSSStyleSheet::CountRules() const { |
120 return m_RuleArray.GetSize(); | 120 return m_RuleArray.GetSize(); |
121 } | 121 } |
122 IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) { | 122 IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) { |
123 return m_RuleArray.GetAt(index); | 123 return m_RuleArray.GetAt(index); |
124 } | 124 } |
125 FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl, | 125 FX_BOOL CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl, |
126 IFX_Stream* pStream, | 126 IFX_Stream* pStream, |
127 FX_WORD wCodePage) { | 127 uint16_t wCodePage) { |
128 FXSYS_assert(pStream != NULL); | 128 FXSYS_assert(pStream != NULL); |
129 IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create(); | 129 IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create(); |
130 if (pSyntax == NULL) { | 130 if (pSyntax == NULL) { |
131 return FALSE; | 131 return FALSE; |
132 } | 132 } |
133 if (pStream->GetCodePage() != wCodePage) { | 133 if (pStream->GetCodePage() != wCodePage) { |
134 pStream->SetCodePage(wCodePage); | 134 pStream->SetCodePage(wCodePage); |
135 } | 135 } |
136 FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax); | 136 FX_BOOL bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax); |
137 pSyntax->Release(); | 137 pSyntax->Release(); |
138 m_wCodePage = wCodePage; | 138 m_wCodePage = wCodePage; |
139 m_szUrl = szUrl; | 139 m_szUrl = szUrl; |
140 return bRet; | 140 return bRet; |
141 } | 141 } |
142 FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl, | 142 FX_BOOL CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl, |
143 const FX_WCHAR* pBuffer, | 143 const FX_WCHAR* pBuffer, |
144 int32_t iBufSize, | 144 int32_t iBufSize, |
145 FX_WORD wCodePage) { | 145 uint16_t wCodePage) { |
146 FXSYS_assert(pBuffer != NULL && iBufSize > 0); | 146 FXSYS_assert(pBuffer != NULL && iBufSize > 0); |
147 IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create(); | 147 IFDE_CSSSyntaxParser* pSyntax = IFDE_CSSSyntaxParser::Create(); |
148 if (pSyntax == NULL) { | 148 if (pSyntax == NULL) { |
149 return FALSE; | 149 return FALSE; |
150 } | 150 } |
151 FX_BOOL bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax); | 151 FX_BOOL bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax); |
152 pSyntax->Release(); | 152 pSyntax->Release(); |
153 m_wCodePage = wCodePage; | 153 m_wCodePage = wCodePage; |
154 m_szUrl = szUrl; | 154 m_szUrl = szUrl; |
155 return bRet; | 155 return bRet; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 return NULL; | 500 return NULL; |
501 } | 501 } |
502 } | 502 } |
503 if (pPersudoFirst == NULL) { | 503 if (pPersudoFirst == NULL) { |
504 return pFirst; | 504 return pFirst; |
505 } else { | 505 } else { |
506 pPersudoLast->SetNext(pFirst); | 506 pPersudoLast->SetNext(pFirst); |
507 return pPersudoFirst; | 507 return pPersudoFirst; |
508 } | 508 } |
509 } | 509 } |
OLD | NEW |