[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

hyatt at apple.com hyatt at apple.com
Thu Apr 8 00:12:14 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 3c3db0d723c10cf94bc38ac5249dc9cda6927b8c
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 2 19:27:17 2009 +0000

    https://bugs.webkit.org/show_bug.cgi?id=32072, clean up invalid @-rule error handling so that we
    pass more CSS test suite stuff.  Make the grammar stop enforcing the ordering of @namespace vs.
    @variables vs. @import.  Just let the parser handle that instead.  This simplifies the grammar and
    makes error handling deal with more cases correctly.
    
    Reviewed by Darin Adler.
    
    Added fast/css/namespaces/namespaces-invalid-at-rules.xml
    
    * css/CSSGrammar.y:
    * css/CSSParser.cpp:
    (WebCore::CSSParser::CSSParser):
    (WebCore::CSSParser::parseRule):
    (WebCore::CSSParser::createCharsetRule):
    (WebCore::CSSParser::createImportRule):
    (WebCore::CSSParser::createMediaRule):
    (WebCore::CSSParser::createKeyframesRule):
    (WebCore::CSSParser::createStyleRule):
    (WebCore::CSSParser::createFontFaceRule):
    (WebCore::CSSParser::addNamespace):
    (WebCore::CSSParser::createVariablesRule):
    * css/CSSParser.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51608 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/fast/css/namespaces/namespaces-invalid-at.xml b/LayoutTests/fast/css/namespaces/namespaces-invalid-at.xml
new file mode 100644
index 0000000..8c2d37f
--- /dev/null
+++ b/LayoutTests/fast/css/namespaces/namespaces-invalid-at.xml
@@ -0,0 +1,33 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <link rel="author" title="Anne van Kesteren" href="http://annevankesteren.nl/"/>
+  <link rel="author" title="Opera Software ASA" href="http://opera.com/"/>
+  <link rel="help" href="http://www.w3.org/TR/css3-namespace/#syntax"/>
+  <meta name="flags" content="invalid"/>
+  <title>CSS Namespaces Test Suite: @namespace and invalid at-rules</title>
+  <style>
+   t, t2, t3 { background:red }
+  </style>
+  <style>
+   @import x {}
+   @namespace x "test";
+   x|t { background:lime }
+  </style>
+  <style>
+   @namespace x "test-top";
+   foobar this is funny { not:sure }
+   @namespace foo {}
+   @namespace foo bar baz;
+   @namespace {}
+   @namespace "test";
+   @foobar this is funnier;
+   t2 { background:lime }
+   x|t3 { background:lime }
+   </style>
+ </head>
+ <body>
+  <p><t xmlns="test">This sentence should have a green background.</t></p>
+  <p><t2 xmlns="test">This sentence should have a green background.</t2></p>
+  <p><t3 xmlns="test-top">This sentence should have a green background.</t3></p>
+ </body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/css/namespaces/namespaces-comments-expected.checksum b/LayoutTests/platform/mac/fast/css/namespaces/namespaces-invalid-at-expected.checksum
similarity index 100%
copy from LayoutTests/platform/mac/fast/css/namespaces/namespaces-comments-expected.checksum
copy to LayoutTests/platform/mac/fast/css/namespaces/namespaces-invalid-at-expected.checksum
diff --git a/LayoutTests/platform/mac/fast/css/namespaces/namespaces-comments-expected.png b/LayoutTests/platform/mac/fast/css/namespaces/namespaces-invalid-at-expected.png
similarity index 100%
copy from LayoutTests/platform/mac/fast/css/namespaces/namespaces-comments-expected.png
copy to LayoutTests/platform/mac/fast/css/namespaces/namespaces-invalid-at-expected.png
diff --git a/LayoutTests/platform/mac/fast/css/namespaces/namespaces-invalid-at-expected.txt b/LayoutTests/platform/mac/fast/css/namespaces/namespaces-invalid-at-expected.txt
new file mode 100644
index 0000000..935fbd7
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/css/namespaces/namespaces-invalid-at-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x118
+  RenderBlock {html} at (0,0) size 800x118
+    RenderBody {body} at (8,16) size 784x86
+      RenderBlock {p} at (0,0) size 784x18
+        RenderInline {t} at (0,0) size 299x18 [bgcolor=#00FF00]
+          RenderText {#text} at (0,0) size 299x18
+            text run at (0,0) width 299: "This sentence should have a green background."
+      RenderBlock {p} at (0,34) size 784x18
+        RenderInline {t2} at (0,0) size 299x18 [bgcolor=#00FF00]
+          RenderText {#text} at (0,0) size 299x18
+            text run at (0,0) width 299: "This sentence should have a green background."
+      RenderBlock {p} at (0,68) size 784x18
+        RenderInline {t3} at (0,0) size 299x18 [bgcolor=#00FF00]
+          RenderText {#text} at (0,0) size 299x18
+            text run at (0,0) width 299: "This sentence should have a green background."
diff --git a/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.checksum b/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.checksum
index b623d03..706402c 100644
--- a/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.checksum
+++ b/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.checksum
@@ -1 +1 @@
-298a5c439d36bd284adea72df4b2cbd5
\ No newline at end of file
+3b521f0661cb5be8ef5513b2de77f62e
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.png b/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.png
index 757a1b2..8babfdc 100644
Binary files a/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.png and b/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.txt b/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.txt
index bbff765..4c10579 100644
--- a/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.txt
+++ b/LayoutTests/platform/mac/fast/css/variables/misplaced-import-test-expected.txt
@@ -2,7 +2,7 @@ layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x34
   RenderBlock {HTML} at (0,0) size 800x34
-    RenderBody {BODY} at (8,8) size 784x18
+    RenderBody {BODY} at (8,8) size 784x18 [bgcolor=#FF0000]
       RenderText {#text} at (0,0) size 511x18
         text run at (0,0) width 316: "This text should be green on a white background. "
         text run at (316,0) width 195: "There should be no red visible."
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0884c7c..1450a12 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2009-12-02  Dave Hyatt  <hyatt at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=32072, clean up invalid @-rule error handling so that we
+        pass more CSS test suite stuff.  Make the grammar stop enforcing the ordering of @namespace vs.
+        @variables vs. @import.  Just let the parser handle that instead.  This simplifies the grammar and
+        makes error handling deal with more cases correctly.
+
+        Added fast/css/namespaces/namespaces-invalid-at-rules.xml
+
+        * css/CSSGrammar.y:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::CSSParser):
+        (WebCore::CSSParser::parseRule):
+        (WebCore::CSSParser::createCharsetRule):
+        (WebCore::CSSParser::createImportRule):
+        (WebCore::CSSParser::createMediaRule):
+        (WebCore::CSSParser::createKeyframesRule):
+        (WebCore::CSSParser::createStyleRule):
+        (WebCore::CSSParser::createFontFaceRule):
+        (WebCore::CSSParser::addNamespace):
+        (WebCore::CSSParser::createVariablesRule):
+        * css/CSSParser.h:
+
 2009-12-02  Yusuke Sato  <yusukes at chromium.org>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/css/CSSGrammar.y b/WebCore/css/CSSGrammar.y
index 7c5f630..22e3aaf 100644
--- a/WebCore/css/CSSGrammar.y
+++ b/WebCore/css/CSSGrammar.y
@@ -97,7 +97,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 
 %}
 
-%expect 51
+%expect 48
 
 %nonassoc LOWEST_PREC
 
@@ -184,18 +184,15 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 
 %type <rule> charset
 %type <rule> ruleset
-%type <rule> valid_rule_or_import
 %type <rule> media
 %type <rule> import
+%type <rule> namespace
 %type <rule> page
 %type <rule> font_face
 %type <rule> keyframes
 %type <rule> invalid_rule
 %type <rule> save_block
 %type <rule> invalid_at
-%type <rule> invalid_at_list
-%type <rule> invalid_import
-%type <rule> invalid_media
 %type <rule> rule
 %type <rule> valid_rule
 %type <ruleList> block_rule_list 
@@ -268,7 +265,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 %%
 
 stylesheet:
-    maybe_space maybe_charset maybe_sgml import_list variables_list namespace_list rule_list
+    maybe_space maybe_charset maybe_sgml rule_list
   | webkit_rule maybe_space
   | webkit_decls maybe_space
   | webkit_value maybe_space
@@ -278,13 +275,8 @@ stylesheet:
   | webkit_keyframe_rule maybe_space
   ;
 
-valid_rule_or_import:
-    valid_rule
-  | import
-  ;
-
 webkit_rule:
-    WEBKIT_RULE_SYM '{' maybe_space valid_rule_or_import maybe_space '}' {
+    WEBKIT_RULE_SYM '{' maybe_space valid_rule maybe_space '}' {
         static_cast<CSSParser*>(parser)->m_rule = $4;
     }
 ;
@@ -373,31 +365,6 @@ charset:
   }
 ;
 
-import_list:
- /* empty */
- | import_list import maybe_sgml {
-     CSSParser* p = static_cast<CSSParser*>(parser);
-     if ($2 && p->m_styleSheet)
-         p->m_styleSheet->append($2);
- }
- | invalid_at_list {
- }
- ;
-
-variables_list:
-/* empty */
-| variables_list variables_rule maybe_sgml {
-    CSSParser* p = static_cast<CSSParser*>(parser);
-     if ($2 && p->m_styleSheet)
-         p->m_styleSheet->append($2);
-}
-;
-
-namespace_list:
-/* empty */
-| namespace_list namespace maybe_sgml
-;
-
 rule_list:
    /* empty */
  | rule_list rule maybe_sgml {
@@ -413,13 +380,15 @@ valid_rule:
   | page
   | font_face
   | keyframes
+  | namespace
+  | import
+  | variables_rule
   ;
 
 rule:
     valid_rule
   | invalid_rule
   | invalid_at
-  | invalid_import
   ;
 
 block_rule_list: 
@@ -445,8 +414,10 @@ block_rule:
     block_valid_rule
   | invalid_rule
   | invalid_at
-  | invalid_import
-  | invalid_media
+  | namespace
+  | import
+  | variables_rule
+  | media
   ;
 
 
@@ -570,12 +541,18 @@ variable_name:
 
 namespace:
 NAMESPACE_SYM maybe_space maybe_ns_prefix string_or_uri maybe_space ';' {
-    CSSParser* p = static_cast<CSSParser*>(parser);
-    if (p->m_styleSheet)
-        p->m_styleSheet->addNamespace(p, $3, $4);
+    static_cast<CSSParser*>(parser)->addNamespace($3, $4);
+    $$ = 0;
+}
+| NAMESPACE_SYM maybe_space maybe_ns_prefix string_or_uri maybe_space invalid_block {
+    $$ = 0;
+}
+| NAMESPACE_SYM error invalid_block {
+    $$ = 0;
+}
+| NAMESPACE_SYM error ';' {
+    $$ = 0;
 }
-| NAMESPACE_SYM error invalid_block
-| NAMESPACE_SYM error ';'
 ;
 
 maybe_ns_prefix:
@@ -1481,23 +1458,6 @@ invalid_at:
     }
     ;
 
-invalid_at_list:
-    invalid_at maybe_sgml
-  | invalid_at_list invalid_at maybe_sgml
-  ;
-
-invalid_import:
-    import {
-        $$ = 0;
-    }
-    ;
-
-invalid_media:
-    media {
-        $$ = 0;
-    }
-    ;
-
 invalid_rule:
     error invalid_block {
         $$ = 0;
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index 8408b7d..5e09f10 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -142,6 +142,9 @@ CSSParser::CSSParser(bool strictParsing)
     , m_defaultNamespace(starAtom)
     , m_data(0)
     , yy_start(1)
+    , m_allowImportRules(true)
+    , m_allowVariablesRules(true)
+    , m_allowNamespaceDeclarations(true)
     , m_floatingMediaQuery(0)
     , m_floatingMediaQueryExp(0)
     , m_floatingMediaQueryExpList(0)
@@ -229,6 +232,7 @@ void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string)
 PassRefPtr<CSSRule> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
 {
     m_styleSheet = sheet;
+    m_allowNamespaceDeclarations = false;
     setupParser("@-webkit-rule{", string, "} ");
     cssyyparse(this);
     return m_rule.release();
@@ -4976,7 +4980,7 @@ CSSRule* CSSParser::createCharsetRule(const CSSParserString& charset)
 
 CSSRule* CSSParser::createImportRule(const CSSParserString& url, MediaList* media)
 {
-    if (!media || !m_styleSheet)
+    if (!media || !m_styleSheet || !m_allowImportRules)
         return 0;
     RefPtr<CSSImportRule> rule = CSSImportRule::create(m_styleSheet, url, media);
     CSSImportRule* result = rule.get();
@@ -4988,6 +4992,7 @@ CSSRule* CSSParser::createMediaRule(MediaList* media, CSSRuleList* rules)
 {
     if (!media || !rules || !m_styleSheet)
         return 0;
+    m_allowImportRules = m_allowNamespaceDeclarations = m_allowVariablesRules = false;
     RefPtr<CSSMediaRule> rule = CSSMediaRule::create(m_styleSheet, media, rules);
     CSSMediaRule* result = rule.get();
     m_parsedStyleObjects.append(rule.release());
@@ -5005,6 +5010,7 @@ CSSRuleList* CSSParser::createRuleList()
 
 WebKitCSSKeyframesRule* CSSParser::createKeyframesRule()
 {
+    m_allowImportRules = m_allowNamespaceDeclarations = m_allowVariablesRules = false;
     RefPtr<WebKitCSSKeyframesRule> rule = WebKitCSSKeyframesRule::create(m_styleSheet);
     WebKitCSSKeyframesRule* rulePtr = rule.get();
     m_parsedStyleObjects.append(rule.release());
@@ -5013,6 +5019,7 @@ WebKitCSSKeyframesRule* CSSParser::createKeyframesRule()
 
 CSSRule* CSSParser::createStyleRule(Vector<CSSSelector*>* selectors)
 {
+    m_allowImportRules = m_allowNamespaceDeclarations = m_allowVariablesRules = false;
     CSSStyleRule* result = 0;
     if (selectors) {
         RefPtr<CSSStyleRule> rule = CSSStyleRule::create(m_styleSheet);
@@ -5029,6 +5036,7 @@ CSSRule* CSSParser::createStyleRule(Vector<CSSSelector*>* selectors)
 
 CSSRule* CSSParser::createFontFaceRule()
 {
+    m_allowImportRules = m_allowNamespaceDeclarations = m_allowVariablesRules = false;
     RefPtr<CSSFontFaceRule> rule = CSSFontFaceRule::create(m_styleSheet);
     for (unsigned i = 0; i < m_numParsedProperties; ++i) {
         CSSProperty* property = m_parsedProperties[i];
@@ -5046,6 +5054,15 @@ CSSRule* CSSParser::createFontFaceRule()
     return result;
 }
 
+void CSSParser::addNamespace(const AtomicString& prefix, const AtomicString& uri)
+{
+    if (!m_styleSheet || !m_allowNamespaceDeclarations)
+        return;
+    m_allowImportRules = false;
+    m_allowVariablesRules = false;
+    m_styleSheet->addNamespace(this, prefix, uri);
+}
+
 #if !ENABLE(CSS_VARIABLES)
 
 CSSRule* CSSParser::createVariablesRule(MediaList*, bool)
@@ -5067,6 +5084,9 @@ bool CSSParser::addVariableDeclarationBlock(const CSSParserString&)
 
 CSSRule* CSSParser::createVariablesRule(MediaList* mediaList, bool variablesKeyword)
 {
+    if (!m_allowVariablesRules)
+        return 0;
+    m_allowImportRules = false;
     RefPtr<CSSVariablesRule> rule = CSSVariablesRule::create(m_styleSheet, mediaList, variablesKeyword);
     rule->setDeclaration(CSSVariablesDeclaration::create(rule.get(), m_variableNames, m_variableValues));
     clearVariables();    
diff --git a/WebCore/css/CSSParser.h b/WebCore/css/CSSParser.h
index e6e2868..d032886 100644
--- a/WebCore/css/CSSParser.h
+++ b/WebCore/css/CSSParser.h
@@ -187,13 +187,15 @@ namespace WebCore {
         MediaQuery* createFloatingMediaQuery(Vector<MediaQueryExp*>*);
         MediaQuery* sinkFloatingMediaQuery(MediaQuery*);
 
+        void addNamespace(const AtomicString& prefix, const AtomicString& uri);
+
         bool addVariable(const CSSParserString&, CSSParserValueList*);
         bool addVariableDeclarationBlock(const CSSParserString&);
         bool checkForVariables(CSSParserValueList*);
         void addUnresolvedProperty(int propId, bool important);
         
         Vector<CSSSelector*>* reusableSelectorVector() { return &m_reusableSelectorVector; }
-        
+
         bool m_strict;
         bool m_important;
         int m_id;
@@ -249,6 +251,10 @@ namespace WebCore {
         int yyTok;
         int yy_start;
 
+        bool m_allowImportRules;
+        bool m_allowVariablesRules;
+        bool m_allowNamespaceDeclarations;
+
         Vector<RefPtr<StyleBase> > m_parsedStyleObjects;
         Vector<RefPtr<CSSRuleList> > m_parsedRuleLists;
         HashSet<CSSSelector*> m_floatingSelectors;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list