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