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"
59 class nsDOMCSSDeclaration
: public nsICSSDeclaration
,
60 public nsIDOMCSS2Properties
63 // Only implement QueryInterface; subclasses have the responsibility
64 // of implementing AddRef/Release.
65 NS_IMETHOD
QueryInterface(REFNSIID aIID
, void** aInstancePtr
);
67 NS_DECL_NSICSSDECLARATION
69 // Require subclasses to implement |GetParentRule|.
70 //NS_DECL_NSIDOMCSSSTYLEDECLARATION
71 NS_IMETHOD
GetCssText(nsAString
& aCssText
);
72 NS_IMETHOD
SetCssText(const nsAString
& aCssText
);
73 NS_IMETHOD
GetPropertyValue(const nsAString
& propertyName
,
75 NS_IMETHOD
GetPropertyCSSValue(const nsAString
& propertyName
,
76 nsIDOMCSSValue
**_retval
);
77 NS_IMETHOD
RemoveProperty(const nsAString
& propertyName
,
79 NS_IMETHOD
GetPropertyPriority(const nsAString
& propertyName
,
81 NS_IMETHOD
SetProperty(const nsAString
& propertyName
,
82 const nsAString
& value
, const nsAString
& priority
);
83 NS_IMETHOD
GetLength(PRUint32
*aLength
);
84 NS_IMETHOD
Item(PRUint32 index
, nsAString
& _retval
);
85 NS_IMETHOD
GetParentRule(nsIDOMCSSRule
* *aParentRule
) = 0;
87 // We implement this as a shim which forwards to GetPropertyValue
88 // and SetPropertyValue; subclasses need not.
89 NS_DECL_NSIDOMCSS2PROPERTIES
92 // This method can return null regardless of the value of aAllocate;
93 // however, a null return should only be considered a failure
94 // if aAllocate is true.
95 virtual mozilla::css::Declaration
* GetCSSDeclaration(PRBool aAllocate
) = 0;
96 virtual nsresult
SetCSSDeclaration(mozilla::css::Declaration
* aDecl
) = 0;
97 // Document that we must call BeginUpdate/EndUpdate on around the
98 // calls to SetCSSDeclaration and the style rule mutation that leads
100 virtual nsIDocument
* DocToUpdate() = 0;
102 // This will only fail if it can't get a parser or a principal.
103 // This means it can return NS_OK without aURI or aCSSLoader being
105 virtual nsresult
GetCSSParsingEnvironment(nsIURI
** aSheetURI
,
107 nsIPrincipal
** aSheetPrincipal
,
108 mozilla::css::Loader
** aCSSLoader
) = 0;
110 nsresult
ParsePropertyValue(const nsCSSProperty aPropID
,
111 const nsAString
& aPropValue
,
112 PRBool aIsImportant
);
114 // Prop-id based version of RemoveProperty. Note that this does not
115 // return the old value; it just does a straight removal.
116 nsresult
RemoveProperty(const nsCSSProperty aPropID
);
119 virtual ~nsDOMCSSDeclaration();
122 #endif // nsDOMCSSDeclaration_h___