deweese 2003/07/20 16:23:27 Modified: samples/tests/spec/scripting styling.svg sources/org/apache/batik/css/engine CSSEngine.java Log: 1) Class and attribute selectors now work with sibling selectors. Revision Changes Path 1.2 +17 -1 xml-batik/samples/tests/spec/scripting/styling.svg Index: styling.svg =================================================================== RCS file: /home/cvs/xml-batik/samples/tests/spec/scripting/styling.svg,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- styling.svg 20 Jul 2003 22:32:30 -0000 1.1 +++ styling.svg 20 Jul 2003 23:23:27 -0000 1.2 @@ -47,6 +47,11 @@ .checkbox > rect { fill: white; stroke: black; stroke-width: 1; } .checkbox[selected=true] > path { visibility: visible;} .checkbox[selected=false] > path { visibility: hidden; } + + .a { fill: red; } + .b { fill: orange; } + rect.a + .b { fill: blue; } + ]]></style> <script type="text/ecmascript"><![CDATA[ @@ -88,6 +93,7 @@ } } + function regardStart() { var e; removeTarget(document.getElementById("rm1")) @@ -101,6 +107,8 @@ document.getElementById("test5").setAttribute("id", "foo"); regardTestInstance.scriptDone(); toggleSelected(document.getElementById("cb")); + + document.getElementById("a").setAttribute("class", ""); } ]]></script> @@ -136,9 +144,17 @@ </g> <g id="cb" class="checkbox" selected="true" transform="translate(10, 225)" - onclick="toggleSelected(evt)"> + onclick="toggleSelectedEvt(evt)"> <rect width="15" height="15" fill="white" stroke="black"/> <path d="M3,3 L12,12 M12,3 L3,12"/> </g> + <g fill="white" stroke="black"> + <rect id="a" class="a" x="10" y="275" width="100" height="50" + onclick="setAttributeEvt(evt, 'class', '')"/> + <rect id="b" class="b" x="150" y="275" width="100" height="50"/> + <g/> + <text x="25" y="300" pointer-events="none" + style="fill: black; stroke: none">Click Me</text> + </g> </svg> 1.25 +30 -35 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.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- CSSEngine.java 20 Jul 2003 22:32:30 -0000 1.24 +++ CSSEngine.java 20 Jul 2003 23:23:27 -0000 1.25 @@ -2153,49 +2153,39 @@ return; } - CSSStylableElement elt = (CSSStylableElement)et; - StyleMap style = elt.getComputedStyleMap(null); - if (style == null) { - // Nobody ever asked for the computed style of the - // element, so it does not require an update... - return; - } - MutationEvent mevt = (MutationEvent)evt; Node attr = mevt.getRelatedNode(); String attrNS = attr.getNamespaceURI(); - if ((attrNS == null && styleNamespaceURI == null) || - (attrNS != null && attrNS.equals(styleNamespaceURI))) { - String name = (attrNS == null) - ? attr.getNodeName() - : attr.getLocalName(); - if (name.equals(styleLocalName)) { - // The style declaration attribute has been modified. - - inlineStyleAttributeUpdated(elt, style, mevt); - - return; - } - } - String name = (attrNS == null) ? attr.getNodeName() : attr.getLocalName(); - - if (nonCSSPresentationalHints != null) { - if ((attrNS == null && - nonCSSPresentationalHintsNamespaceURI == null) || - (attrNS != null && - attrNS.equals(nonCSSPresentationalHintsNamespaceURI))) { - if (nonCSSPresentationalHints.contains(name)) { - // The 'name' attribute which represents a non CSS - // presentational hint has been modified. - - nonCSSPresentationalHintUpdated(elt, style, name, - mevt); + + CSSStylableElement elt = (CSSStylableElement)et; + StyleMap style = elt.getComputedStyleMap(null); + if (style != null) { + if ((attrNS == null && styleNamespaceURI == null) || + (attrNS != null && attrNS.equals(styleNamespaceURI))) { + if (name.equals(styleLocalName)) { + // The style declaration attribute has been modified. + inlineStyleAttributeUpdated(elt, style, mevt); return; } } + + if (nonCSSPresentationalHints != null) { + if ((attrNS == null && + nonCSSPresentationalHintsNamespaceURI == null) || + (attrNS != null && + attrNS.equals(nonCSSPresentationalHintsNamespaceURI))) { + if (nonCSSPresentationalHints.contains(name)) { + // The 'name' attribute which represents a non CSS + // presentational hint has been modified. + nonCSSPresentationalHintUpdated(elt, style, name, + mevt); + return; + } + } + } } if (selectorAttributes != null && @@ -2203,6 +2193,11 @@ // An attribute has been modified, invalidate all the // properties to correctly match attribute selectors. invalidateProperties(elt, null); + for (Node n = elt.getNextSibling(); + n != null; + n = n.getNextSibling()) { + invalidateProperties(n, null); + } } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]