summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Henty <onepoint@starurchin.org>2010-11-21 21:11:37 +0000
committerJeremy Henty <onepoint@starurchin.org>2010-11-21 21:11:37 +0000
commitf74781ad9083b1483f423cc8e87220c9361d7dfa (patch)
tree51af4d9304da48275ba67578e61fe4a247d750e9 /src
parent80e2bcf67331dc18a2776f98e7103bbeb70cd667 (diff)
imported patch ignore-unknown-at-rules-1
Diffstat (limited to 'src')
-rw-r--r--src/cssparser.cc63
-rw-r--r--src/cssparser.hh2
2 files changed, 56 insertions, 9 deletions
diff --git a/src/cssparser.cc b/src/cssparser.cc
index ed880d17..ec7cb29b 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -1443,25 +1443,70 @@ const char * CssParser::propertyNameString(CssPropertyName name)
{
return Css_property_info[name].symbol;
}
+
+void CssParser::ignoreBlock()
+{
+ int depth = 0;
+
+ while (ttype != CSS_TK_END) {
+ if (ttype == CSS_TK_CHAR) {
+ if (tval[0] =='{')
+ depth++;
+ else if (tval[0] =='}') {
+ depth--;
+ if (depth == 0) {
+ nextToken();
+ return;
+ }
+ }
+ }
+ nextToken();
+ }
+}
+
+void CssParser::ignoreStatement()
+{
+ while (ttype != CSS_TK_END) {
+ if (ttype == CSS_TK_CHAR) {
+ if (tval[0] == ';') {
+ nextToken();
+ return;
+ }
+ else if (tval[0] =='{') {
+ ignoreBlock();
+ return;
+ }
+ }
+ nextToken();
+ }
+}
void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context,
const char *buf,
int buflen, CssOrigin origin)
{
CssParser parser (context, origin, buf, buflen);
+ bool importsAreAllowed = true;
- while (parser.ttype == CSS_TK_CHAR && parser.tval[0] == '@') {
- parser.nextToken();
- if (html != NULL &&
- parser.ttype == CSS_TK_SYMBOL &&
- dStrcasecmp(parser.tval, "import") == 0) {
+ while (parser.ttype != CSS_TK_END) {
+ if (parser.ttype == CSS_TK_CHAR &&
+ parser.tval[0] == '@') {
parser.nextToken();
- parser.parseImport(html, url);
+ if (parser.ttype == CSS_TK_SYMBOL &&
+ dStrcasecmp(parser.tval, "import") == 0 &&
+ html != NULL &&
+ importsAreAllowed) {
+ parser.nextToken();
+ parser.parseImport(html, url);
+ }
+ else
+ parser.ignoreStatement();
+ }
+ else {
+ importsAreAllowed = false;
+ parser.parseRuleset();
}
}
-
- while (parser.ttype != CSS_TK_END)
- parser.parseRuleset();
}
CssPropertyList *CssParser::parseDeclarationBlock(const char *buf, int buflen)
diff --git a/src/cssparser.hh b/src/cssparser.hh
index 1e471c68..9d3feeaf 100644
--- a/src/cssparser.hh
+++ b/src/cssparser.hh
@@ -42,6 +42,8 @@ class CssParser {
void parseImport(DilloHtml *html, DilloUrl *url);
CssSelector *parseSelector();
void parseRuleset();
+ void ignoreBlock();
+ void ignoreStatement();
public:
static CssPropertyList *parseDeclarationBlock(const char *buf,