Move public API to end
This commit is contained in:
parent
6e5e5761fc
commit
4136a4d64e
|
@ -149,134 +149,6 @@ html_convert_css_callback(hlcache_handle *css,
|
|||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* exported interface documented in render/html.h */
|
||||
struct html_stylesheet *html_get_stylesheets(hlcache_handle *h, unsigned int *n)
|
||||
{
|
||||
html_content *c = (html_content *) hlcache_handle_get_content(h);
|
||||
|
||||
assert(c != NULL);
|
||||
assert(n != NULL);
|
||||
|
||||
*n = c->stylesheet_count;
|
||||
|
||||
return c->stylesheets;
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in render/html_internal.h */
|
||||
nserror html_css_free_stylesheets(html_content *html)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i != html->stylesheet_count; i++) {
|
||||
if (html->stylesheets[i].sheet != NULL) {
|
||||
hlcache_handle_release(html->stylesheets[i].sheet);
|
||||
}
|
||||
if (html->stylesheets[i].node != NULL) {
|
||||
dom_node_unref(html->stylesheets[i].node);
|
||||
}
|
||||
}
|
||||
free(html->stylesheets);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* exported interface documented in render/html_internal.h */
|
||||
nserror html_css_quirks_stylesheets(html_content *c)
|
||||
{
|
||||
nserror ns_error = NSERROR_OK;
|
||||
hlcache_child_context child;
|
||||
|
||||
assert(c->stylesheets != NULL);
|
||||
|
||||
if (c->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) {
|
||||
child.charset = c->encoding;
|
||||
child.quirks = c->base.quirks;
|
||||
|
||||
ns_error = hlcache_handle_retrieve(html_quirks_stylesheet_url,
|
||||
0, content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child,
|
||||
CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_QUIRKS].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
}
|
||||
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
/* exported interface documented in render/html_internal.h */
|
||||
nserror html_css_new_stylesheets(html_content *c)
|
||||
{
|
||||
nserror ns_error;
|
||||
hlcache_child_context child;
|
||||
|
||||
if (c->stylesheets != NULL) {
|
||||
return NSERROR_OK; /* already initialised */
|
||||
}
|
||||
|
||||
/* stylesheet 0 is the base style sheet,
|
||||
* stylesheet 1 is the quirks mode style sheet,
|
||||
* stylesheet 2 is the adblocking stylesheet,
|
||||
* stylesheet 3 is the user stylesheet */
|
||||
c->stylesheets = calloc(STYLESHEET_START, sizeof(struct html_stylesheet));
|
||||
if (c->stylesheets == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
c->stylesheets[STYLESHEET_BASE].sheet = NULL;
|
||||
c->stylesheets[STYLESHEET_QUIRKS].sheet = NULL;
|
||||
c->stylesheets[STYLESHEET_ADBLOCK].sheet = NULL;
|
||||
c->stylesheets[STYLESHEET_USER].sheet = NULL;
|
||||
c->stylesheet_count = STYLESHEET_START;
|
||||
|
||||
child.charset = c->encoding;
|
||||
child.quirks = c->base.quirks;
|
||||
|
||||
ns_error = hlcache_handle_retrieve(html_default_stylesheet_url, 0,
|
||||
content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child, CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_BASE].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
|
||||
|
||||
if (nsoption_bool(block_ads)) {
|
||||
ns_error = hlcache_handle_retrieve(html_adblock_stylesheet_url,
|
||||
0, content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child, CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_ADBLOCK].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
|
||||
}
|
||||
|
||||
ns_error = hlcache_handle_retrieve(html_user_stylesheet_url, 0,
|
||||
content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child, CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_USER].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
static nserror
|
||||
html_stylesheet_from_domnode(html_content *c,
|
||||
dom_node *node,
|
||||
|
@ -544,6 +416,134 @@ no_memory:
|
|||
return false;
|
||||
}
|
||||
|
||||
/* exported interface documented in render/html.h */
|
||||
struct html_stylesheet *html_get_stylesheets(hlcache_handle *h, unsigned int *n)
|
||||
{
|
||||
html_content *c = (html_content *) hlcache_handle_get_content(h);
|
||||
|
||||
assert(c != NULL);
|
||||
assert(n != NULL);
|
||||
|
||||
*n = c->stylesheet_count;
|
||||
|
||||
return c->stylesheets;
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in render/html_internal.h */
|
||||
nserror html_css_free_stylesheets(html_content *html)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i != html->stylesheet_count; i++) {
|
||||
if (html->stylesheets[i].sheet != NULL) {
|
||||
hlcache_handle_release(html->stylesheets[i].sheet);
|
||||
}
|
||||
if (html->stylesheets[i].node != NULL) {
|
||||
dom_node_unref(html->stylesheets[i].node);
|
||||
}
|
||||
}
|
||||
free(html->stylesheets);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* exported interface documented in render/html_internal.h */
|
||||
nserror html_css_quirks_stylesheets(html_content *c)
|
||||
{
|
||||
nserror ns_error = NSERROR_OK;
|
||||
hlcache_child_context child;
|
||||
|
||||
assert(c->stylesheets != NULL);
|
||||
|
||||
if (c->quirks == DOM_DOCUMENT_QUIRKS_MODE_FULL) {
|
||||
child.charset = c->encoding;
|
||||
child.quirks = c->base.quirks;
|
||||
|
||||
ns_error = hlcache_handle_retrieve(html_quirks_stylesheet_url,
|
||||
0, content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child,
|
||||
CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_QUIRKS].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
}
|
||||
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
/* exported interface documented in render/html_internal.h */
|
||||
nserror html_css_new_stylesheets(html_content *c)
|
||||
{
|
||||
nserror ns_error;
|
||||
hlcache_child_context child;
|
||||
|
||||
if (c->stylesheets != NULL) {
|
||||
return NSERROR_OK; /* already initialised */
|
||||
}
|
||||
|
||||
/* stylesheet 0 is the base style sheet,
|
||||
* stylesheet 1 is the quirks mode style sheet,
|
||||
* stylesheet 2 is the adblocking stylesheet,
|
||||
* stylesheet 3 is the user stylesheet */
|
||||
c->stylesheets = calloc(STYLESHEET_START, sizeof(struct html_stylesheet));
|
||||
if (c->stylesheets == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
c->stylesheets[STYLESHEET_BASE].sheet = NULL;
|
||||
c->stylesheets[STYLESHEET_QUIRKS].sheet = NULL;
|
||||
c->stylesheets[STYLESHEET_ADBLOCK].sheet = NULL;
|
||||
c->stylesheets[STYLESHEET_USER].sheet = NULL;
|
||||
c->stylesheet_count = STYLESHEET_START;
|
||||
|
||||
child.charset = c->encoding;
|
||||
child.quirks = c->base.quirks;
|
||||
|
||||
ns_error = hlcache_handle_retrieve(html_default_stylesheet_url, 0,
|
||||
content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child, CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_BASE].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
|
||||
|
||||
if (nsoption_bool(block_ads)) {
|
||||
ns_error = hlcache_handle_retrieve(html_adblock_stylesheet_url,
|
||||
0, content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child, CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_ADBLOCK].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
|
||||
}
|
||||
|
||||
ns_error = hlcache_handle_retrieve(html_user_stylesheet_url, 0,
|
||||
content_get_url(&c->base), NULL,
|
||||
html_convert_css_callback, c, &child, CONTENT_CSS,
|
||||
&c->stylesheets[STYLESHEET_USER].sheet);
|
||||
if (ns_error != NSERROR_OK) {
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
c->base.active++;
|
||||
LOG(("%d fetches active", c->base.active));
|
||||
|
||||
return ns_error;
|
||||
}
|
||||
|
||||
nserror
|
||||
html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue