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 <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @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 <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @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 @@ <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: unitTesting.xml,v 1.2 2002/04/11 16:51:36 hillion Exp $ --> +<!-- @version $Id: unitTesting.xml,v 1.3 2002/06/10 14:04:24 hillion Exp $ --> <!-- ========================================================================= --> <testSuite id="css.dom.unitTesting" name="CSS DOM - Unit Testing" class="org.apache.batik.css.dom.EcmaScriptCSSDOMTest"> @@ -17,6 +17,6 @@ <test id="rgbTest" /> <test id="rgbUpdateTest" /> <test id="rgbPresentationTest" /> + <test id="bug9740" /> </testGroup> - </testSuite> 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 =================================================================== <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- ========================================================================= --> <!-- 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. --> <!-- ========================================================================= --> <!-- ========================================================================= --> <!-- This test checks that the various RGB values read from the SVGColor --> <!-- interface return accurate values. --> <!-- --> <!-- @author [EMAIL PROTECTED] --> <!-- @version $Id: bug9740.svg,v 1.1 2002/06/10 14:04:24 hillion Exp $ --> <!-- ========================================================================= --> <?xml-stylesheet href="bug9740-1.css" type="text/css"?> <?xml-stylesheet href="bug9740-2.css" type="text/css"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:test="http://xml.apache.org/batik/test" width="450" height="500" viewBox="0 0 450 500" onload="runTest(evt)"> <test:testResult id="testResult" /> <script type="text/ecmascript"><![CDATA[ var testNS = "http://xml.apache.org/batik/test"; function runTest() { var result = document.getElementById("testResult"); var elt = document.getElementById("targetElement"); result.setAttributeNS(null, "result", "failed"); if (elt == null){ result.setAttributeNS(null, "errorCode", "cannot.find.test.element"); var entry = document.createElementNS(testNS, "errorDescriptionEntry"); entry.setAttributeNS(null, "id", "missing.element.id"); entry.setAttributeNS(null, "value", "targetElement"); result.appendChild(entry); return; } var style = document.documentElement.getComputedStyle(elt, null); if (style == null){ result.setAttributeNS(null, "errorCode", "getComputedStyle() returned null"); return; } var val = style.getPropertyCSSValue("fill"); if ( val == null ){ result.setAttributeNS(null, "errorCode", "CSSStyleDeclaration.getPropertyCSSValue returned null"); return; } val = val.getRGBColor() if (val.red.getFloatValue(1) != 255 || val.green.getFloatValue(1) != 0 || val.blue.getFloatValue(1) != 0) { result.setAttributeNS(null, "errorCode", "invalid color components"); return; } result.setAttributeNS(null, "result", "passed"); } ]]></script> <g fill="blue"> <rect x="10%" y="10%" width="80%" height="80%" id="targetElement" class="redBackground"/> </g> </svg>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]