diff options
author | Sebastian Geerken <devnull@localhost> | 2014-04-09 15:11:58 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-04-09 15:11:58 +0200 |
commit | 78f994b717711a902944ef804c7df54567584711 (patch) | |
tree | f4fb300a2cf46ad5c6f3059af92a15b9a37d9ade /src/styleengine.cc | |
parent | 9de46071dab2c8b8b9cbf033f472c8d7073caca6 (diff) | |
parent | d7b2163db989b8d9d3eab0c1ea35b08b392bb305 (diff) |
Merge with main repo.
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r-- | src/styleengine.cc | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc index 27412019..024ef56d 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -58,7 +58,8 @@ void StyleImageDeletionReceiver::deleted (lout::signal::ObservedObject *object) // ---------------------------------------------------------------------- -StyleEngine::StyleEngine (dw::core::Layout *layout, const DilloUrl *baseUrl) { +StyleEngine::StyleEngine (dw::core::Layout *layout, + const DilloUrl *pageUrl, const DilloUrl *baseUrl) { StyleAttrs style_attrs; FontAttrs font_attrs; @@ -67,7 +68,8 @@ StyleEngine::StyleEngine (dw::core::Layout *layout, const DilloUrl *baseUrl) { cssContext = new CssContext (); buildUserStyle (); this->layout = layout; - this->baseUrl = baseUrl; + this->pageUrl = pageUrl ? a_Url_dup(pageUrl) : NULL; + this->baseUrl = baseUrl ? a_Url_dup(baseUrl) : NULL; importDepth = 0; stackPush (); @@ -100,6 +102,9 @@ StyleEngine::~StyleEngine () { stackPop (); // dummy node on the bottom of the stack assert (stack->size () == 0); + a_Url_free(pageUrl); + a_Url_free(baseUrl); + delete stack; delete doctree; delete cssContext; @@ -356,6 +361,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, Font *parentFont = stack->get (i - 1).style->font; char *c, *fontName; int lineHeight; + DilloUrl *imgUrl = NULL; /* Determine font first so it can be used to resolve relative lengths. */ for (int i = 0; i < props->size (); i++) { @@ -523,33 +529,8 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, Color::create(layout, prefs.white_bg_replacement); break; case CSS_PROPERTY_BACKGROUND_IMAGE: - if (prefs.load_background_images) - { - // p->value.strVal should be absolute, so baseUrl is not needed - DilloUrl *imgUrl = a_Url_new (p->value.strVal, NULL); - - attrs->backgroundImage = StyleImage::create(); - DilloImage *image = - a_Image_new(layout, - (void*)attrs->backgroundImage - ->getMainImgRenderer(), - 0xffffff); - - DilloWeb *web = a_Web_new(bw, imgUrl, baseUrl); - web->Image = image; - a_Image_ref(image); - web->flags |= WEB_Image; - - int clientKey; - if ((clientKey = a_Capi_open_url(web, NULL, NULL)) != 0) { - a_Bw_add_client(bw, clientKey, 0); - a_Bw_add_url(bw, imgUrl); - attrs->backgroundImage->connectDeletion - (new StyleImageDeletionReceiver (clientKey)); - } - - a_Url_free (imgUrl); - } + // p->value.strVal should be absolute, so baseUrl is not needed + imgUrl = a_Url_new (p->value.strVal, NULL); break; case CSS_PROPERTY_BACKGROUND_POSITION: computeLength (&attrs->backgroundPositionX, p->value.posVal->posX, @@ -748,6 +729,31 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, } } + if (imgUrl && prefs.load_background_images && attrs->display != DISPLAY_NONE) + { + attrs->backgroundImage = StyleImage::create(); + DilloImage *image = + a_Image_new(layout, + (void*)attrs->backgroundImage + ->getMainImgRenderer(), + 0xffffff); + + // we use the pageUrl as requester to prevent cross + // domain requests as specified in domainrc + DilloWeb *web = a_Web_new(bw, imgUrl, pageUrl); + web->Image = image; + a_Image_ref(image); + web->flags |= WEB_Image; + + int clientKey; + if ((clientKey = a_Capi_open_url(web, NULL, NULL)) != 0) { + a_Bw_add_client(bw, clientKey, 0); + a_Bw_add_url(bw, imgUrl); + attrs->backgroundImage->connectDeletion + (new StyleImageDeletionReceiver (clientKey)); + } + } + a_Url_free (imgUrl); } /** |