I flunked one aspect of my Technical Review here:

Please create a Jira bug to track this issues and record this checkin there.

Please create a release note in that Jira item discussing the change in 
behavior of NodeModel and the new warning.  (Cf., Fred's email of this morning)

On 2010-09-17, at 13:21, [email protected] wrote:

> Author: hqm
> Date: 2010-09-17 10:21:41 -0700 (Fri, 17 Sep 2010)
> New Revision: 17506
> 
> Modified:
>   
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/LineMetrics.java
>   
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
>   
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java
>   
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler_Test.java
>   
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java
>   openlaszlo/trunk/demos/calendar/event.lzx
> Log:
> Change hqm-20100917-shr by [email protected] on 2010-09-17 12:15:33 EDT
>    in /Users/hqm/openlaszlo/trunk3
>    for http://svn.openlaszlo.org/openlaszlo/trunk
> 
> Summary: remove compile-time text metrics measurement
> 
> New Features:
> 
> Bugs Fixed:
> 
> Technical Reviewer: ptw
> QA Reviewer: max
> Doc Reviewer: (pending)
> 
> Documentation:
> 
> Release Notes:
> 
> Overview:
> 
> + remove code from ViewCompiler which calculates text width and font style 
> inheritance at compile-time. It doesn't
> work anymore, and the runtime does it properly now.
> 
> Note: This change just removes the text metrics and font inheritance
> stuff, and does not address the new proposal regarding an 'html'
> attribute and using CDATA to specify verbatim text.
> 
> Details:
> 
> 
> NodeModel:
> 
> Modified addText() so it only adds text content if the tag is known to have a 
> text attribute (previously, it was adding
> text by default to any element which had text content)
> 
> Add warning if an element has both a text attribute and any non-whitespace 
> literal text in it's content.
> 
> ViewCompiler:
> 
> compile(): remove call to mapTextMetricsCompilation
> 
> remove mergeClassFontInfo() method, no longer needed
> 
> TextCompiler:
> 
>  remove computeTextWidth() method
> 
>  getElementWidth renamed to getHTMLContent, as it is now only used to collect 
> the HTML text from the node's Content.
>  I'm passing CompilationEnvironment down to it, in case we need this code to 
> emit any compilation warnings at some point, 
>  but it's not used right now.
> 
> 
> LineMetrics:
> 
>  Remove code that tries to calculate char width from font metrics. This code 
> now just is used by TextCompiler to 
>  accumulate HTML content while normalizing out whitespace.  
> 
> 
> 
> 
> 
> 
> Tests:
> 
> ant lztest
> compile demos without compilation errors or warnings: 
> calendar,amazon,weather,youtube,lzproject,
> examples/components/component_sampler
> examples/components/form_example
> examples/components/grid_example
> examples/components/tree_example
> examples/components/tabs_example.lzx
> 
> 
> 
> Modified: 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/LineMetrics.java
> ===================================================================
> --- 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/LineMetrics.java
>   2010-09-17 16:59:41 UTC (rev 17505)
> +++ 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/LineMetrics.java
>   2010-09-17 17:21:41 UTC (rev 17506)
> @@ -3,7 +3,7 @@
>  * 
> ****************************************************************************/
> 
> /* J_LZ_COPYRIGHT_BEGIN 
> *******************************************************
> -* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.             
>  *
> +* Copyright 2001-2008, 2010 Laszlo Systems, Inc.  All Rights Reserved.       
>        *
> * Use is subject to license terms.                                            
> *
> * J_LZ_COPYRIGHT_END 
> *********************************************************/
> 
> @@ -22,8 +22,6 @@
> 
> /** Used to hold line widths while calculating element text metrics */
> class LineMetrics {
> -    double maxw = 0.0;
> -    double w = 0.0;
>     boolean verbatim = false;
>     int nlines = 1;
> 
> @@ -53,7 +51,7 @@
>     StringBuffer buf = new StringBuffer();
> 
>     public String toString() {
> -        return "LineMetrics: maxw="+maxw+" nlines="+nlines+" 
> verbatim="+verbatim+ " str=|"+buf.toString()+"|";
> +        return "LineMetrics: nlines="+nlines+" verbatim="+verbatim+ " 
> str=|"+buf.toString()+"|";
>     }
> 
>     /* Add a run of HTML, normalizing runs of whitespace to single
> @@ -73,7 +71,7 @@
> 
>     */
> 
> -    void addHTML (String rawtext, String normalized_text, FontInfo fontInfo, 
> SWFWriter generator) {
> +    void addHTML (String rawtext, String normalized_text) {
>         if (rawtext.length() == 0) {
>             return;
>         }
> @@ -98,7 +96,7 @@
>             this.trim = trailing_whitespace;
>         }
> 
> -        addSpan(normalized_text, fontInfo, generator);
> +        addSpan(normalized_text);
>     }
> 
>     void setVerbatim (boolean val) {
> @@ -108,12 +106,8 @@
> 
>     /** Add a run of text to the current text block, tracking the max width
>      and accumulating the text into a buffer.  */
> -    void addSpan (String str, FontInfo fontInfo, SWFWriter generator) {
> +    void addSpan (String str) {
>         if (str.length() > 0) {
> -            if (generator != null) {
> -                double sw = TextCompiler.getTextWidth(str, fontInfo, 
> generator, this);
> -                w += sw;
> -            }
>             str = XMLUtils.escapeXml(str);
> 
>             // Remember the position of the last space char on the
> @@ -141,7 +135,7 @@
>         buf.append(str);
>     }
> 
> -    void addStartTag (String tagName, FontInfo fontInfo, SWFWriter 
> generator) {
> +    void addStartTag (String tagName) {
>         addFormat("<" + tagName);
>     }
> 
> @@ -158,25 +152,20 @@
>         return buf.toString();
>     }
> 
> -    /* Compute maxwidth of this line and any previous lines. */
> +    /* */
>     void endOfLine() {
>         // Trim trailing whitespace at end of lines
>         if (!verbatim) {
>             if (last_space_pos > 0 && last_space_pos > last_newline_pos) {
>                 buf.deleteCharAt(last_space_pos);
> -                w -= last_spacewidth;
>             }
>         }
> -        maxw = Math.max(maxw, w);
> -        w = 0.0;
>         last_space_pos = -1;
>     }
> 
>     /** act as if a linebreak had occurred, for purposes of calculating max 
> text width
>      */
>      void resetLineWidth() {
> -         maxw = Math.max(maxw, w);
> -         w = 0.0;         
>          last_space_pos = -1;
>      }
> 
> 
> Modified: 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
> ===================================================================
> --- 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
>     2010-09-17 16:59:41 UTC (rev 17505)
> +++ 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
>     2010-09-17 17:21:41 UTC (rev 17506)
> @@ -2279,25 +2279,32 @@
>     }
> 
>     void addText() {
> +      boolean hasTextAttr = (parentClassModel.getAttribute("text", 
> ALLOCATION_INSTANCE) != null);
> +      if (hasTextAttr) {
>         if (schema.hasHTMLContent(element)) {
> -            String text = TextCompiler.getHTMLContent(element);
> -            if (text.length() != 0) {
> -                if (!attrs.containsKey("text")) {
> -                  addProperty("text", ScriptCompiler.quote(text), 
> ALLOCATION_INSTANCE);
> -                }
> +          String text = TextCompiler.getHTMLContent(element, env);
> +          if (text.length() != 0) {
> +            if (!attrs.containsKey("text")) {
> +              addProperty("text", ScriptCompiler.quote(text), 
> ALLOCATION_INSTANCE);
> +            } else {
> +              env.warn("Element '"+element.getName()+ "' has both text 
> content in it's body and a text attribute value.", element);
>             }
> +          }
>         } else if (schema.hasTextContent(element)) {
> -            String text;
> -            // The current inputtext component doesn't understand
> -            // HTML, but we'd like to have some way to enter
> -            // linebreaks in the source.
> -            text = TextCompiler.getInputText(element);
> -            if (text.length() != 0) {
> -                if (!attrs.containsKey("text")) {
> -                  addProperty("text", ScriptCompiler.quote(text), 
> ALLOCATION_INSTANCE);
> -                }
> +          String text;
> +          // The current inputtext component doesn't understand
> +          // HTML, but we'd like to have some way to enter
> +          // linebreaks in the source.
> +          text = TextCompiler.getInputText(element);
> +          if (text.length() != 0) {
> +            if (!attrs.containsKey("text")) {
> +              addProperty("text", ScriptCompiler.quote(text), 
> ALLOCATION_INSTANCE);
> +            } else {
> +              env.warn("Element '"+element.getName()+ "' has both text 
> content in it's body and a text attribute value.", element);
>             }
> +          }
>         }
> +      }
>     }
> 
>     void updateAttrs() {
> 
> Modified: 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java
> ===================================================================
> --- 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java
>  2010-09-17 16:59:41 UTC (rev 17505)
> +++ 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler.java
>  2010-09-17 17:21:41 UTC (rev 17506)
> @@ -3,7 +3,7 @@
>  * 
> ****************************************************************************/
> 
> /* J_LZ_COPYRIGHT_BEGIN 
> *******************************************************
> -* Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved.             
>  *
> +* Copyright 2001-2006, 2010 Laszlo Systems, Inc.  All Rights Reserved.       
>        *
> * Use is subject to license terms.                                            
> *
> * J_LZ_COPYRIGHT_END 
> *********************************************************/
> 
> @@ -33,12 +33,6 @@
>     private static Logger mLogger  = Logger.getLogger(TextCompiler.class);
>     private static Logger mTextLogger = Logger.getLogger("lps.text");
> 
> -    public static double computeTextWidth(String text, FontInfo fontInfo, 
> SWFWriter generator)
> -      throws CompilationError {
> -        LineMetrics lm = new LineMetrics();
> -        return computeTextWidth(text, fontInfo, generator, lm);
> -    }
> -
>     /** Check if a specified font is known by the Font Manager
>      *
>      * @param generator
> @@ -63,223 +57,19 @@
>         }
>     }
> 
> -    /**
> -     * Compute text width for a given font
> +    /** Collect the "HTML" text from the Content of an Element
>      *
> -     * @param text text stringtext string
> -     * @param fontInfo font info for this text
> -     * @return text width in pixels
> -     */
> -    public static double computeTextWidth(String text, FontInfo fontInfo, 
> SWFWriter generator, LineMetrics lm)
> -        throws CompilationError {
> -
> -        boolean trace = false; //mProperties.getProperty("trace.fonts", 
> "false") == "true";
> -
> -        String fontName = fontInfo.getName();
> -        int    size     = fontInfo.getSize();
> -        int    style    = fontInfo.styleBits;
> -
> -
> -        if (mTextLogger.isDebugEnabled()) {
> -        mTextLogger.debug(
> -/* (non-Javadoc)
> - * @i18n.test
> - * @org-mes="computeTextWidth fontName " + p[0] + " (style: " + p[1] + ", 
> size: " + p[2] + ") text: " + p[3]
> - */
> -                        org.openlaszlo.i18n.LaszloMessages.getMessage(
> -                                TextCompiler.class.getName(),"051018-87", 
> new Object[] {fontName, fontInfo.getStyle(), new Integer(fontInfo.getSize()), 
> text})
> -                                );
> -        }
> -
> -        if (text.length() == 0) {
> -            return 0;
> -        }
> -
> -        generator.checkFontExists(fontInfo);
> -
> -        FontFamily family = 
> generator.getFontManager().getFontFamily(fontName);
> -        if (family == null) {
> -            throw new CompilationError("Can't find font " + fontName);
> -        }
> -
> -        Font font = family.getStyle(style);
> -        if (font == null) {
> -            throw new CompilationError(
> -/* (non-Javadoc)
> - * @i18n.test
> - * @org-mes="Can't measure text because font " + p[0] + " " + p[1] + " is 
> missing."
> - */
> -                        org.openlaszlo.i18n.LaszloMessages.getMessage(
> -                                TextCompiler.class.getName(),"051018-109", 
> new Object[] {FontInfo.styleBitsToString(style), fontName})
> -                                                                             
>            );
> -        }
> -
> -        Rectangle2D[] bounds = family.getBounds(style);
> -
> -        if (bounds == null) {
> -            throw new CompilationError(
> -/* (non-Javadoc)
> - * @i18n.test
> - * @org-mes="Can't measure text because font " + p[0] + " " + p[1] + " is 
> missing its bounds array."
> - */
> -                        org.openlaszlo.i18n.LaszloMessages.getMessage(
> -                                TextCompiler.class.getName(),"051018-122", 
> new Object[] {FontInfo.styleBitsToString(style), fontName})
> -                                                                             
>            );
> -        }
> -
> -        double width = 0;
> -        int length = text.length();
> -        char c = text.charAt(0);
> -        int idx = font.getIndex(c);
> -        int nextIdx;
> -
> -        double last_charwidth = 0;
> -
> -        // Cope with \n \r and missing characters? XXX
> -        for(int i = 0; i < length; i++) {
> -            if (idx == -1) {
> -                mLogger.warn(
> -/* (non-Javadoc)
> - * @i18n.test
> - * @org-mes="Character \'" + p[0] + "\' (" + p[1] + ") not available in font 
> " + p[2] + " (style " + p[3] + ")"
> - */
> -                        org.openlaszlo.i18n.LaszloMessages.getMessage(
> -                                TextCompiler.class.getName(),"051018-143", 
> new Object[] {new Character(c), new Integer((int) c), fontName, 
> fontInfo.getStyle()})
> -                                                );
> -                continue;
> -            } else {
> -                double adv = font.getAdvanceValue(idx);
> -
> -                if (i == length - 1) {
> -                    double m = 0;
> -                    try {
> -                        m = bounds[idx].getMaxX();
> -                    } catch (Exception e) {
> -                    }
> -                    if (m > adv) {
> -                        adv = m;
> -                    }
> -                }
> -
> -                if (i == 0) {
> -                    try {
> -                        double m = bounds[idx].getMinX();
> -                        if (m > 0) {
> -                            adv += m;
> -                        }
> -                    } catch (Exception e) {
> -                    }
> -                }
> -
> -                last_charwidth = adv;
> -                width += adv;
> -
> -                if (mLogger.isDebugEnabled()) {
> -                mLogger.debug("adv " + adv);
> -                }
> -            }
> -
> -            if (i != length - 1) {
> -                c = text.charAt(i+1);
> -                nextIdx = font.getIndex(c);
> -                if (nextIdx != -1) {
> -                    double cw = font.getKerning(idx, nextIdx);
> -                    width += cw;
> -                }
> -                idx = nextIdx;
> -            }
> -        }
> -        // Width in pixels
> -        double w = (double)(width * fontInfo.getSize()) / 1024.0;
> -
> -        // If the last character was a space, remember it's width, as we may 
> need
> -        // to trim the trailing space from the HTML formatted text
> -        if (c == ' ') {
> -            lm.last_spacewidth = (double)(last_charwidth  * 
> fontInfo.getSize()) / 1024.0;
> -        }
> -
> -        if (mTextLogger.isDebugEnabled()) {
> -        mTextLogger.debug(
> -/* (non-Javadoc)
> - * @i18n.test
> - * @org-mes="computeTextWidth: " + p[0] + " (font: " + p[1] + ", size: " + 
> p[2] + ", style: " + p[3] + ") has textwidth: " + p[4]
> - */
> -                        org.openlaszlo.i18n.LaszloMessages.getMessage(
> -                                TextCompiler.class.getName(),"051018-201", 
> new Object[] {text, fontInfo.getName(), new Integer(fontInfo.getSize()), 
> fontInfo.getStyle(), new Double(w)})
> -                                );
> -        }
> -
> -        // FIXME: [2003-09-26 bloch] handle empty string case? should it be 
> w/out slop?
> -        // Match this in LzNewText.as
> -        //
> -        final int SLOP = 2;
> -
> -        return w + SLOP;
> -    }
> -
> -    /** Compute the text width of a string. If there are multiple
> -     * lines, return the maximum line width.
> +     * For back compatibility, this normalizes whitespace, using rules 
> similar to browser HTML text.
>      *
> -     * <p>
>      *
> -     * The only multi-line strings we will ever see here will be
> -     * non-normalized text such as inside &ltpre;&gt; verbatim
> -     * regions, because in normal running HTML text, the normalization
> -     * will have stripped out newlines.
> -     *
> -     * <p>
> -     *
> -     * The LineMetrics holds state from possibly a previous text run
> -     * on the same line, telling us whether we need to prepend an
> -     * extra whitespace.
> -     */
> -    static double getTextWidth(String str, FontInfo fontInfo, SWFWriter 
> generator,
> -                               LineMetrics lm) {
> -
> -        double maxw = 0;
> -        int lastpos = 0;
> -        int nextpos = str.indexOf('\n');
> -        String substr;
> -
> -        if (nextpos < 0) {
> -            return computeTextWidth(str, fontInfo, generator, lm);
> -        }
> -        while (nextpos >= 0) {
> -            substr = str.substring(lastpos, nextpos);
> -            maxw = Math.max(maxw, computeTextWidth(substr, fontInfo, 
> generator, lm));
> -            lastpos = nextpos+1;
> -            nextpos = str.indexOf('\n', lastpos);
> -            lm.nlines++;
> -        }
> -
> -        substr = str.substring(lastpos);
> -        maxw = Math.max(maxw, computeTextWidth(substr, fontInfo, generator, 
> lm));
> -        return maxw;
> -    }
> -
> -    /** Measure the content text allowing for "HTML" markup.
> -     *
> -     * This uses rules similar to how you would measure browser HTML text:
> -     *
>      * <ul>
>      * <li> All text is whitespace normalized, except that which occurs 
> between &lt;pre&gt; tags
>      * <li> Linebreaks occur only when &lt;br/&gt; or &lt;p/&gt; elements 
> occur, or when a newline
>      * is present inside of a &lt;pre&gt; region.
> -     * <li> When multiple text lines are present, the length of the longest 
> line is returned.
>      * </ul>
>      */
> 
> -    static LineMetrics getElementWidth(Element e, FontInfo fontInfo, 
> SWFWriter generator) {
> -        LineMetrics lm = new LineMetrics();
> -        getElementWidth(e, fontInfo, generator, lm);
> -        lm.endOfLine();
> -        // cache the normalized HTML content
> -        ((ElementWithLocationInfo) e).setHTMLContent(lm.getText());
> -        return lm;
> -    }
> -
> -    /** Gets the text content, with HTML normalization rules applied */
> -    static String getHTMLContent(Element e) {
> +    static String getHTMLContent(Element e, CompilationEnvironment env) {
>         // check if the normalized text is cached
>         if ((e instanceof ElementWithLocationInfo) &&
>             ((ElementWithLocationInfo) e).getHTMLContent() != null) {
> @@ -287,10 +77,7 @@
>         }
> 
>         LineMetrics lm = new LineMetrics();
> -        // Just use a dummy font info, we only care about the HTML
> -        // text, not string widths
> -        FontInfo fontInfo = new FontInfo("default", "8", "");
> -        getElementWidth(e, fontInfo, null, lm);
> +        getHTMLContent(e, env, lm);
>         lm.endOfLine();
>         return lm.getText();
>     }
> @@ -343,8 +130,7 @@
>         </ul>
> 
>     */
> -    static void getElementWidth(Element e, FontInfo fontInfo, SWFWriter 
> generator,
> -                                LineMetrics lm) {
> +    static void getHTMLContent(Element e, CompilationEnvironment env, 
> LineMetrics lm) {
>         for (Iterator iter = e.getContent().iterator();
>              iter.hasNext();) {
>             Object node = iter.next();
> @@ -354,29 +140,21 @@
> 
>                 if (tagName.equals("br")) {
>                     lm.newline(); // explicit linebreak
> -                    getElementWidth(child, fontInfo, generator, lm);
> +                    getHTMLContent(child, env, lm);
>                     if (!child.getText().equals("")) {
>                         lm.newline();
>                     }
>                 } else if (tagName.equals("p")) {
>                     lm.paragraphBreak();
> -                    getElementWidth(child, fontInfo, generator, lm);
> +                    getHTMLContent(child, env);
>                     lm.paragraphBreak();
>                 } else if (tagName.equals("pre")) {
>                     boolean prev = lm.verbatim;
>                     lm.setVerbatim(true);
> -                    getElementWidth(child, fontInfo, generator, lm);
> +                    getHTMLContent(child, env, lm);
>                     lm.setVerbatim(prev);
>                 } else if (ViewSchema.isHTMLElement(child)) {
> -                    FontInfo newInfo = new FontInfo(fontInfo);
> -                    if (tagName.equals("b")) {
> -                        newInfo.styleBits |= FontInfo.BOLD;
> -                    } else if (tagName.equals("i")) {
> -                        newInfo.styleBits |= FontInfo.ITALIC;
> -                    } else if (tagName.equals("font")) {
> -                        ViewCompiler.setFontInfo(newInfo, child);
> -                    }
> -                    lm.addStartTag(tagName, newInfo, generator);
> +                    lm.addStartTag(tagName);
>                     // print font-related attributes:
>                     // face, size, color
>                     // supported Flash HTML tags: 
> http://www.macromedia.com/support/flash/ts/documents/htmltext.htm
> @@ -389,8 +167,10 @@
>                         lm.addFormat(" "+name+"=\""+value+"\"");
>                     }
>                     lm.endStartTag();
> -                    getElementWidth(child, newInfo, generator, lm);
> +                    getHTMLContent(child, env, lm);
>                     lm.addEndTag(tagName);
> +                } else {
> +                    // Ignore any tag which is not a 'known' HTML tag
>                 }
>             } else if ((node instanceof Text) || (node instanceof CDATA)) {
>                 String rawtext;
> @@ -400,7 +180,7 @@
>                     rawtext = ((CDATA) node).getText();
>                 }
>                 if (lm.verbatim) {
> -                    lm.addSpan(rawtext, fontInfo, generator);
> +                    lm.addSpan(rawtext);
>                 } else {
>                     // Apply HTML normalization rules to the text content.
>                     if (rawtext.length() > 0) {
> @@ -411,21 +191,23 @@
>                         } else {
>                             normalized_text = ((CDATA) 
> node).getTextNormalize();
>                         }
> -                        lm.addHTML (rawtext, normalized_text, fontInfo, 
> generator);
> +                        lm.addHTML (rawtext, normalized_text);
>                     }
>                 }
>             } else if (node instanceof EntityRef) {
>                 // EntityRefs don't seem to occur in our JDOM, they were all 
> resolved
>                 // to strings by the parser already
>                 throw new RuntimeException(
> -/* (non-Javadoc)
> - * @i18n.test
> - * @org-mes="encountered unexpected EntityRef node in getElementWidth()"
> - */
> -                        org.openlaszlo.i18n.LaszloMessages.getMessage(
> -                                TextCompiler.class.getName(),"051018-418")
> -);
> +                    /* (non-Javadoc)
> +                     * @i18n.test
> +                     * @org-mes="encountered unexpected EntityRef node in 
> getHTMLContent()"
> +                     */
> +                    org.openlaszlo.i18n.LaszloMessages.getMessage(
> +                        TextCompiler.class.getName(),"051018-418")
> +                                           );
>             }
>         }
>     }
> +
> +
> }
> 
> Modified: 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler_Test.java
> ===================================================================
> --- 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler_Test.java
>     2010-09-17 16:59:41 UTC (rev 17505)
> +++ 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/TextCompiler_Test.java
>     2010-09-17 17:21:41 UTC (rev 17506)
> @@ -3,7 +3,7 @@
> * 
> ****************************************************************************/
> 
> /* J_LZ_COPYRIGHT_BEGIN 
> *******************************************************
> -* Copyright 2001-2004 Laszlo Systems, Inc.  All Rights Reserved.             
>  *
> +* Copyright 2001-2004, 2010 Laszlo Systems, Inc.  All Rights Reserved.       
>        *
> * Use is subject to license terms.                                            
> *
> * J_LZ_COPYRIGHT_END 
> *********************************************************/
> 
> @@ -151,7 +151,7 @@
> 
>                 assertEquals("getHTMLContent(\"" + source + "\")",
>                              result,
> -                             TextCompiler.getHTMLContent(xml));
> +                             TextCompiler.getHTMLContent(xml, null));
>             } catch (IOException e) {
>                 throw new ChainedException(e);
>             } catch (org.xml.sax.SAXParseException e) {
> 
> Modified: 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java
> ===================================================================
> --- 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java
>  2010-09-17 16:59:41 UTC (rev 17505)
> +++ 
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewCompiler.java
>  2010-09-17 17:21:41 UTC (rev 17506)
> @@ -154,13 +154,6 @@
>               );
>           }
> 
> -          try {
> -              // A blank FontInfo with all empty slots
> -              fontInfo = FontInfo.blankFontInfo();
> -              mapTextMetricsCompilation(element, mEnv, fontInfo, new 
> HashSet());
> -          } catch (NumberFormatException e) {
> -              throw new CompilationError(e.getMessage());
> -          }
>         }
>         compileXML(element, fontInfo);
>     }
> @@ -497,201 +490,7 @@
>         }
>     }
> 
> -    /**
> -     * Walk the whole superclass chain, starting at the root, merging 
> fontInfo.
> -     */
> -    protected static void mergeClassFontInfo (Element elt, FontInfo fontInfo,
> -                                              CompilationEnvironment env) {
> -        String classname = elt.getName();
> -        // check for a cached fontInfo on the class
> -        FontInfo cachedInfo = env.getClassFontInfo(classname);
> -        if (cachedInfo != null) {
> -            fontInfo.mergeFontInfoFrom(cachedInfo);
> -            return;
> -        }
> 
> -        ViewSchema schema = env.getSchema();
> -        ClassModel classinfo =  schema.getClassModel(classname);
> -        if (classinfo == null || classinfo.definition == null) {
> -            return;
> -        }
> -
> -        // Build a list of superclasses
> -        Vector parents = new Vector();
> -        ClassModel lzxclass = classinfo;
> -        // walk
> -        while (lzxclass != null) {
> -            parents.insertElementAt(lzxclass, 0);
> -            lzxclass = lzxclass.superModel;
> -        }
> -
> -        // A blank FontInfo with all empty slots
> -        FontInfo cinfo = FontInfo.blankFontInfo();
> -
> -        // Pop off elements starting at base class
> -        while (parents.size() > 0) {
> -            lzxclass = (ClassModel) parents.firstElement();
> -            parents.removeElementAt(0); // pop
> -            mergeClassFontInfo(lzxclass, cinfo);
> -        }
> -
> -        env.addClassFontInfo(classname, cinfo);
> -        // apply the class' style changes, if any, to our fontInfo arg
> -        fontInfo.mergeFontInfoFrom(cinfo);
> -    }
> -
> -    /**
> -     * Merge FontInfo from a class definition.
> -     */
> -    protected static void mergeClassFontInfo (ClassModel classinfo,
> -                                              FontInfo fontInfo) {
> -        if (classinfo != null && classinfo.definition != null) {
> -            Element celt = classinfo.definition;
> -            mergeFontInfo(celt, fontInfo);
> -        }
> -    }
> -
> -    /**
> -     * Adds in text widths for all text views below this element that
> -     * need them.  This walks down into class definitions, merging
> -     * font info as it goes.  We don't need to walk into class defs
> -     * for measuring text, since we have no way to pass those text
> -     * widths to the runtime, but we do need this to check if we need
> -     * to import the default bold or italic fonts.
> -     *
> -     *
> -     *
> -     * @param env
> -     * @param elt
> -     * @param fontInfo the current font name/style/size
> -     */
> -    protected void mapTextMetricsCompilation(Element elt,
> -                                             CompilationEnvironment env,
> -                                             FontInfo fontInfo,
> -                                             Set classList) {
> -
> -        ViewSchema schema = env.getSchema();
> -
> -        // Clone a copy of the font info
> -        fontInfo = new FontInfo(fontInfo);
> -
> -        // Check class defaults for font info
> -        mergeClassFontInfo (elt, fontInfo, env);
> -        // Now override with any directly declared attributes
> -        mergeFontInfo(elt, fontInfo);
> -
> -        // If it inherits from text or inputttext, annotate it with font info
> -        String eltName = elt.getName();
> -        if ("text".equals(eltName) ||
> -            "text".equals(schema.getBaseClassname(eltName)) ||
> -            "inputtext".equals(eltName) ||
> -            "inputtext".equals(schema.getBaseClassname(eltName))) {
> -            compileTextMetrics(elt, env, fontInfo);
> -        }
> -
> -        // Only set fontInfo for self, so the runtime knows when font is
> -        // actually set via the class/instance
> -
> -/*
> -        ClassModel classinfo =  env.getSchema().getClassModel(eltName);
> -
> -        // If this invokes a 'user-defined' class, let's walk that
> -        // class's source tree now
> -        if (classinfo != null && classinfo.definition != null) {
> -            classList = new HashSet(classList);
> -            // check if we are in an instance of a class that we are
> -            // already descended into (loop detection)
> -            if (classList.contains(eltName.intern())) {
> -                return;
> -            }
> -            for (Iterator iter = 
> classinfo.definition.getChildren().iterator(); iter.hasNext();
> -                 ) {
> -                Element e = (Element) iter.next();
> -                String ename = e.getName();
> -                if (!(ename.equals("method") || ename.equals("attribute"))) {
> -                    // Avoid recursively traversing class definitions.
> -                    // Mark this class as having been traversed, to
> -                    // avoid loops.
> -                    classList.add(classinfo.tagName.intern());
> -                    mapTextMetricsCompilation(e, env, fontInfo, classList);
> -                }
> -            }
> -        }
> -
> -        // Now do immediate children
> -        for (Iterator iter = elt.getChildren().iterator(); iter.hasNext();
> -             ) {
> -            Element e = (Element) iter.next();
> -            mapTextMetricsCompilation(e, env, fontInfo, classList);
> -        }
> -*/
> -    }
> -
> -    /** Merges font name/size/style from an element's direct
> -     * attributes into a FontInfo */
> -    protected static void mergeFontAttributes (Element elt, FontInfo 
> fontInfo) {
> -        String myfont = getAttributeValue(elt, "font");
> -        if (myfont != null) {
> -            if (myfont.matches(sFontNamePatStr)) {
> -                fontInfo.setName(myfont);
> -            } else {
> -                // we don't know what font value is, so set back to the 
> 'unknown' value
> -                fontInfo.setName(FontInfo.NULL_FONT);
> -            }
> -        }
> -
> -        String mysize = getAttributeValue(elt, "fontsize");
> -        if (mysize != null) {
> -            if (mysize.matches(sFontSizePatStr)) {
> -                fontInfo.setSize(mysize);
> -            } else {
> -                // we don't know what font size is, so set back to the
> -                // 'unknown' value
> -                fontInfo.setSize(FontInfo.NULL_SIZE);
> -            }
> -        }
> -
> -        String mystyle = getAttributeValue(elt, 
> NodeModel.FONTSTYLE_ATTRIBUTE);
> -        if (mystyle != null) {
> -            if (mystyle.matches(sFontstylePatStr)) {
> -                fontInfo.setStyle(mystyle);
> -            } else {
> -                // we don't know what font size is, so set back to the 
> 'unknown' value
> -                fontInfo.setStyleBits(FontInfo.NULL_STYLE);
> -            }
> -        }
> -    }
> -
> -    /** Merge in font attribute info from an element into a FontInfo.
> -     *
> -     * @param elt the element to look for font attributes on
> -     * @param fontInfo  merge font attribute info into this struct
> -     */
> -    private static void mergeFontInfo(Element elt, FontInfo fontInfo) {
> -        mergeFontAttributes(elt, fontInfo);
> -
> -        // Static sized textfield optimization; need to cascade resizable
> -        String resizable = getAttributeValue(elt, "resizable");
> -        if ("true".equals(resizable)) {
> -            fontInfo.resizable = FontInfo.FONTINFO_TRUE;
> -        } else if ("false".equals(resizable)) {
> -            fontInfo.resizable = FontInfo.FONTINFO_FALSE;
> -        }
> -
> -        // Static sized textfield optimization; need to cascade multiline
> -        String multiline = getAttributeValue(elt, "multiline");
> -        if ("true".equals(multiline)) {
> -            fontInfo.multiline = FontInfo.FONTINFO_TRUE;
> -        } else if ("false".equals(multiline)) {
> -            fontInfo.multiline = FontInfo.FONTINFO_FALSE;
> -        }
> -    }
> -
> -    /** Pattern matcher for compile-time optimizations */
> -    static String sConstPatStr = "\\s*(\\d*)\\s*";
> -    static String sFontstylePatStr = "\\s*(bold 
> italic|bold-italic|bold|plain|italic)\\s*";
> -    static String sFontSizePatStr = "\\s*\\d*\\s*";
> -    static String sFontNamePatStr = "\\s*[^${}]*\\s*";
>     static String sConstraintPatStr = "^\\s*\\$(\\w*)\\{(.*)}\\s*";
>     static final Pattern sConstraintPat;
> 
> @@ -699,7 +498,6 @@
>         // $once{parent +|- DDDDD}
>         sConstraintPat   = Pattern.compile(sConstraintPatStr);
>     }
> -
>     /** return true if element has an attribute named ATTRIBUTE in
>      * it's attribute list, or has a child lzx element
>      * <attribute name="ATTRIBUTE"/>
> @@ -743,33 +541,6 @@
>     }
> 
> 
> -    /**
> -     * Adds in text metrics for this element.
> -     *
> -     * @param env
> -     * @param elt
> -     * @param fontInfo font information for this element
> -     */
> -    private void compileTextMetrics(Element elt,
> -                                    CompilationEnvironment env,
> -                                    FontInfo fontInfo) {
> -
> -
> -        if (fontInfo.getName() != null) {
> -            elt.setAttribute("font", fontInfo.getName());
> -        }
> -
> -        if (fontInfo.getSize() != -1) {
> -            elt.setAttribute("fontsize", "" + fontInfo.getSize());
> -        }
> -
> -        if (fontInfo.getStyle() != null) {
> -            elt.setAttribute("fontstyle", fontInfo.getStyle());
> -        }
> -
> -    }
> -
> -
>     static void setFontInfo(FontInfo info, Element elt) {
>         String face = elt.getAttributeValue("face");
>         String size = elt.getAttributeValue("size");
> 
> Modified: openlaszlo/trunk/demos/calendar/event.lzx
> ===================================================================
> --- openlaszlo/trunk/demos/calendar/event.lzx 2010-09-17 16:59:41 UTC (rev 
> 17505)
> +++ openlaszlo/trunk/demos/calendar/event.lzx 2010-09-17 17:21:41 UTC (rev 
> 17506)
> @@ -74,7 +74,7 @@
>               visible="$once{!this.classroot.classroot.opened}">
> 
>             <attribute name="text" 
> -                        value="${ classroot.startHour }" type="text" />/>
> +                        value="${ classroot.startHour }" type="text" />
> 
>             <datapath xpath="start[1]">
>                 <!-- Usually data bound views are 'automagically' displayed
> @@ -93,6 +93,7 @@
>                 super.setAttribute('text', h + ap );
>                 ]]>
>             </setter>
> +
>         </text>
> 
>         <text name="smalltitletext" fgcolor="#4B5D6C"
> @@ -201,7 +202,7 @@
> 
> </library>
> <!-- * X_LZ_COPYRIGHT_BEGIN 
> ***************************************************
> -* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.             
>  *
> +* Copyright 2001-2008, 2010 Laszlo Systems, Inc.  All Rights Reserved.       
>        *
> * Use is subject to license terms.                                            
> *
> * X_LZ_COPYRIGHT_END ****************************************************** 
> -->
> <!-- @LZX_VERSION@                                                         -->
> 
> 
> _______________________________________________
> Laszlo-checkins mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins


Reply via email to