diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-01-23 13:55:39 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-23 20:24:23 +0000 |
commit | b76f49b36baffea2b2ecb90d67c7b6bb734e7bb9 (patch) | |
tree | 3331545c1296500ddf164267f4bb715c16e38bb3 /xfa/fxfa/app/cxfa_textparser.cpp | |
parent | 6414b273506f97012f82c8a32c020b483d5df31a (diff) | |
download | pdfium-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/app/cxfa_textparser.cpp')
-rw-r--r-- | xfa/fxfa/app/cxfa_textparser.cpp | 30 |
1 files changed, 14 insertions, 16 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( |