Style Sheet member ownership
This commit is contained in:
@ -68,12 +68,12 @@ StyleEngine::StyleEngine (dw::core::Layout *layout,
|
||||
StyleAttrs style_attrs;
|
||||
FontAttrs font_attrs;
|
||||
|
||||
doctree = new Doctree ();
|
||||
cssContext = new CssContext ();
|
||||
doctree = std::make_unique< Doctree >();
|
||||
cssContext = std::make_unique< CssContext >();
|
||||
buildUserStyle ();
|
||||
this->layout = layout;
|
||||
this->pageUrl = pageUrl ? a_Url_dup(pageUrl).release() : nullptr;
|
||||
this->baseUrl = baseUrl ? a_Url_dup(baseUrl).release() : nullptr;
|
||||
this->pageUrl = pageUrl ? a_Url_dup(pageUrl) : nullptr;
|
||||
this->baseUrl = baseUrl ? a_Url_dup(baseUrl) : nullptr;
|
||||
importDepth = 0;
|
||||
dpmm = layout->dpiX () / 25.4; /* assume dpiX == dpiY */
|
||||
this->zoom = zoom;
|
||||
@ -107,12 +107,6 @@ StyleEngine::~StyleEngine () {
|
||||
|
||||
stackPop (); // dummy node on the bottom of the stack
|
||||
assert (stack.size () == 0);
|
||||
|
||||
delete pageUrl;
|
||||
delete baseUrl;
|
||||
|
||||
delete doctree;
|
||||
delete cssContext;
|
||||
}
|
||||
|
||||
void StyleEngine::stackPush () {
|
||||
@ -199,7 +193,7 @@ void StyleEngine::setStyle (const char *styleAttr) {
|
||||
n->styleAttrProperties = std::make_unique< CssPropertyList >(true);
|
||||
n->styleAttrPropertiesImportant = new CssPropertyList (true);
|
||||
|
||||
CssParser::parseDeclarationBlock (baseUrl, styleAttr, strlen (styleAttr),
|
||||
CssParser::parseDeclarationBlock (baseUrl.get(), styleAttr, strlen (styleAttr),
|
||||
n->styleAttrProperties.get(),
|
||||
n->styleAttrPropertiesImportant);
|
||||
}
|
||||
@ -766,7 +760,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
|
||||
|
||||
// we use the pageUrl as requester to prevent cross
|
||||
// domain requests as specified in domainrc
|
||||
DilloWeb *web = a_Web_new(bw, imgUrl.get(), pageUrl);
|
||||
DilloWeb *web = a_Web_new(bw, imgUrl.get(), pageUrl.get());
|
||||
web->Image = std::move( image );
|
||||
web->flags |= WEB_Image;
|
||||
|
||||
@ -934,7 +928,7 @@ Style * StyleEngine::style0 (int i, BrowserWindow *bw) {
|
||||
nonCssProperties = stack.at (i).nonCssProperties;
|
||||
|
||||
// merge style information
|
||||
cssContext->apply (&props, doctree, stack.at(i).doctreeNode,
|
||||
cssContext->apply (&props, doctree.get(), stack.at(i).doctreeNode,
|
||||
styleAttrProperties, styleAttrPropertiesImportant,
|
||||
nonCssProperties);
|
||||
|
||||
@ -1002,7 +996,7 @@ void StyleEngine::parse (DilloHtml *html, DilloUrl *url, const char *buf,
|
||||
}
|
||||
|
||||
importDepth++;
|
||||
CssParser::parse (html, url, cssContext, buf, buflen, origin);
|
||||
CssParser::parse (html, url, cssContext.get(), buf, buflen, origin);
|
||||
importDepth--;
|
||||
}
|
||||
|
||||
@ -1079,6 +1073,6 @@ void StyleEngine::buildUserStyle () {
|
||||
|
||||
const std::string style= a_Misc_file2dstr(filename.c_str());
|
||||
if (not style.empty()) {
|
||||
CssParser::parse (NULL,NULL,cssContext, style.c_str(), style.size(), CSS_ORIGIN_USER);
|
||||
CssParser::parse( nullptr, nullptr, cssContext.get(), style.c_str(), style.size(), CSS_ORIGIN_USER );
|
||||
}
|
||||
}
|
||||
|
@ -48,12 +48,13 @@ class StyleEngine {
|
||||
|
||||
dw::core::Layout *layout;
|
||||
std::vector <Node> stack;
|
||||
CssContext *cssContext;
|
||||
Doctree *doctree;
|
||||
std::unique_ptr< CssContext > cssContext;
|
||||
std::unique_ptr< Doctree > doctree;
|
||||
int importDepth;
|
||||
float dpmm;
|
||||
float zoom;
|
||||
DilloUrl *pageUrl, *baseUrl;
|
||||
std::unique_ptr< DilloUrl > pageUrl;
|
||||
std::unique_ptr< DilloUrl > baseUrl;
|
||||
|
||||
void stackPush ();
|
||||
void stackPop ();
|
||||
|
Reference in New Issue
Block a user