Return-Path: Delivered-To: apmail-xml-batik-dev-archive@xml.apache.org Received: (qmail 30995 invoked by uid 500); 10 Jun 2002 14:04:24 -0000 Mailing-List: contact batik-dev-help@xml.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: batik-dev@xml.apache.org Delivered-To: mailing list batik-dev@xml.apache.org Received: (qmail 30984 invoked by uid 500); 10 Jun 2002 14:04:24 -0000 Delivered-To: apmail-xml-batik-cvs@apache.org Date: 10 Jun 2002 14:04:24 -0000 Message-ID: <20020610140424.37305.qmail@icarus.apache.org> From: hillion@apache.org To: xml-batik-cvs@apache.org Subject: cvs commit: xml-batik/test-resources/org/apache/batik/css/dom bug9740-1.css bug9740-2.css bug9740.svg unitTesting.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N hillion 2002/06/10 07:04:24 Modified: sources/org/apache/batik/css/dom CSSOMSVGComputedStyle.java sources/org/apache/batik/css/engine CSSEngine.java test-resources/org/apache/batik/css/dom unitTesting.xml Added: test-resources/org/apache/batik/css/dom bug9740-1.css bug9740-2.css bug9740.svg Log: Fixed bug #9740. Revision Changes Path 1.2 +2 -2 xml-batik/sources/org/apache/batik/css/dom/CSSOMSVGComputedStyle.java Index: CSSOMSVGComputedStyle.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/dom/CSSOMSVGComputedStyle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CSSOMSVGComputedStyle.java 9 Apr 2002 16:27:18 -0000 1.1 +++ CSSOMSVGComputedStyle.java 10 Jun 2002 14:04:23 -0000 1.2 @@ -24,7 +24,7 @@ * This class represents the computed style of an SVG element. * * @author Stephane Hillion - * @version $Id: CSSOMSVGComputedStyle.java,v 1.1 2002/04/09 16:27:18 hillion Exp $ + * @version $Id: CSSOMSVGComputedStyle.java,v 1.2 2002/06/10 14:04:23 hillion Exp $ */ public class CSSOMSVGComputedStyle extends CSSOMComputedStyle { @@ -95,7 +95,7 @@ /** * To manage a computed paint CSSValue. */ - protected class ComputedCSSPaintValue + public class ComputedCSSPaintValue extends CSSOMSVGPaint implements CSSOMSVGPaint.ValueProvider { 1.14 +60 -15 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- CSSEngine.java 23 May 2002 09:01:36 -0000 1.13 +++ CSSEngine.java 10 Jun 2002 14:04:24 -0000 1.14 @@ -58,7 +58,7 @@ * This is the base class for all the CSS engines. * * @author Stephane Hillion - * @version $Id: CSSEngine.java,v 1.13 2002/05/23 09:01:36 hillion Exp $ + * @version $Id: CSSEngine.java,v 1.14 2002/06/10 14:04:24 hillion Exp $ */ public abstract class CSSEngine { @@ -648,14 +648,16 @@ // Apply the user-agent style-sheet to the result. if (userAgentStyleSheet != null) { - putStyleSheetRules(elt, pseudo, result, userAgentStyleSheet, - StyleMap.USER_AGENT_ORIGIN); + List rules = new ArrayList(); + addMatchingRules(rules, userAgentStyleSheet, elt, pseudo); + addRules(elt, pseudo, result, rules, StyleMap.USER_AGENT_ORIGIN); } // Apply the user properties style-sheet to the result. if (userStyleSheet != null) { - putStyleSheetRules(elt, pseudo, result, userStyleSheet, - StyleMap.USER_ORIGIN); + List rules = new ArrayList(); + addMatchingRules(rules, userStyleSheet, elt, pseudo); + addRules(elt, pseudo, result, rules, StyleMap.USER_ORIGIN); } element = elt; @@ -693,17 +695,20 @@ // Apply the document style-sheets to the result. List snodes = getStyleSheetNodes(); int slen = snodes.size(); - for (int i = 0; i < slen; i++) { - CSSStyleSheetNode ssn = (CSSStyleSheetNode)snodes.get(i); - StyleSheet ss = ssn.getCSSStyleSheet(); - if (ss != null && - (!ss.isAlternate() || - ss.getTitle() == null || - ss.getTitle().equals(alternateStyleSheet)) && - mediaMatch(ss.getMedia())) { - putStyleSheetRules(elt, pseudo, result, ss, - StyleMap.AUTHOR_ORIGIN); + if (slen > 0) { + List rules = new ArrayList(); + for (int i = 0; i < slen; i++) { + CSSStyleSheetNode ssn = (CSSStyleSheetNode)snodes.get(i); + StyleSheet ss = ssn.getCSSStyleSheet(); + if (ss != null && + (!ss.isAlternate() || + ss.getTitle() == null || + ss.getTitle().equals(alternateStyleSheet)) && + mediaMatch(ss.getMedia())) { + addMatchingRules(rules, ss, elt, pseudo); + } } + addRules(elt, pseudo, result, rules, StyleMap.AUTHOR_ORIGIN); } // Apply the inline style to the result. @@ -1131,6 +1136,46 @@ addMatchingRules(rules, mr, elt, pseudo); } break; + } + } + } + + /** + * Adds the rules contained in the given list to a stylemap. + */ + protected void addRules(Element elt, + String pseudo, + StyleMap sm, + List rules, + short origin) { + sortRules(rules, elt, pseudo); + int rlen = rules.size(); + int props = getNumberOfProperties(); + + if (origin == StyleMap.AUTHOR_ORIGIN) { + for (int r = 0; r < rlen; r++) { + StyleRule sr = (StyleRule)rules.get(r); + StyleDeclaration sd = sr.getStyleDeclaration(); + int len = sd.size(); + for (int i = 0; i < len; i++) { + putAuthorProperty(sm, + sd.getIndex(i), + sd.getValue(i), + sd.getPriority(i), + origin); + } + } + } else { + for (int r = 0; r < rlen; r++) { + StyleRule sr = (StyleRule)rules.get(r); + StyleDeclaration sd = sr.getStyleDeclaration(); + int len = sd.size(); + for (int i = 0; i < len; i++) { + int idx = sd.getIndex(i); + sm.putValue(idx, sd.getValue(i)); + sm.putImportant(idx, sd.getPriority(i)); + sm.putOrigin(idx, origin); + } } } } 1.3 +2 -2 xml-batik/test-resources/org/apache/batik/css/dom/unitTesting.xml Index: unitTesting.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/css/dom/unitTesting.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- unitTesting.xml 11 Apr 2002 16:51:36 -0000 1.2 +++ unitTesting.xml 10 Jun 2002 14:04:24 -0000 1.3 @@ -8,7 +8,7 @@ - + @@ -17,6 +17,6 @@ + - 1.1 xml-batik/test-resources/org/apache/batik/css/dom/bug9740-1.css Index: bug9740-1.css =================================================================== rect.redBackground { fill: red;} 1.1 xml-batik/test-resources/org/apache/batik/css/dom/bug9740-2.css Index: bug9740-2.css =================================================================== rect {stroke: white; fill: #a0a0a0;} 1.1 xml-batik/test-resources/org/apache/batik/css/dom/bug9740.svg Index: bug9740.svg =================================================================== --------------------------------------------------------------------- To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org For additional commands, e-mail: batik-dev-help@xml.apache.org