2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-25 05:47:31 +00:00
|
|
|
|
|
|
|
/* base class for DOM objects for element.style and cssStyleRule.style */
|
|
|
|
|
1998-10-06 01:39:33 +00:00
|
|
|
#ifndef nsDOMCSSDeclaration_h___
|
2003-10-30 01:40:33 +00:00
|
|
|
#define nsDOMCSSDeclaration_h___
|
1998-09-25 00:51:45 +00:00
|
|
|
|
2004-06-08 01:32:29 +00:00
|
|
|
#include "nsICSSDeclaration.h"
|
2013-08-22 06:29:57 +00:00
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-05-09 15:23:14 +00:00
|
|
|
#include "nsIURI.h"
|
2009-09-18 13:09:55 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-09-25 00:51:45 +00:00
|
|
|
|
2007-05-03 01:15:53 +00:00
|
|
|
class nsIPrincipal;
|
2009-12-11 16:13:19 +00:00
|
|
|
class nsIDocument;
|
2014-03-07 17:14:26 +00:00
|
|
|
struct JSContext;
|
|
|
|
class JSObject;
|
1998-09-25 00:51:45 +00:00
|
|
|
|
2010-03-02 21:00:53 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
2010-06-28 22:49:35 +00:00
|
|
|
class Declaration;
|
2010-03-02 21:00:53 +00:00
|
|
|
class Loader;
|
2011-04-08 01:23:46 +00:00
|
|
|
class Rule;
|
2010-03-02 21:00:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-30 21:14:06 +00:00
|
|
|
class nsDOMCSSDeclaration : public nsICSSDeclaration
|
1998-09-25 00:51:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2003-09-24 03:34:27 +00:00
|
|
|
// Only implement QueryInterface; subclasses have the responsibility
|
|
|
|
// of implementing AddRef/Release.
|
2013-05-29 19:37:49 +00:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) MOZ_OVERRIDE;
|
1998-09-25 00:51:45 +00:00
|
|
|
|
2012-08-24 04:08:08 +00:00
|
|
|
// Declare addref and release so they can be called on us, but don't
|
|
|
|
// implement them. Our subclasses must handle their own
|
|
|
|
// refcounting.
|
2014-03-27 20:38:33 +00:00
|
|
|
NS_IMETHOD_(MozExternalRefCountType) AddRef() MOZ_OVERRIDE = 0;
|
|
|
|
NS_IMETHOD_(MozExternalRefCountType) Release() MOZ_OVERRIDE = 0;
|
2012-08-24 04:08:08 +00:00
|
|
|
|
2004-06-08 01:32:29 +00:00
|
|
|
NS_DECL_NSICSSDECLARATION
|
2012-08-24 04:08:08 +00:00
|
|
|
using nsICSSDeclaration::GetLength;
|
2004-06-08 01:32:29 +00:00
|
|
|
|
2003-06-24 05:40:37 +00:00
|
|
|
// Require subclasses to implement |GetParentRule|.
|
|
|
|
//NS_DECL_NSIDOMCSSSTYLEDECLARATION
|
2013-05-14 16:33:23 +00:00
|
|
|
NS_IMETHOD GetCssText(nsAString & aCssText) MOZ_OVERRIDE;
|
2012-09-14 16:10:08 +00:00
|
|
|
NS_IMETHOD SetCssText(const nsAString & aCssText) MOZ_OVERRIDE;
|
2003-06-24 05:40:37 +00:00
|
|
|
NS_IMETHOD GetPropertyValue(const nsAString & propertyName,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsAString & _retval) MOZ_OVERRIDE;
|
2012-10-01 16:49:41 +00:00
|
|
|
virtual already_AddRefed<mozilla::dom::CSSValue>
|
|
|
|
GetPropertyCSSValue(const nsAString & propertyName,
|
|
|
|
mozilla::ErrorResult& aRv) MOZ_OVERRIDE;
|
|
|
|
using nsICSSDeclaration::GetPropertyCSSValue;
|
2003-06-24 05:40:37 +00:00
|
|
|
NS_IMETHOD RemoveProperty(const nsAString & propertyName,
|
2013-05-14 16:33:23 +00:00
|
|
|
nsAString & _retval) MOZ_OVERRIDE;
|
2003-06-24 05:40:37 +00:00
|
|
|
NS_IMETHOD GetPropertyPriority(const nsAString & propertyName,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsAString & _retval) MOZ_OVERRIDE;
|
2003-06-24 05:40:37 +00:00
|
|
|
NS_IMETHOD SetProperty(const nsAString & propertyName,
|
2012-09-14 16:10:08 +00:00
|
|
|
const nsAString & value, const nsAString & priority) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetLength(uint32_t *aLength) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetParentRule(nsIDOMCSSRule * *aParentRule) MOZ_OVERRIDE = 0;
|
1998-11-26 01:34:53 +00:00
|
|
|
|
2012-08-24 04:08:08 +00:00
|
|
|
// WebIDL interface for CSS2Properties
|
2013-03-25 16:24:21 +00:00
|
|
|
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) publicname_
|
2012-08-24 04:08:08 +00:00
|
|
|
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \
|
|
|
|
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
|
|
|
|
void \
|
|
|
|
Get##method_(nsAString& aValue, mozilla::ErrorResult& rv) \
|
|
|
|
{ \
|
|
|
|
rv = GetPropertyValue(eCSSProperty_##id_, aValue); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void \
|
|
|
|
Set##method_(const nsAString& aValue, mozilla::ErrorResult& rv) \
|
|
|
|
{ \
|
|
|
|
rv = SetPropertyValue(eCSSProperty_##id_, aValue); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
|
|
|
|
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_, pref_) \
|
|
|
|
CSS_PROP(name_, id_, method_, flags_, pref_, X, X, X, X, X)
|
|
|
|
#include "nsCSSPropList.h"
|
|
|
|
|
|
|
|
#define CSS_PROP_ALIAS(aliasname_, propid_, aliasmethod_, pref_) \
|
|
|
|
CSS_PROP(X, propid_, aliasmethod_, X, pref_, X, X, X, X, X)
|
|
|
|
#include "nsCSSPropAliasList.h"
|
|
|
|
#undef CSS_PROP_ALIAS
|
|
|
|
|
|
|
|
#undef CSS_PROP_SHORTHAND
|
|
|
|
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL
|
|
|
|
#undef CSS_PROP
|
2013-03-25 16:24:21 +00:00
|
|
|
#undef CSS_PROP_PUBLIC_OR_PRIVATE
|
2012-08-24 04:08:08 +00:00
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) MOZ_OVERRIDE;
|
2012-08-24 04:08:08 +00:00
|
|
|
|
2014-04-08 22:27:18 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2012-08-24 04:08:09 +00:00
|
|
|
|
2003-06-18 01:59:57 +00:00
|
|
|
protected:
|
2010-07-23 18:00:34 +00: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 06:19:26 +00:00
|
|
|
virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) = 0;
|
2010-07-23 18:00:47 +00:00
|
|
|
virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) = 0;
|
2009-12-11 16:13:19 +00:00
|
|
|
// Document that we must call BeginUpdate/EndUpdate on around the
|
2010-07-23 18:00:47 +00:00
|
|
|
// calls to SetCSSDeclaration and the style rule mutation that leads
|
2009-12-11 16:13:19 +00:00
|
|
|
// to it.
|
|
|
|
virtual nsIDocument* DocToUpdate() = 0;
|
2010-03-02 20:59:32 +00:00
|
|
|
|
2011-04-27 20:53:49 +00: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 01:59:57 +00:00
|
|
|
|
2011-04-12 06:18:42 +00:00
|
|
|
// An implementation for GetCSSParsingEnvironment for callers wrapping
|
2011-04-08 01:23:46 +00:00
|
|
|
// an css::Rule.
|
|
|
|
static void GetCSSParsingEnvironmentForRule(mozilla::css::Rule* aRule,
|
2011-04-27 20:53:49 +00:00
|
|
|
CSSParsingEnvironment& aCSSParseEnv);
|
2011-04-12 06:18:42 +00:00
|
|
|
|
2004-06-08 01:32:29 +00:00
|
|
|
nsresult ParsePropertyValue(const nsCSSProperty aPropID,
|
2010-04-02 06:07:40 +00:00
|
|
|
const nsAString& aPropValue,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsImportant);
|
2004-06-08 01:32:29 +00: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 20:59:32 +00:00
|
|
|
|
2013-12-12 02:09:46 +00:00
|
|
|
void GetCustomPropertyValue(const nsAString& aPropertyName, nsAString& aValue);
|
|
|
|
nsresult RemoveCustomProperty(const nsAString& aPropertyName);
|
|
|
|
nsresult ParseCustomPropertyValue(const nsAString& aPropertyName,
|
|
|
|
const nsAString& aPropValue,
|
|
|
|
bool aIsImportant);
|
|
|
|
|
1998-09-25 00:51:45 +00:00
|
|
|
protected:
|
1998-10-06 01:39:33 +00:00
|
|
|
virtual ~nsDOMCSSDeclaration();
|
2012-08-24 04:08:09 +00:00
|
|
|
nsDOMCSSDeclaration()
|
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
1998-09-25 00:51:45 +00:00
|
|
|
};
|
|
|
|
|
2014-03-07 17:14:26 +00:00
|
|
|
bool IsCSSPropertyExposedToJS(nsCSSProperty aProperty, JSContext* cx, JSObject* obj);
|
|
|
|
|
|
|
|
template <nsCSSProperty Property>
|
|
|
|
MOZ_ALWAYS_INLINE bool IsCSSPropertyExposedToJS(JSContext* cx, JSObject* obj)
|
|
|
|
{
|
|
|
|
return IsCSSPropertyExposedToJS(Property, cx, obj);
|
|
|
|
}
|
|
|
|
|
1998-10-06 01:39:33 +00:00
|
|
|
#endif // nsDOMCSSDeclaration_h___
|