Unique pointer a member of style node.

This commit is contained in:
2025-03-03 00:49:53 -05:00
parent 865e176e5d
commit 23599df231
2 changed files with 7 additions and 7 deletions

View File

@ -116,16 +116,15 @@ StyleEngine::~StyleEngine () {
}
void StyleEngine::stackPush () {
static const Node emptyNode = {
Node emptyNode = {
NULL, NULL, NULL, NULL, NULL, NULL, false, false, NULL
};
stack.push_back( emptyNode );
stack.push_back( std::move( emptyNode ) );
}
void StyleEngine::stackPop () {
Node *n = &stack.at (stack.size () - 1);
delete n->styleAttrProperties;
delete n->styleAttrPropertiesImportant;
delete n->nonCssProperties;
if (n->style)
@ -199,11 +198,11 @@ void StyleEngine::setStyle (const char *styleAttr) {
assert (n->styleAttrProperties == NULL);
// parse style information from style="" attribute, if it exists
if (styleAttr && prefs.parse_embedded_css) {
n->styleAttrProperties = new CssPropertyList (true);
n->styleAttrProperties = std::make_unique< CssPropertyList >(true);
n->styleAttrPropertiesImportant = new CssPropertyList (true);
CssParser::parseDeclarationBlock (baseUrl, styleAttr, strlen (styleAttr),
n->styleAttrProperties,
n->styleAttrProperties.get(),
n->styleAttrPropertiesImportant);
}
}
@ -934,7 +933,7 @@ Style * StyleEngine::style0 (int i, BrowserWindow *bw) {
attrs.resetValues ();
preprocessAttrs (&attrs);
styleAttrProperties = stack.at (i).styleAttrProperties;
styleAttrProperties = stack.at (i).styleAttrProperties.get();
styleAttrPropertiesImportant = stack.at(i).styleAttrPropertiesImportant;
nonCssProperties = stack.at (i).nonCssProperties;

View File

@ -14,6 +14,7 @@
#define __STYLEENGINE_HH__
#include <vector>
#include <memory>
class StyleEngine;
@ -34,7 +35,7 @@ class StyleEngine;
class StyleEngine {
private:
struct Node {
CssPropertyList *styleAttrProperties;
std::unique_ptr< CssPropertyList >styleAttrProperties;
CssPropertyList *styleAttrPropertiesImportant;
CssPropertyList *nonCssProperties;
dw::core::style::Style *style;