Reviewers: ihab.awad,

Description:
CSS spec allows you to say word-spacing:-3px and letter-spacing:-3px,
but caja's css21-defs.json thinks the range is constrained to [0,inf)

This change removes the constraint.

Please review this at http://codereview.appspot.com/91076

Affected files:
  M     src/com/google/caja/lang/css/css21-defs.json
  M     tests/com/google/caja/plugin/CssValidatorTest.java


Index: tests/com/google/caja/plugin/CssValidatorTest.java
===================================================================
--- tests/com/google/caja/plugin/CssValidatorTest.java  (revision 3549)
+++ tests/com/google/caja/plugin/CssValidatorTest.java  (working copy)
@@ -1230,6 +1230,28 @@
             );
   }

+  public void testNegativeSpacing() throws Exception {
+    runTest("p { letter-spacing: -4px; word-spacing: -2px }",
+        "StyleSheet\n"
+        + "  RuleSet\n"
+        + "    Selector\n"
+        + "      SimpleSelector\n"
+        + "        IdentLiteral : p\n"
+        + "    PropertyDeclaration\n"
+        + "      Property : letter-spacing\n"
+        + "      Expr\n"
+        + "        Term : NEGATION ; cssPropertyPartType=LENGTH"
+                    + " ; cssPropertyPart=letter-spacing\n"
+        + "          QuantityLiteral : 4px\n"
+        + "    PropertyDeclaration\n"
+        + "      Property : word-spacing\n"
+        + "      Expr\n"
+        + "        Term : NEGATION ; cssPropertyPartType=LENGTH"
+                    + " ; cssPropertyPart=word-spacing\n"
+        + "          QuantityLiteral : 2px\n"
+        );
+  }
+
   public void testOpacity() throws Exception {
     runTest("img {\n"
             + "  opacity: 0.5;\n"
@@ -1406,7 +1428,7 @@
   public void testSimpleAttrSelectorEqual() throws Exception {
     // various forms of attribute selector with an 'equals' comparator
     runTest("input[type='radio'] { font-weight: bold }", null);
-    runTest("input[type=radio] { font-weight: bold }", null);
+    runTest("input[type=radio] { font-weight: bold }", null);
     fails("input[zork='radio'] { font-weight: bold }");
     fails("input[type='atyourservice'] { font-weight: bold }");
     fails("input[type=atyourservice] { font-weight: bold }");
@@ -1422,10 +1444,10 @@
     fails("input[zork~='radio'] { font-weight: bold }");
     fails("input[zork~='radio atyourservice'] { font-weight: bold }");
     fails("input[type~='atyourservice'] { font-weight: bold }");
-    fails("input[type~=atyourservice] { font-weight: bold }");
+    fails("input[type~=atyourservice] { font-weight: bold }");
     fails("input[type~='radio atyourservice'] { font-weight: bold }");
   }
-
+
   public void testSimpleAttrSelectorDashMatch() throws Exception {
     // we don't know how to whitelist the "|=" form so rejected
     fails("input[type|='button'] { font-weight: bold }");
Index: src/com/google/caja/lang/css/css21-defs.json
===================================================================
--- src/com/google/caja/lang/css/css21-defs.json        (revision 3549)
+++ src/com/google/caja/lang/css/css21-defs.json        (working copy)
@@ -386,7 +386,7 @@
       "dom2property": "left" },

     { "key": "letter-spacing",
-      "signature": "normal | <length:0,> | inherit",
+      "signature": "normal | <length> | inherit",
       "default": "normal",
       "appliesTo": "*",
       "inherited": true,
@@ -847,7 +847,7 @@
       "dom2property": "width" },

     { "key": "word-spacing",
-      "signature": "normal | <length:0,> | inherit",
+      "signature": "normal | <length> | inherit",
       "default": "normal",
       "appliesTo": "*",
       "inherited": true,


Reply via email to