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-09-25 04:51:45 +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-09-25 04:51:45 +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-09-25 04:51:45 +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):
|
2005-03-27 15:36:08 +04:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* 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 ***** */
|
1998-09-25 04:51:45 +04:00
|
|
|
|
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
|
|
|
#include "nsDOMCSSDeclaration.h"
|
2000-04-20 17:50:56 +04:00
|
|
|
#include "nsIDOMCSSRule.h"
|
2010-03-02 23:59:32 +03:00
|
|
|
#include "nsCSSParser.h"
|
2010-06-29 02:49:35 +04:00
|
|
|
#include "mozilla/css/Loader.h"
|
1998-09-25 04:51:45 +04:00
|
|
|
#include "nsIStyleRule.h"
|
2010-06-29 02:49:35 +04:00
|
|
|
#include "mozilla/css/Declaration.h"
|
1998-09-25 04:51:45 +04:00
|
|
|
#include "nsCSSProps.h"
|
2000-04-20 17:50:56 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-01-15 05:07:46 +03:00
|
|
|
#include "nsIURL.h"
|
2004-01-30 01:04:45 +03:00
|
|
|
#include "nsReadableUtils.h"
|
2007-05-03 05:15:53 +04:00
|
|
|
#include "nsIPrincipal.h"
|
1998-09-25 04:51:45 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
#include "nsContentUtils.h"
|
2009-12-11 19:13:19 +03:00
|
|
|
#include "mozAutoDocUpdate.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
2010-03-03 00:00:53 +03:00
|
|
|
namespace css = mozilla::css;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
1998-10-06 05:39:33 +04:00
|
|
|
nsDOMCSSDeclaration::~nsDOMCSSDeclaration()
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-01-12 16:08:43 +03:00
|
|
|
DOMCI_DATA(CSSStyleDeclaration, nsDOMCSSDeclaration)
|
|
|
|
|
2009-07-13 15:14:57 +04:00
|
|
|
NS_INTERFACE_TABLE_HEAD(nsDOMCSSDeclaration)
|
2010-07-15 00:58:56 +04:00
|
|
|
NS_INTERFACE_TABLE5(nsDOMCSSDeclaration,
|
|
|
|
nsICSSDeclaration,
|
|
|
|
nsIDOMCSSStyleDeclaration,
|
|
|
|
nsIDOMCSS2Properties,
|
|
|
|
nsIDOMSVGCSS2Properties,
|
|
|
|
nsIDOMNSCSS2Properties)
|
|
|
|
NS_INTERFACE_TABLE_TO_MAP_SEGUE
|
2010-03-17 18:09:05 +03:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSStyleDeclaration)
|
2003-07-12 00:44:25 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
1998-09-25 04:51:45 +04:00
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSDeclaration::GetPropertyValue(const nsCSSProperty aPropID,
|
|
|
|
nsAString& aValue)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPropID != eCSSProperty_UNKNOWN,
|
|
|
|
"Should never pass eCSSProperty_UNKNOWN around");
|
2010-06-29 02:49:35 +04:00
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
css::Declaration* decl = GetCSSDeclaration(PR_FALSE);
|
2004-06-08 05:32:29 +04:00
|
|
|
|
|
|
|
aValue.Truncate();
|
|
|
|
if (decl) {
|
2010-07-23 22:00:34 +04:00
|
|
|
decl->GetValue(aPropID, aValue);
|
2004-06-08 05:32:29 +04:00
|
|
|
}
|
2010-07-23 22:00:34 +04:00
|
|
|
return NS_OK;
|
2004-06-08 05:32:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSDeclaration::SetPropertyValue(const nsCSSProperty aPropID,
|
|
|
|
const nsAString& aValue)
|
|
|
|
{
|
|
|
|
if (aValue.IsEmpty()) {
|
|
|
|
// If the new value of the property is an empty string we remove the
|
|
|
|
// property.
|
|
|
|
return RemoveProperty(aPropID);
|
|
|
|
}
|
|
|
|
|
2010-04-02 10:07:40 +04:00
|
|
|
return ParsePropertyValue(aPropID, aValue, PR_FALSE);
|
2004-06-08 05:32:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-20 17:50:56 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsDOMCSSDeclaration::GetCssText(nsAString& aCssText)
|
1998-11-26 04:34:53 +03:00
|
|
|
{
|
2010-07-23 22:00:34 +04:00
|
|
|
css::Declaration* decl = GetCSSDeclaration(PR_FALSE);
|
2000-04-20 17:50:56 +04:00
|
|
|
aCssText.Truncate();
|
2001-05-15 12:25:03 +04:00
|
|
|
|
|
|
|
if (decl) {
|
|
|
|
decl->ToString(aCssText);
|
|
|
|
}
|
|
|
|
|
1998-11-26 04:34:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-20 17:50:56 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
1998-11-26 04:34:53 +03:00
|
|
|
{
|
2010-07-23 22:00:49 +04:00
|
|
|
// We don't need to *do* anything with the old declaration, but we need
|
|
|
|
// to ensure that it exists, or else SetCSSDeclaration may crash.
|
|
|
|
css::Declaration* olddecl = GetCSSDeclaration(PR_TRUE);
|
|
|
|
if (!olddecl) {
|
2010-07-23 22:00:34 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2010-07-23 22:00:19 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
nsresult result;
|
2010-07-23 22:00:19 +04:00
|
|
|
nsRefPtr<css::Loader> cssLoader;
|
|
|
|
nsCOMPtr<nsIURI> baseURI, sheetURI;
|
|
|
|
nsCOMPtr<nsIPrincipal> sheetPrincipal;
|
|
|
|
|
|
|
|
result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
|
|
|
|
getter_AddRefs(baseURI),
|
|
|
|
getter_AddRefs(sheetPrincipal),
|
|
|
|
getter_AddRefs(cssLoader));
|
|
|
|
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:47 +04:00
|
|
|
// For nsDOMCSSAttributeDeclaration, SetCSSDeclaration will lead to
|
2010-07-23 22:00:19 +04:00
|
|
|
// Attribute setting code, which leads in turn to BeginUpdate. We
|
|
|
|
// need to start the update now so that the old rule doesn't get used
|
|
|
|
// between when we mutate the declaration and when we set the new
|
|
|
|
// rule (see stack in bug 209575).
|
|
|
|
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), PR_TRUE);
|
|
|
|
|
2010-07-23 22:00:52 +04:00
|
|
|
nsAutoPtr<css::Declaration> decl(new css::Declaration());
|
2010-07-23 22:00:49 +04:00
|
|
|
decl->InitializeEmpty();
|
2010-07-23 22:00:19 +04:00
|
|
|
nsCSSParser cssParser(cssLoader);
|
|
|
|
PRBool changed;
|
|
|
|
result = cssParser.ParseDeclarations(aCssText, sheetURI, baseURI,
|
|
|
|
sheetPrincipal, decl, &changed);
|
2010-07-23 22:00:34 +04:00
|
|
|
if (NS_FAILED(result) || !changed) {
|
|
|
|
return result;
|
2010-07-23 22:00:19 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:52 +04:00
|
|
|
return SetCSSDeclaration(decl.forget());
|
1998-11-26 04:34:53 +03:00
|
|
|
}
|
|
|
|
|
2000-04-20 17:50:56 +04:00
|
|
|
NS_IMETHODIMP
|
1998-10-06 05:39:33 +04:00
|
|
|
nsDOMCSSDeclaration::GetLength(PRUint32* aLength)
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
2010-07-23 22:00:34 +04:00
|
|
|
css::Declaration* decl = GetCSSDeclaration(PR_FALSE);
|
2010-06-29 02:49:35 +04:00
|
|
|
|
2003-06-18 05:59:57 +04:00
|
|
|
if (decl) {
|
2002-01-16 01:43:37 +03:00
|
|
|
*aLength = decl->Count();
|
2003-06-18 05:59:57 +04:00
|
|
|
} else {
|
|
|
|
*aLength = 0;
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
return NS_OK;
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2000-04-20 17:50:56 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsDOMCSSDeclaration::GetPropertyCSSValue(const nsAString& aPropertyName,
|
2000-04-20 17:50:56 +04:00
|
|
|
nsIDOMCSSValue** aReturn)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
|
|
|
|
|
|
|
// We don't support CSSValue yet so we'll just return null...
|
|
|
|
*aReturn = nsnull;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsDOMCSSDeclaration::Item(PRUint32 aIndex, nsAString& aReturn)
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
2010-07-23 22:00:34 +04:00
|
|
|
css::Declaration* decl = GetCSSDeclaration(PR_FALSE);
|
1998-09-25 04:51:45 +04:00
|
|
|
|
|
|
|
aReturn.SetLength(0);
|
2003-06-18 05:59:57 +04:00
|
|
|
if (decl) {
|
2010-07-23 22:00:34 +04:00
|
|
|
decl->GetNthProperty(aIndex, aReturn);
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
return NS_OK;
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName,
|
2002-03-24 01:56:05 +03:00
|
|
|
nsAString& aReturn)
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
2004-06-08 05:32:29 +04:00
|
|
|
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName);
|
|
|
|
if (propID == eCSSProperty_UNKNOWN) {
|
|
|
|
aReturn.Truncate();
|
|
|
|
return NS_OK;
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
2010-07-23 22:00:34 +04:00
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
return GetPropertyValue(propID, aReturn);
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSDeclaration::GetPropertyPriority(const nsAString& aPropertyName,
|
2002-03-24 01:56:05 +03:00
|
|
|
nsAString& aReturn)
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
2010-07-23 22:00:34 +04:00
|
|
|
css::Declaration* decl = GetCSSDeclaration(PR_FALSE);
|
1998-09-25 04:51:45 +04:00
|
|
|
|
2003-06-18 05:59:57 +04:00
|
|
|
aReturn.Truncate();
|
|
|
|
if (decl && decl->GetValueIsImportant(aPropertyName)) {
|
2010-07-23 22:00:34 +04:00
|
|
|
aReturn.AssignLiteral("important");
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
return NS_OK;
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName,
|
|
|
|
const nsAString& aValue,
|
2002-03-24 01:56:05 +03:00
|
|
|
const nsAString& aPriority)
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
2004-06-08 05:32:29 +04:00
|
|
|
// In the common (and fast) cases we can use the property id
|
|
|
|
nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName);
|
|
|
|
if (propID == eCSSProperty_UNKNOWN) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-04-02 10:07:40 +04:00
|
|
|
|
2001-09-28 05:38:36 +04:00
|
|
|
if (aValue.IsEmpty()) {
|
2004-06-08 05:32:29 +04:00
|
|
|
// If the new value of the property is an empty string we remove the
|
|
|
|
// property.
|
2010-04-02 10:07:40 +04:00
|
|
|
// XXX this ignores the priority string, should it?
|
2004-06-08 05:32:29 +04:00
|
|
|
return RemoveProperty(propID);
|
2000-05-02 02:59:54 +04:00
|
|
|
}
|
|
|
|
|
2002-08-08 21:40:20 +04:00
|
|
|
if (aPriority.IsEmpty()) {
|
2010-04-02 10:07:40 +04:00
|
|
|
return ParsePropertyValue(propID, aValue, PR_FALSE);
|
2002-08-08 21:40:20 +04:00
|
|
|
}
|
2002-10-03 23:41:42 +04:00
|
|
|
|
2010-04-02 10:07:40 +04:00
|
|
|
if (aPriority.EqualsLiteral("important")) {
|
|
|
|
return ParsePropertyValue(propID, aValue, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX silent failure?
|
|
|
|
return NS_OK;
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
2003-06-18 05:59:57 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCSSDeclaration::RemoveProperty(const nsAString& aPropertyName,
|
|
|
|
nsAString& aReturn)
|
|
|
|
{
|
2004-06-08 05:32:29 +04:00
|
|
|
const nsCSSProperty propID = nsCSSProps::LookupProperty(aPropertyName);
|
|
|
|
if (propID == eCSSProperty_UNKNOWN) {
|
|
|
|
aReturn.Truncate();
|
2004-06-07 23:30:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-07-23 22:00:34 +04:00
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
nsresult rv = GetPropertyValue(propID, aReturn);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-07-23 22:00:34 +04:00
|
|
|
|
|
|
|
return RemoveProperty(propID);
|
2003-06-18 05:59:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-06-08 05:32:29 +04:00
|
|
|
nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
|
2010-04-02 10:07:40 +04:00
|
|
|
const nsAString& aPropValue,
|
|
|
|
PRBool aIsImportant)
|
2003-06-18 05:59:57 +04:00
|
|
|
{
|
2010-07-23 22:00:49 +04:00
|
|
|
css::Declaration* olddecl = GetCSSDeclaration(PR_TRUE);
|
|
|
|
if (!olddecl) {
|
2010-07-23 22:00:34 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2003-06-18 05:59:57 +04:00
|
|
|
}
|
2010-03-02 23:59:32 +03:00
|
|
|
|
2010-07-23 22:00:34 +04:00
|
|
|
nsresult result;
|
2010-03-03 00:00:53 +03:00
|
|
|
nsRefPtr<css::Loader> cssLoader;
|
2004-09-11 03:31:48 +04:00
|
|
|
nsCOMPtr<nsIURI> baseURI, sheetURI;
|
2007-05-03 05:15:53 +04:00
|
|
|
nsCOMPtr<nsIPrincipal> sheetPrincipal;
|
2010-03-02 23:59:32 +03:00
|
|
|
|
2004-09-11 03:31:48 +04:00
|
|
|
result = GetCSSParsingEnvironment(getter_AddRefs(sheetURI),
|
|
|
|
getter_AddRefs(baseURI),
|
2007-05-03 05:15:53 +04:00
|
|
|
getter_AddRefs(sheetPrincipal),
|
2010-03-02 23:59:32 +03:00
|
|
|
getter_AddRefs(cssLoader));
|
2003-06-18 05:59:57 +04:00
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:47 +04:00
|
|
|
// For nsDOMCSSAttributeDeclaration, SetCSSDeclaration will lead to
|
2009-12-11 19:13:19 +03:00
|
|
|
// Attribute setting code, which leads in turn to BeginUpdate. We
|
|
|
|
// need to start the update now so that the old rule doesn't get used
|
|
|
|
// between when we mutate the declaration and when we set the new
|
|
|
|
// rule (see stack in bug 209575).
|
|
|
|
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), PR_TRUE);
|
2010-07-23 22:00:49 +04:00
|
|
|
css::Declaration* decl = olddecl->EnsureMutable();
|
2009-12-11 19:13:19 +03:00
|
|
|
|
2010-03-02 23:59:32 +03:00
|
|
|
nsCSSParser cssParser(cssLoader);
|
2003-07-01 01:39:22 +04:00
|
|
|
PRBool changed;
|
2010-03-02 23:59:32 +03:00
|
|
|
result = cssParser.ParseProperty(aPropID, aPropValue, sheetURI, baseURI,
|
2010-04-02 10:07:40 +04:00
|
|
|
sheetPrincipal, decl, &changed,
|
|
|
|
aIsImportant);
|
2010-07-23 22:00:34 +04:00
|
|
|
if (NS_FAILED(result) || !changed) {
|
2010-07-23 22:00:49 +04:00
|
|
|
if (decl != olddecl) {
|
2010-07-23 22:00:52 +04:00
|
|
|
delete decl;
|
2010-07-23 22:00:49 +04:00
|
|
|
}
|
2010-07-23 22:00:34 +04:00
|
|
|
return result;
|
2003-06-18 05:59:57 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:47 +04:00
|
|
|
return SetCSSDeclaration(decl);
|
2003-06-18 05:59:57 +04:00
|
|
|
}
|
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
nsresult
|
|
|
|
nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
|
|
|
|
{
|
2010-07-23 22:00:34 +04:00
|
|
|
css::Declaration* decl = GetCSSDeclaration(PR_FALSE);
|
2004-06-08 05:32:29 +04:00
|
|
|
if (!decl) {
|
2010-07-23 22:00:34 +04:00
|
|
|
return NS_OK; // no decl, so nothing to remove
|
2004-06-08 05:32:29 +04:00
|
|
|
}
|
|
|
|
|
2010-07-23 22:00:47 +04:00
|
|
|
// For nsDOMCSSAttributeDeclaration, SetCSSDeclaration will lead to
|
2009-12-11 19:13:19 +03:00
|
|
|
// Attribute setting code, which leads in turn to BeginUpdate. We
|
|
|
|
// need to start the update now so that the old rule doesn't get used
|
|
|
|
// between when we mutate the declaration and when we set the new
|
|
|
|
// rule (see stack in bug 209575).
|
|
|
|
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), PR_TRUE);
|
|
|
|
|
2010-07-23 22:00:49 +04:00
|
|
|
decl = decl->EnsureMutable();
|
2010-07-23 22:00:34 +04:00
|
|
|
decl->RemoveProperty(aPropID);
|
2010-07-23 22:00:47 +04:00
|
|
|
return SetCSSDeclaration(decl);
|
2004-06-08 05:32:29 +04:00
|
|
|
}
|
2003-06-18 05:59:57 +04:00
|
|
|
|
2002-10-03 23:41:42 +04:00
|
|
|
// nsIDOMCSS2Properties
|
2010-02-06 16:46:54 +03:00
|
|
|
// nsIDOMSVGCSS2Properties
|
2002-10-03 23:41:42 +04:00
|
|
|
// nsIDOMNSCSS2Properties
|
|
|
|
|
2009-09-11 14:46:36 +04:00
|
|
|
#define CSS_PROP(name_, id_, method_, flags_, datastruct_, member_, type_, \
|
|
|
|
kwtable_, stylestruct_, stylestructoffset_, animtype_) \
|
2004-01-30 01:04:45 +03:00
|
|
|
NS_IMETHODIMP \
|
2010-07-15 00:58:56 +04:00
|
|
|
nsDOMCSSDeclaration::Get##method_(nsAString& aValue) \
|
2004-01-30 01:04:45 +03:00
|
|
|
{ \
|
2010-07-15 00:58:56 +04:00
|
|
|
return GetPropertyValue(eCSSProperty_##id_, aValue); \
|
2004-01-30 01:04:45 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
NS_IMETHODIMP \
|
2010-07-15 00:58:56 +04:00
|
|
|
nsDOMCSSDeclaration::Set##method_(const nsAString& aValue) \
|
2004-01-30 01:04:45 +03:00
|
|
|
{ \
|
2010-07-15 00:58:56 +04:00
|
|
|
return SetPropertyValue(eCSSProperty_##id_, aValue); \
|
2004-06-08 05:32:29 +04:00
|
|
|
}
|
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
#define CSS_PROP_LIST_EXCLUDE_INTERNAL
|
2008-10-08 02:10:19 +04:00
|
|
|
#define CSS_PROP_SHORTHAND(name_, id_, method_, flags_) \
|
2009-09-11 14:46:36 +04:00
|
|
|
CSS_PROP(name_, id_, method_, flags_, X, X, X, X, X, X, X)
|
2002-09-26 07:46:50 +04:00
|
|
|
#include "nsCSSPropList.h"
|
2004-02-24 09:48:25 +03:00
|
|
|
|
|
|
|
// Aliases
|
2010-07-15 00:58:56 +04:00
|
|
|
CSS_PROP(X, opacity, MozOpacity, X, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline, MozOutline, X, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_color, MozOutlineColor, X, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_style, MozOutlineStyle, X, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_width, MozOutlineWidth, X, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_offset, MozOutlineOffset, X, X, X, X, X, X, X, X)
|
2004-02-24 09:48:25 +03:00
|
|
|
|
2003-06-08 02:14:42 +04:00
|
|
|
#undef CSS_PROP_SHORTHAND
|
|
|
|
#undef CSS_PROP_LIST_EXCLUDE_INTERNAL
|
2002-09-26 07:46:50 +04:00
|
|
|
#undef CSS_PROP
|