deweese     2003/07/28 17:24:33

  Modified:    sources/org/apache/batik/css/engine CSSEngine.java
               sources/org/apache/batik/gvt CompositeGraphicsNode.java
                        UpdateTracker.java
               sources/org/apache/batik/util ParsedURL.java
  Log:
  1) Fixed notification of change ofwith properties under some circumstances.
  2) Fixed some issues with documents lacking a base URI.
  3) Composite graphics nodes no longer invalidate when
     their visibility changes (their children will if it propogates).
  
  Revision  Changes    Path
  1.26      +119 -128  xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java
  
  Index: CSSEngine.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- CSSEngine.java    20 Jul 2003 23:23:27 -0000      1.25
  +++ CSSEngine.java    29 Jul 2003 00:24:32 -0000      1.26
  @@ -582,10 +582,9 @@
               media = parser.parseMedia(str);
           } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("media.error",
  -                                       new Object[] { str,
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String s =Messages.formatMessage
  +                ("media.error", new Object[] { str, m });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
       }
  @@ -685,12 +684,12 @@
                                             StyleMap.NON_CSS_ORIGIN);
                       } catch (Exception e) {
                           String m = e.getMessage();
  -                        String s =
  -                            Messages.formatMessage("property.syntax.error.at",
  -                                new Object[] { documentURI.toString(),
  -                                               an,
  -                                               attr.getNodeValue(),
  -                                               (m == null) ? "" : m });
  +                        if (m == null) m = "";
  +                        String u = ((documentURI == null)?"<unknown>":
  +                                    documentURI.toString());
  +                        String s = Messages.formatMessage
  +                            ("property.syntax.error.at",
  +                             new Object[] { u, an, attr.getNodeValue(),m});
                           throw new DOMException(DOMException.SYNTAX_ERR, s);
                       }
                   }
  @@ -730,12 +729,12 @@
                       styleDeclarationDocumentHandler.styleMap = null;
                   } catch (Exception e) {
                       String m = e.getMessage();
  -                    String s =
  -                        Messages.formatMessage("style.syntax.error.at",
  -                                      new Object[] { documentURI.toString(),
  -                                                     styleLocalName,
  -                                                     style,
  -                                                     (m == null) ? "" : m });
  +                    if (m == null) m = "";
  +                    String u = ((documentURI == null)?"<unknown>":
  +                                documentURI.toString());
  +                    String s = Messages.formatMessage
  +                        ("style.syntax.error.at",
  +                         new Object[] { u, styleLocalName, style, m});
                       throw new DOMException(DOMException.SYNTAX_ERR, s);
                   }
               }
  @@ -879,12 +878,12 @@
               return vm.createValue(lu, this);
           } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("property.syntax.error.at",
  -                                       new Object[] { documentURI.toString(),
  -                                                      prop,
  -                                                      value,
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String u = ((documentURI == null)?"<unknown>":
  +                        documentURI.toString());
  +            String s = Messages.formatMessage
  +                ("property.syntax.error.at",
  +                 new Object[] { u, prop, value, m});
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           } finally {
               element = null;
  @@ -908,10 +907,11 @@
               return styleDeclarationBuilder.styleDeclaration;
           } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("syntax.error.at",
  -                                       new Object[] { documentURI.toString(),
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String u = ((documentURI == null)?"<unknown>":
  +                        documentURI.toString());
  +            String s = Messages.formatMessage
  +                ("syntax.error.at", new Object[] { u, m });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
       }
  @@ -928,10 +928,11 @@
               ss.setMedia(parser.parseMedia(media));
           } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("syntax.error.at",
  -                                       new Object[] { documentURI.toString(),
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String u = ((documentURI == null)?"<unknown>":
  +                        documentURI.toString());
  +            String s = Messages.formatMessage
  +                ("syntax.error.at", new Object[] { u, m });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
           parseStyleSheet(ss, uri);
  @@ -952,10 +953,11 @@
               parseStyleSheet(ss, is, uri);
           } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("syntax.error.at",
  -                                       new Object[] { documentURI.toString(),
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String u = ((documentURI == null)?"<unknown>":
  +                        documentURI.toString());
  +            String s = Messages.formatMessage
  +                ("syntax.error.at", new Object[] { u, m });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
           return ss;
  @@ -968,9 +970,9 @@
        */
       public void parseStyleSheet(StyleSheet ss, URL uri) throws DOMException {
           if (uri == null) {
  -            String s = Messages.formatMessage("syntax.error.at",
  -                                              new Object[] { "Null Document 
reference", 
  -                                                             "" });
  +            String s = Messages.formatMessage
  +                ("syntax.error.at",
  +                 new Object[] { "Null Document reference", "" });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
   
  @@ -980,8 +982,7 @@
                if (documentURI != null) {
                    pDocURL = new ParsedURL(documentURI);
                }
  -             ParsedURL pURL = null;
  -                 pURL = new ParsedURL(uri);
  +             ParsedURL pURL = new ParsedURL(uri);
                cssContext.checkLoadExternalResource(pURL, pDocURL);
                
                parseStyleSheet(ss, new InputSource(uri.toString()), uri);
  @@ -989,10 +990,9 @@
               throw e; 
           } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("syntax.error.at",
  -                                       new Object[] { uri.toString(),
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String s = Messages.formatMessage
  +                ("syntax.error.at", new Object[] { uri.toString(), m });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
       }
  @@ -1010,10 +1010,11 @@
               ss.setMedia(parser.parseMedia(media));
           } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("syntax.error.at",
  -                                       new Object[] { documentURI.toString(),
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String u = ((documentURI == null)?"<unknown>":
  +                        documentURI.toString());
  +            String s = Messages.formatMessage
  +                ("syntax.error.at", new Object[] { u, m });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
           parseStyleSheet(ss, rules, uri);
  @@ -1033,11 +1034,10 @@
               parseStyleSheet(ss, new InputSource(new StringReader(rules)), uri);
        } catch (Exception e) {
               String m = e.getMessage();
  -            String s =
  -                Messages.formatMessage("stylesheet.syntax.error",
  -                                       new Object[] { uri.toString(),
  -                                                      rules,
  -                                                      (m == null) ? "" : m });
  +            if (m == null) m = "";
  +            String s = Messages.formatMessage
  +                ("stylesheet.syntax.error",
  +                 new Object[] { uri.toString(), rules, m });
               throw new DOMException(DOMException.SYNTAX_ERR, s);
           }
       }
  @@ -1346,7 +1346,11 @@
               ir.setMediaList(media);
               ir.setParent(styleSheet);
               try {
  -                ir.setURI(new URL(getCSSBaseURI(), uri));
  +                URL base = getCSSBaseURI();
  +                URL url;
  +                if (base == null) url = new URL(uri);
  +                else              url = new URL(base, uri);
  +                ir.setURI(url);
               } catch (MalformedURLException e) {
               }
               styleSheet.append(ir);
  @@ -1417,7 +1421,9 @@
               Value fontFamily = sm.getValue(pidx);
               if (fontFamily == null) return;
   
  -            ParsedURL purl = new ParsedURL(getCSSBaseURI());
  +            URL base = getCSSBaseURI();
  +            ParsedURL purl = null;
  +            if (base != null) purl = new ParsedURL(base);
               fontFaces.add(new FontFaceRule(sm, purl));
           }
       
  @@ -1650,6 +1656,7 @@
           case MutationEvent.ADDITION:
           case MutationEvent.MODIFICATION:
               String decl = evt.getNewValue();
  +            // System.err.println("Inline Style Update: '" + decl + "'");
               if (decl.length() > 0) {
                   element = elt;
                   try {
  @@ -1661,12 +1668,12 @@
                       styleDeclarationUpdateHandler.styleMap = null;
                   } catch (Exception e) {
                       String m = e.getMessage();
  -                    String s =
  -                        Messages.formatMessage("style.syntax.error.at",
  -                                      new Object[] { documentURI.toString(),
  -                                                     styleLocalName,
  -                                                     decl,
  -                                                     (m == null) ? "" : m });
  +                    if (m == null) m = "";
  +                    String u = ((documentURI == null)?"<unknown>":
  +                                documentURI.toString());
  +                    String s = Messages.formatMessage
  +                        ("style.syntax.error.at",
  +                         new Object[] { u, styleLocalName, decl, m });
                       throw new DOMException(DOMException.SYNTAX_ERR, s);
                   }
                   element = null;
  @@ -1710,25 +1717,14 @@
                       : updated[colorIndex];
                   
                   for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
  -                    if (!updated[i]) {
  -                        if (style.isComputed(i)) {
  -                            if (fs && style.isFontSizeRelative(i)) {
  -                                updated[i] = true;
  -                                count++;
  -                                clearComputedValue(style, i);
  -                            }
  -                            if (lh && style.isLineHeightRelative(i)) {
  -                                updated[i] = true;
  -                                count++;
  -                                clearComputedValue(style, i);
  -                            }
  -                            if (cl && style.isColorRelative(i)) {
  -                                updated[i] = true;
  -                                count++;
  -                                clearComputedValue(style, i);
  -                            }
  -                        }
  -                    } else {
  +                    if (updated[i]) {
  +                        count++;
  +                    } 
  +                    else if ((fs && style.isFontSizeRelative(i)) ||
  +                             (lh && style.isLineHeightRelative(i)) ||
  +                             (cl && style.isColorRelative(i))) {
  +                        updated[i] = true;
  +                        clearComputedValue(style, i);
                           count++;
                       }
                   }
  @@ -1858,24 +1854,13 @@
               for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
                   if (updated[i]) {
                       count++;
  -                    continue;
                   }
  -                if (style.isComputed(i)) {
  -                    if (fs && style.isFontSizeRelative(i)) {
  -                        updated[i] = true;
  -                        count++;
  -                        clearComputedValue(style, i);
  -                    }
  -                    if (lh && style.isLineHeightRelative(i)) {
  -                        updated[i] = true;
  -                        count++;
  -                        clearComputedValue(style, i);
  -                    }
  -                    if (cl && style.isColorRelative(i)) {
  -                        updated[i] = true;
  -                        count++;
  -                        clearComputedValue(style, i);
  -                    }
  +                else if ((fs && style.isFontSizeRelative(i)) ||
  +                         (lh && style.isLineHeightRelative(i)) ||
  +                         (cl && style.isColorRelative(i))) {
  +                    updated[i] = true;
  +                    clearComputedValue(style, i);
  +                    count++;
                   }
               }
   
  @@ -1893,14 +1878,34 @@
               }
           }
   
  +        int [] inherited = props;
  +        if (props != null) {
  +            // Filter out uninheritable properties when we 
  +            // propogate to children.
  +            int count = 0;
  +            for (int i=0; i<props.length; i++) {
  +                ValueManager vm = valueManagers[props[i]];
  +                if (vm.isInheritedProperty()) count++;
  +                else props[i] = -1;
  +            }
  +            
  +            if (count == 0) 
  +                return; // nothing to propogate
  +            inherited = new int[count];
  +            count=0;
  +            for (int i=0; i<props.length; i++)
  +                if (props[i] != -1)
  +                    inherited[count++] = props[i];
  +        }
  +
           Node c = getImportedChild(node);
           if (c != null) {
  -            invalidateProperties(c, props);
  +            invalidateProperties(c, inherited);
           }
           for (Node n = node.getFirstChild();
                n != null;
                n = n.getNextSibling()) {
  -            invalidateProperties(n, props);
  +            invalidateProperties(n, inherited);
           }
       }
   
  @@ -1938,9 +1943,7 @@
                       return;
                   }
   
  -                if (styleMap.isComputed(i)) {
  -                    updatedProperties[i] = true;
  -                }
  +                updatedProperties[i] = true;
   
                   Value v = valueManagers[i].createValue(value, CSSEngine.this);
                   styleMap.putMask(i, (short)0);
  @@ -1987,13 +1990,12 @@
                   style.putOrigin(idx, StyleMap.NON_CSS_ORIGIN);
               } catch (Exception e) {
                   String m = e.getMessage();
  -                String s =
  -                    Messages.formatMessage("property.syntax.error.at",
  -                        new Object[]
  -                        { documentURI.toString(),
  -                          property,
  -                          evt.getNewValue(),
  -                          (m == null) ? "" : m });
  +                if (m == null) m = "";
  +                String u = ((documentURI == null)?"<unknown>":
  +                            documentURI.toString());
  +                String s = Messages.formatMessage
  +                    ("property.syntax.error.at",
  +                     new Object[] { u, property, evt.getNewValue(), m });
                   throw new DOMException(DOMException.SYNTAX_ERR, s);
               }
               element = null;
  @@ -2018,25 +2020,14 @@
           int count = 0;
   
           for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
  -            if (!updated[i]) {
  -                if (style.isComputed(i)) {
  -                    if (fs && style.isFontSizeRelative(i)) {
  -                        updated[i] = true;
  -                        count++;
  -                        clearComputedValue(style, i);
  -                    }
  -                    if (lh && style.isLineHeightRelative(i)) {
  -                        updated[i] = true;
  -                        count++;
  -                        clearComputedValue(style, i);
  -                    }
  -                    if (cl && style.isColorRelative(i)) {
  -                        updated[i] = true;
  -                        count++;
  -                        clearComputedValue(style, i);
  -                    }
  -                }
  -            } else {
  +            if (updated[i]) {
  +                count++;
  +            }
  +            else if ((fs && style.isFontSizeRelative(i)) ||
  +                     (lh && style.isLineHeightRelative(i)) ||
  +                     (cl && style.isColorRelative(i))) {
  +                updated[i] = true;
  +                clearComputedValue(style, i);
                   count++;
               }
           }
  
  
  
  1.34      +15 -1     
xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java
  
  Index: CompositeGraphicsNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- CompositeGraphicsNode.java        16 Jul 2003 23:46:27 -0000      1.33
  +++ CompositeGraphicsNode.java        29 Jul 2003 00:24:32 -0000      1.34
  @@ -107,6 +107,20 @@
           return backgroundEnableRgn;
       }
   
  +    /**
  +     * Sets if this node is visible or not depending on the specified value.
  +     * Don't fire a graphicsNodeChange event because this doesn't really
  +     * effect us (it effects our children through CSS inheritence).
  +     *
  +     * @param isVisible If true this node is visible
  +     */
  +    public void setVisible(boolean isVisible) {
  +        // fireGraphicsNodeChangeStarted();
  +        this.isVisible = isVisible;
  +        // fireGraphicsNodeChangeCompleted();
  +    }
  +
  +
       //
       // Drawing methods
       //
  
  
  
  1.20      +13 -8     xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java
  
  Index: UpdateTracker.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- UpdateTracker.java        20 Jul 2003 22:32:30 -0000      1.19
  +++ UpdateTracker.java        29 Jul 2003 00:24:32 -0000      1.20
  @@ -56,7 +56,7 @@
           while (i.hasNext()) {
               WeakReference gnWRef = (WeakReference)i.next();
               GraphicsNode  gn     = (GraphicsNode)gnWRef.get();
  -            //GraphicsNode  srcGN  = gn;
  +            // GraphicsNode  srcGN  = gn;
   
               // if the weak ref has been cleared then this node is no
               // longer part of the GVT tree (and the change should be
  @@ -132,12 +132,11 @@
                   //       srcORgn + "\n" + srcNRgn + "\n");
                   // <!>
                   Shape oRgn = srcORgn;
  -                // System.err.println("src: " + srcORgn);
  -                // System.err.println("GN: " + srcGN);
  -                if (oat != null){
  -                    oRgn = oat.createTransformedShape(srcORgn);
  -                }
                   if (oRgn != null) {
  +                    if (oat != null)
  +                        oRgn = oat.createTransformedShape(srcORgn);
  +                    // System.err.println("GN: " + srcGN);
  +                    // System.err.println("Src: " + oRgn.getBounds2D());
                       ret.add(oRgn);
                   }
                   
  @@ -235,7 +234,13 @@
           // Add this dirty region to any existing dirty region.
           Rectangle2D r2d = (Rectangle2D)fromBounds.remove(gnWRef);
           if (rgn != null) {
  -            if (r2d != null) r2d = r2d.createUnion(rgn);
  +            if (r2d != null) {
  +                // System.err.println("GN: " + gn);
  +                // System.err.println("R2d: " + r2d);
  +                // System.err.println("Rgn: " + rgn);
  +                r2d = r2d.createUnion(rgn);
  +                // System.err.println("Union: " + r2d);
  +            }
               else             r2d = rgn;
           }
   
  
  
  
  1.17      +7 -1      xml-batik/sources/org/apache/batik/util/ParsedURL.java
  
  Index: ParsedURL.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURL.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ParsedURL.java    23 Apr 2003 00:46:11 -0000      1.16
  +++ ParsedURL.java    29 Jul 2003 00:24:32 -0000      1.17
  @@ -488,6 +488,9 @@
        * @param urlStr the sub URL string to parse.
        */
       public static ParsedURLData parseURL(String baseStr, String urlStr) {
  +        if (baseStr == null)
  +            return parseURL(urlStr);
  +
           ParsedURL purl = new ParsedURL(baseStr);
           return parseURL(purl, urlStr);
       }
  @@ -499,6 +502,9 @@
        * @param urlStr the sub URL string to parse.
        */
       public static ParsedURLData parseURL(ParsedURL baseURL, String urlStr) {
  +        if (baseURL == null)
  +            return parseURL(urlStr);
  +
           String protocol = getProtocol(urlStr);
           if (protocol == null)
               protocol = baseURL.getProtocol();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to