Implement element.style for XUL elements. Fully fault XUL attributes when style attribute is modified, and ensure that string and style rule versions of style attribute stay in sync. (HTML elements only store the latter.) b=7639 r+sr=bzbarsky
This commit is contained in:
Родитель
fdcb1a27a5
Коммит
2319e1e03e
|
@ -42,7 +42,7 @@
|
|||
#include "nsChangeHint.h"
|
||||
|
||||
class nsString;
|
||||
class nsIStyleRule;
|
||||
class nsICSSStyleRule;
|
||||
class nsISupportsArray;
|
||||
class nsRuleWalker;
|
||||
|
||||
|
@ -65,7 +65,9 @@ public:
|
|||
NS_IMETHOD_(PRBool) HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const = 0;
|
||||
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0;
|
||||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule** aStyleRule) = 0;
|
||||
|
||||
NS_IMETHOD GetInlineStyleRule(nsICSSStyleRule** aStyleRule) = 0;
|
||||
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Does the list of style rules walked by |WalkContentStyleRules|
|
||||
|
|
|
@ -2111,12 +2111,20 @@ nsGenericElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::GetInlineStyleRule(nsIStyleRule** aStyleRule)
|
||||
nsGenericElement::GetInlineStyleRule(nsICSSStyleRule** aStyleRule)
|
||||
{
|
||||
*aStyleRule = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule,
|
||||
PRBool aNotify)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("nsGenericElement::SetInlineStyleRule");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsGenericElement::HasAttributeDependentStyle(const nsIAtom* aAttribute) const
|
||||
{
|
||||
|
|
|
@ -400,7 +400,8 @@ public:
|
|||
NS_IMETHOD GetClasses(nsVoidArray& aArray) const;
|
||||
NS_IMETHOD_(PRBool) HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule** aStyleRule);
|
||||
NS_IMETHOD GetInlineStyleRule(nsICSSStyleRule** aStyleRule);
|
||||
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
|
||||
NS_IMETHOD_(PRBool)
|
||||
HasAttributeDependentStyle(const nsIAtom* aAttribute) const;
|
||||
NS_IMETHOD GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
|
|
|
@ -2294,7 +2294,7 @@ nsGenericHTMLElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetInlineStyleRule(nsIStyleRule** aStyleRule)
|
||||
nsGenericHTMLElement::GetInlineStyleRule(nsICSSStyleRule** aStyleRule)
|
||||
{
|
||||
*aStyleRule = nsnull;
|
||||
|
||||
|
@ -2317,6 +2317,14 @@ nsGenericHTMLElement::GetInlineStyleRule(nsIStyleRule** aStyleRule)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule,
|
||||
PRBool aNotify)
|
||||
{
|
||||
return SetHTMLAttribute(nsHTMLAtoms::style, nsHTMLValue(aStyleRule),
|
||||
aNotify);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetBaseURL(nsIURI** aBaseURL) const
|
||||
{
|
||||
|
@ -3120,7 +3128,7 @@ nsGenericHTMLElement::ParseStyleAttribute(const nsAString& aValue, nsHTMLValue&
|
|||
nsCOMPtr<nsIURI> baseURL;
|
||||
GetBaseURL(getter_AddRefs(baseURL));
|
||||
|
||||
nsCOMPtr<nsIStyleRule> rule;
|
||||
nsCOMPtr<nsICSSStyleRule> rule;
|
||||
result = cssParser->ParseStyleAttribute(aValue, baseURL,
|
||||
getter_AddRefs(rule));
|
||||
if (cssLoader) {
|
||||
|
|
|
@ -227,7 +227,8 @@ public:
|
|||
NS_IMETHOD_(nsIAtom*) GetClassAttributeName() const;
|
||||
NS_IMETHOD_(PRBool) HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule** aStyleRule);
|
||||
NS_IMETHOD GetInlineStyleRule(nsICSSStyleRule** aStyleRule);
|
||||
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
|
||||
NS_IMETHOD GetBaseURL(nsIURI** aBaseURL) const;
|
||||
NS_IMETHOD GetBaseTarget(nsAString& aBaseTarget) const;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
class nsIStyleRule;
|
||||
class nsICSSStyleRule;
|
||||
class nsICSSStyleSheet;
|
||||
class nsIUnicharInputStream;
|
||||
class nsIURI;
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
// the declaration.
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsIStyleRule** aResult) = 0;
|
||||
nsICSSStyleRule** aResult) = 0;
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aBaseURL,
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
// vim:cindent:ts=8:et:sw=4:
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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"),
|
||||
* 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
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* 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
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCSSOMFactory.h"
|
||||
#include "nsDOMCSSAttrDeclaration.h"
|
||||
|
||||
nsCSSOMFactory::nsCSSOMFactory()
|
||||
{
|
||||
}
|
||||
|
||||
nsCSSOMFactory::~nsCSSOMFactory()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCSSOMFactory, nsICSSOMFactory)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSOMFactory::CreateDOMCSSAttributeDeclaration(nsIHTMLContent *aContent,
|
||||
nsDOMCSSDeclaration **aResult)
|
||||
{
|
||||
nsDOMCSSDeclaration *result = new nsDOMCSSAttributeDeclaration(aContent);
|
||||
if (!result) {
|
||||
*aResult = 0;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(result);
|
||||
*aResult = result;
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
// vim:cindent:ts=8:et:sw=4:
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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"),
|
||||
* 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
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* 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
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsCSSOMFactory_h___
|
||||
#define nsCSSOMFactory_h___
|
||||
|
||||
#include "nsICSSOMFactory.h"
|
||||
|
||||
class nsCSSOMFactory : public nsICSSOMFactory {
|
||||
|
||||
public:
|
||||
|
||||
nsCSSOMFactory();
|
||||
virtual ~nsCSSOMFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateDOMCSSAttributeDeclaration(nsIHTMLContent *aContent,
|
||||
nsDOMCSSDeclaration **aResult);
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsCSSOMFactory_h___ */
|
|
@ -111,9 +111,9 @@ public:
|
|||
nsIURI* aInputURL,
|
||||
nsICSSStyleSheet*& aResult);
|
||||
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsIStyleRule** aResult);
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult);
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aBaseURL,
|
||||
|
@ -596,7 +596,7 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
|
|||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsIStyleRule** aResult)
|
||||
nsICSSStyleRule** aResult)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aBaseURL, "need base URL");
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "nsCSSDeclaration.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
MOZ_DECL_CTOR_COUNTER(nsDOMCSSAttributeDeclaration)
|
||||
|
||||
nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent)
|
||||
nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(nsIStyledContent *aContent)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsDOMCSSAttributeDeclaration);
|
||||
|
||||
|
@ -81,25 +81,16 @@ nsresult
|
|||
nsDOMCSSAttributeDeclaration::DeclarationChanged()
|
||||
{
|
||||
NS_ASSERTION(mContent, "Must have content node to set the decl!");
|
||||
nsHTMLValue val;
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
mContent->GetHTMLAttribute(nsHTMLAtoms::style, val);
|
||||
NS_ASSERTION(rv == NS_CONTENT_ATTR_HAS_VALUE &&
|
||||
eHTMLUnit_ISupports == val.GetUnit(),
|
||||
"content must have rule");
|
||||
nsCOMPtr<nsICSSStyleRule> oldRule =
|
||||
do_QueryInterface(nsCOMPtr<nsISupports>(val.GetISupportsValue()));
|
||||
nsCOMPtr<nsICSSStyleRule> oldRule;
|
||||
mContent->GetInlineStyleRule(getter_AddRefs(oldRule));
|
||||
NS_ASSERTION(oldRule, "content must have rule");
|
||||
|
||||
nsCOMPtr<nsICSSStyleRule> newRule = oldRule->DeclarationChanged(PR_FALSE);
|
||||
if (!newRule) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return mContent->SetHTMLAttribute(nsHTMLAtoms::style,
|
||||
nsHTMLValue(newRule),
|
||||
PR_TRUE);
|
||||
return mContent->SetInlineStyleRule(newRule, PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -110,15 +101,10 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
|||
|
||||
*aDecl = nsnull;
|
||||
if (mContent) {
|
||||
nsHTMLValue val;
|
||||
result = mContent->GetHTMLAttribute(nsHTMLAtoms::style, val);
|
||||
if (result == NS_CONTENT_ATTR_HAS_VALUE &&
|
||||
eHTMLUnit_ISupports == val.GetUnit()) {
|
||||
nsCOMPtr<nsISupports> rule = val.GetISupportsValue();
|
||||
nsCOMPtr<nsICSSStyleRule> cssRule = do_QueryInterface(rule, &result);
|
||||
if (cssRule) {
|
||||
*aDecl = cssRule->GetDeclaration();
|
||||
}
|
||||
nsCOMPtr<nsICSSStyleRule> cssRule;
|
||||
mContent->GetInlineStyleRule(getter_AddRefs(cssRule));
|
||||
if (cssRule) {
|
||||
*aDecl = cssRule->GetDeclaration();
|
||||
}
|
||||
else if (aAllocate) {
|
||||
nsCSSDeclaration *decl = new nsCSSDeclaration();
|
||||
|
@ -136,9 +122,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
|||
return result;
|
||||
}
|
||||
|
||||
result = mContent->SetHTMLAttribute(nsHTMLAtoms::style,
|
||||
nsHTMLValue(cssRule),
|
||||
PR_FALSE);
|
||||
result = mContent->SetInlineStyleRule(cssRule, PR_FALSE);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
*aDecl = decl;
|
||||
}
|
||||
|
|
|
@ -45,14 +45,14 @@
|
|||
#include "nsString.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIHTMLContent;
|
||||
class nsIStyledContent;
|
||||
class nsICSSLoader;
|
||||
class nsICSSParser;
|
||||
|
||||
class nsDOMCSSAttributeDeclaration : public nsDOMCSSDeclaration
|
||||
{
|
||||
public:
|
||||
nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent);
|
||||
nsDOMCSSAttributeDeclaration(nsIStyledContent *aContent);
|
||||
~nsDOMCSSAttributeDeclaration();
|
||||
|
||||
// impl AddRef/Release; QI is implemented by our parent class
|
||||
|
@ -75,7 +75,7 @@ protected:
|
|||
nsAutoRefCnt mRefCnt;
|
||||
NS_DECL_OWNINGTHREAD
|
||||
|
||||
nsIHTMLContent *mContent;
|
||||
nsIStyledContent *mContent;
|
||||
};
|
||||
|
||||
#endif /* nsDOMCSSAttributeDeclaration_h___ */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsDOMCSSDeclaration_h___
|
||||
#define nsDOMCSSSDeclaration_h___
|
||||
#define nsDOMCSSDeclaration_h___
|
||||
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMCSS2Properties.h"
|
||||
|
|
|
@ -452,7 +452,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
|
|||
|
||||
if (styledContent) {
|
||||
// just get the one and only style rule from the content's STYLE attribute
|
||||
nsCOMPtr<nsIStyleRule> rule;
|
||||
nsCOMPtr<nsICSSStyleRule> rule;
|
||||
styledContent->GetInlineStyleRule(getter_AddRefs(rule));
|
||||
if (rule)
|
||||
aData->mRuleWalker->Forward(rule);
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
// vim:cindent:ts=8:et:sw=4:
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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"),
|
||||
* 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
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* 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
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsICSSOMFactory_h___
|
||||
#define nsICSSOMFactory_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIHTMLContent;
|
||||
|
||||
// bfdd87bd-79c8-4041-ae14-91fa8536ce61
|
||||
#define NS_ICSSOMFACTORY_IID \
|
||||
{ 0xbfdd87bd, 0x79c8, 0x4041, \
|
||||
{0xae, 0x14, 0x91, 0xfa, 0x85, 0x36, 0xce, 0x61 } }
|
||||
|
||||
// 5fcaa2c1-7ca4-4f73-a357-93e79d709376
|
||||
#define NS_CSSOMFACTORY_CID \
|
||||
{ 0x5fcaa2c1, 0x7ca4, 0x4f73, \
|
||||
{0xa3, 0x57, 0x93, 0xe7, 0x9d, 0x70, 0x93, 0x76 } }
|
||||
|
||||
class nsICSSOMFactory : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICSSOMFACTORY_IID)
|
||||
|
||||
NS_IMETHOD CreateDOMCSSAttributeDeclaration(nsIHTMLContent *aContent,
|
||||
nsDOMCSSDeclaration **aResult) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsICSSOMFactory_h___ */
|
|
@ -39,7 +39,7 @@
|
|||
#include "nsSVGValue.h"
|
||||
#include "nsISVGStyleValue.h"
|
||||
#include "nsSVGStyleValue.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsICSSParser.h"
|
||||
|
@ -72,7 +72,7 @@ protected:
|
|||
void UpdateStyleRule(nsIContent* aContent);
|
||||
|
||||
nsString mValue;
|
||||
nsCOMPtr<nsIStyleRule> mRule; // lazily cached
|
||||
nsCOMPtr<nsICSSStyleRule> mRule; // lazily cached
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -69,5 +69,6 @@ LOCAL_INCLUDES = \
|
|||
-I$(srcdir)/../../../xml/content/src \
|
||||
-I$(srcdir)/../../../base/src \
|
||||
-I$(srcdir)/../../../xml/document/src \
|
||||
-I$(srcdir)/../../../html/style/src \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -729,7 +730,7 @@ nsresult nsXULAttributes::UpdateStyleRule(nsIURI* aDocURL, const nsAString& aVal
|
|||
return result;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStyleRule> rule;
|
||||
nsCOMPtr<nsICSSStyleRule> rule;
|
||||
result = css->ParseStyleAttribute(aValue, aDocURL, getter_AddRefs(rule));
|
||||
|
||||
if ((NS_OK == result) && rule) {
|
||||
|
@ -740,13 +741,13 @@ nsresult nsXULAttributes::UpdateStyleRule(nsIURI* aDocURL, const nsAString& aVal
|
|||
}
|
||||
|
||||
|
||||
nsresult nsXULAttributes::SetInlineStyleRule(nsIStyleRule* aRule)
|
||||
nsresult nsXULAttributes::SetInlineStyleRule(nsICSSStyleRule* aRule)
|
||||
{
|
||||
mStyleRule = aRule;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::GetInlineStyleRule(nsIStyleRule*& aRule)
|
||||
nsresult nsXULAttributes::GetInlineStyleRule(nsICSSStyleRule*& aRule)
|
||||
{
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
if (mStyleRule != nsnull)
|
||||
|
|
|
@ -1,208 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either 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"),
|
||||
* 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
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* 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
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A set of helper classes used to implement attributes.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsXULAttributes_h__
|
||||
#define nsXULAttributes_h__
|
||||
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsXULAttributeValue.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsINodeInfo;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class nsClassList {
|
||||
public:
|
||||
nsClassList(nsIAtom* aAtom)
|
||||
: mAtom(getter_AddRefs(aAtom)), mNext(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsClassList);
|
||||
}
|
||||
|
||||
|
||||
nsClassList(const nsClassList& aCopy)
|
||||
: mAtom(aCopy.mAtom), mNext(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsClassList);
|
||||
if (aCopy.mNext) mNext = new nsClassList(*(aCopy.mNext));
|
||||
}
|
||||
|
||||
nsClassList& operator=(const nsClassList& aClassList)
|
||||
{
|
||||
if (this != &aClassList) {
|
||||
delete mNext;
|
||||
mNext = nsnull;
|
||||
mAtom = aClassList.mAtom;
|
||||
|
||||
if (aClassList.mNext) {
|
||||
mNext = new nsClassList(*(aClassList.mNext));
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
~nsClassList(void)
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsClassList);
|
||||
delete mNext;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> mAtom;
|
||||
nsClassList* mNext;
|
||||
|
||||
static PRBool
|
||||
HasClass(nsClassList* aList, nsIAtom* aClass);
|
||||
|
||||
static nsresult
|
||||
GetClasses(nsClassList* aList, nsVoidArray& aArray);
|
||||
|
||||
static nsresult
|
||||
ParseClasses(nsClassList** aList, const nsAString& aValue);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsXULAttribute : public nsIDOMAttr
|
||||
{
|
||||
protected:
|
||||
nsXULAttribute(nsIContent* aContent,
|
||||
nsINodeInfo* aNodeInfo,
|
||||
const nsAString& aValue);
|
||||
|
||||
virtual ~nsXULAttribute();
|
||||
|
||||
public:
|
||||
static nsresult
|
||||
Create(nsIContent* aContent,
|
||||
nsINodeInfo* aNodeInfo,
|
||||
const nsAString& aValue,
|
||||
nsXULAttribute** aResult);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_NSIDOMNODE
|
||||
|
||||
// nsIDOMAttr interface
|
||||
NS_DECL_NSIDOMATTR
|
||||
|
||||
// Implementation methods
|
||||
void GetQualifiedName(nsAString& aAttributeName);
|
||||
|
||||
nsINodeInfo* GetNodeInfo() const { return mNodeInfo; }
|
||||
nsresult SetValueInternal(const nsAString& aValue);
|
||||
nsresult GetValueAsAtom(nsIAtom** aResult);
|
||||
|
||||
protected:
|
||||
union {
|
||||
nsIContent* mContent; // The content object that owns the attribute
|
||||
nsXULAttribute* mNext; // For objects on the freelist
|
||||
};
|
||||
|
||||
nsINodeInfo* mNodeInfo; // The attribute name
|
||||
nsXULAttributeValue mValue; // The attribute value; either an nsIAtom* or PRUnichar*,
|
||||
// with the low-order bit tagging its type
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsXULAttributes : public nsIDOMNamedNodeMap
|
||||
{
|
||||
public:
|
||||
static nsresult
|
||||
Create(nsIContent* aElement, nsXULAttributes** aResult);
|
||||
|
||||
static void
|
||||
Destroy(nsXULAttributes *aAttrs);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
NS_DECL_NSIDOMNAMEDNODEMAP
|
||||
|
||||
// Implementation methods
|
||||
// VoidArray Helpers
|
||||
PRUint32 Count() { return mAttributes.Count(); };
|
||||
nsXULAttribute* ElementAt(PRInt32 i) { return (nsXULAttribute*)mAttributes.ElementAt(i); };
|
||||
void AppendElement(nsXULAttribute* aElement) { mAttributes.AppendElement((void*)aElement); };
|
||||
void RemoveElementAt(PRInt32 aIndex) { mAttributes.RemoveElementAt(aIndex); };
|
||||
|
||||
// Style Helpers
|
||||
nsresult GetClasses(nsVoidArray& aArray) const;
|
||||
PRBool HasClass(nsIAtom* aClass) const;
|
||||
|
||||
nsresult SetClassList(nsClassList* aClassList);
|
||||
nsresult UpdateClassList(const nsAString& aValue);
|
||||
nsresult UpdateStyleRule(nsIURI* aDocURL, const nsAString& aValue);
|
||||
|
||||
nsresult SetInlineStyleRule(nsIStyleRule* aRule);
|
||||
nsresult GetInlineStyleRule(nsIStyleRule*& aRule);
|
||||
|
||||
protected:
|
||||
nsXULAttributes(nsIContent* aContent);
|
||||
virtual ~nsXULAttributes();
|
||||
|
||||
nsIContent* mContent;
|
||||
nsClassList* mClassList;
|
||||
nsCOMPtr<nsIStyleRule> mStyleRule;
|
||||
nsAutoVoidArray mAttributes;
|
||||
private:
|
||||
// Hide so that all construction and destruction use Create and Destroy.
|
||||
static void *operator new(size_t) CPP_THROW_NEW { return 0; };
|
||||
static void operator delete(void *, size_t) { };
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXULAttributes_h__
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptGlobalObjectOwner.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
@ -125,6 +125,7 @@
|
|||
#include "nsRuleWalker.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsCSSDeclaration.h"
|
||||
#include "nsXULAtoms.h"
|
||||
#include "nsIListBoxObject.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -155,6 +156,8 @@ class nsIDocShell;
|
|||
nsICSSParser* nsXULPrototypeElement::sCSSParser = nsnull;
|
||||
nsIXULPrototypeCache* nsXULPrototypeScript::sXULPrototypeCache = nsnull;
|
||||
nsIXBLService * nsXULElement::gXBLService = nsnull;
|
||||
nsICSSOMFactory* nsXULElement::gCSSOMFactory = nsnull;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@ -162,6 +165,7 @@ static NS_DEFINE_CID(kEventListenerManagerCID, NS_EVENTLISTENERMANAGER_CID);
|
|||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
|
||||
static NS_DEFINE_CID(kCSSOMFactoryCID, NS_CSSOMFACTORY_CID);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@ -2299,6 +2303,8 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
|
|||
// XXX attribute code swiped from nsGenericContainerElement
|
||||
// this class could probably just use nsGenericContainerElement
|
||||
// needed to maintain attribute namespace ID as well as ordering
|
||||
// NOTE: Changes to this function may need to be made in
|
||||
// |SetInlineStyleRule| as well.
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAString& aValue,
|
||||
|
@ -2366,7 +2372,10 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
|
|||
// to unhook the old one.
|
||||
|
||||
// Save whether this is a modification before we muck with the attr pointer.
|
||||
PRBool modification = attr || protoattr;
|
||||
|
||||
PRInt32 modHint = (attr || protoattr)
|
||||
? PRInt32(nsIDOMMutationEvent::MODIFICATION)
|
||||
: PRInt32(nsIDOMMutationEvent::ADDITION);
|
||||
|
||||
if (attr) {
|
||||
attr->SetValueInternal(aValue);
|
||||
|
@ -2391,12 +2400,22 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
|
|||
if (aNodeInfo->Equals(nsXULAtoms::accesskey, kNameSpaceID_None))
|
||||
UnregisterAccessKey(oldValue);
|
||||
|
||||
FinishSetAttr(attrns, attrName, oldValue, aValue, modHint, aNotify);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::FinishSetAttr(PRInt32 aAttrNS, nsIAtom* aAttrName,
|
||||
const nsAString& aOldValue, const nsAString& aValue,
|
||||
PRInt32 aModHint, PRBool aNotify)
|
||||
{
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
mDocument->GetBindingManager()->GetBinding(NS_STATIC_CAST(nsIStyledContent*, this), getter_AddRefs(binding));
|
||||
|
||||
if (binding)
|
||||
binding->AttributeChanged(attrName, attrns, PR_FALSE, aNotify);
|
||||
binding->AttributeChanged(aAttrName, aAttrNS, PR_FALSE, aNotify);
|
||||
|
||||
if (HasMutationListeners(NS_STATIC_CAST(nsIStyledContent*, this), NS_EVENT_BITS_MUTATION_ATTRMODIFIED)) {
|
||||
nsCOMPtr<nsIDOMEventTarget> node(do_QueryInterface(NS_STATIC_CAST(nsIStyledContent*, this)));
|
||||
|
@ -2406,34 +2425,25 @@ nsXULElement::SetAttr(nsINodeInfo* aNodeInfo,
|
|||
mutation.mTarget = node;
|
||||
|
||||
nsAutoString attrName2;
|
||||
attrName->ToString(attrName2);
|
||||
aAttrName->ToString(attrName2);
|
||||
nsCOMPtr<nsIDOMAttr> attrNode;
|
||||
GetAttributeNode(attrName2, getter_AddRefs(attrNode));
|
||||
mutation.mRelatedNode = attrNode;
|
||||
|
||||
mutation.mAttrName = attrName;
|
||||
if (!oldValue.IsEmpty())
|
||||
mutation.mPrevAttrValue = do_GetAtom(oldValue);
|
||||
mutation.mAttrName = aAttrName;
|
||||
if (!aOldValue.IsEmpty())
|
||||
mutation.mPrevAttrValue = do_GetAtom(aOldValue);
|
||||
if (!aValue.IsEmpty())
|
||||
mutation.mNewAttrValue = do_GetAtom(aValue);
|
||||
if (modification)
|
||||
mutation.mAttrChange = nsIDOMMutationEvent::MODIFICATION;
|
||||
else
|
||||
mutation.mAttrChange = nsIDOMMutationEvent::ADDITION;
|
||||
mutation.mAttrChange = aModHint;
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
HandleDOMEvent(nsnull, &mutation, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
|
||||
if (aNotify) {
|
||||
PRInt32 modHint = modification
|
||||
? PRInt32(nsIDOMMutationEvent::MODIFICATION)
|
||||
: PRInt32(nsIDOMMutationEvent::ADDITION);
|
||||
|
||||
mDocument->AttributeChanged(this, attrns, attrName, modHint);
|
||||
mDocument->AttributeChanged(this, aAttrNS, aAttrName, aModHint);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3516,7 +3526,7 @@ nsXULElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetInlineStyleRule(nsIStyleRule** aStyleRule)
|
||||
nsXULElement::GetInlineStyleRule(nsICSSStyleRule** aStyleRule)
|
||||
{
|
||||
// Fetch the cached style rule from the attributes.
|
||||
nsresult result = NS_OK;
|
||||
|
@ -3533,6 +3543,73 @@ nsXULElement::GetInlineStyleRule(nsIStyleRule** aStyleRule)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify)
|
||||
{
|
||||
// Fault everything, for the same reason as |GetAttributes|, and
|
||||
// force the creation of the attributes struct.
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> domattrs;
|
||||
nsresult rv = GetAttributes(getter_AddRefs(domattrs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aNotify = aNotify && mDocument;
|
||||
|
||||
// This function does roughly the same things that |SetAttr| does.
|
||||
|
||||
mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify);
|
||||
if (aNotify) {
|
||||
mDocument->AttributeWillChange(this, kNameSpaceID_None,
|
||||
nsXULAtoms::style);
|
||||
}
|
||||
|
||||
PRInt32 modHint;
|
||||
nsCOMPtr<nsICSSStyleRule> oldRule;
|
||||
nsAutoString oldValue;
|
||||
GetInlineStyleRule(getter_AddRefs(oldRule));
|
||||
if (oldRule) {
|
||||
modHint = PRInt32(nsIDOMMutationEvent::MODIFICATION);
|
||||
oldRule->GetDeclaration()->ToString(oldValue);
|
||||
} else {
|
||||
modHint = PRInt32(nsIDOMMutationEvent::ADDITION);
|
||||
}
|
||||
|
||||
rv = Attributes()->SetInlineStyleRule(aStyleRule);
|
||||
|
||||
nsAutoString stringValue;
|
||||
aStyleRule->GetDeclaration()->ToString(stringValue);
|
||||
|
||||
// Fix the copy stored as a string too.
|
||||
nsXULAttribute* attr = FindLocalAttribute(kNameSpaceID_None,
|
||||
nsXULAtoms::style);
|
||||
if (attr) {
|
||||
attr->SetValueInternal(stringValue);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
NodeInfo()->GetNodeInfoManager(getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
rv = nimgr->GetNodeInfo(nsXULAtoms::style, nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Need to create a local attr
|
||||
rv = nsXULAttribute::Create(NS_STATIC_CAST(nsIStyledContent*, this),
|
||||
ni, stringValue, &attr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// transfer ownership here...
|
||||
nsXULAttributes *attrs = mSlots->GetAttributes();
|
||||
attrs->AppendElement(attr);
|
||||
}
|
||||
|
||||
FinishSetAttr(kNameSpaceID_None, nsXULAtoms::style,
|
||||
oldValue, stringValue, modHint, aNotify);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
|
@ -4056,8 +4133,33 @@ nsXULElement::SetStatusText(const nsAString& aAttr)
|
|||
nsresult
|
||||
nsXULElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
// Fault everything, for the same reason as |GetAttributes|, and
|
||||
// force the creation of the attributes struct.
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> domattrs;
|
||||
nsresult rv = GetAttributes(getter_AddRefs(domattrs));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXULAttributes *attrs = Attributes();
|
||||
if (!attrs->GetDOMStyle()) {
|
||||
if (!gCSSOMFactory) {
|
||||
rv = CallGetService(kCSSOMFactoryCID, &gCSSOMFactory);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMCSSDeclaration> domStyle;
|
||||
rv = gCSSOMFactory->CreateDOMCSSAttributeDeclaration(this,
|
||||
getter_AddRefs(domStyle));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
attrs->SetDOMStyle(domStyle);
|
||||
}
|
||||
|
||||
// Why bother with QI?
|
||||
NS_IF_ADDREF(*aStyle = attrs->GetDOMStyle());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4520,6 +4622,7 @@ nsXULElement::Slots::~Slots()
|
|||
|
||||
nsXULPrototypeAttribute::~nsXULPrototypeAttribute()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsXULPrototypeAttribute);
|
||||
if (mEventHandler)
|
||||
RemoveJSGCRoot(&mEventHandler);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "nsINodeInfo.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
|
@ -78,6 +79,7 @@
|
|||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsXULAttributeValue.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsICSSOMFactory.h"
|
||||
#include "nsLayoutCID.h"
|
||||
|
||||
#include "nsGenericElement.h" // for nsCheapVoidArray
|
||||
|
@ -113,6 +115,8 @@ static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
|
|||
|
||||
*/
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsXULPrototypeAttribute)
|
||||
|
||||
class nsXULPrototypeAttribute
|
||||
{
|
||||
public:
|
||||
|
@ -120,6 +124,7 @@ public:
|
|||
: mEventHandler(nsnull)
|
||||
{
|
||||
XUL_PROTOTYPE_ATTRIBUTE_METER(gNumAttributes);
|
||||
MOZ_COUNT_CTOR(nsXULPrototypeAttribute);
|
||||
}
|
||||
|
||||
~nsXULPrototypeAttribute();
|
||||
|
@ -271,7 +276,7 @@ public:
|
|||
PRUint32 mNumAttributes;
|
||||
nsXULPrototypeAttribute* mAttributes; // [OWNER]
|
||||
|
||||
nsCOMPtr<nsIStyleRule> mInlineStyleRule; // [OWNER]
|
||||
nsCOMPtr<nsICSSStyleRule> mInlineStyleRule; // [OWNER]
|
||||
nsClassList* mClassList;
|
||||
|
||||
nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsAString& aValue);
|
||||
|
@ -387,12 +392,17 @@ public:
|
|||
CallGetService("@mozilla.org/xbl;1", &gXBLService);
|
||||
return gXBLService;
|
||||
}
|
||||
static void ReleaseGlobals() { NS_IF_RELEASE(gXBLService); }
|
||||
static void ReleaseGlobals() {
|
||||
NS_IF_RELEASE(gXBLService);
|
||||
NS_IF_RELEASE(gCSSOMFactory);
|
||||
}
|
||||
|
||||
protected:
|
||||
static nsrefcnt gRefCnt;
|
||||
// pseudo-constants
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsIXBLService* gXBLService;
|
||||
static nsICSSOMFactory* gCSSOMFactory;
|
||||
|
||||
public:
|
||||
static nsresult
|
||||
|
@ -473,7 +483,8 @@ public:
|
|||
NS_IMETHOD_(PRBool) HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
|
||||
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule** aStyleRule);
|
||||
NS_IMETHOD GetInlineStyleRule(nsICSSStyleRule** aStyleRule);
|
||||
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
|
||||
NS_IMETHOD GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
nsChangeHint& aHint) const;
|
||||
|
@ -651,6 +662,10 @@ protected:
|
|||
|
||||
nsresult HideWindowChrome(PRBool aShouldHide);
|
||||
|
||||
void FinishSetAttr(PRInt32 aAttrNS, nsIAtom* aAttrName,
|
||||
const nsAString& aOldValue, const nsAString& aNewValue,
|
||||
PRInt32 aModHint, PRBool aNotify);
|
||||
|
||||
protected:
|
||||
// Internal accessors. These shadow the 'Slots', and return
|
||||
// appropriate default values if there are no slots defined in the
|
||||
|
@ -660,8 +675,6 @@ protected:
|
|||
nsXULAttributes *Attributes() const { return mSlots ? mSlots->GetAttributes() : nsnull; }
|
||||
|
||||
void UnregisterAccessKey(const nsAString& aOldValue);
|
||||
|
||||
static nsIXBLService *gXBLService;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ nsCSSOMFactory::~nsCSSOMFactory()
|
|||
NS_IMPL_ISUPPORTS1(nsCSSOMFactory, nsICSSOMFactory)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCSSOMFactory::CreateDOMCSSAttributeDeclaration(nsIHTMLContent *aContent,
|
||||
nsCSSOMFactory::CreateDOMCSSAttributeDeclaration(nsIStyledContent *aContent,
|
||||
nsDOMCSSDeclaration **aResult)
|
||||
{
|
||||
nsDOMCSSDeclaration *result = new nsDOMCSSAttributeDeclaration(aContent);
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateDOMCSSAttributeDeclaration(nsIHTMLContent *aContent,
|
||||
NS_IMETHOD CreateDOMCSSAttributeDeclaration(nsIStyledContent *aContent,
|
||||
nsDOMCSSDeclaration **aResult);
|
||||
|
||||
};
|
||||
|
|
|
@ -111,9 +111,9 @@ public:
|
|||
nsIURI* aInputURL,
|
||||
nsICSSStyleSheet*& aResult);
|
||||
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsIStyleRule** aResult);
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsICSSStyleRule** aResult);
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aBaseURL,
|
||||
|
@ -596,7 +596,7 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
|
|||
NS_IMETHODIMP
|
||||
CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsIStyleRule** aResult)
|
||||
nsICSSStyleRule** aResult)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aBaseURL, "need base URL");
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "nsCSSDeclaration.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsHTMLValue.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
|
@ -54,7 +54,7 @@
|
|||
|
||||
MOZ_DECL_CTOR_COUNTER(nsDOMCSSAttributeDeclaration)
|
||||
|
||||
nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent)
|
||||
nsDOMCSSAttributeDeclaration::nsDOMCSSAttributeDeclaration(nsIStyledContent *aContent)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsDOMCSSAttributeDeclaration);
|
||||
|
||||
|
@ -81,25 +81,16 @@ nsresult
|
|||
nsDOMCSSAttributeDeclaration::DeclarationChanged()
|
||||
{
|
||||
NS_ASSERTION(mContent, "Must have content node to set the decl!");
|
||||
nsHTMLValue val;
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
mContent->GetHTMLAttribute(nsHTMLAtoms::style, val);
|
||||
NS_ASSERTION(rv == NS_CONTENT_ATTR_HAS_VALUE &&
|
||||
eHTMLUnit_ISupports == val.GetUnit(),
|
||||
"content must have rule");
|
||||
nsCOMPtr<nsICSSStyleRule> oldRule =
|
||||
do_QueryInterface(nsCOMPtr<nsISupports>(val.GetISupportsValue()));
|
||||
nsCOMPtr<nsICSSStyleRule> oldRule;
|
||||
mContent->GetInlineStyleRule(getter_AddRefs(oldRule));
|
||||
NS_ASSERTION(oldRule, "content must have rule");
|
||||
|
||||
nsCOMPtr<nsICSSStyleRule> newRule = oldRule->DeclarationChanged(PR_FALSE);
|
||||
if (!newRule) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return mContent->SetHTMLAttribute(nsHTMLAtoms::style,
|
||||
nsHTMLValue(newRule),
|
||||
PR_TRUE);
|
||||
return mContent->SetInlineStyleRule(newRule, PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -110,15 +101,10 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
|||
|
||||
*aDecl = nsnull;
|
||||
if (mContent) {
|
||||
nsHTMLValue val;
|
||||
result = mContent->GetHTMLAttribute(nsHTMLAtoms::style, val);
|
||||
if (result == NS_CONTENT_ATTR_HAS_VALUE &&
|
||||
eHTMLUnit_ISupports == val.GetUnit()) {
|
||||
nsCOMPtr<nsISupports> rule = val.GetISupportsValue();
|
||||
nsCOMPtr<nsICSSStyleRule> cssRule = do_QueryInterface(rule, &result);
|
||||
if (cssRule) {
|
||||
*aDecl = cssRule->GetDeclaration();
|
||||
}
|
||||
nsCOMPtr<nsICSSStyleRule> cssRule;
|
||||
mContent->GetInlineStyleRule(getter_AddRefs(cssRule));
|
||||
if (cssRule) {
|
||||
*aDecl = cssRule->GetDeclaration();
|
||||
}
|
||||
else if (aAllocate) {
|
||||
nsCSSDeclaration *decl = new nsCSSDeclaration();
|
||||
|
@ -136,9 +122,7 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
|||
return result;
|
||||
}
|
||||
|
||||
result = mContent->SetHTMLAttribute(nsHTMLAtoms::style,
|
||||
nsHTMLValue(cssRule),
|
||||
PR_FALSE);
|
||||
result = mContent->SetInlineStyleRule(cssRule, PR_FALSE);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
*aDecl = decl;
|
||||
}
|
||||
|
|
|
@ -45,14 +45,14 @@
|
|||
#include "nsString.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIHTMLContent;
|
||||
class nsIStyledContent;
|
||||
class nsICSSLoader;
|
||||
class nsICSSParser;
|
||||
|
||||
class nsDOMCSSAttributeDeclaration : public nsDOMCSSDeclaration
|
||||
{
|
||||
public:
|
||||
nsDOMCSSAttributeDeclaration(nsIHTMLContent *aContent);
|
||||
nsDOMCSSAttributeDeclaration(nsIStyledContent *aContent);
|
||||
~nsDOMCSSAttributeDeclaration();
|
||||
|
||||
// impl AddRef/Release; QI is implemented by our parent class
|
||||
|
@ -75,7 +75,7 @@ protected:
|
|||
nsAutoRefCnt mRefCnt;
|
||||
NS_DECL_OWNINGTHREAD
|
||||
|
||||
nsIHTMLContent *mContent;
|
||||
nsIStyledContent *mContent;
|
||||
};
|
||||
|
||||
#endif /* nsDOMCSSAttributeDeclaration_h___ */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsDOMCSSDeclaration_h___
|
||||
#define nsDOMCSSSDeclaration_h___
|
||||
#define nsDOMCSSDeclaration_h___
|
||||
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsIDOMCSS2Properties.h"
|
||||
|
|
|
@ -452,7 +452,7 @@ HTMLCSSStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
|
|||
|
||||
if (styledContent) {
|
||||
// just get the one and only style rule from the content's STYLE attribute
|
||||
nsCOMPtr<nsIStyleRule> rule;
|
||||
nsCOMPtr<nsICSSStyleRule> rule;
|
||||
styledContent->GetInlineStyleRule(getter_AddRefs(rule));
|
||||
if (rule)
|
||||
aData->mRuleWalker->Forward(rule);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIHTMLContent;
|
||||
class nsIStyledContent;
|
||||
|
||||
// bfdd87bd-79c8-4041-ae14-91fa8536ce61
|
||||
#define NS_ICSSOMFACTORY_IID \
|
||||
|
@ -58,7 +58,7 @@ class nsICSSOMFactory : public nsISupports {
|
|||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICSSOMFACTORY_IID)
|
||||
|
||||
NS_IMETHOD CreateDOMCSSAttributeDeclaration(nsIHTMLContent *aContent,
|
||||
NS_IMETHOD CreateDOMCSSAttributeDeclaration(nsIStyledContent *aContent,
|
||||
nsDOMCSSDeclaration **aResult) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
class nsIStyleRule;
|
||||
class nsICSSStyleRule;
|
||||
class nsICSSStyleSheet;
|
||||
class nsIUnicharInputStream;
|
||||
class nsIURI;
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
// the declaration.
|
||||
NS_IMETHOD ParseStyleAttribute(const nsAString& aAttributeValue,
|
||||
nsIURI* aBaseURL,
|
||||
nsIStyleRule** aResult) = 0;
|
||||
nsICSSStyleRule** aResult) = 0;
|
||||
|
||||
NS_IMETHOD ParseAndAppendDeclaration(const nsAString& aBuffer,
|
||||
nsIURI* aBaseURL,
|
||||
|
|
Загрузка…
Ссылка в новой задаче