From b76f49b36baffea2b2ecb90d67c7b6bb734e7bb9 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 23 Jan 2017 13:55:39 -0500 Subject: Remove unused author and and user stylesheets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: dsinclair --- xfa/fxfa/app/cxfa_textparser.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'xfa/fxfa/app/cxfa_textparser.cpp') 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 +#include #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 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(); + return sheet->LoadBuffer(s_pStyle, FXSYS_wcslen(s_pStyle)) ? std::move(sheet) + : nullptr; } CFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( -- cgit v1.2.3