diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-02-08 10:05:05 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-09 15:55:20 +0000 |
commit | 21e954b59fcef1b84fdcdb9ae337e2d4c060b19e (patch) | |
tree | 2053cd0a8b0d4c1bb6903db3aa6f753a23afedcf /xfa/fde/css/cfde_cssstyleselector.cpp | |
parent | 1b08df18300bbc67dabd12fb35ab6ce1732a1024 (diff) | |
download | pdfium-21e954b59fcef1b84fdcdb9ae337e2d4c060b19e.tar.xz |
Remove CopyToLocal from CFDE_CSSDeclaration
This CL removes the CopyToLocal method and creates CFX_WideString's directly.
This fixes several memory leaks as the CopyToLocal strings were not cleaned
up correctly.
Change-Id: Ie5ba4cdc4d713cd0b8e3fb85e02f27dc09f38af1
Reviewed-on: https://pdfium-review.googlesource.com/2553
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/css/cfde_cssstyleselector.cpp')
-rw-r--r-- | xfa/fde/css/cfde_cssstyleselector.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/xfa/fde/css/cfde_cssstyleselector.cpp b/xfa/fde/css/cfde_cssstyleselector.cpp index fa17f7b20b..1319a64a84 100644 --- a/xfa/fde/css/cfde_cssstyleselector.cpp +++ b/xfa/fde/css/cfde_cssstyleselector.cpp @@ -105,10 +105,8 @@ void CFDE_CSSStyleSelector::ComputeStyle( if (!styleString.IsEmpty()) AppendInlineStyle(pDecl.get(), styleString); if (!alignString.IsEmpty()) { - FDE_CSSPropertyArgs args; - args.pStringCache = nullptr; - args.pProperty = FDE_GetCSSPropertyByEnum(FDE_CSSProperty::TextAlign); - pDecl->AddProperty(&args, alignString.c_str(), alignString.GetLength()); + pDecl->AddProperty(FDE_GetCSSPropertyByEnum(FDE_CSSProperty::TextAlign), + alignString.AsStringC()); } } ApplyDeclarations(declArray, pDecl.get(), pDest); @@ -130,7 +128,7 @@ void CFDE_CSSStyleSelector::ApplyDeclarations( for (auto& prop : normals) ApplyProperty(prop->eProperty, prop->pValue.Get(), pComputedStyle); for (auto& prop : customs) - pComputedStyle->AddCustomStyle(prop->pwsName, prop->pwsValue); + pComputedStyle->AddCustomStyle(*prop); for (auto& prop : importants) ApplyProperty(prop->eProperty, prop->pValue.Get(), pComputedStyle); } @@ -159,28 +157,23 @@ void CFDE_CSSStyleSelector::AppendInlineStyle(CFDE_CSSDeclaration* pDecl, return; int32_t iLen2 = 0; - const FX_WCHAR* psz2; - FDE_CSSPropertyArgs args; - args.pStringCache = nullptr; - args.pProperty = nullptr; + const FDE_CSSPropertyTable* table = 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); + CFX_WideStringC strValue = pSyntax->GetCurrentString(); + table = FDE_GetCSSPropertyByName(strValue); + if (!table) + wsName = CFX_WideString(strValue); } 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); + if (table || iLen2 > 0) { + CFX_WideStringC strValue = pSyntax->GetCurrentString(); + if (!strValue.IsEmpty()) { + if (table) + pDecl->AddProperty(table, strValue); + else if (iLen2 > 0) + pDecl->AddProperty(wsName, CFX_WideString(strValue)); } } } else { |