Eliminate all virtual functions from nsCSSRule to eliminate its vtable pointer. (Bug 596140) r=bzbarsky a2.0=roc

This commit is contained in:
L. David Baron 2010-09-18 11:43:17 -07:00
Родитель b3befc88bf
Коммит 0428eed0da
6 изменённых файлов: 78 добавлений и 151 удалений

Просмотреть файл

@ -116,7 +116,6 @@ CPPSRCS = \
nsCSSProps.cpp \
nsCSSPseudoClasses.cpp \
nsCSSPseudoElements.cpp \
nsCSSRule.cpp \
nsCSSRuleProcessor.cpp \
nsCSSRules.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___
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsCSSStyleSheet.h"
class nsIStyleSheet;
class nsCSSStyleSheet;
struct nsRuleData;
class nsICSSGroupRule;
template<class T> struct already_AddRefed;
class nsCSSRule {
public:
nsCSSRule(void);
nsCSSRule(const nsCSSRule& aCopy);
virtual ~nsCSSRule(void);
nsCSSRule(void)
: mSheet(nsnull),
mParentRule(nsnull)
{
}
// for implementing nsISupports
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
protected:
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
public:
nsCSSRule(const nsCSSRule& aCopy)
: mSheet(aCopy.mSheet),
mParentRule(aCopy.mParentRule)
{
}
virtual already_AddRefed<nsIStyleSheet> GetStyleSheet() const;
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet);
already_AddRefed<nsIStyleSheet>
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
// The new mapping function.
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
void
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;
}
protected:
nsCSSStyleSheet* mSheet;
nsICSSGroupRule* mParentRule;
#ifdef DEBUG_REFS
PRInt32 mInstance;
#endif
};
#endif /* nsCSSRule_h___ */

Просмотреть файл

@ -193,9 +193,10 @@ class CSSCharsetRuleImpl : public nsCSSRule,
public:
CSSCharsetRuleImpl(const nsAString& aEncoding);
CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy);
virtual ~CSSCharsetRuleImpl(void);
NS_DECL_ISUPPORTS_INHERITED
private:
~CSSCharsetRuleImpl() {}
public:
NS_DECL_ISUPPORTS
DECL_STYLE_RULE_INHERIT
@ -231,12 +232,8 @@ CSSCharsetRuleImpl::CSSCharsetRuleImpl(const CSSCharsetRuleImpl& aCopy)
{
}
CSSCharsetRuleImpl::~CSSCharsetRuleImpl(void)
{
}
NS_IMPL_ADDREF_INHERITED(CSSCharsetRuleImpl, nsCSSRule)
NS_IMPL_RELEASE_INHERITED(CSSCharsetRuleImpl, nsCSSRule)
NS_IMPL_ADDREF(CSSCharsetRuleImpl)
NS_IMPL_RELEASE(CSSCharsetRuleImpl)
DOMCI_DATA(CSSCharsetRule, CSSCharsetRuleImpl)
@ -363,9 +360,11 @@ class CSSImportRuleImpl : public nsCSSRule,
public:
CSSImportRuleImpl(nsMediaList* aMedia);
CSSImportRuleImpl(const CSSImportRuleImpl& aCopy);
virtual ~CSSImportRuleImpl(void);
private:
~CSSImportRuleImpl();
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_ISUPPORTS
DECL_STYLE_RULE_INHERIT
@ -421,15 +420,15 @@ CSSImportRuleImpl::CSSImportRuleImpl(const CSSImportRuleImpl& aCopy)
// SetSheet sets mMedia appropriately
}
CSSImportRuleImpl::~CSSImportRuleImpl(void)
CSSImportRuleImpl::~CSSImportRuleImpl()
{
if (mChildSheet) {
mChildSheet->SetOwnerRule(nsnull);
}
}
NS_IMPL_ADDREF_INHERITED(CSSImportRuleImpl, nsCSSRule)
NS_IMPL_RELEASE_INHERITED(CSSImportRuleImpl, nsCSSRule)
NS_IMPL_ADDREF(CSSImportRuleImpl)
NS_IMPL_RELEASE(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)
static PRBool
@ -887,8 +889,8 @@ nsCSSMediaRule::~nsCSSMediaRule()
}
}
NS_IMPL_ADDREF_INHERITED(nsCSSMediaRule, nsCSSRule)
NS_IMPL_RELEASE_INHERITED(nsCSSMediaRule, nsCSSRule)
NS_IMPL_ADDREF_INHERITED(nsCSSMediaRule, nsCSSGroupRule)
NS_IMPL_RELEASE_INHERITED(nsCSSMediaRule, nsCSSGroupRule)
DOMCI_DATA(CSSMediaRule, nsCSSMediaRule)
@ -1050,8 +1052,8 @@ nsCSSDocumentRule::~nsCSSDocumentRule(void)
{
}
NS_IMPL_ADDREF_INHERITED(nsCSSDocumentRule, nsCSSRule)
NS_IMPL_RELEASE_INHERITED(nsCSSDocumentRule, nsCSSRule)
NS_IMPL_ADDREF_INHERITED(nsCSSDocumentRule, nsCSSGroupRule)
NS_IMPL_RELEASE_INHERITED(nsCSSDocumentRule, nsCSSGroupRule)
DOMCI_DATA(CSSMozDocumentRule, nsCSSDocumentRule)
@ -1236,9 +1238,10 @@ class CSSNameSpaceRuleImpl : public nsCSSRule,
public:
CSSNameSpaceRuleImpl(void);
CSSNameSpaceRuleImpl(const CSSNameSpaceRuleImpl& aCopy);
virtual ~CSSNameSpaceRuleImpl(void);
NS_DECL_ISUPPORTS_INHERITED
private:
~CSSNameSpaceRuleImpl();
public:
NS_DECL_ISUPPORTS
DECL_STYLE_RULE_INHERIT
@ -1281,13 +1284,13 @@ CSSNameSpaceRuleImpl::CSSNameSpaceRuleImpl(const CSSNameSpaceRuleImpl& aCopy)
NS_IF_ADDREF(mPrefix);
}
CSSNameSpaceRuleImpl::~CSSNameSpaceRuleImpl(void)
CSSNameSpaceRuleImpl::~CSSNameSpaceRuleImpl()
{
NS_IF_RELEASE(mPrefix);
}
NS_IMPL_ADDREF_INHERITED(CSSNameSpaceRuleImpl, nsCSSRule)
NS_IMPL_RELEASE_INHERITED(CSSNameSpaceRuleImpl, nsCSSRule)
NS_IMPL_ADDREF(CSSNameSpaceRuleImpl)
NS_IMPL_RELEASE(CSSNameSpaceRuleImpl)
DOMCI_DATA(CSSNameSpaceRule, CSSNameSpaceRuleImpl)
@ -1773,8 +1776,8 @@ nsCSSFontFaceRule::Clone() const
return clone.forget();
}
NS_IMPL_ADDREF_INHERITED(nsCSSFontFaceRule, nsCSSRule)
NS_IMPL_RELEASE_INHERITED(nsCSSFontFaceRule, nsCSSRule)
NS_IMPL_ADDREF(nsCSSFontFaceRule)
NS_IMPL_RELEASE(nsCSSFontFaceRule)
DOMCI_DATA(CSSFontFaceRule, nsCSSFontFaceRule)

