From 5ec968c09a86287b8400b7abf3e34af6700f6bb8 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 18 Mar 2013 22:55:41 -0600 Subject: [PATCH 1/3] Better parsing of unknown at rule This parses rules such as @-moz-document url-prefix() { ... } --- lib/Sabberworm/CSS/Parser.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Sabberworm/CSS/Parser.php b/lib/Sabberworm/CSS/Parser.php index 5a55ba2f..825d3674 100644 --- a/lib/Sabberworm/CSS/Parser.php +++ b/lib/Sabberworm/CSS/Parser.php @@ -133,6 +133,7 @@ private function parseAtRule() { return new CSSNamespace($mUrl, $sPrefix); } else { //Unknown other at rule (font-face or such) + $sIdentifier .= $this->consumeUntil('{'); $this->consume('{'); $this->consumeWhiteSpace(); $oAtRule = new AtRule($sIdentifier); From 6f4df1d6bf5994aa1cf92e63e2ff0de540625abe Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 18 Mar 2013 23:02:53 -0600 Subject: [PATCH 2/3] Need to preserve space if it exists --- lib/Sabberworm/CSS/Parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Sabberworm/CSS/Parser.php b/lib/Sabberworm/CSS/Parser.php index 825d3674..8da13b9f 100644 --- a/lib/Sabberworm/CSS/Parser.php +++ b/lib/Sabberworm/CSS/Parser.php @@ -133,7 +133,7 @@ private function parseAtRule() { return new CSSNamespace($mUrl, $sPrefix); } else { //Unknown other at rule (font-face or such) - $sIdentifier .= $this->consumeUntil('{'); + $sIdentifier .= rtrim(' ' . $this->consumeUntil('{')); $this->consume('{'); $this->consumeWhiteSpace(); $oAtRule = new AtRule($sIdentifier); From 650070efd34dce3af69b95e8f713a264b368cbc9 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 18 Mar 2013 23:29:08 -0600 Subject: [PATCH 3/3] AtRule needs to extend CSSBlockList, not RuleSet Since AtRule needs to generically handle unknown @ rules, it should be a list instead of a ruleset since the former can handle possible embedded lists while the latter cannot. For example, this is CSS from the jquerymobile project: @-moz-document url-prefix() { .ui-select .ui-btn select { opacity: 0.0001; }} --- lib/Sabberworm/CSS/{RuleSet => CSSList}/AtRule.php | 6 +++--- lib/Sabberworm/CSS/Parser.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename lib/Sabberworm/CSS/{RuleSet => CSSList}/AtRule.php (85%) diff --git a/lib/Sabberworm/CSS/RuleSet/AtRule.php b/lib/Sabberworm/CSS/CSSList/AtRule.php similarity index 85% rename from lib/Sabberworm/CSS/RuleSet/AtRule.php rename to lib/Sabberworm/CSS/CSSList/AtRule.php index 1287ebbc..6133c91f 100644 --- a/lib/Sabberworm/CSS/RuleSet/AtRule.php +++ b/lib/Sabberworm/CSS/CSSList/AtRule.php @@ -1,11 +1,11 @@ consume('{'); $this->consumeWhiteSpace(); $oAtRule = new AtRule($sIdentifier); - $this->parseRuleSet($oAtRule); + $this->parseList($oAtRule); return $oAtRule; } }