summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-23 13:55:39 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-23 20:24:23 +0000
commitb76f49b36baffea2b2ecb90d67c7b6bb734e7bb9 (patch)
tree3331545c1296500ddf164267f4bb715c16e38bb3 /xfa/fxfa
parent6414b273506f97012f82c8a32c020b483d5df31a (diff)
downloadpdfium-b76f49b36baffea2b2ecb90d67c7b6bb734e7bb9.tar.xz
Remove unused author and and user stylesheets
We only load atyles from the CXFA_TextParser which loads a static UserAgent stylesheet. This CL removes the User and Author styles from the system and simplifies the storage of the stylesheets. Change-Id: I7abcf39333655f8dd6bc2cfe685c8cf73b779c7d Reviewed-on: https://pdfium-review.googlesource.com/2293 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/app/cxfa_textparser.cpp30
-rw-r--r--xfa/fxfa/app/cxfa_textparser.h4
2 files changed, 16 insertions, 18 deletions
diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp
index 703d11ec11..6386edfad8 100644
--- a/xfa/fxfa/app/cxfa_textparser.cpp
+++ b/xfa/fxfa/app/cxfa_textparser.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/app/cxfa_textparser.h"
#include <algorithm>
+#include <utility>
#include "third_party/base/ptr_util.h"
#include "xfa/fde/css/cfde_cssaccelerator.h"
@@ -39,12 +40,10 @@ enum class TabStopStatus {
} // namespace
-CXFA_TextParser::CXFA_TextParser() : m_pUASheet(nullptr), m_bParsed(false) {}
+CXFA_TextParser::CXFA_TextParser()
+ : m_bParsed(false), m_cssInitialized(false) {}
CXFA_TextParser::~CXFA_TextParser() {
- if (m_pUASheet)
- m_pUASheet->Release();
-
for (auto& pair : m_mapXMLNodeToParseContext) {
if (pair.second)
delete pair.second;
@@ -76,14 +75,16 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
m_pSelector->SetDefFontSize(fFontSize);
}
- if (!m_pUASheet) {
- m_pUASheet = LoadDefaultSheetStyle();
- m_pSelector->SetStyleSheet(FDE_CSSStyleSheetGroup::UserAgent, m_pUASheet);
- m_pSelector->UpdateStyleIndex();
- }
+ if (m_cssInitialized)
+ return;
+
+ m_cssInitialized = true;
+ auto uaSheet = LoadDefaultSheetStyle();
+ m_pSelector->SetUAStyleSheet(std::move(uaSheet));
+ m_pSelector->UpdateStyleIndex();
}
-CFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() {
+std::unique_ptr<CFDE_CSSStyleSheet> CXFA_TextParser::LoadDefaultSheetStyle() {
static const FX_WCHAR s_pStyle[] =
L"html,body,ol,p,ul{display:block}"
L"li{display:list-item}"
@@ -95,12 +96,9 @@ CFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() {
L"sup{vertical-align:+15em;font-size:.66em}"
L"sub{vertical-align:-15em;font-size:.66em}";
- CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet();
- if (!pStyleSheet->LoadBuffer(s_pStyle, FXSYS_wcslen(s_pStyle))) {
- pStyleSheet->Release();
- pStyleSheet = nullptr;
- }
- return pStyleSheet;
+ auto sheet = pdfium::MakeUnique<CFDE_CSSStyleSheet>();
+ return sheet->LoadBuffer(s_pStyle, FXSYS_wcslen(s_pStyle)) ? std::move(sheet)
+ : nullptr;
}
CFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle(
diff --git a/xfa/fxfa/app/cxfa_textparser.h b/xfa/fxfa/app/cxfa_textparser.h
index a0b5ab1f29..7a94f83aeb 100644
--- a/xfa/fxfa/app/cxfa_textparser.h
+++ b/xfa/fxfa/app/cxfa_textparser.h
@@ -88,13 +88,13 @@ class CXFA_TextParser {
void ParseRichText(CFDE_XMLNode* pXMLNode,
CFDE_CSSComputedStyle* pParentStyle);
void ParseTagInfo(CFDE_XMLNode* pXMLNode, CXFA_CSSTagProvider& tagProvider);
- CFDE_CSSStyleSheet* LoadDefaultSheetStyle();
+ std::unique_ptr<CFDE_CSSStyleSheet> LoadDefaultSheetStyle();
CFDE_CSSComputedStyle* CreateStyle(CFDE_CSSComputedStyle* pParentStyle);
std::unique_ptr<CFDE_CSSStyleSelector> m_pSelector;
- CFDE_CSSStyleSheet* m_pUASheet;
std::map<CFDE_XMLNode*, CXFA_TextParseContext*> m_mapXMLNodeToParseContext;
bool m_bParsed;
+ bool m_cssInitialized;
};
#endif // XFA_FXFA_APP_CXFA_TEXTPARSER_H_