summaryrefslogtreecommitdiff
path: root/xfa/fde/css/fde_cssstylesheet.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-16 16:03:44 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-16 21:14:58 +0000
commitcfb856c4744a9e0ff0f0db5602d0a13c835570ce (patch)
tree8880b3041fd6d780a630ba49813a17a608b83d35 /xfa/fde/css/fde_cssstylesheet.cpp
parent135609831bcad2da79d720cfdd3b55929b48b0ea (diff)
downloadpdfium-cfb856c4744a9e0ff0f0db5602d0a13c835570ce.tar.xz
Remove IFDE_CSS interfaces which are only implemented once.
This CL cleans up some interface classes from FDE CSS. Change-Id: I975e5d63f8ae6a0bc7bb849b6f11f0ae43092e4d Reviewed-on: https://pdfium-review.googlesource.com/2177 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fde/css/fde_cssstylesheet.cpp')
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp50
1 files changed, 21 insertions, 29 deletions
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index f48789533c..a3783c3756 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -13,24 +13,10 @@
#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fgas/crt/fgas_codepage.h"
-IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer(
- const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- uint16_t wCodePage,
- uint32_t dwMediaList) {
- CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
- if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) {
- pStyleSheet->Release();
- pStyleSheet = nullptr;
- }
- return pStyleSheet;
-}
-
-CFDE_CSSStyleSheet::CFDE_CSSStyleSheet(uint32_t dwMediaList)
+CFDE_CSSStyleSheet::CFDE_CSSStyleSheet()
: m_wCodePage(FX_CODEPAGE_UTF8),
m_wRefCount(1),
- m_dwMediaList(dwMediaList),
+ m_dwMediaList(FDE_CSSMEDIATYPE_ALL),
m_RuleArray(100) {
ASSERT(m_dwMediaList > 0);
}
@@ -68,9 +54,8 @@ uint32_t CFDE_CSSStyleSheet::Retain() {
uint32_t CFDE_CSSStyleSheet::Release() {
uint32_t dwRefCount = --m_wRefCount;
- if (dwRefCount == 0) {
+ if (dwRefCount == 0)
delete this;
- }
return dwRefCount;
}
@@ -95,16 +80,15 @@ IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
return m_RuleArray.GetAt(index);
}
-bool CFDE_CSSStyleSheet::LoadFromBuffer(const CFX_WideString& szUrl,
- const FX_WCHAR* pBuffer,
- int32_t iBufSize,
- uint16_t wCodePage) {
+bool CFDE_CSSStyleSheet::LoadFromBuffer(const FX_WCHAR* pBuffer,
+ int32_t iBufSize) {
ASSERT(pBuffer && iBufSize > 0);
- std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
- bool bRet = pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax.get());
- m_wCodePage = wCodePage;
- m_szUrl = szUrl;
- return bRet;
+
+ m_wCodePage = FX_CODEPAGE_UTF8;
+ m_szUrl = CFX_WideString();
+
+ auto pSyntax = pdfium::MakeUnique<CFDE_CSSSyntaxParser>();
+ return pSyntax->Init(pBuffer, iBufSize) && LoadFromSyntax(pSyntax.get());
}
bool CFDE_CSSStyleSheet::LoadFromSyntax(CFDE_CSSSyntaxParser* pSyntax) {
@@ -333,6 +317,10 @@ FDE_CSSSyntaxStatus CFDE_CSSStyleSheet::SkipRuleSet(
CFDE_CSSStyleRule::CFDE_CSSStyleRule()
: m_ppSelector(nullptr), m_iSelectors(0) {}
+FDE_CSSRuleType CFDE_CSSStyleRule::GetType() const {
+ return FDE_CSSRuleType::Style;
+}
+
int32_t CFDE_CSSStyleRule::CountSelectorLists() const {
return m_iSelectors;
}
@@ -373,6 +361,10 @@ CFDE_CSSMediaRule::~CFDE_CSSMediaRule() {
}
}
+FDE_CSSRuleType CFDE_CSSMediaRule::GetType() const {
+ return FDE_CSSRuleType::Media;
+}
+
uint32_t CFDE_CSSMediaRule::GetMediaList() const {
return m_dwMediaList;
}
@@ -532,6 +524,6 @@ CFDE_CSSSelector* CFDE_CSSSelector::FromString(
return pPseudoFirst;
}
-CFDE_CSSDeclaration* CFDE_CSSFontFaceRule::GetDeclaration() {
- return &m_Declaration;
+FDE_CSSRuleType CFDE_CSSFontFaceRule::GetType() const {
+ return FDE_CSSRuleType::FontFace;
}