diff options
author | dsinclair <dsinclair@chromium.org> | 2016-04-21 13:37:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-21 13:37:10 -0700 |
commit | bc1cbabe8d8bfa74d25160c14afa30d5b40df335 (patch) | |
tree | bc8ba8fbf303f863ca62d71f0bad013bd622309a /xfa/fxfa/app | |
parent | 5d9da0c1255a75dd9b7b2005f8b7d6ae4948feaf (diff) | |
download | pdfium-bc1cbabe8d8bfa74d25160c14afa30d5b40df335.tar.xz |
Remove IFDE_CSSTagProvider.
There is only one subsclass, use that instead. Remove the use of WideStringC
in the API.
BUG=pdfium:468
Review URL: https://codereview.chromium.org/1911843002
Diffstat (limited to 'xfa/fxfa/app')
-rw-r--r-- | xfa/fxfa/app/xfa_textlayout.cpp | 33 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_textlayout.h | 29 |
2 files changed, 19 insertions, 43 deletions
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp index c0a8895bc7..b2030814bc 100644 --- a/xfa/fxfa/app/xfa_textlayout.cpp +++ b/xfa/fxfa/app/xfa_textlayout.cpp @@ -21,40 +21,11 @@ #include "xfa/fxfa/include/xfa_ffdoc.h" #include "xfa/fxfa/include/xfa_fontmgr.h" -CXFA_CSSTagProvider::~CXFA_CSSTagProvider() { - FX_POSITION pos = m_Attributes.GetStartPosition(); - while (pos) { - CFX_WideString *pName = NULL, *pValue = NULL; - m_Attributes.GetNextAssoc(pos, (void*&)pName, (void*&)pValue); - delete pName; - delete pValue; - } -} -void CXFA_CSSTagProvider::GetNextAttribute(FX_POSITION& pos, - CFX_WideStringC& wsAttr, - CFX_WideStringC& wsValue) { - if (pos == NULL) { - return; - } - CFX_WideString* pName = NULL; - CFX_WideString* pValue = NULL; - m_Attributes.GetNextAssoc(pos, (void*&)pName, (void*&)pValue); - wsAttr = pName->AsStringC(); - wsValue = pValue->AsStringC(); -} -void CXFA_CSSTagProvider::SetAttribute(const CFX_WideString& wsAttr, - const CFX_WideString& wsValue) { - CFX_WideString* pName = new CFX_WideString(); - CFX_WideString* pValue = new CFX_WideString(); - *pName = wsAttr; - *pValue = wsValue; - m_Attributes.SetAt(pName, pValue); -} void CXFA_TextParseContext::SetDecls(const IFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount) { - if (iDeclCount <= 0 || ppDeclArray == NULL) { + if (iDeclCount <= 0 || !ppDeclArray) return; - } + m_dwMatchedDecls = iDeclCount; m_ppMatchedDecls = FX_Alloc(IFDE_CSSDeclaration*, iDeclCount); FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, diff --git a/xfa/fxfa/app/xfa_textlayout.h b/xfa/fxfa/app/xfa_textlayout.h index 9c3184b48b..9cced6a65a 100644 --- a/xfa/fxfa/app/xfa_textlayout.h +++ b/xfa/fxfa/app/xfa_textlayout.h @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ #define XFA_FXFA_APP_XFA_TEXTLAYOUT_H_ +#include <map> + #include "xfa/fde/css/fde_css.h" #include "xfa/fde/fde_gedevice.h" #include "xfa/fgas/layout/fgas_rtfbreak.h" @@ -20,28 +22,31 @@ class CXFA_Font; class CXFA_TextProvider; class CXFA_TextTabstopsContext; -class CXFA_CSSTagProvider : public IFDE_CSSTagProvider { +class CXFA_CSSTagProvider { public: CXFA_CSSTagProvider() : m_bTagAviliable(FALSE), m_bContent(FALSE) {} - virtual ~CXFA_CSSTagProvider(); + ~CXFA_CSSTagProvider() {} + + CFX_WideString GetTagName() { return m_wsTagName; } + + using AttributeMap = std::map<CFX_WideString, CFX_WideString>; + AttributeMap::iterator begin() { return m_Attributes.begin(); } + AttributeMap::iterator end() { return m_Attributes.end(); } + + bool empty() const { return m_Attributes.empty(); } - // Note: |this| must outlive the use of GetTagName()'s result. - virtual CFX_WideStringC GetTagName() { return m_wsTagName.AsStringC(); } - virtual FX_POSITION GetFirstAttribute() { - return m_Attributes.GetStartPosition(); - } - virtual void GetNextAttribute(FX_POSITION& pos, - CFX_WideStringC& wsAttr, - CFX_WideStringC& wsValue); void SetTagNameObj(const CFX_WideString& wsName) { m_wsTagName = wsName; } void SetAttribute(const CFX_WideString& wsAttr, - const CFX_WideString& wsValue); + const CFX_WideString& wsValue) { + m_Attributes.insert({wsAttr, wsValue}); + } + FX_BOOL m_bTagAviliable; FX_BOOL m_bContent; protected: CFX_WideString m_wsTagName; - CFX_MapPtrToPtr m_Attributes; + AttributeMap m_Attributes; }; class CXFA_TextParseContext : public CFX_Target { |