hillion 02/05/23 02:01:36 Modified: sources/org/apache/batik/css/engine CSSEngine.java test-resources/org/apache/batik/dom/svg unitTesting.xml Added: test-resources/org/apache/batik/dom/svg presentationAttrRemovalTest.svg Log: Fixed a bug with CSS computed style and presentation attributes removal + test. Revision Changes Path 1.13 +44 -21 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- CSSEngine.java 21 May 2002 09:51:38 -0000 1.12 +++ CSSEngine.java 23 May 2002 09:01:36 -0000 1.13 @@ -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.12 2002/05/21 09:51:38 hillion Exp $ + * @version $Id: CSSEngine.java,v 1.13 2002/05/23 09:01:36 hillion Exp $ */ public abstract class CSSEngine { @@ -1930,27 +1930,50 @@ boolean comp = style.isComputed(idx); - element = elt; - try { - LexicalUnit lu; - lu = parser.parsePropertyValue(evt.getNewValue()); - ValueManager vm = valueManagers[idx]; - Value v = vm.createValue(lu, CSSEngine.this); - style.putMask(idx, (short)0); - style.putValue(idx, v); - 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 }); - throw new DOMException(DOMException.SYNTAX_ERR, s); + switch (evt.getAttrChange()) { + case MutationEvent.ADDITION: + case MutationEvent.MODIFICATION: + element = elt; + try { + LexicalUnit lu; + lu = parser.parsePropertyValue(evt.getNewValue()); + ValueManager vm = valueManagers[idx]; + Value v = vm.createValue(lu, CSSEngine.this); + style.putMask(idx, (short)0); + style.putValue(idx, v); + 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 }); + throw new DOMException(DOMException.SYNTAX_ERR, s); + } + element = null; + cssBaseURI = null; + break; + + case MutationEvent.REMOVAL: + // Invalidate all the values. + elt.setComputedStyleMap(null, null); + + firePropertiesChangedEvent(elt, ALL_PROPERTIES); + + Node c = getImportedChild(elt); + if (c != null) { + propagateChanges(c, ALL_PROPERTIES); + } + for (Node n = elt.getFirstChild(); + n != null; + n = n.getNextSibling()) { + propagateChanges(n, ALL_PROPERTIES); + } + return; } - element = null; - cssBaseURI = null; if (!comp) { // The previous value was not computed: nobody is 1.4 +3 -2 xml-batik/test-resources/org/apache/batik/dom/svg/unitTesting.xml Index: unitTesting.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/dom/svg/unitTesting.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- unitTesting.xml 2 May 2002 14:15:03 -0000 1.3 +++ unitTesting.xml 23 May 2002 09:01:36 -0000 1.4 @@ -8,7 +8,7 @@ <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: unitTesting.xml,v 1.3 2002/05/02 14:15:03 hillion Exp $ --> +<!-- @version $Id: unitTesting.xml,v 1.4 2002/05/23 09:01:36 hillion Exp $ --> <!-- ========================================================================= --> <testSuite id="dom.svg.unitTesting" name="org.apache.batik.dom.svg package - Unit Testing"> @@ -36,10 +36,11 @@ <!-- ================================================================ --> <!-- Self contained tests --> <!-- ================================================================ --> - <testGroup id="basic" name="Basic SVG DOM Testing" + <testGroup id="dom.svg.basic" name="Basic SVG DOM Testing" class="org.apache.batik.dom.svg.EcmaScriptSVGDOMTest"> <test id="lengthTest"/> <test id="locatableTest"/> + <test id="presentationAttrRemovalTest"/> </testGroup> </testSuite> 1.1 xml-batik/test-resources/org/apache/batik/dom/svg/presentationAttrRemovalTest.svg Index: presentationAttrRemovalTest.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: presentationAttrRemovalTest.svg,v 1.1 2002/05/23 09:01:36 hillion Exp $ --> <!-- ========================================================================= --> <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"); result.setAttributeNS(null, "result", "failed"); var r1 = document.getElementById("r1") if (r1 == 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", "r1"); result.appendChild(entry); return; } var compStyle = document.documentElement.getComputedStyle(r1, null); if (compStyle.getPropertyValue("fill") != "rgb(0, 255, 0)") { result.setAttributeNS(null, "errorCode", "wrong.computed.style"); var entry = document.createElementNS(testNS, "errorDescriptionEntry"); entry.setAttributeNS(null, "value", "invalid.value"); entry.setAttributeNS(null, "value", compStyle.getPropertyValue("fill")); result.appendChild(entry); return; } r1.removeAttributeNS(null, "fill"); if (compStyle.getPropertyValue("fill") != "rgb(255, 0, 0)") { result.setAttributeNS(null, "errorCode", "wrong.computed.style"); var entry = document.createElementNS(testNS, "errorDescriptionEntry"); entry.setAttributeNS(null, "value", "invalid.value"); entry.setAttributeNS(null, "value", compStyle.getPropertyValue("fill")); result.appendChild(entry); return; } result.setAttributeNS(null, "result", "passed"); } ]]></script> <g fill="rgb(255, 0, 0)"> <rect id="r1" x="0" y="0" width="100" height="100" fill="rgb(0, 255, 0)"/> <rect id="r2" x="20" y="20" width="100" height="100"/> </g> </svg>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]