[Adding laszlo-dev]

On 2009-10-08, at 22:10, Max Carlson wrote:

Sounds good.  I'll look into that.

I sent you a change that should reduce the warnings.

Here's another conundrum: CSS breaks fontstyle out into font-style and
font-weight, but we overload them into one value, e.g. bolditalic.
Maybe the best approach is to add a fontweight setter for CSS and have
that combine with fontstyle as we have it now - but that could lead to
results like 'bolditalicbold', hmm...

I'm thinking we create a number of pseudo-attributes that are not part of the public API, but use the attribute style/binding/default mechanism to gather the CSS properties and use a single installer method to combine those properties and adjust the corresponding LZX attributes. Something like:

/** @access private */
var cssfontspec;
function $lzc$set_cssfontfamily(val) {
  this.cssfontspec.fontfamily = val;
  this.setFontAttrsFromCSS(this.cssfontspec);
}
attributes.cssfontfamily = new LzStyleConstraintExpr('cssfontfamily', 'font-family', 'string', 'serif')
function $lzc$set_cssfontstyle(val) {
  this.cssfontspec.style = val;
  this.setFontAttrsFromCSS(this.cssfontspec);
}
attributes.cssfontstyle = new LzStyleConstraintExpr('cssfontstyle', 'font-style', 'string', 'normal')
function $lzc$set_cssfontwieght(val) {
  this.cssfontspec.weight = val;
  this.setFontAttrsFromCSS(this.cssfontspec);
}
attributes.cssfontweight = new LzStyleConstraintExpr('cssfontweight', 'font-weight', 'string', 'normal')

So, cssfontfamily, cssfontstyle, cssfontweight, etc. are not real attributes, but they have setters and style bindings that will be looked up and computed at init time and combined into a fontspec, and then the various LZX font* attributes will be set by the setFontAttrsFromCSS method. Maybe we have to supply an additional state flag so that setFontAttrsFromCSS can just gather data while applyArgs is in progress and then install the result when it knows all the args have been applied.

In any case, there isn't always going to be a 1-to-one mapping between
CSS styles and LZX attributes.  Some CSS attributes combine multiple
values into one, e.g. box-shadow: 10px 10px 5px #888; padding: 5px 5px
5px 15px; - which would need to map to separate LZX attributes.  This
seems more straightforward - it can be done with a CSS parser and setter
that breaks out the discreet values...

I think the CSS abbreviations, like `font`, for instance, that lets you specify `font-family`, `font-style`, `font-weight`, etc. all in one attribute should just be handled by the parser and expanded into the individual properties. There is no reason these abbreviations should ever appear in a parsed style sheet (and you should not be binding attributes to these abbreviations, instead you need to handle each of the individual properties, as above).

P T Withington wrote:
I think I can adjust the warning only to be output when there is no
fallback.

Or we could turn it off altogether. I put it in for wt when they could not tell why their styles were not working, but now there is a debugger
'explainStyles' API that serves that purpose.

On Oct 8, 2009, at 20:05, Max Carlson <m...@laszlosystems.com> wrote:

I tried, and it does work - mostly.  There are some issues with
constraints failing, and the debugger warns all over the place for
styles that don't match - we probably only want to only warn for 'user
created' styles or something like that.  I'll keep digging into the
constraint issue...

P T Withington wrote:
I leave it up to you to try actually adding some defaults and see if
this actually works!
attributes.bgcolor = new LzStyleConstraintExpr('bgcolor',
'background-color', 'color', null)';
On 2009-10-07, at 23:09, Max Carlson wrote:
Approved!  This is good stuff!

P T Withington wrote:
Change 20091007-ptw-x by p...@repo-man.home on 2009-10-07 17:38:08 EDT
 in /Users/ptw/OpenLaszlo/trunk-2
 for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Implement a simple mechanism for constant style bindings
New Features:
 With this change, it should be possible to define default style
 bindings for LFC classes by saying (for example):
 attributes.bgcolor = new LzStyleConstraintExpr('bgcolor',
'background-color', 'color', null)';
Which says that the `bgcolor` attribute will be styled by the CSS `background-color` property, that the attribute is of type `color`
 and that the default, if there is no CSS style, is `null`.
Instances and subclasses can override this style binding using the
 normal mechanisms.
Bugs Fixed:
Technical Reviewer: max (pending)
QA Reviewer: hminsky (pending)
Doc Reviewer: (pending)
Details:
 Create a simpler mechanism for style bindings that have constant
CSS property names. A new subclass of constraint-expr is used to
 encode this and is applied specially by applyConstraint.  This
eliminates the need to create a separate binding method for every
 styled attribute in a class.
Tests:
 test/style/metasuite has the same 2 errors as before
Inspecting the output of the compiler shows a savings of about 12%
 in the DHTML case.
Files:
M      WEB-INF/lps/lfc/services/LzCSSStyle.lzs
M      WEB-INF/lps/lfc/core/LzNode.lzs
M      WEB-INF/lps/lfc/core/LzDefs.lzs
M WEB-INF/lps/server/src/org/openlaszlo/compiler/ NodeModel.java
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/20091007-ptw-x.tar

--
Regards,
Max Carlson
OpenLaszlo.org

--
Regards,
Max Carlson
OpenLaszlo.org

--
Regards,
Max Carlson
OpenLaszlo.org
_______________________________________________
Laszlo-reviews mailing list
laszlo-revi...@www.openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-reviews

Reply via email to