/*
 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

module css {

    // Introduced in DOM Level 2:
    interface [
        GenerateConstructor,
        DelegatingPutFunction,
        HasNameGetter,
        HasIndexGetter,
        InterfaceUUID=9989b2c3-a2b6-449b-abf9-c60d2260b1d7,
        ImplementationUUID=985c50c7-9f19-436a-9e45-c0aa02996d0e
    ] CSSStyleDeclaration {
                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString        cssText
                     setter raises(DOMException);

        [ConvertNullStringTo=Null] DOMString          getPropertyValue(in DOMString propertyName);
        CSSValue           getPropertyCSSValue(in DOMString propertyName);
        [ConvertNullStringTo=Null] DOMString          removeProperty(in DOMString propertyName)
            raises(DOMException);
        [ConvertNullStringTo=Null] DOMString          getPropertyPriority(in DOMString propertyName);
        [OldStyleObjC] void setProperty(in DOMString propertyName, 
                                        in [ConvertNullToNullString] DOMString value, 
                                        in DOMString priority)
            raises(DOMException);

        readonly attribute unsigned long    length;
        [ConvertNullStringTo=Null] DOMString          item(in unsigned long index);
        readonly attribute CSSRule          parentRule;

        // Extensions
        [ConvertNullStringTo=Null] DOMString          getPropertyShorthand(in DOMString propertyName);
        boolean            isPropertyImplicit(in DOMString propertyName);
    };

}
