Wednesday, March 4, 2015

Re: [ERROR] Only either css files or gss files are supported on one interface

What you are asking for is simply not possible in a reliable way under the requirement that old css syntax needs to be converted to gss syntax to avoid producing compile errors when activating GSS for a project.

When I give you (which is hopefully similar to your use case):

@Source({ app-constants.gss, library-constants.css, library-mywidget.css, app-mywidget.gss })

Then what should GWT do to produce valid GSS code that can be handed over to closure stylesheets? 

- The ordering of files is important as later files can override CSS rules in previous files (e.g. library-mywidget could produce a red widget by default and app-mywidget overrides it to a blue gradient)
- Any css file might be compatible with GSS as-is but maybe it is not. If you can not use the file extension to decide it you need to try parsing a css file using a GSS parser. If it fails it is incompatible and would need to be converted using the css2gss in-memory converter.
- app-mywidget.gss might reuse constants provided by library-constants.css as well use constants from app-constants.gss.


So what would you do now?

1.) You can not try parsing each file one-by-one to figure out if it is GSS compatible because each file might use constants provided by other files. If the parser does not see the constant definition it would fail even though the file might be GSS compatible. The parser needs complete knowledge.

2.) Because of the previous you need to merge all files before parsing so you have all information available. Parsing the merged data might work if the css files are GSS compatible in which case you would hand over the merge result to closure stylesheet to parse it again and produce the final css output. However if the merged data fails to parse then you know that some files are incompatible but not wich ones. So you don't know if its because of a GSS syntax error in one of the gss files (in which case you would fail the compile) or if its because one of the css files contain legacy syntax that needs to be converted using the in-memory converter.
To figure that out you would need to assume that css files are incompatible, merge just the css files (because of 1. and because the converter does not want gss input)), run them through the css2gss converter and finally merge the conversion result with the remaining gss files. However when doing so you might have changed the ordering of css rules that needs to be avoided as it changes rendering behavior.

So the only way to make it fool proof for GWT is to assume that *.css files must always be converted and that *.gss files can be used as-is and that you can never mix them for a given CssResource. And that is exactly what GWT does.



So in your case you need to provide gss and css files for your widgets. You can generate the gss files from the css files by using the css2gss tool provided in gwt-user.jar. GWT itself does the same for its widgets.



-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment