2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-06 05:39:33 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-10-06 05:39:33 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-10-06 05:39:33 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 05:32:19 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 05:32:19 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/* base class for DOM objects for element.style and cssStyleRule.style */
|
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
#ifndef nsDOMCSSDeclaration_h___
|
2003-10-30 04:40:33 +03:00
|
|
|
#define nsDOMCSSDeclaration_h___
|
1998-10-06 05:39:33 +04:00
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
#include "nsICSSDeclaration.h"
|
2010-08-06 09:32:01 +04:00
|
|
|
#include "nsIDOMCSS2Properties.h"
|
2009-09-18 17:09:55 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1998-10-06 05:39:33 +04:00
|
|
|
|
2010-03-02 23:59:32 +03:00
|
|
|
class nsCSSParser;
|
1999-06-23 07:29:44 +04:00
|
|
|
class nsIURI;
|
2007-05-03 05:15:53 +04:00
|
|
|
class nsIPrincipal;
|
2009-12-11 19:13:19 +03:00
|
|
|
class nsIDocument;
|
1998-10-06 05:39:33 +04:00
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
2010-06-29 02:49:35 +04:00
|
|
|
class Declaration;
|
2010-03-03 00:00:53 +03:00
|
|
|
class Loader;
|
2011-04-08 05:23:46 +04:00
|
|
|
class Rule;
|
2010-03-03 00:00:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-15 00:58:56 +04:00
|
|
|
class nsDOMCSSDeclaration : public nsICSSDeclaration,
|
2010-08-06 09:32:01 +04:00
|
|
|
public nsIDOMCSS2Properties
|
1998-10-06 05:39:33 +04:00
|
|
|
{
|
|
|
|
public:
|
2003-09-24 07:34:27 +04:00
|
|
|
// Only implement QueryInterface; subclasses have the responsibility
|
|
|
|
// of implementing AddRef/Release.
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
|
1998-10-06 05:39:33 +04:00
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
NS_DECL_NSICSSDECLARATION
|
|
|
|
|
2003-06-24 09:40:37 +04:00
|
|
|
// Require subclasses to implement |GetParentRule|.
|
|
|
|
//NS_DECL_NSIDOMCSSSTYLEDECLARATION
|
|
|
|
NS_IMETHOD GetCssText(nsAString & aCssText);
|
|
|
|
NS_IMETHOD SetCssText(const nsAString & aCssText);
|
|
|
|
NS_IMETHOD GetPropertyValue(const nsAString & propertyName,
|
|
|
|
nsAString & _retval);
|
|
|
|
NS_IMETHOD GetPropertyCSSValue(const nsAString & propertyName,
|
|
|
|
nsIDOMCSSValue **_retval);
|
|
|
|
NS_IMETHOD RemoveProperty(const nsAString & propertyName,
|
|
|
|
nsAString & _retval);
|
|
|
|
NS_IMETHOD GetPropertyPriority(const nsAString & propertyName,
|
|
|
|
nsAString & _retval);
|
|
|
|
NS_IMETHOD SetProperty(const nsAString & propertyName,
|
|
|
|
const nsAString & value, const nsAString & priority);
|
|
|
|
NS_IMETHOD GetLength(PRUint32 *aLength);
|
|
|
|
NS_IMETHOD Item(PRUint32 index, nsAString & _retval);
|
2010-03-02 23:59:32 +03:00
|
|
|
NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) = 0;
|
1998-11-26 04:34:53 +03:00
|
|
|
|
2010-08-06 09:32:01 +04:00
|
|
|
// We implement this as a shim which forwards to GetPropertyValue
|
2010-07-15 00:58:56 +04:00
|
|
|
// and SetPropertyValue; subclasses need not.
|
|
|
|
NS_DECL_NSIDOMCSS2PROPERTIES
|
|
|
|
|
2003-06-18 05:59:57 +04:00
|
|
|
protected:
|
2010-07-23 22:00:34 +04:00
|
|
|
// This method can return null regardless of the value of aAllocate;
|
|
|
|
// however, a null return should only be considered a failure
|
|
|
|
// if aAllocate is true.
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) = 0;
|
2010-07-23 22:00:47 +04:00
|
|
|
virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) = 0;
|
2009-12-11 19:13:19 +03:00
|
|
|
// Document that we must call BeginUpdate/EndUpdate on around the
|
2010-07-23 22:00:47 +04:00
|
|
|
// calls to SetCSSDeclaration and the style rule mutation that leads
|
2009-12-11 19:13:19 +03:00
|
|
|
// to it.
|
|
|
|
virtual nsIDocument* DocToUpdate() = 0;
|
2010-03-02 23:59:32 +03:00
|
|
|
|
2011-04-28 00:53:49 +04:00
|
|
|
// Information neded to parse a declaration. We need the mSheetURI
|
|
|
|
// for error reporting, mBaseURI to resolve relative URIs,
|
|
|
|
// mPrincipal for subresource loads, and mCSSLoader for determining
|
|
|
|
// whether we're in quirks mode. mBaseURI needs to be a strong
|
|
|
|
// pointer because of xml:base possibly creating base URIs on the
|
|
|
|
// fly. This is why we don't use CSSParsingEnvironment as a return
|
|
|
|
// value, to avoid multiple-refcounting of mBaseURI.
|
|
|
|
struct CSSParsingEnvironment {
|
|
|
|
nsIURI* mSheetURI;
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
nsIPrincipal* mPrincipal;
|
|
|
|
mozilla::css::Loader* mCSSLoader;
|
|
|
|
};
|
|
|
|
|
|
|
|
// On failure, mPrincipal should be set to null in aCSSParseEnv.
|
|
|
|
// If mPrincipal is null, the other members may not be set to
|
|
|
|
// anything meaningful.
|
|
|
|
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) = 0;
|
2003-06-18 05:59:57 +04:00
|
|
|
|
2011-04-12 10:18:42 +04:00
|
|
|
// An implementation for GetCSSParsingEnvironment for callers wrapping
|
2011-04-08 05:23:46 +04:00
|
|
|
// an css::Rule.
|
|
|
|
static void GetCSSParsingEnvironmentForRule(mozilla::css::Rule* aRule,
|
2011-04-28 00:53:49 +04:00
|
|
|
CSSParsingEnvironment& aCSSParseEnv);
|
2011-04-12 10:18:42 +04:00
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
nsresult ParsePropertyValue(const nsCSSProperty aPropID,
|
2010-04-02 10:07:40 +04:00
|
|
|
const nsAString& aPropValue,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsImportant);
|
2004-06-08 05:32:29 +04:00
|
|
|
|
|
|
|
// Prop-id based version of RemoveProperty. Note that this does not
|
|
|
|
// return the old value; it just does a straight removal.
|
|
|
|
nsresult RemoveProperty(const nsCSSProperty aPropID);
|
2010-03-02 23:59:32 +03:00
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
protected:
|
|
|
|
virtual ~nsDOMCSSDeclaration();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsDOMCSSDeclaration_h___
|