summaryrefslogtreecommitdiff
path: root/xfa/fde/css/fde_cssstyleselector.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-11 10:26:05 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-11 10:26:05 -0700
commitf74ad998d2e8d2636fb25e94823946a3b151e34e (patch)
tree0b18e0a29fdc4bf1cce66ea437d8a4841b3daf4a /xfa/fde/css/fde_cssstyleselector.cpp
parent2c3a16a7698ba15476173e849f82c97ea3da9939 (diff)
downloadpdfium-f74ad998d2e8d2636fb25e94823946a3b151e34e.tar.xz
Replace some calls to Release() with direct delete, part 1.
Searching for the anti-pattern: void Release() { delete this; } We must be explicit on the ownership model. Add unique_ptrs as a result. Review-Url: https://codereview.chromium.org/1960673003
Diffstat (limited to 'xfa/fde/css/fde_cssstyleselector.cpp')
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp63
1 files changed, 31 insertions, 32 deletions
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index 27b251a783..05f036b1f3 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -7,6 +7,7 @@
#include "xfa/fde/css/fde_cssstyleselector.h"
#include <algorithm>
+#include <memory>
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
@@ -538,44 +539,42 @@ void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl,
const FX_WCHAR* psz,
int32_t iLen) {
ASSERT(pDecl && psz && iLen > 0);
+ std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+ if (!pSyntax->Init(psz, iLen, 32, TRUE))
+ return;
- CFDE_CSSSyntaxParser* pSyntax = new CFDE_CSSSyntaxParser;
- if (pSyntax->Init(psz, iLen, 32, TRUE)) {
- int32_t iLen;
- const FX_WCHAR* psz;
- FDE_CSSPROPERTYARGS args;
- args.pStringCache = NULL;
- args.pStaticStore = m_pInlineStyleStore;
- args.pProperty = NULL;
- CFX_WideString wsName;
- for (;;) {
- FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse();
- if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) {
- psz = pSyntax->GetCurrentString(iLen);
- args.pProperty = FDE_GetCSSPropertyByName(CFX_WideStringC(psz, iLen));
- if (args.pProperty == NULL) {
- wsName = CFX_WideStringC(psz, iLen);
- }
- } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) {
- if (args.pProperty != NULL) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, psz, iLen);
- }
- } else if (iLen > 0) {
- psz = pSyntax->GetCurrentString(iLen);
- if (iLen > 0) {
- pDecl->AddProperty(&args, wsName.c_str(), wsName.GetLength(), psz,
- iLen);
- }
+ int32_t iLen2;
+ const FX_WCHAR* psz2;
+ FDE_CSSPROPERTYARGS args;
+ args.pStringCache = nullptr;
+ args.pStaticStore = m_pInlineStyleStore;
+ args.pProperty = nullptr;
+ CFX_WideString wsName;
+ while (1) {
+ FDE_CSSSYNTAXSTATUS eStatus = pSyntax->DoSyntaxParse();
+ if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyName) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ args.pProperty = FDE_GetCSSPropertyByName(CFX_WideStringC(psz2, iLen2));
+ if (!args.pProperty)
+ wsName = CFX_WideStringC(psz2, iLen2);
+ } else if (eStatus == FDE_CSSSYNTAXSTATUS_PropertyValue) {
+ if (args.pProperty) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ if (iLen2 > 0)
+ pDecl->AddProperty(&args, psz2, iLen2);
+ } else if (iLen2 > 0) {
+ psz2 = pSyntax->GetCurrentString(iLen2);
+ if (iLen2 > 0) {
+ pDecl->AddProperty(&args, wsName.c_str(), wsName.GetLength(), psz2,
+ iLen2);
}
- } else {
- break;
}
+ } else {
+ break;
}
}
- pSyntax->Release();
}
+
#define FDE_CSSNONINHERITS (pComputedStyle->m_NonInheritedData)
#define FDE_CSSINHERITS (pComputedStyle->m_InheritedData)
#define FDE_CSSFONTSIZE (FDE_CSSINHERITS.m_fFontSize)