01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19:
20: package org.apache.batik.css.dom;
21:
22: import org.apache.batik.css.engine.CSSEngine;
23: import org.apache.batik.css.engine.CSSStylableElement;
24: import org.w3c.dom.Element;
25: import org.w3c.dom.css.CSSStyleDeclaration;
26: import org.w3c.dom.css.ViewCSS;
27: import org.w3c.dom.views.DocumentView;
28:
29: /**
30: * This class represents an object which provides the computed styles
31: * of the elements of a document.
32: *
33: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
34: * @version $Id: CSSOMViewCSS.java 475477 2006-11-15 22:44:28Z cam $
35: */
36: public class CSSOMViewCSS implements ViewCSS {
37:
38: /**
39: * The associated CSS engine.
40: */
41: protected CSSEngine cssEngine;
42:
43: /**
44: * Creates a new ViewCSS.
45: */
46: public CSSOMViewCSS(CSSEngine engine) {
47: cssEngine = engine;
48: }
49:
50: /**
51: * <b>DOM</b>: Implements {@link
52: * org.w3c.dom.views.AbstractView#getDocument()}.
53: */
54: public DocumentView getDocument() {
55: return (DocumentView) cssEngine.getDocument();
56: }
57:
58: /**
59: * <b>DOM</b>: Implements {@link
60: * org.w3c.dom.css.ViewCSS#getComputedStyle(Element,String)}.
61: */
62: public CSSStyleDeclaration getComputedStyle(Element elt,
63: String pseudoElt) {
64: if (elt instanceof CSSStylableElement) {
65: return new CSSOMComputedStyle(cssEngine,
66: (CSSStylableElement) elt, pseudoElt);
67: }
68: return null;
69: }
70:
71: }
|