summaryrefslogtreecommitdiff
path: root/xfa/fde/css
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde/css')
-rw-r--r--xfa/fde/css/fde_css.h2
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp12
-rw-r--r--xfa/fde/css/fde_cssstylesheet.h2
-rw-r--r--xfa/fde/css/fde_csssyntax.cpp21
-rw-r--r--xfa/fde/css/fde_csssyntax.h7
5 files changed, 25 insertions, 19 deletions
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index 3c216290d2..15468c2c4a 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -751,7 +751,7 @@ class IFDE_CSSStyleSheet : public IFX_Retainable {
static IFDE_CSSStyleSheet* LoadHTMLStandardStyleSheet();
static IFDE_CSSStyleSheet* LoadFromStream(
const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage,
uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
static IFDE_CSSStyleSheet* LoadFromBuffer(
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index 9c91e43cce..fbecf4325b 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -8,6 +8,7 @@
#include <memory>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/css/fde_cssdatatable.h"
#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -49,7 +50,7 @@ IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() {
IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream(
const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage,
uint32_t dwMediaList) {
CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
@@ -143,10 +144,11 @@ IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
return m_RuleArray.GetAt(index);
}
-bool CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
- uint16_t wCodePage) {
- std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+bool CFDE_CSSStyleSheet::LoadFromStream(
+ const CFX_WideString& szUrl,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ uint16_t wCodePage) {
+ auto pSyntax = pdfium::MakeUnique<CFDE_CSSSyntaxParser>();
if (pStream->GetCodePage() != wCodePage)
pStream->SetCodePage(wCodePage);
diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h
index 2460959a97..ad1f8dfbe3 100644
--- a/xfa/fde/css/fde_cssstylesheet.h
+++ b/xfa/fde/css/fde_cssstylesheet.h
@@ -111,7 +111,7 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
IFDE_CSSRule* GetRule(int32_t index) override;
bool LoadFromStream(const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage);
bool LoadFromBuffer(const CFX_WideString& szUrl,
const FX_WCHAR* pBuffer,
diff --git a/xfa/fde/css/fde_csssyntax.cpp b/xfa/fde/css/fde_csssyntax.cpp
index bdad0155d5..50ad190857 100644
--- a/xfa/fde/css/fde_csssyntax.cpp
+++ b/xfa/fde/css/fde_csssyntax.cpp
@@ -35,7 +35,7 @@ CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() {
m_TextPlane.Reset();
}
-bool CFDE_CSSSyntaxParser::Init(IFGAS_Stream* pStream,
+bool CFDE_CSSSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize,
bool bOnlyDeclaration) {
@@ -433,22 +433,25 @@ bool CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) {
m_bExtBuf = false;
return ExpandBuf(iAllocSize);
}
-int32_t CFDE_CSSTextBuf::LoadFromStream(IFGAS_Stream* pTxtStream,
- int32_t iStreamOffset,
- int32_t iMaxChars,
- bool& bEOS) {
+
+int32_t CFDE_CSSTextBuf::LoadFromStream(
+ const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
+ int32_t iStreamOffset,
+ int32_t iMaxChars,
+ bool& bEOS) {
ASSERT(iStreamOffset >= 0 && iMaxChars > 0);
Clear();
m_bExtBuf = false;
- if (!ExpandBuf(iMaxChars)) {
+ if (!ExpandBuf(iMaxChars))
return 0;
- }
- if (pTxtStream->GetPosition() != iStreamOffset) {
+
+ if (pTxtStream->GetPosition() != iStreamOffset)
pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset);
- }
+
m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, bEOS);
return m_iDatLen;
}
+
bool CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
if (m_bExtBuf) {
return false;
diff --git a/xfa/fde/css/fde_csssyntax.h b/xfa/fde/css/fde_csssyntax.h
index 03662037d9..6417df07d4 100644
--- a/xfa/fde/css/fde_csssyntax.h
+++ b/xfa/fde/css/fde_csssyntax.h
@@ -7,6 +7,7 @@
#ifndef XFA_FDE_CSS_FDE_CSSSYNTAX_H_
#define XFA_FDE_CSS_FDE_CSSSYNTAX_H_
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "xfa/fde/css/fde_css.h"
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_stream.h"
@@ -18,7 +19,7 @@ class CFDE_CSSTextBuf : public CFX_Target {
bool AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen);
bool EstimateSize(int32_t iAllocSize);
- int32_t LoadFromStream(IFGAS_Stream* pTxtStream,
+ int32_t LoadFromStream(const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
int32_t iStreamOffset,
int32_t iMaxChars,
bool& bEOS);
@@ -80,7 +81,7 @@ class CFDE_CSSSyntaxParser : public CFX_Target {
CFDE_CSSSyntaxParser();
~CFDE_CSSSyntaxParser() override;
- bool Init(IFGAS_Stream* pStream,
+ bool Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize = 32,
bool bOnlyDeclaration = false);
@@ -106,7 +107,7 @@ class CFDE_CSSSyntaxParser : public CFX_Target {
bool IsImportEnabled() const;
void DisableImport() { m_dwCheck = 0; }
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
int32_t m_iStreamPos;
int32_t m_iPlaneSize;
CFDE_CSSTextBuf m_TextData;