As part of our css devtools we need a way to check that a css property value is 
valid. This is used to validate the value onkeyup. Our current solution is to 
call the following method on each keypress:

  function validate(aValue)
  {
    let name = this.prop.name;
    let value = typeof aValue == "undefined" ? this.prop.value : aValue;
    let style = this.doc.createElementNS(HTML_NS, "div").style;

    style.setProperty(name, value, null);

    return !!style.getPropertyValue(name);
   },

The problem with this solution is that it spews css error messages for invalid 
property values, but we could work around this with:

  let prefVal = getPref("layout.css.report_errors");
  setPref("layout.css.report_errors", false);
  try {
    style.setProperty(name, value, null);
  } finally {
    setPref("layout.css.report_errors, prefVal");
  }

It occurs to me that we are also adding autocomplete to the properties, so can 
any of you guys think of:
1. A better way to validate css property values.
2. A way to get a list of possible property values for a given css property 
(this could be used for autocomplete and validation).
3. A better way to do both 1 and 2 ;o)

~Mike Ratcliffe
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to