1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* base class for DOM objects for element.style and cssStyleRule.style */
40 #ifndef nsDOMCSSDeclaration_h___
41 #define nsDOMCSSDeclaration_h___
43 #include "nsICSSDeclaration.h"
44 #include "nsIDOMCSS2Properties.h"
46 class nsCSSDeclaration
;
52 class CSS2PropertiesTearoff
: public nsIDOMNSCSS2Properties
55 NS_DECL_ISUPPORTS_INHERITED
57 NS_DECL_NSIDOMCSS2PROPERTIES
58 NS_DECL_NSIDOMNSCSS2PROPERTIES
60 CSS2PropertiesTearoff(nsICSSDeclaration
*aOuter
);
61 virtual ~CSS2PropertiesTearoff();
64 nsICSSDeclaration
* mOuter
;
67 class nsDOMCSSDeclaration
: public nsICSSDeclaration
70 nsDOMCSSDeclaration();
72 // Only implement QueryInterface; subclasses have the responsibility
73 // of implementing AddRef/Release.
74 NS_IMETHOD
QueryInterface(REFNSIID aIID
, void** aInstancePtr
);
76 NS_DECL_NSICSSDECLARATION
78 // Require subclasses to implement |GetParentRule|.
79 //NS_DECL_NSIDOMCSSSTYLEDECLARATION
80 NS_IMETHOD
GetCssText(nsAString
& aCssText
);
81 NS_IMETHOD
SetCssText(const nsAString
& aCssText
);
82 NS_IMETHOD
GetPropertyValue(const nsAString
& propertyName
,
84 NS_IMETHOD
GetPropertyCSSValue(const nsAString
& propertyName
,
85 nsIDOMCSSValue
**_retval
);
86 NS_IMETHOD
RemoveProperty(const nsAString
& propertyName
,
88 NS_IMETHOD
GetPropertyPriority(const nsAString
& propertyName
,
90 NS_IMETHOD
SetProperty(const nsAString
& propertyName
,
91 const nsAString
& value
, const nsAString
& priority
);
92 NS_IMETHOD
GetLength(PRUint32
*aLength
);
93 NS_IMETHOD
Item(PRUint32 index
, nsAString
& _retval
);
94 NS_IMETHOD
GetParentRule(nsIDOMCSSRule
* *aParentRule
) = 0;
96 virtual void DropReference() = 0;
98 // Always fills in the out parameter, even on failure, and if the out
99 // parameter is null the nsresult will be the correct thing to
101 virtual nsresult
GetCSSDeclaration(nsCSSDeclaration
**aDecl
,
102 PRBool aAllocate
) = 0;
103 virtual nsresult
DeclarationChanged() = 0;
105 // This will only fail if it can't get a parser or a principal.
106 // This means it can return NS_OK without aURI or aCSSLoader being
108 virtual nsresult
GetCSSParsingEnvironment(nsIURI
** aSheetURI
,
110 nsIPrincipal
** aSheetPrincipal
,
111 nsICSSLoader
** aCSSLoader
,
112 nsICSSParser
** aCSSParser
) = 0;
114 nsresult
ParsePropertyValue(const nsCSSProperty aPropID
,
115 const nsAString
& aPropValue
);
116 nsresult
ParseDeclaration(const nsAString
& aDecl
,
117 PRBool aParseOnlyOneDecl
, PRBool aClearOldDecl
);
119 // Prop-id based version of RemoveProperty. Note that this does not
120 // return the old value; it just does a straight removal.
121 nsresult
RemoveProperty(const nsCSSProperty aPropID
);
125 virtual ~nsDOMCSSDeclaration();
128 CSS2PropertiesTearoff mInner
;
131 #endif // nsDOMCSSDeclaration_h___