зеркало из https://github.com/mozilla/pjs.git
Eliminate all virtual functions from nsCSSRule to eliminate its vtable pointer. (Bug 596140) r=bzbarsky a2.0=roc
This commit is contained in:
Родитель
b3befc88bf
Коммит
0428eed0da
|
@ -116,7 +116,6 @@ CPPSRCS = \
|
||||||
nsCSSProps.cpp \
|
nsCSSProps.cpp \
|
||||||
nsCSSPseudoClasses.cpp \
|
nsCSSPseudoClasses.cpp \
|
||||||
nsCSSPseudoElements.cpp \
|
nsCSSPseudoElements.cpp \
|
||||||
nsCSSRule.cpp \
|
|
||||||
nsCSSRuleProcessor.cpp \
|
nsCSSRuleProcessor.cpp \
|
||||||
nsCSSRules.cpp \
|
nsCSSRules.cpp \
|
||||||
nsCSSScanner.cpp \
|
nsCSSScanner.cpp \
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* ***** 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) 1999
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* 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"),
|
|
||||||
* 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 ***** */
|
|
||||||
|
|
||||||
/* base class for all rule types in a CSS style sheet */
|
|
||||||
|
|
||||||
#include "nsCSSRule.h"
|
|
||||||
#include "nsCRT.h"
|
|
||||||
#include "nsCSSStyleSheet.h"
|
|
||||||
|
|
||||||
nsCSSRule::nsCSSRule(void)
|
|
||||||
: mSheet(nsnull),
|
|
||||||
mParentRule(nsnull)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCSSRule::nsCSSRule(const nsCSSRule& aCopy)
|
|
||||||
: mSheet(aCopy.mSheet),
|
|
||||||
mParentRule(aCopy.mParentRule)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
nsCSSRule::~nsCSSRule(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsCSSRule)
|
|
||||||
NS_IMPL_RELEASE(nsCSSRule)
|
|
||||||
|
|
||||||
/* virtual */ already_AddRefed<nsIStyleSheet>
|
|
||||||
nsCSSRule::GetStyleSheet() const
|
|
||||||
{
|
|
||||||
NS_IF_ADDREF(mSheet);
|
|
||||||
return mSheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* virtual */ void
|
|
||||||
nsCSSRule::SetStyleSheet(nsCSSStyleSheet* aSheet)
|
|
||||||
{
|
|
||||||
// We don't reference count this up reference. The style sheet
|
|
||||||
// will tell us when it's going away or when we're detached from
|
|
||||||
// it.
|
|
||||||
mSheet = aSheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* virtual */ void
|
|
||||||
nsCSSRule::SetParentRule(nsICSSGroupRule* aRule)
|
|
||||||
{
|
|
||||||
// We don't reference count this up reference. The group rule
|
|
||||||
// will tell us when it's going away or when we're detached from
|
|
||||||
// it.
|
|
||||||
mParentRule = aRule;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* virtual */ void
|
|
||||||
nsCSSRule::MapRuleInfoInto(nsRuleData* aRuleData)
|
|
||||||
{
|
|
||||||
// The nsIStyleRule contract is not appropriate for all CSS rules.
|
|
||||||
NS_NOTREACHED("nsCSSRule::MapRuleInfoInto");
|
|
||||||
}
|
|
|
@ -41,42 +41,53 @@
|
||||||
#define nsCSSRule_h___
|
#define nsCSSRule_h___
|
||||||
|
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsCSSStyleSheet.h"
|
||||||
|
|
||||||
class nsIStyleSheet;
|
|
||||||
class nsCSSStyleSheet;
|
|
||||||
struct nsRuleData;
|
|
||||||
class nsICSSGroupRule;
|
class nsICSSGroupRule;
|
||||||
template<class T> struct already_AddRefed;
|
|
||||||
|
|
||||||
class nsCSSRule {
|
class nsCSSRule {
|
||||||
public:
|
public:
|
||||||
nsCSSRule(void);
|
nsCSSRule(void)
|
||||||
nsCSSRule(const nsCSSRule& aCopy);
|
: mSheet(nsnull),
|
||||||
virtual ~nsCSSRule(void);
|
mParentRule(nsnull)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// for implementing nsISupports
|
nsCSSRule(const nsCSSRule& aCopy)
|
||||||
NS_IMETHOD_(nsrefcnt) AddRef();
|
: mSheet(aCopy.mSheet),
|
||||||
NS_IMETHOD_(nsrefcnt) Release();
|
mParentRule(aCopy.mParentRule)
|
||||||
protected:
|
{
|
||||||
nsAutoRefCnt mRefCnt;
|
}
|
||||||
NS_DECL_OWNINGTHREAD
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
|
already_AddRefed<nsIStyleSheet>
|
||||||
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
|
GetStyleSheet() const
|
||||||
|
{
|
||||||
|
NS_IF_ADDREF(mSheet);
|
||||||
|
return mSheet;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void SetParentRule(nsICSSGroupRule* aRule);
|
void
|
||||||
|
SetStyleSheet(nsCSSStyleSheet* aSheet)
|
||||||
|
{
|
||||||
|
// We don't reference count this up reference. The style sheet
|
||||||
|
// will tell us when it's going away or when we're detached from
|
||||||
|
// it.
|
||||||
|
mSheet = aSheet;
|
||||||
|
}
|
||||||
|
|
||||||
// nsIStyleRule methods
|
void
|
||||||
// The new mapping function.
|
SetParentRule(nsICSSGroupRule* aRule)
|
||||||
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
{
|
||||||
|
// We don't reference count this up reference. The group rule
|
||||||
|
// will tell us when it's going away or when we're detached from
|
||||||
|
// it.
|
||||||
|
mParentRule = aRule;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsCSSStyleSheet* mSheet;
|
nsCSSStyleSheet* mSheet;
|
||||||
nsICSSGroupRule* mParentRule;
|
nsICSSGroupRule* mParentRule;
|
||||||
#ifdef DEBUG_REFS
|
|
||||||
PRInt32 mInstance;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsCSSRule_h___ */
|
#endif /* nsCSSRule_h___ */
|
||||||
|
|
|
@ -193,9 +193,10 @@ class CSSCharsetRuleImpl : public nsCSSRule,
|
||||||
public:
|
public:
|
||||||
CSSCharsetRuleImpl(const nsAString& aEncoding);
|
CSSCharsetRuleImpl(const nsAString& aEncoding);
|
||||||
CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy);
|
CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy);
|
||||||
virtual ~CSSCharsetRuleImpl(void);
|
private:
|
||||||
|
~CSSCharsetRuleImpl() {}
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
DECL_STYLE_RULE_INHERIT
|
DECL_STYLE_RULE_INHERIT
|
||||||
|
|
||||||
|
@ -231,12 +232,8 @@ CSSCharsetRuleImpl::CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSCharsetRuleImpl::~CSSCharsetRuleImpl(void)
|
NS_IMPL_ADDREF(CSSCharsetRuleImpl)
|
||||||
{
|
NS_IMPL_RELEASE(CSSCharsetRuleImpl)
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(CSSCharsetRuleImpl, nsCSSRule)
|
|
||||||
NS_IMPL_RELEASE_INHERITED(CSSCharsetRuleImpl, nsCSSRule)
|
|
||||||
|
|
||||||
DOMCI_DATA(CSSCharsetRule, CSSCharsetRuleImpl)
|
DOMCI_DATA(CSSCharsetRule, CSSCharsetRuleImpl)
|
||||||
|
|
||||||
|
@ -363,9 +360,11 @@ class CSSImportRuleImpl : public nsCSSRule,
|
||||||
public:
|
public:
|
||||||
CSSImportRuleImpl(nsMediaList* aMedia);
|
CSSImportRuleImpl(nsMediaList* aMedia);
|
||||||
CSSImportRuleImpl(const CSSImportRuleImpl& aCopy);
|
CSSImportRuleImpl(const CSSImportRuleImpl& aCopy);
|
||||||
virtual ~CSSImportRuleImpl(void);
|
private:
|
||||||
|
~CSSImportRuleImpl();
|
||||||
|
public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
DECL_STYLE_RULE_INHERIT
|
DECL_STYLE_RULE_INHERIT
|
||||||
|
|
||||||
|
@ -421,15 +420,15 @@ CSSImportRuleImpl::CSSImportRuleImpl(const CSSImportRuleImpl& aCopy)
|
||||||
// SetSheet sets mMedia appropriately
|
// SetSheet sets mMedia appropriately
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSImportRuleImpl::~CSSImportRuleImpl(void)
|
CSSImportRuleImpl::~CSSImportRuleImpl()
|
||||||
{
|
{
|
||||||
if (mChildSheet) {
|
if (mChildSheet) {
|
||||||
mChildSheet->SetOwnerRule(nsnull);
|
mChildSheet->SetOwnerRule(nsnull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(CSSImportRuleImpl, nsCSSRule)
|
NS_IMPL_ADDREF(CSSImportRuleImpl)
|
||||||
NS_IMPL_RELEASE_INHERITED(CSSImportRuleImpl, nsCSSRule)
|
NS_IMPL_RELEASE(CSSImportRuleImpl)
|
||||||
|
|
||||||
DOMCI_DATA(CSSImportRule, CSSImportRuleImpl)
|
DOMCI_DATA(CSSImportRule, CSSImportRuleImpl)
|
||||||
|
|
||||||
|
@ -664,6 +663,9 @@ nsCSSGroupRule::~nsCSSGroupRule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMPL_ADDREF(nsCSSGroupRule)
|
||||||
|
NS_IMPL_RELEASE(nsCSSGroupRule)
|
||||||
|
|
||||||
IMPL_STYLE_RULE_INHERIT2(nsCSSGroupRule, nsCSSRule)
|
IMPL_STYLE_RULE_INHERIT2(nsCSSGroupRule, nsCSSRule)
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
|
@ -887,8 +889,8 @@ nsCSSMediaRule::~nsCSSMediaRule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(nsCSSMediaRule, nsCSSRule)
|
NS_IMPL_ADDREF_INHERITED(nsCSSMediaRule, nsCSSGroupRule)
|
||||||
NS_IMPL_RELEASE_INHERITED(nsCSSMediaRule, nsCSSRule)
|
NS_IMPL_RELEASE_INHERITED(nsCSSMediaRule, nsCSSGroupRule)
|
||||||
|
|
||||||
DOMCI_DATA(CSSMediaRule, nsCSSMediaRule)
|
DOMCI_DATA(CSSMediaRule, nsCSSMediaRule)
|
||||||
|
|
||||||
|
@ -1050,8 +1052,8 @@ nsCSSDocumentRule::~nsCSSDocumentRule(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(nsCSSDocumentRule, nsCSSRule)
|
NS_IMPL_ADDREF_INHERITED(nsCSSDocumentRule, nsCSSGroupRule)
|
||||||
NS_IMPL_RELEASE_INHERITED(nsCSSDocumentRule, nsCSSRule)
|
NS_IMPL_RELEASE_INHERITED(nsCSSDocumentRule, nsCSSGroupRule)
|
||||||
|
|
||||||
DOMCI_DATA(CSSMozDocumentRule, nsCSSDocumentRule)
|
DOMCI_DATA(CSSMozDocumentRule, nsCSSDocumentRule)
|
||||||
|
|
||||||
|
@ -1236,9 +1238,10 @@ class CSSNameSpaceRuleImpl : public nsCSSRule,
|
||||||
public:
|
public:
|
||||||
CSSNameSpaceRuleImpl(void);
|
CSSNameSpaceRuleImpl(void);
|
||||||
CSSNameSpaceRuleImpl(const CSSNameSpaceRuleImpl& aCopy);
|
CSSNameSpaceRuleImpl(const CSSNameSpaceRuleImpl& aCopy);
|
||||||
virtual ~CSSNameSpaceRuleImpl(void);
|
private:
|
||||||
|
~CSSNameSpaceRuleImpl();
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
DECL_STYLE_RULE_INHERIT
|
DECL_STYLE_RULE_INHERIT
|
||||||
|
|
||||||
|
@ -1281,13 +1284,13 @@ CSSNameSpaceRuleImpl::CSSNameSpaceRuleImpl(const CSSNameSpaceRuleImpl& aCopy)
|
||||||
NS_IF_ADDREF(mPrefix);
|
NS_IF_ADDREF(mPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSNameSpaceRuleImpl::~CSSNameSpaceRuleImpl(void)
|
CSSNameSpaceRuleImpl::~CSSNameSpaceRuleImpl()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(mPrefix);
|
NS_IF_RELEASE(mPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(CSSNameSpaceRuleImpl, nsCSSRule)
|
NS_IMPL_ADDREF(CSSNameSpaceRuleImpl)
|
||||||
NS_IMPL_RELEASE_INHERITED(CSSNameSpaceRuleImpl, nsCSSRule)
|
NS_IMPL_RELEASE(CSSNameSpaceRuleImpl)
|
||||||
|
|
||||||
DOMCI_DATA(CSSNameSpaceRule, CSSNameSpaceRuleImpl)
|
DOMCI_DATA(CSSNameSpaceRule, CSSNameSpaceRuleImpl)
|
||||||
|
|
||||||
|
@ -1773,8 +1776,8 @@ nsCSSFontFaceRule::Clone() const
|
||||||
return clone.forget();
|
return clone.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(nsCSSFontFaceRule, nsCSSRule)
|
NS_IMPL_ADDREF(nsCSSFontFaceRule)
|
||||||
NS_IMPL_RELEASE_INHERITED(nsCSSFontFaceRule, nsCSSRule)
|
NS_IMPL_RELEASE(nsCSSFontFaceRule)
|
||||||
|
|
||||||
DOMCI_DATA(CSSFontFaceRule, nsCSSFontFaceRule)
|
DOMCI_DATA(CSSFontFaceRule, nsCSSFontFaceRule)
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,14 @@ protected:
|
||||||
nsCSSGroupRule(const nsCSSGroupRule& aCopy);
|
nsCSSGroupRule(const nsCSSGroupRule& aCopy);
|
||||||
~nsCSSGroupRule();
|
~nsCSSGroupRule();
|
||||||
|
|
||||||
|
// Implement part of nsISupports.
|
||||||
|
NS_IMETHOD_(nsrefcnt) AddRef();
|
||||||
|
NS_IMETHOD_(nsrefcnt) Release();
|
||||||
|
protected:
|
||||||
|
nsAutoRefCnt mRefCnt;
|
||||||
|
NS_DECL_OWNINGTHREAD
|
||||||
|
public:
|
||||||
|
|
||||||
// implement part of nsIStyleRule and nsICSSRule
|
// implement part of nsIStyleRule and nsICSSRule
|
||||||
DECL_STYLE_RULE_INHERIT_NO_DOMRULE
|
DECL_STYLE_RULE_INHERIT_NO_DOMRULE
|
||||||
|
|
||||||
|
@ -254,7 +262,7 @@ class nsCSSFontFaceRule : public nsCSSRule,
|
||||||
public nsIDOMCSSFontFaceRule
|
public nsIDOMCSSFontFaceRule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
// nsIStyleRule methods
|
// nsIStyleRule methods
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -1284,7 +1284,7 @@ private:
|
||||||
css::Declaration *aDeclaration);
|
css::Declaration *aDeclaration);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
virtual nsCSSSelectorList* Selector(void);
|
virtual nsCSSSelectorList* Selector(void);
|
||||||
|
|
||||||
|
@ -1327,8 +1327,8 @@ private:
|
||||||
// These are not supported and are not implemented!
|
// These are not supported and are not implemented!
|
||||||
CSSStyleRuleImpl& operator=(const CSSStyleRuleImpl& aCopy);
|
CSSStyleRuleImpl& operator=(const CSSStyleRuleImpl& aCopy);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
virtual ~CSSStyleRuleImpl(void);
|
~CSSStyleRuleImpl();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsCSSSelectorList* mSelector; // null for style attribute
|
nsCSSSelectorList* mSelector; // null for style attribute
|
||||||
|
@ -1393,7 +1393,7 @@ CSSStyleRuleImpl::CSSStyleRuleImpl(CSSStyleRuleImpl& aCopy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSStyleRuleImpl::~CSSStyleRuleImpl(void)
|
CSSStyleRuleImpl::~CSSStyleRuleImpl()
|
||||||
{
|
{
|
||||||
delete mSelector;
|
delete mSelector;
|
||||||
delete mDeclaration;
|
delete mDeclaration;
|
||||||
|
@ -1412,8 +1412,8 @@ NS_INTERFACE_MAP_BEGIN(CSSStyleRuleImpl)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSStyleRule)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSStyleRule)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
NS_IMPL_ADDREF_INHERITED(CSSStyleRuleImpl, nsCSSRule)
|
NS_IMPL_ADDREF(CSSStyleRuleImpl)
|
||||||
NS_IMPL_RELEASE_INHERITED(CSSStyleRuleImpl, nsCSSRule)
|
NS_IMPL_RELEASE(CSSStyleRuleImpl)
|
||||||
|
|
||||||
nsCSSSelectorList* CSSStyleRuleImpl::Selector(void)
|
nsCSSSelectorList* CSSStyleRuleImpl::Selector(void)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче