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-03-03 00:00:53 +03:00
|
|
|
#include "nsCSSLoader.h"
|
1998-09-25 04:51:45 +04:00
|
|
|
#include "nsIStyleRule.h"
|
2002-01-16 01:43:37 +03:00
|
|
|
#include "nsCSSDeclaration.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)
|
|
|
|
NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsDOMCSSDeclaration)
|
|
|
|
NS_INTERFACE_TABLE_ENTRY(nsDOMCSSDeclaration, nsICSSDeclaration)
|
|
|
|
NS_INTERFACE_TABLE_ENTRY(nsDOMCSSDeclaration, nsIDOMCSSStyleDeclaration)
|
|
|
|
NS_INTERFACE_TABLE_ENTRY(nsDOMCSSDeclaration, nsISupports)
|
|
|
|
NS_OFFSET_AND_INTERFACE_TABLE_END
|
|
|
|
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
|
2009-09-18 17:09:55 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIDOMCSS2Properties,
|
|
|
|
new CSS2PropertiesTearoff(this))
|
2010-02-06 16:46:54 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIDOMSVGCSS2Properties,
|
|
|
|
new CSS2PropertiesTearoff(this))
|
2009-09-18 17:09:55 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIDOMNSCSS2Properties,
|
|
|
|
new CSS2PropertiesTearoff(this))
|
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");
|
|
|
|
|
|
|
|
nsCSSDeclaration *decl;
|
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
|
|
|
|
|
|
|
|
aValue.Truncate();
|
|
|
|
if (decl) {
|
|
|
|
result = decl->GetValue(aPropID, aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration* decl;
|
2000-04-20 17:50:56 +04:00
|
|
|
aCssText.Truncate();
|
2002-01-16 01:43:37 +03:00
|
|
|
GetCSSDeclaration(&decl, PR_FALSE);
|
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
|
|
|
{
|
2001-12-15 07:33:11 +03:00
|
|
|
return ParseDeclaration(aCssText, PR_FALSE, PR_TRUE);
|
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
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration *decl;
|
1998-10-06 05:39:33 +04:00
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
|
1998-09-25 04:51:45 +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
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration *decl;
|
1998-10-06 05:39:33 +04:00
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_FALSE);
|
1998-09-25 04:51:45 +04:00
|
|
|
|
|
|
|
aReturn.SetLength(0);
|
2003-06-18 05:59:57 +04:00
|
|
|
if (decl) {
|
1998-09-25 04:51:45 +04:00
|
|
|
result = decl->GetNthProperty(aIndex, aReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsDOMCSSDeclaration::GetPropertyValue(const nsAString& aPropertyName,
|
|
|
|
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
|
|
|
}
|
2004-06-08 05:32:29 +04:00
|
|
|
|
|
|
|
return GetPropertyValue(propID, aReturn);
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsDOMCSSDeclaration::GetPropertyPriority(const nsAString& aPropertyName,
|
|
|
|
nsAString& aReturn)
|
1998-09-25 04:51:45 +04:00
|
|
|
{
|
2002-01-16 01:43:37 +03:00
|
|
|
nsCSSDeclaration *decl;
|
1998-10-06 05:39:33 +04:00
|
|
|
nsresult result = GetCSSDeclaration(&decl, 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)) {
|
2004-06-17 04:13:25 +04:00
|
|
|
aReturn.AssignLiteral("important");
|
1998-09-25 04:51:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:56:05 +03:00
|
|
|
nsDOMCSSDeclaration::SetProperty(const nsAString& aPropertyName,
|
|
|
|
const nsAString& aValue,
|
|
|
|
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;
|
|
|
|
}
|
2004-06-08 05:32:29 +04:00
|
|
|
|
|
|
|
nsresult rv = GetPropertyValue(propID, aReturn);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = RemoveProperty(propID);
|
2003-06-18 05:59:57 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
nsCSSDeclaration* decl;
|
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
|
|
|
|
if (!decl) {
|
|
|
|
return result;
|
|
|
|
}
|
2010-03-02 23:59:32 +03:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-12-11 19:13:19 +03:00
|
|
|
// For nsDOMCSSAttributeDeclaration, DeclarationChanged will lead to
|
|
|
|
// 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-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);
|
2003-07-01 01:39:22 +04:00
|
|
|
if (NS_SUCCEEDED(result) && changed) {
|
2003-06-18 05:59:57 +04:00
|
|
|
result = DeclarationChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsDOMCSSDeclaration::ParseDeclaration(const nsAString& aDecl,
|
|
|
|
PRBool aParseOnlyOneDecl,
|
|
|
|
PRBool aClearOldDecl)
|
|
|
|
{
|
|
|
|
nsCSSDeclaration* decl;
|
|
|
|
nsresult result = GetCSSDeclaration(&decl, PR_TRUE);
|
|
|
|
if (!decl) {
|
|
|
|
return 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;
|
2003-06-18 05:59:57 +04: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;
|
|
|
|
}
|
|
|
|
|
2009-12-11 19:13:19 +03:00
|
|
|
// For nsDOMCSSAttributeDeclaration, DeclarationChanged will lead to
|
|
|
|
// 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-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.ParseAndAppendDeclaration(aDecl, sheetURI, baseURI,
|
|
|
|
sheetPrincipal, decl,
|
|
|
|
aParseOnlyOneDecl,
|
|
|
|
&changed,
|
|
|
|
aClearOldDecl);
|
|
|
|
|
2003-07-01 01:39:22 +04:00
|
|
|
if (NS_SUCCEEDED(result) && changed) {
|
2003-06-18 05:59:57 +04:00
|
|
|
result = DeclarationChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
nsresult
|
|
|
|
nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
|
|
|
|
{
|
|
|
|
nsCSSDeclaration* decl;
|
|
|
|
nsresult rv = GetCSSDeclaration(&decl, PR_FALSE);
|
|
|
|
if (!decl) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-12-11 19:13:19 +03:00
|
|
|
// For nsDOMCSSAttributeDeclaration, DeclarationChanged will lead to
|
|
|
|
// 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);
|
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
rv = decl->RemoveProperty(aPropID);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = DeclarationChanged();
|
|
|
|
} else {
|
|
|
|
// RemoveProperty used to throw in all sorts of situations -- e.g.
|
|
|
|
// if the property was a shorthand one. Do not propagate its return
|
|
|
|
// value to callers. (XXX or should we propagate it again now?)
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2003-06-18 05:59:57 +04:00
|
|
|
|
2002-10-03 23:41:42 +04:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-06-08 05:32:29 +04:00
|
|
|
CSS2PropertiesTearoff::CSS2PropertiesTearoff(nsICSSDeclaration *aOuter)
|
2003-07-12 00:44:25 +04:00
|
|
|
: mOuter(aOuter)
|
2001-09-17 04:57:46 +04:00
|
|
|
{
|
2003-07-12 00:44:25 +04:00
|
|
|
NS_ASSERTION(mOuter, "must have outer");
|
2002-10-03 23:41:42 +04:00
|
|
|
}
|
2001-09-28 05:38:36 +04:00
|
|
|
|
2002-10-03 23:41:42 +04:00
|
|
|
CSS2PropertiesTearoff::~CSS2PropertiesTearoff()
|
|
|
|
{
|
2001-09-17 04:57:46 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 17:09:55 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_1(CSS2PropertiesTearoff, mOuter)
|
2002-10-03 23:41:42 +04:00
|
|
|
|
2009-09-18 17:09:55 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(CSS2PropertiesTearoff)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(CSS2PropertiesTearoff)
|
2002-09-26 07:46:50 +04:00
|
|
|
|
2009-09-18 17:09:55 +04:00
|
|
|
NS_INTERFACE_TABLE_HEAD(CSS2PropertiesTearoff)
|
2010-02-06 16:46:54 +03:00
|
|
|
NS_INTERFACE_TABLE_INHERITED3(CSS2PropertiesTearoff,
|
2009-09-18 17:09:55 +04:00
|
|
|
nsIDOMCSS2Properties,
|
2010-02-06 16:46:54 +03:00
|
|
|
nsIDOMSVGCSS2Properties,
|
2009-09-18 17:09:55 +04:00
|
|
|
nsIDOMNSCSS2Properties)
|
|
|
|
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(CSS2PropertiesTearoff)
|
|
|
|
NS_INTERFACE_MAP_END_AGGREGATED(mOuter)
|
2002-09-26 07:46:50 +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 \
|
|
|
|
CSS2PropertiesTearoff::Get##method_(nsAString& aValue) \
|
|
|
|
{ \
|
2004-06-08 05:32:29 +04:00
|
|
|
return mOuter->GetPropertyValue(eCSSProperty_##id_, aValue); \
|
2004-01-30 01:04:45 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
NS_IMETHODIMP \
|
|
|
|
CSS2PropertiesTearoff::Set##method_(const nsAString& aValue) \
|
|
|
|
{ \
|
2004-06-08 05:32:29 +04:00
|
|
|
return mOuter->SetPropertyValue(eCSSProperty_##id_, aValue); \
|
|
|
|
}
|
|
|
|
|
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
|
2009-09-11 14:46:36 +04:00
|
|
|
CSS_PROP(X, opacity, MozOpacity, 0, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline, MozOutline, 0, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_color, MozOutlineColor, 0, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_style, MozOutlineStyle, 0, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_width, MozOutlineWidth, 0, X, X, X, X, X, X, X)
|
|
|
|
CSS_PROP(X, outline_offset, MozOutlineOffset, 0, 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
|