hillion     01/10/17 07:47:26

  Modified:    sources/org/apache/batik/bridge CSSUtilities.java
               sources/org/apache/batik/css AbstractViewCSS.java
                        CSSOMReadOnlyStyleDeclaration.java
                        ExtendedElementCSSInlineStyle.java
                        HiddenChildElement.java
                        HiddenChildElementSupport.java PropertyMap.java
               sources/org/apache/batik/dom AbstractAttr.java
                        AbstractDocument.java
               sources/org/apache/batik/dom/svg AbstractElement.java
               sources/org/apache/batik/extension ExtensionElement.java
  Added:       sources/org/apache/batik/css ElementWithBaseURI.java
  Removed:     sources/org/apache/batik/dom/util
                        SoftDoublyIndexedTable.java
  Log:
  few CSS engine cleanups.
  
  Revision  Changes    Path
  1.33      +10 -6     xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java
  
  Index: CSSUtilities.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- CSSUtilities.java 2001/10/12 07:33:09     1.32
  +++ CSSUtilities.java 2001/10/17 14:47:25     1.33
  @@ -25,6 +25,7 @@
   import org.apache.batik.css.AbstractViewCSS;
   import org.apache.batik.css.CSSOMReadOnlyStyleDeclaration;
   import org.apache.batik.css.CSSOMReadOnlyValue;
  +import org.apache.batik.css.HiddenChildElementSupport;
   import org.apache.batik.css.value.ImmutableString;
   
   import org.apache.batik.dom.svg.SVGOMDocument;
  @@ -66,7 +67,7 @@
    * concrete objects regarding to CSS properties.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: CSSUtilities.java,v 1.32 2001/10/12 07:33:09 hillion Exp $
  + * @version $Id: CSSUtilities.java,v 1.33 2001/10/17 14:47:25 hillion Exp $
    */
   public abstract class CSSUtilities 
       implements CSSConstants, ErrorConstants, XMLConstants {
  @@ -837,14 +838,17 @@
   
           SVGOMDocument document
               = (SVGOMDocument)localRefElement.getOwnerDocument();
  -        ViewCSS view = (ViewCSS)document.getDefaultView();
  +        AbstractViewCSS view = (AbstractViewCSS)document.getDefaultView();
   
  +
           SVGOMDocument refDocument
               = (SVGOMDocument)refElement.getOwnerDocument();
  -        ViewCSS refView = (ViewCSS)refDocument.getDefaultView();
  -
  -        computeStyle(refElement,      refView,
  -                     localRefElement, view);
  +        AbstractViewCSS refView = (AbstractViewCSS)refDocument.getDefaultView();
  +        
  +        HiddenChildElementSupport.setStyle(localRefElement,
  +                                           view,
  +                                           refElement,
  +                                           refView);
       }
   
       /**
  
  
  
  1.19      +32 -256   xml-batik/sources/org/apache/batik/css/AbstractViewCSS.java
  
  Index: AbstractViewCSS.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/AbstractViewCSS.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AbstractViewCSS.java      2001/10/11 18:37:33     1.18
  +++ AbstractViewCSS.java      2001/10/17 14:47:26     1.19
  @@ -18,6 +18,7 @@
   import org.apache.batik.css.sac.ExtendedSelector;
   import org.apache.batik.css.value.ImmutableInherit;
   import org.apache.batik.css.value.RelativeValueResolver;
  +import org.apache.batik.util.SoftDoublyIndexedTable;
   
   import org.w3c.css.sac.SelectorList;
   import org.w3c.dom.DOMException;
  @@ -44,7 +45,7 @@
    * {@link org.w3c.dom.css.ViewCSS} interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: AbstractViewCSS.java,v 1.18 2001/10/11 18:37:33 hillion Exp $
  + * @version $Id: AbstractViewCSS.java,v 1.19 2001/10/17 14:47:26 hillion Exp $
    */
   public abstract class AbstractViewCSS implements ViewCSS {
   
  @@ -56,7 +57,7 @@
       /**
        * The cached computed styles.
        */
  -    protected ComputedStyleCache styles = new ComputedStyleCache();
  +    protected SoftDoublyIndexedTable styles = new SoftDoublyIndexedTable();
   
       /**
        * The media to use for cascading.
  @@ -109,7 +110,8 @@
       public CSSOMReadOnlyStyleDeclaration getComputedStyleInternal(Element elt,
                                                                     String pseudoElt) 
{
           pseudoElt = (pseudoElt == null) ? "" : pseudoElt;
  -        CSSOMReadOnlyStyleDeclaration result = styles.get(elt, pseudoElt);
  +        CSSOMReadOnlyStyleDeclaration result;
  +        result = (CSSOMReadOnlyStyleDeclaration)styles.get(elt, pseudoElt);
        
           if (result == null) {
               result = computeStyle(elt, pseudoElt);
  @@ -126,14 +128,14 @@
                                    CSSOMReadOnlyStyleDeclaration sd) {
           pseudoElt = (pseudoElt == null) ? "" : pseudoElt;
           sd.setContext(this, elt);
  -        styles.putPermanent(elt, pseudoElt, sd);
  +        styles.put(elt, pseudoElt, sd);
       }
   
       /**
  -     * Disposes the style declarations explicitly setted in the cache.
  +     * Clears the caches.
        */
       public void dispose() {
  -        styles.dispose();
  +        styles.clear();
       }
   
       /**
  @@ -171,10 +173,15 @@
       public CSSOMReadOnlyStyleDeclaration computeStyle(Element elt,
                                                         String pseudoElt) {
           CSSOMReadOnlyStyleDeclaration result;
  -        result = getCascadedStyle(elt, pseudoElt);
  +        if (elt instanceof HiddenChildElement) {
  +            result = ((HiddenChildElement)elt).getCascadedStyle();
  +            if (result != null) {
  +                return new CSSOMReadOnlyStyleDeclaration(result);
  +            }
  +        }
   
  +        result = getCascadedStyle(elt, pseudoElt);
        computeRelativeValues(elt, pseudoElt, result);
  -
        return result;
       }
   
  @@ -186,12 +193,12 @@
           CSSOMReadOnlyStyleDeclaration result;
           result = new CSSOMReadOnlyStyleDeclaration(this, elt);
   
  -     addUserAgentProperties(elt, pseudoElt, result);
  -     addUserProperties(elt, pseudoElt, result);
  -     addNonCSSPresentationalHints(elt, pseudoElt, result);
  -     addAuthorStyleSheetProperties(elt, pseudoElt, result);
  -     addInlineStyleProperties(elt, pseudoElt, result);
  -     addOverrideStyleProperties(elt, pseudoElt, result);
  +        addUserAgentProperties(elt, pseudoElt, result);
  +        addUserProperties(elt, pseudoElt, result);
  +        addNonCSSPresentationalHints(elt, pseudoElt, result);
  +        addAuthorStyleSheetProperties(elt, pseudoElt, result);
  +        addInlineStyleProperties(elt, pseudoElt, result);
  +        addOverrideStyleProperties(elt, pseudoElt, result);
   
        return result;
       }
  @@ -457,6 +464,17 @@
           if (dval == null ||
               dorg != CSSOMReadOnlyStyleDeclaration.USER_ORIGIN ||
               dprio.length() == 0) {
  +            /*
  +            if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
  +                if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_URI) {
  +                    value.setImmutableValue
  +                        (new ImmutableString
  +                         (CSSPrimitiveValue.CSS_URI,
  +                          new ParsedURL(basePURL, 
  +                                        value.getStringValue()).toString()));
  +                }
  +            }
  +            */
               dest.setPropertyCSSValue(name,
                                        value,
                                        prio,
  @@ -565,247 +583,5 @@
            }
        }
        return false;
  -    }
  -
  -    /**
  -     * To cache the computed styles.
  -     */
  -    protected static class ComputedStyleCache {
  -
  -        /**
  -         * The table used to store the style.
  -         */
  -        protected Entry[] table;
  -
  -        /**
  -         * The number of entries
  -         */
  -        protected int count;
  -
  -        /**
  -         * Creates a new ComputedStyleCache.
  -         */
  -        public ComputedStyleCache() {
  -            table = new Entry[11];
  -        }
  -
  -        /**
  -         * Caches the given computed style.
  -         */
  -        public void put(Element elt, String pe, CSSOMReadOnlyStyleDeclaration sd) {
  -            int hash  = hashCode(elt, pe) & 0x7FFFFFFF;
  -            int index = hash % table.length;
  -     
  -            for (Entry e = table[index]; e != null; e = e.next) {
  -                if ((e.hash == hash) && e.match(elt, pe)) {
  -                    e.computedStyleReference = new SoftReference(sd);
  -                    return;
  -                }
  -            }
  -
  -            // The key is not in the hash table
  -            int len = table.length;
  -            if (count++ >= (len * 3) >>> 2) {
  -                rehash();
  -                index = hash % table.length;
  -            }
  -            
  -            Entry e = new Entry(hash, elt, pe, new SoftReference(sd), table[index]);
  -            table[index] = e;
  -        }
  -
  -        /**
  -         * Caches the given computed style without possibility of collection.
  -         */
  -        public void putPermanent(Element elt, String pe,
  -                                 CSSOMReadOnlyStyleDeclaration sd) {
  -            int hash  = hashCode(elt, pe) & 0x7FFFFFFF;
  -            int index = hash % table.length;
  -     
  -            for (Entry e = table[index]; e != null; e = e.next) {
  -                if ((e.hash == hash) && e.match(elt, pe)) {
  -                    e.computedStyleReference = new StrongReference(sd);
  -                    return;
  -                }
  -            }
  -
  -            // The key is not in the hash table
  -            int len = table.length;
  -            if (count++ >= (len * 3) >>> 2) {
  -                rehash();
  -                index = hash % table.length;
  -            }
  -            
  -            Entry e = new Entry(hash, elt, pe, new StrongReference(sd), 
table[index]);
  -            table[index] = e;
  -        }
  -
  -        /**
  -         * Returns the computed style mapped with the given element
  -         * and pseudo-element, if any.
  -         */
  -        public CSSOMReadOnlyStyleDeclaration get(Element elt, String pe) {
  -            int hash  = hashCode(elt, pe) & 0x7FFFFFFF;
  -            int index = hash % table.length;
  -     
  -            for (Entry e = table[index]; e != null; e = e.next) {
  -                if ((e.hash == hash) && e.match(elt, pe)) {
  -                    return 
(CSSOMReadOnlyStyleDeclaration)e.computedStyleReference.get();
  -                }
  -            }
  -            return null;
  -        }
  -
  -        /**
  -         * Rehash the table
  -         */
  -        protected void rehash () {
  -            Entry[] oldTable = table;
  -     
  -            table = new Entry[oldTable.length * 2 + 1];
  -     
  -            for (int i = oldTable.length-1; i >= 0; i--) {
  -                for (Entry old = oldTable[i]; old != null;) {
  -                    Entry e = old;
  -                    old = old.next;
  -                    
  -                    int index = e.hash % table.length;
  -                    e.next = table[index];
  -                    table[index] = e;
  -                }
  -            }
  -        }
  -
  -        /**
  -         * Updates the table.
  -         */
  -        protected void update() {
  -            for (int i = table.length - 1; i >= 0; --i) {
  -                Entry e = table[i];
  -                Entry p = null;
  -                if (e != null) {
  -                    if (e.computedStyleReference.get() == null) {
  -                        table[i] = e.next;
  -                        count--;
  -                    }
  -                    p = e;
  -                    e = e.next;
  -                }
  -                while (e != null) {
  -                    if (e.computedStyleReference.get() == null) {
  -                        p.next = e.next;
  -                        count--;
  -                    }
  -                    p = e;
  -                    e = e.next;
  -                }
  -            }
  -        }
  -
  -        /**
  -         * Removes the permanently cached style declarations.
  -         */
  -        public void dispose() {
  -            for (int i = table.length - 1; i >= 0; --i) {
  -                Entry e = table[i];
  -                Entry p = null;
  -                if (e != null) {
  -                    if (e.computedStyleReference instanceof StrongReference) {
  -                        table[i] = e.next;
  -                        count--;
  -                    }
  -                    p = e;
  -                    e = e.next;
  -                }
  -                while (e != null) {
  -                    if (e.computedStyleReference instanceof StrongReference) {
  -                        p.next = e.next;
  -                        count--;
  -                    }
  -                    p = e;
  -                    e = e.next;
  -                }
  -            }
  -        }
  -
  -        /**
  -         * Computes a hash code for the given element and pseudo-element.
  -         */
  -        protected int hashCode(Element e, String pe) {
  -            return e.hashCode() ^ pe.hashCode();
  -        }
  -
  -        /**
  -         * To store computed style with a strong reference.
  -         */
  -        protected static class StrongReference extends SoftReference {
  -            
  -            /**
  -             * A strong reference.
  -             */
  -            protected Object reference;
  -
  -            /**
  -             * Creates a new strong reference.
  -             */
  -            public StrongReference(Object o) {
  -                super(o);
  -                reference = o;
  -            }
  -        }
  -
  -        /**
  -         * To manage collisions in the table.
  -         */
  -        protected static class Entry {
  -            
  -            /**
  -             * The hash code
  -             */
  -            public int hash;
  -     
  -            /**
  -             * The element.
  -             */
  -            public Element element;
  -
  -            /**
  -             * The pseudo-element.
  -             */
  -            public String pseudoElement;
  -
  -            /**
  -             * The computed style.
  -             */
  -            public SoftReference computedStyleReference;
  -
  -            /**
  -             * The next entry.
  -             */
  -            public Entry next;
  -
  -            /**
  -             * Creates a new entry.
  -             */
  -            public Entry(int h, Element e, String pe, SoftReference sd, Entry n) {
  -                hash = h;
  -                element = e;
  -                pseudoElement = pe;
  -                computedStyleReference = sd;
  -                next = n;
  -            }
  -
  -            /**
  -             * Whether this entry match the given keys.
  -             */
  -            public boolean match(Element e, String pe) {
  -                if (e == element) {
  -                    if (pe.equals(pseudoElement)) {
  -                        return true;
  -                    }
  -                }
  -                return false;
  -            }
  -        }
       }
   }
  
  
  
  1.11      +38 -2     
