diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-10-19 17:39:38 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-19 17:39:38 +0200 |
commit | fed668f20fb227ff0dc3e26f614827d10f2f581c (patch) | |
tree | 717c0150130386202c4d5c4b857af52cd0ec6176 /Libraries/LibHTML | |
parent | 6cbf8a34269fc0ee6dbfe4c1f071c7a28cd3b0b0 (diff) | |
download | serenity-fed668f20fb227ff0dc3e26f614827d10f2f581c.zip |
LibHTML: Skip over CSS @media rules for now
Diffstat (limited to 'Libraries/LibHTML')
-rw-r--r-- | Libraries/LibHTML/Parser/CSSParser.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Libraries/LibHTML/Parser/CSSParser.cpp b/Libraries/LibHTML/Parser/CSSParser.cpp index 49b7a53113..e12cbd20ec 100644 --- a/Libraries/LibHTML/Parser/CSSParser.cpp +++ b/Libraries/LibHTML/Parser/CSSParser.cpp @@ -104,6 +104,16 @@ public: { } + bool next_is(const char* str) const + { + int len = strlen(str); + for (int i = 0; i < len; ++i) { + if (peek(i) != str[i]) + return false; + } + return true; + } + char peek(int offset = 0) const { if ((index + offset) < css.length()) @@ -335,6 +345,25 @@ public: void parse_rule() { + // FIXME: We ignore @media rules for now. + if (next_is("@media")) { + while (peek() != '{') + consume_one(); + int level = 0; + for (;;) { + auto ch = consume_one(); + if (ch == '{') { + ++level; + } else if (ch == '}') { + --level; + if (level == 0) + break; + } + } + consume_whitespace_or_comments(); + return; + } + parse_selector_list(); consume_specific('{'); parse_declaration(); |