Просмотреть файл

@ -76,6 +76,14 @@ protected:
nsCSSGroupRule(const nsCSSGroupRule& aCopy);
~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
DECL_STYLE_RULE_INHERIT_NO_DOMRULE
@ -254,7 +262,7 @@ class nsCSSFontFaceRule : public nsCSSRule,
public nsIDOMCSSFontFaceRule
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_ISUPPORTS
// nsIStyleRule methods
#ifdef DEBUG

Просмотреть файл

@ -1284,7 +1284,7 @@ private:
css::Declaration *aDeclaration);
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_ISUPPORTS
virtual nsCSSSelectorList* Selector(void);
@ -1327,8 +1327,8 @@ private:
// These are not supported and are not implemented!
CSSStyleRuleImpl& operator=(const CSSStyleRuleImpl& aCopy);
protected:
virtual ~CSSStyleRuleImpl(void);
private:
~CSSStyleRuleImpl();
protected:
nsCSSSelectorList* mSelector; // null for style attribute
@ -1393,7 +1393,7 @@ CSSStyleRuleImpl::CSSStyleRuleImpl(CSSStyleRuleImpl& aCopy,
}
}
CSSStyleRuleImpl::~CSSStyleRuleImpl(void)
CSSStyleRuleImpl::~CSSStyleRuleImpl()
{
delete mSelector;
delete mDeclaration;
@ -1412,8 +1412,8 @@ NS_INTERFACE_MAP_BEGIN(CSSStyleRuleImpl)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICSSStyleRule)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF_INHERITED(CSSStyleRuleImpl, nsCSSRule)
NS_IMPL_RELEASE_INHERITED(CSSStyleRuleImpl, nsCSSRule)
NS_IMPL_ADDREF(CSSStyleRuleImpl)
NS_IMPL_RELEASE(CSSStyleRuleImpl)
nsCSSSelectorList* CSSStyleRuleImpl::Selector(void)
{