xml-batik/sources/org/apache/batik/css/CSSOMReadOnlyStyleDeclaration.java
  
  Index: CSSOMReadOnlyStyleDeclaration.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/css/CSSOMReadOnlyStyleDeclaration.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CSSOMReadOnlyStyleDeclaration.java        2001/03/18 16:29:22     1.10
  +++ CSSOMReadOnlyStyleDeclaration.java        2001/10/17 14:47:26     1.11
  @@ -29,7 +29,7 @@
    * interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: CSSOMReadOnlyStyleDeclaration.java,v 1.10 2001/03/18 16:29:22 
hillion Exp $
  + * @version $Id: CSSOMReadOnlyStyleDeclaration.java,v 1.11 2001/10/17 14:47:26 
hillion Exp $
    */
   public class CSSOMReadOnlyStyleDeclaration implements CSSStyleDeclaration {
       /**
  @@ -70,6 +70,15 @@
       }
   
       /**
  +     * Creates a new CSSOMReadOnlyStyleDeclaration object.
  +     */
  +    public CSSOMReadOnlyStyleDeclaration(CSSOMReadOnlyStyleDeclaration sd) {
  +        properties = new PropertyMap(sd.properties);
  +        viewCSS = sd.viewCSS;
  +        parentElement = sd.parentElement;
  +    }
  +
  +    /**
        * Sets the declaration context.
        */
       public void setContext(AbstractViewCSS v, Element elt) {
  @@ -560,6 +569,33 @@
           }
   
           /**
  +         * Creates a copy of the given PropertyMap object.
  +         * @param t The table to copy.
  +         */
  +        public PropertyMap(PropertyMap t) {
  +            count = t.count;
  +            table = new ValueEntry[t.table.length];
  +            for (int i = 0; i < table.length; i++) {
  +                ValueEntry e = t.table[i];
  +                ValueEntry n = null;
  +                if (e != null) {
  +                    n = createValueEntry(e.value, e.getPriority(),
  +                                         e.getOrigin());
  +                    n.initialize(e.hash, e.key, null);
  +                    table[i] = n;
  +                    e = e.next;
  +                    while (e != null) {
  +                        n.next = createValueEntry(e.value, e.getPriority(),
  +                                                  e.getOrigin());
  +                        n = n.next;
  +                        n.initialize(e.hash, e.key, null);
  +                        e = e.next;
  +                    }
  +                }
  +            }
  +        }
  +
  +        /**
            * Returns the size of this table.
            */
           public int size() {
  @@ -715,7 +751,7 @@
           protected void rehash () {
               ValueEntry[] oldTable = table;
        
  -            table     = new ValueEntry[oldTable.length * 2 + 1];
  +            table = new ValueEntry[oldTable.length * 2 + 1];
        
               for (int i = oldTable.length-1; i >= 0; i--) {
                   for (ValueEntry old = oldTable[i]; old != null;) {
  
  
  
  1.2       +2 -1      
xml-batik/sources/org/apache/batik/css/ExtendedElementCSSInlineStyle.java
  
  Index: ExtendedElementCSSInlineStyle.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/css/ExtendedElementCSSInlineStyle.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExtendedElementCSSInlineStyle.java        2000/10/10 18:37:18     1.1
  +++ ExtendedElementCSSInlineStyle.java        2001/10/17 14:47:26     1.2
  @@ -14,9 +14,10 @@
    * This interface extends the {@link org.w3c.dom.css.ElementCSSInlineStyle}.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: ExtendedElementCSSInlineStyle.java,v 1.1 2000/10/10 18:37:18 
hillion Exp $
  + * @version $Id: ExtendedElementCSSInlineStyle.java,v 1.2 2001/10/17 14:47:26 
hillion Exp $
    */
   public interface ExtendedElementCSSInlineStyle extends ElementCSSInlineStyle {
  +
       /**
        * Whether the element that implements this interface has a specified
        * style attribute.
  
  
  
  1.3       +11 -1     xml-batik/sources/org/apache/batik/css/HiddenChildElement.java
  
  Index: HiddenChildElement.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/HiddenChildElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HiddenChildElement.java   2000/10/23 09:44:25     1.2
  +++ HiddenChildElement.java   2001/10/17 14:47:26     1.3
  @@ -15,7 +15,7 @@
    * of another element without being added to the DOM tree.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: HiddenChildElement.java,v 1.2 2000/10/23 09:44:25 hillion Exp $
  + * @version $Id: HiddenChildElement.java,v 1.3 2001/10/17 14:47:26 hillion Exp $
    */
   public interface HiddenChildElement {
       /**
  @@ -27,4 +27,14 @@
        * Sets the parent element of this element.
        */
       void setParentElement(Element elt);
  +
  +    /**
  +     * Sets the cascaded style of this element.
  +     */
  +    CSSOMReadOnlyStyleDeclaration getCascadedStyle();
  +
  +    /**
  +     * Sets the cascaded style of this element.
  +     */
  +    void setCascadedStyle(CSSOMReadOnlyStyleDeclaration sd);
   }
  
  
  
  1.2       +23 -2     
xml-batik/sources/org/apache/batik/css/HiddenChildElementSupport.java
  
  Index: HiddenChildElementSupport.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/css/HiddenChildElementSupport.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HiddenChildElementSupport.java    2000/10/24 11:41:50     1.1
  +++ HiddenChildElementSupport.java    2001/10/17 14:47:26     1.2
  @@ -15,7 +15,7 @@
    * This class provides utility methods for HiddenChildElement support.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: HiddenChildElementSupport.java,v 1.1 2000/10/24 11:41:50 hillion 
Exp $
  + * @version $Id: HiddenChildElementSupport.java,v 1.2 2001/10/17 14:47:26 hillion 
Exp $
    */
   public class HiddenChildElementSupport {
       /**
  @@ -27,7 +27,7 @@
       /**
        * Returns the parent element.
        */
  -    public final static Element getParentElement(Element e) {
  +    public static Element getParentElement(Element e) {
           Node n = e.getParentNode();
           if (n == null) {
               if (e instanceof HiddenChildElement) {
  @@ -42,5 +42,26 @@
               n = n.getParentNode();
           } while (n != null); 
           return null;
  +    }
  +
  +    /**
  +     * Recursively imports the style from the 'src' element.
  +     */
  +    public static void setStyle(Element e,
  +                                AbstractViewCSS ev,
  +                                Element src,
  +                                AbstractViewCSS srcv) {
  +        CSSOMReadOnlyStyleDeclaration sd;
  +        sd = (CSSOMReadOnlyStyleDeclaration)srcv.computeStyle(src, null);
  +        ((HiddenChildElement)e).setCascadedStyle(sd);
  +        sd.setContext(ev, e);
  +        
  +        for (Node en = e.getFirstChild(), sn = src.getFirstChild();
  +             en != null;
  +             en = en.getNextSibling(), sn = sn.getNextSibling()) {
  +            if (en.getNodeType() == Node.ELEMENT_NODE) {
  +                setStyle((Element)en, ev, (Element)sn, srcv);
  +            }
  +        }
       }
   }
  
  
  
  1.2       +7 -15     xml-batik/sources/org/apache/batik/css/PropertyMap.java
  
  Index: PropertyMap.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/PropertyMap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertyMap.java  2000/10/10 18:37:18     1.1
  +++ PropertyMap.java  2001/10/17 14:47:26     1.2
  @@ -13,7 +13,7 @@
    * equality test made with '=='.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: PropertyMap.java,v 1.1 2000/10/10 18:37:18 hillion Exp $
  + * @version $Id: PropertyMap.java,v 1.2 2001/10/17 14:47:26 hillion Exp $
    */
   public class PropertyMap {
       /**
  @@ -37,16 +37,10 @@
       protected int count;
            
       /**
  -     * The resizing threshold
  -     */
  -    protected int threshold;
  -         
  -    /**
        * Creates a new table.
        */
       public PropertyMap() {
  -     table     = new Entry[INITIAL_CAPACITY];
  -     threshold = (int)(INITIAL_CAPACITY * LOAD_FACTOR);
  +     table = new Entry[INITIAL_CAPACITY];
       }
   
       /**
  @@ -54,7 +48,6 @@
        * @param t The table to copy.
        */
       public PropertyMap(PropertyMap t) {
  -     threshold = t.threshold;
        count = t.count;
        table = new Entry[t.table.length];
        for (int i = 0; i < table.length; i++) {
  @@ -113,7 +106,8 @@
        }
        
        // The key is not in the hash table
  -     if (count++ >= threshold) {
  +        int len = table.length;
  +     if (count++ >= (len * 3) >>> 2) {
            rehash();
            index = hash % table.length;
        }
  @@ -198,9 +192,8 @@
        * Clears the map.
        */
       public void clear() {
  -     table     = new Entry[INITIAL_CAPACITY];
  -     threshold = (int)(INITIAL_CAPACITY * LOAD_FACTOR);
  -     count     = 0;
  +     table = new Entry[INITIAL_CAPACITY];
  +     count = 0;
       }
   
       /**
  @@ -209,8 +202,7 @@
       protected void rehash () {
        Entry[] oldTable = table;
        
  -     table     = new Entry[oldTable.length * 2 + 1];
  -     threshold = (int)(table.length * LOAD_FACTOR);
  +     table = new Entry[oldTable.length * 2 + 1];
        
        for (int i = oldTable.length-1; i >= 0; i--) {
            for (Entry old = oldTable[i]; old != null;) {
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/css/ElementWithBaseURI.java
  
  Index: ElementWithBaseURI.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.css;
  
  /**
   * This interface represents elements which are able to compute their
   * base URI.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
   * @version $Id: ElementWithBaseURI.java,v 1.1 2001/10/17 14:47:26 hillion Exp $
   */
  public interface ElementWithBaseURI {
      
      /**
       * Returns this element's base URI. Must be absolute.
       */
      String getBaseURI();
  }
  
  
  
  1.7       +3 -3      xml-batik/sources/org/apache/batik/dom/AbstractAttr.java
  
  Index: AbstractAttr.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractAttr.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractAttr.java 2001/10/17 12:02:07     1.6
  +++ AbstractAttr.java 2001/10/17 14:47:26     1.7
  @@ -20,7 +20,7 @@
    * This class implements the {@link org.w3c.dom.Attr} interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: AbstractAttr.java,v 1.6 2001/10/17 12:02:07 tkormann Exp $
  + * @version $Id: AbstractAttr.java,v 1.7 2001/10/17 14:47:26 hillion Exp $
    */
   public abstract class AbstractAttr extends AbstractParentNode implements Attr {
       /**
  @@ -195,14 +195,14 @@
        * Called when a child node has been added.
        */
       protected void nodeAdded(Node n) {
  -     setSpecified(true);
  +        setSpecified(true);
       }
   
       /**
        * Called when a child node is going to be removed.
        */
       protected void nodeToBeRemoved(Node n) {
  -     setSpecified(true);
  +        setSpecified(true);
       }
   
       /**
  
  
  
  1.10      +3 -2      xml-batik/sources/org/apache/batik/dom/AbstractDocument.java
  
  Index: AbstractDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractDocument.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractDocument.java     2001/09/12 08:54:33     1.9
  +++ AbstractDocument.java     2001/10/17 14:47:26     1.10
  @@ -20,10 +20,11 @@
   
   import org.apache.batik.dom.events.DocumentEventSupport;
   import org.apache.batik.dom.traversal.TraversalSupport;
  -import org.apache.batik.dom.util.SoftDoublyIndexedTable;
   import org.apache.batik.i18n.Localizable;
   import org.apache.batik.i18n.LocalizableSupport;
   
  +import org.apache.batik.util.SoftDoublyIndexedTable;
  +
   import org.w3c.dom.Attr;
   import org.w3c.dom.Document;
   import org.w3c.dom.DocumentType;
  @@ -44,7 +45,7 @@
    * This class implements the {@link org.w3c.dom.Document} interface.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: AbstractDocument.java,v 1.9 2001/09/12 08:54:33 hillion Exp $
  + * @version $Id: AbstractDocument.java,v 1.10 2001/10/17 14:47:26 hillion Exp $
    */
   public abstract class AbstractDocument
       extends    AbstractParentNode
  
  
  
  1.5       +39 -3     xml-batik/sources/org/apache/batik/dom/svg/AbstractElement.java
  
  Index: AbstractElement.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/AbstractElement.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractElement.java      2001/09/27 09:57:13     1.4
  +++ AbstractElement.java      2001/10/17 14:47:26     1.5
  @@ -8,6 +8,8 @@
   
   package org.apache.batik.dom.svg;
   
  +import org.apache.batik.css.CSSOMReadOnlyStyleDeclaration;
  +import org.apache.batik.css.ElementWithBaseURI;
   import org.apache.batik.css.ElementWithID;
   import org.apache.batik.css.ElementWithPseudoClass;
   import org.apache.batik.css.HiddenChildElement;
  @@ -18,7 +20,7 @@
   
   import org.apache.batik.dom.events.NodeEventTarget;
   
  -import org.apache.batik.dom.util.SoftDoublyIndexedTable;
  +import org.apache.batik.util.SoftDoublyIndexedTable;
   
   import org.w3c.dom.Attr;
   import org.w3c.dom.DOMException;
  @@ -33,11 +35,12 @@
    * an element interoperable with the SVG elements.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: AbstractElement.java,v 1.4 2001/09/27 09:57:13 hillion Exp $
  + * @version $Id: AbstractElement.java,v 1.5 2001/10/17 14:47:26 hillion Exp $
    */
   public abstract class AbstractElement
       extends org.apache.batik.dom.AbstractElement
  -    implements ElementWithID,
  +    implements ElementWithBaseURI,
  +               ElementWithID,
                  ElementWithPseudoClass,
                  HiddenChildElement {
       
  @@ -52,6 +55,11 @@
       protected transient SoftDoublyIndexedTable liveAttributeValues;
   
       /**
  +     * The cascaded style, if any.
  +     */
  +    protected transient CSSOMReadOnlyStyleDeclaration cascadedStyle;
  +
  +    /**
        * Creates a new Element object.
        */
       protected AbstractElement() {
  @@ -68,6 +76,20 @@
        initializeAttributes();
       }
   
  +    // ElementWithBaseURI ////////////////////////////////////////////
  +
  +    /**
  +     * Returns this element's base URI.
  +     */
  +    public String getBaseURI() {
  +        try {
  +            return new java.net.URL(((SVGOMDocument)ownerDocument).getURLObject(),
  +                                    XMLBaseSupport.getXMLBase(this)).toString();
  +        } catch (java.net.MalformedURLException e) {
  +            throw new RuntimeException(e.getMessage());
  +        }
  +    }
  +
       // ElementWithID /////////////////////////////////////////////////
   
       /**
  @@ -122,6 +144,20 @@
        */
       public void setParentElement(Element elt) {
           parentElement = elt;
  +    }
  +
  +    /**
  +     * Sets the cascaded style of this element.
  +     */
  +    public CSSOMReadOnlyStyleDeclaration getCascadedStyle() {
  +        return cascadedStyle;
  +    }
  +
  +    /**
  +     * Sets the cascaded style of this element.
  +     */
  +    public void setCascadedStyle(CSSOMReadOnlyStyleDeclaration sd) {
  +        cascadedStyle = sd;
       }
   
       /**
  
  
  
  1.2       +3 -85     
xml-batik/sources/org/apache/batik/extension/ExtensionElement.java
  
  Index: ExtensionElement.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/extension/ExtensionElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExtensionElement.java     2001/05/10 13:36:06     1.1
  +++ ExtensionElement.java     2001/10/17 14:47:26     1.2
  @@ -8,42 +8,19 @@
   
   package org.apache.batik.extension;
   
  -import org.apache.batik.css.ElementWithID;
  -import org.apache.batik.css.ElementWithPseudoClass;
  -import org.apache.batik.css.HiddenChildElement;
  -import org.apache.batik.css.HiddenChildElementSupport;
  -
   import org.apache.batik.dom.AbstractDocument;
  -import org.apache.batik.dom.AbstractElement;
  -
  -import org.w3c.dom.DOMException;
  -import org.w3c.dom.Element;
  -import org.w3c.dom.Node;
  +import org.apache.batik.dom.svg.AbstractElement;
   
   /**
    * This class implements the basic features an element must have in order
    * to be usable as a foreign element within an SVGOMDocument.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: ExtensionElement.java,v 1.1 2001/05/10 13:36:06 hillion Exp $
  + * @version $Id: ExtensionElement.java,v 1.2 2001/10/17 14:47:26 hillion Exp $
    */
  -public abstract class ExtensionElement
  -    extends    AbstractElement
  -    implements ElementWithID,
  -               ElementWithPseudoClass,
  -               HiddenChildElement {
  -    
  -    /**
  -     * The element ID attribute name.
  -     */
  -    protected final static String ID_NAME = "id";
  +public abstract class ExtensionElement extends AbstractElement {
   
       /**
  -     * The parent element.
  -     */
  -    protected transient Element parentElement;
  -
  -    /**
        * Creates a new Element object.
        */
       protected ExtensionElement() {
  @@ -57,24 +34,6 @@
       protected ExtensionElement(String name, AbstractDocument owner) {
           super(name, owner);
       }
  -    
  -    // HiddenChildElement //////////////////////////////////////////////////
  -
  -    /**
  -     * The parent element of this element.
  -     */
  -    public Element getParentElement() {
  -        return parentElement;
  -    }
  -
  -    /**
  -     * Sets the parent element.
  -     */
  -    public void setParentElement(Element elt) {
  -        parentElement = elt;
  -    }
  -
  -    // ExtendedNode //////////////////////////////////////////////////
   
       /**
        * Tests whether this node is readonly.
  @@ -88,45 +47,4 @@
        */
       public void setReadonly(boolean v) {
       }
  -
  -    // ElementWithID /////////////////////////////////////////////////
  -
  -    /**
  -     * Sets the element ID attribute name.
  -     * @param uri The namespace uri.
  -     * @param s   The attribute local name.
  -     */
  -    public void setIDName(String uri, String s) {
  -        if (uri != null || s == null || !s.equals(ID_NAME)) {
  -         throw createDOMException
  -             (DOMException.NO_MODIFICATION_ALLOWED_ERR,
  -              "id.name",
  -              new Object[] { s });
  -        }
  -    }
  -
  -    /**
  -     * Returns the ID of this element or the empty string.
  -     */
  -    public String getID() {
  -        return getAttribute(ID_NAME);
  -    }
  -
  -    // ElementWithPseudoClass ////////////////////////////////////////
  -
  -    /**
  -     * Whether this element matches the given pseudo-class.
  -     * This methods supports the :first-child pseudo class.
  -     */
  -    public boolean matchPseudoClass(String pseudoClass) {
  -        if (pseudoClass.equals("first-child")) {
  -            Node n = getPreviousSibling();
  -            while (n != null && n.getNodeType() != ELEMENT_NODE) {
  -                n = n.getPreviousSibling();
  -            }
  -            return n == null;
  -        }
  -        return false;
  -    }
  -
   }
  
  
  

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

Reply via email to