aboutsummaryrefslogtreecommitdiff
path: root/src/styleengine.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-04-08 16:33:02 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-04-08 16:33:02 +0200
commit4b9363baacc314fb5f7fcf6b180f4d099bc8479e (patch)
tree2a610d19c301ddbb29315e0c0d0b88b41cca6fe4 /src/styleengine.cc
parentb9c1cd2a051f4a04f62a910477a1ca7546a5d3d5 (diff)
support CSS @import directive
Diffstat (limited to 'src/styleengine.cc')
-rw-r--r--src/styleengine.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/styleengine.cc b/src/styleengine.cc
index 4c00f362..63dac1ec 100644
--- a/src/styleengine.cc
+++ b/src/styleengine.cc
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <math.h>
#include "../dlib/dlib.h"
+#include "msg.h"
#include "prefs.h"
#include "html_common.hh"
#include "styleengine.hh"
@@ -26,6 +27,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) {
cssContext = new CssContext ();
this->layout = layout;
num = 0;
+ importDepth = 0;
stack->increase ();
Node *n = stack->getRef (stack->size () - 1);
@@ -561,6 +563,13 @@ Style * StyleEngine::wordStyle0 (CssPropertyList *nonCssProperties) {
return stack->getRef (stack->size () - 1)->wordStyle;
}
-void StyleEngine::parse (const char *buf, int buflen, CssOrigin origin) {
- CssParser::parse (cssContext, buf, buflen, origin);
+void StyleEngine::parse (DilloHtml *html, DilloUrl *url, const char *buf, int buflen, CssOrigin origin) {
+ if (importDepth > 10) { // avoid looping with recursive @import directives
+ MSG_WARN("Maximum depth of CSS @import reached - ignoring stylesheet.\n");
+ return;
+ }
+
+ importDepth++;
+ CssParser::parse (html, url, cssContext, buf, buflen, origin);
+ importDepth--;
}