Why not simply use ConstructorMap in WEB-INF/lps/lfc/glue/ 
LaszloInitiator.as?

jim

On Sep 6, 2006, at 2:07 PM, [EMAIL PROTECTED] wrote:

> Author: ben
> Date: 2006-09-06 14:07:31 -0700 (Wed, 06 Sep 2006)
> New Revision: 1758
>
> Added:
>    openlaszlo/branches/coal/test/style/elementselector/main.lzx
>    openlaszlo/branches/coal/test/style/elementselector/ 
> specialclassnames-test.lzx
> Modified:
>    openlaszlo/branches/coal/WEB-INF/lps/lfc/services/LzCSSStyle.js
>    openlaszlo/branches/coal/test/style/elementselector/ 
> elementselector-test.lzx
>    openlaszlo/branches/coal/test/style/elementselector/ 
> elementselectors.css
> Log:
> Change change.Pn6jg7H06.txt by [EMAIL PROTECTED] /Users/ben/src/svn/ 
> openlaszlo/branches/coal on 2006-09-06 14:00:19 PDT
>
> Summary: Make CSS support styling LzView, LzText, etc, where  
> classname != tagname
>
> New Features: CSS selectors with tag name work
>
> Bugs Fixed:
>
> Technical Reviewer: adam (pending)
> QA Reviewer: frisco (pending)
> Doc Reviewer: frisco (pending)
>
> Documentation:
> Selectors like this will work now:
> view {
>     nicebgcolor: "0x366d3c";
>     styledname: "Frank";
> }
> These are a special case because LzView is the classname for
> nodes specified with the tag "view". Similarly for all of these:
> case "view":        return "LzView";
> case "animator":    return "LzAnimator";
> case "animatorgroup": return "LzAnimatorGroup";
> case "canvas":      return  "LzCanvas";
> case "drawview":    return "LzDrawView";
> case "inputtext":   return "LzInputText";
> case "layout":      return "LzLayout";
> case "node":        return "LzNode";
> case "state":       return "LzState";
> case "text":        return "LzText";
>
> .. This is a limited subset of the actual tags with different
> names than the associated classname. I selected this subset to be
> the tags that are likely to be styled via CSS.
>
> Release Notes:
>
> There will almost certainly be weird behavior for drawview, text,
> inputtext, and maybe canvas; this patch makes the tag to classname
> mapping, but does not address the rest of these classes style-ability.
>
> Details:
>
>
> Tests:
> http://localhost:8080/coal/test/style/elementselector/main.lzx
>
> Modified: openlaszlo/branches/coal/WEB-INF/lps/lfc/services/ 
> LzCSSStyle.js
> ===================================================================
> --- openlaszlo/branches/coal/WEB-INF/lps/lfc/services/LzCSSStyle.js    
> 2006-09-06 09:00:09 UTC (rev 1757)
> +++ openlaszlo/branches/coal/WEB-INF/lps/lfc/services/LzCSSStyle.js    
> 2006-09-06 21:07:31 UTC (rev 1758)
> @@ -158,12 +158,9 @@
>
>  }
>  //this ideally would be two separate functions, but merging them
> -//and inlining the cases of the switch statement is a 2x speedup
> +//and inlining the cases of the switch statement is a 2x speedup  
> [awolff]
>  LzCSSStyle._ruleOrSelectorApplies = function ( r , node ){
>
> -    //TODO: special case where the classname is not the same as  
> the tagname;
> -    //e.g. view != LzView
> -
>      //if it's a rule, grab the selector
>      if ( r.parsed ) var rp = r.parsed;
>      else var rp = r;
> @@ -178,10 +175,6 @@
>          case (this._selTypes.class ):
>              return (node instanceof _root.global[ rp.classname  ]);
>
> -        case (this._selTypes.idAndClass ):
> -            if ( node.id != rp.id ) return false;
> -            return (node instanceof _root.global[ rp.classname  ]);
> -
>          case (this._selTypes.compound ):
>              var curnode = node;
>              var sindex = rp.length -1;
> @@ -223,10 +216,9 @@
>      "star"         : 1,  // *
>      "id"           : 2,  // #gMyId
>      "class"        : 3,  // styledbox
> -    "idAndClass"   : 4,  // TODO: the compiler isn't outputting  
> idAndClass-ish rules yet
> -    "compound"     : 5,  // E F
> -    "attribute"    : 6,  // [attr="val"]
> -    "classAndAttr" : 7   // class[attr="val"]
> +    "compound"     : 4,  // E F
> +    "attribute"    : 5,  // [attr="val"]
> +    "classAndAttr" : 6   // class[attr="val"]
>  }
>
>  LzCSSStyle._rules = new Array();
> @@ -289,13 +281,7 @@
>          if (index >= 0) {
>              // Assumption: there should only be one # in a selector
>              parsed.id =  sel.substring(index + 1);
> -            if ( index == 0 ){
> -                parsed.type =  this._selTypes.id;
> -            } else {
> -                parsed.type =  this._selTypes.idAndClass;
> -                parsed.classname = this._normalizeClassname(
> -                                    sel.substring(0, index) );
> -            }
> +            parsed.type =  this._selTypes.id;
>          } else {
>              parsed.type =  this._selTypes.class;
>              parsed.classname = this._normalizeClassname( sel );
> @@ -306,8 +292,28 @@
>      return parsed;
>  }
>
> +
> +/* The tag name of some nodes doesn't match the associated class  
> name, ie,
> + nodes declared with tag <view> are instances of LzView, not  
> instances of view.
> + This function normalizes tag names into class names. The complete  
> tag to classname
> + mapping is listed in LaszloInitiator.as. For speed and size, I am  
> only actually
> + mapping the class names which it seems sane to style. I am  
> excluding data-related
> + classes, because they will have undefined behavior when used  
> together with CSS.
> + */
>  LzCSSStyle._normalizeClassname = function ( cn ){
> -    return cn;
> +    switch (cn) {
> +        case "view":        return "LzView";
> +        case "animator":    return "LzAnimator";
> +        case "animatorgroup": return "LzAnimatorGroup";
> +        case "canvas":      return  "LzCanvas";
> +        case "drawview":    return "LzDrawView";
> +        case "inputtext":   return "LzInputText";
> +        case "layout":      return "LzLayout";
> +        case "node":        return "LzNode";
> +        case "state":       return "LzState";
> +        case "text":        return "LzText";
> +        default: return cn;
> +    }
>  }
>
>  // These objects implement
>
> Modified: openlaszlo/branches/coal/test/style/elementselector/ 
> elementselector-test.lzx
> ===================================================================
> --- openlaszlo/branches/coal/test/style/elementselector/ 
> elementselector-test.lzx      2006-09-06 09:00:09 UTC (rev 1757)
> +++ openlaszlo/branches/coal/test/style/elementselector/ 
> elementselector-test.lzx      2006-09-06 21:07:31 UTC (rev 1758)
> @@ -1,13 +1,5 @@
>  <!-- Copyright 2001-2006 Laszlo Systems, Inc.  All Rights  
> Reserved. -->
> -<canvas debug="true" cssfile="elementselectors.css">
> -    <include href="../test"/>
> -    <script>
> -    Debug.write("This test file exercises RUNTIME support for CSS"
> -        + " and element selectors.");
> -    </script>
> -    <debug/>
> -
> -    <include href="../runtime-only-tests/designerview.lzx" />
> +<library>
>      <simplelayout />
>      <designerview id="gRobby" />
>      <designerview id="gPatrick" />
> @@ -40,4 +32,4 @@
>      </testsuite>
>
>
> -</canvas>
> +</library>
> \ No newline at end of file
>
> Modified: openlaszlo/branches/coal/test/style/elementselector/ 
> elementselectors.css
> ===================================================================
> --- openlaszlo/branches/coal/test/style/elementselector/ 
> elementselectors.css  2006-09-06 09:00:09 UTC (rev 1757)
> +++ openlaszlo/branches/coal/test/style/elementselector/ 
> elementselectors.css  2006-09-06 21:07:31 UTC (rev 1758)
> @@ -5,3 +5,5 @@
>      innercolor: "0x1e4d75";
>  }
>
> +
> +
>
> Added: openlaszlo/branches/coal/test/style/elementselector/main.lzx
>
>
> Property changes on: openlaszlo/branches/coal/test/style/ 
> elementselector/main.lzx
> ___________________________________________________________________
> Name: svn:mime-type
>    + text/plain
> Name: svn:eol-style
>    + native
>
> Added: openlaszlo/branches/coal/test/style/elementselector/ 
> specialclassnames-test.lzx
>
>
> Property changes on: openlaszlo/branches/coal/test/style/ 
> elementselector/specialclassnames-test.lzx
> ___________________________________________________________________
> Name: svn:mime-type
>    + text/plain
> Name: svn:eol-style
>    + native
>
>
> _______________________________________________
> Laszlo-checkins mailing list
> [EMAIL PROTECTED]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins


_______________________________________________
Laszlo-dev mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-dev

Reply via email to