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

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

Issue 2559763002: Refcount IFGAS_ streams all the time, too (Closed)
Patch Set: more Created 4 years 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/fde/css/fde_cssstylesheet.h ('k') | xfa/fde/css/fde_csssyntax.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_cssstylesheet.h" 7 #include "xfa/fde/css/fde_cssstylesheet.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "third_party/base/ptr_util.h"
11 #include "xfa/fde/css/fde_cssdatatable.h" 12 #include "xfa/fde/css/fde_cssdatatable.h"
12 #include "xfa/fde/css/fde_csssyntax.h" 13 #include "xfa/fde/css/fde_csssyntax.h"
13 #include "xfa/fgas/crt/fgas_codepage.h" 14 #include "xfa/fgas/crt/fgas_codepage.h"
14 15
15 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() { 16 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() {
16 static const FX_WCHAR s_pStyle[] = 17 static const FX_WCHAR s_pStyle[] =
17 L"html,address,blockquote,body,dd,div,dl,dt,fieldset,form,frame,frameset," 18 L"html,address,blockquote,body,dd,div,dl,dt,fieldset,form,frame,frameset,"
18 L"h1,h2,h3,h4,h5,h6,noframes,ol,p,ul,center,dir,hr,menu,pre{display:" 19 L"h1,h2,h3,h4,h5,h6,noframes,ol,p,ul,center,dir,hr,menu,pre{display:"
19 L"block}" 20 L"block}"
20 L"li{display:list-item}head{display:none}table{display:table}tr{display:" 21 L"li{display:list-item}head{display:none}table{display:table}tr{display:"
(...skipping 21 matching lines...) Expand all
42 L"ruby{display:ruby}rt{display:ruby-text;font-size:.5em}rb{display:ruby-" 43 L"ruby{display:ruby}rt{display:ruby-text;font-size:.5em}rb{display:ruby-"
43 L"base}rbc{display:ruby-base-group}rtc{display:ruby-text-group}" 44 L"base}rbc{display:ruby-base-group}rtc{display:ruby-text-group}"
44 L"q:before{content:open-quote}q:after{content:close-quote}" 45 L"q:before{content:open-quote}q:after{content:close-quote}"
45 L"rp{display:none}"; 46 L"rp{display:none}";
46 return IFDE_CSSStyleSheet::LoadFromBuffer( 47 return IFDE_CSSStyleSheet::LoadFromBuffer(
47 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); 48 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8);
48 } 49 }
49 50
50 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream( 51 IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream(
51 const CFX_WideString& szUrl, 52 const CFX_WideString& szUrl,
52 IFGAS_Stream* pStream, 53 const CFX_RetainPtr<IFGAS_Stream>& pStream,
53 uint16_t wCodePage, 54 uint16_t wCodePage,
54 uint32_t dwMediaList) { 55 uint32_t dwMediaList) {
55 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); 56 CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
56 if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) { 57 if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) {
57 pStyleSheet->Release(); 58 pStyleSheet->Release();
58 pStyleSheet = nullptr; 59 pStyleSheet = nullptr;
59 } 60 }
60 return pStyleSheet; 61 return pStyleSheet;
61 } 62 }
62 63
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 137 }
137 138
138 int32_t CFDE_CSSStyleSheet::CountRules() const { 139 int32_t CFDE_CSSStyleSheet::CountRules() const {
139 return m_RuleArray.GetSize(); 140 return m_RuleArray.GetSize();
140 } 141 }
141 142
142 IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) { 143 IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
143 return m_RuleArray.GetAt(index); 144 return m_RuleArray.GetAt(index);
144 } 145 }
145 146
146 bool CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl, 147 bool CFDE_CSSStyleSheet::LoadFromStream(
147 IFGAS_Stream* pStream, 148 const CFX_WideString& szUrl,
148 uint16_t wCodePage) { 149 const CFX_RetainPtr<IFGAS_Stream>& pStream,
149 std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser); 150 uint16_t wCodePage) {
151 auto pSyntax = pdfium::MakeUnique<CFDE_CSSSyntaxParser>();
150 if (pStream->GetCodePage() != wCodePage) 152 if (pStream->GetCodePage() != wCodePage)
151 pStream->SetCodePage(wCodePage); 153 pStream->SetCodePage(wCodePage);
152 154
153 bool bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax.get()); 155 bool bRet = pSyntax->Init(pStream, 4096) && LoadFromSyntax(pSyntax.get());
154 m_wCodePage = wCodePage; 156 m_wCodePage = wCodePage;
155 m_szUrl = szUrl; 157 m_szUrl = szUrl;
156 return bRet; 158 return bRet;
157 } 159 }
158 160
159 bool CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl, 161 bool CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl,
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (!pPersudoFirst) 579 if (!pPersudoFirst)
578 return pFirst; 580 return pFirst;
579 581
580 pPersudoLast->SetNext(pFirst); 582 pPersudoLast->SetNext(pFirst);
581 return pPersudoFirst; 583 return pPersudoFirst;
582 } 584 }
583 585
584 CFDE_CSSDeclaration* CFDE_CSSFontFaceRule::GetDeclaration() { 586 CFDE_CSSDeclaration* CFDE_CSSFontFaceRule::GetDeclaration() {
585 return &m_Declaration; 587 return &m_Declaration;
586 } 588 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstylesheet.h ('k') | xfa/fde/css/fde_csssyntax.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698