Add preference for whether to enable marquee, and set the default to disabled. b=161109 r=caillon sr=bzbarsky a=rjesup

This commit is contained in:
dbaron%fas.harvard.edu 2002-10-15 00:06:57 +00:00
Родитель ee222f56de
Коммит fc4297892b
5 изменённых файлов: 371 добавлений и 34 удалений

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

@ -205,6 +205,7 @@ HTML_ATOM(longdesc, "longdesc")
HTML_ATOM(map, "map") HTML_ATOM(map, "map")
HTML_ATOM(marginheight, "marginheight") HTML_ATOM(marginheight, "marginheight")
HTML_ATOM(marginwidth, "marginwidth") HTML_ATOM(marginwidth, "marginwidth")
HTML_ATOM(marquee, "marquee")
HTML_ATOM(maxlength, "maxlength") HTML_ATOM(maxlength, "maxlength")
HTML_ATOM(mayscript, "mayscript") HTML_ATOM(mayscript, "mayscript")
HTML_ATOM(media, "media") HTML_ATOM(media, "media")

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

@ -61,8 +61,13 @@
#include "nsIStyleSet.h" #include "nsIStyleSet.h"
#include "nsISizeOfHandler.h" #include "nsISizeOfHandler.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranchInternal.h"
#include "nsIObserver.h"
static NS_DEFINE_CID(kCSSFrameConstructorCID, NS_CSSFRAMECONSTRUCTOR_CID); static NS_DEFINE_CID(kCSSFrameConstructorCID, NS_CSSFRAMECONSTRUCTOR_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID);
class HTMLColorRule : public nsIStyleRule { class HTMLColorRule : public nsIStyleRule {
public: public:
@ -170,8 +175,7 @@ void HTMLColorRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("HTMLColorRule");
tag = getter_AddRefs(NS_NewAtom("HTMLColorRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -258,8 +262,7 @@ void HTMLDocumentColorRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &a
} }
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("HTMLDocumentColorRule");
tag = getter_AddRefs(NS_NewAtom("HTMLDocumentColorRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -271,6 +274,89 @@ void HTMLDocumentColorRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &a
} }
#endif #endif
class MarqueeDisableRule : public nsIStyleRule {
public:
MarqueeDisableRule(nsIHTMLStyleSheet* aSheet);
virtual ~MarqueeDisableRule();
NS_DECL_ISUPPORTS
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
// The new mapping function.
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
#ifdef DEBUG
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize);
#endif
nsIHTMLStyleSheet* mSheet;
};
MarqueeDisableRule::MarqueeDisableRule(nsIHTMLStyleSheet* aSheet)
: mSheet(aSheet)
{
NS_INIT_ISUPPORTS();
}
MarqueeDisableRule::~MarqueeDisableRule()
{
}
NS_IMPL_ISUPPORTS1(MarqueeDisableRule, nsIStyleRule)
NS_IMETHODIMP
MarqueeDisableRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
{
NS_IF_ADDREF(mSheet);
aSheet = mSheet;
return NS_OK;
}
NS_IMETHODIMP
MarqueeDisableRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSID == eStyleStruct_Display) {
if (aRuleData->mDisplayData->mDisplay.GetUnit() == eCSSUnit_Null)
aRuleData->mDisplayData->mBinding = nsCSSValue(eCSSUnit_None);
}
return NS_OK;
}
#ifdef DEBUG
NS_IMETHODIMP
MarqueeDisableRule::List(FILE* out, PRInt32 aIndent) const
{
return NS_OK;
}
void MarqueeDisableRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
{
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
// first get the unique items collection
UNIQUE_STYLE_ITEMS(uniqueItems);
if(! uniqueItems->AddItem((void*)this) ){
// object has already been accounted for
return;
}
// get or create a tag for this instance
nsCOMPtr<nsIAtom> tag = do_GetAtom("MarqueeDisableRule");
// get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize);
if(mSheet){
PRUint32 localSize=0;
mSheet->SizeOf(aSizeOfHandler, localSize);
}
}
#endif
class GenericTableRule: public nsIStyleRule { class GenericTableRule: public nsIStyleRule {
public: public:
GenericTableRule(nsIHTMLStyleSheet* aSheet); GenericTableRule(nsIHTMLStyleSheet* aSheet);
@ -355,8 +441,7 @@ void GenericTableRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("GenericTableRule");
tag = getter_AddRefs(NS_NewAtom("GenericTableRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -808,6 +893,7 @@ protected:
HTMLColorRule* mVisitedRule; HTMLColorRule* mVisitedRule;
HTMLColorRule* mActiveRule; HTMLColorRule* mActiveRule;
HTMLDocumentColorRule* mDocumentColorRule; HTMLDocumentColorRule* mDocumentColorRule;
MarqueeDisableRule* mMarqueeDisableRule;
TableTbodyRule* mTableTbodyRule; TableTbodyRule* mTableTbodyRule;
TableRowRule* mTableRowRule; TableRowRule* mTableRowRule;
TableColgroupRule* mTableColgroupRule; TableColgroupRule* mTableColgroupRule;
@ -819,6 +905,49 @@ protected:
PLDHashTable mMappedAttrTable; PLDHashTable mMappedAttrTable;
}; };
static PRBool gEnableMarquee = PR_FALSE;
static PRBool gHaveMarqueePref = PR_FALSE;
static const char kMarqueePrefBranch[] = "browser.display.";
static const char kMarqueePrefName[] = "enable_marquee";
class MarqueePrefObserver : public nsIObserver
{
public:
MarqueePrefObserver();
virtual ~MarqueePrefObserver();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
};
MarqueePrefObserver::MarqueePrefObserver()
{
NS_INIT_ISUPPORTS();
NS_ASSERTION(gHaveMarqueePref == PR_TRUE, "oops");
}
MarqueePrefObserver::~MarqueePrefObserver()
{
gHaveMarqueePref = PR_FALSE;
}
NS_IMPL_ISUPPORTS1(MarqueePrefObserver, nsIObserver)
NS_IMETHODIMP
MarqueePrefObserver::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
NS_ASSERTION(nsDependentString(aData) ==
NS_ConvertASCIItoUCS2(kMarqueePrefName),
"wrong pref");
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(aSubject);
branch->GetBoolPref(kMarqueePrefName, &gEnableMarquee);
return NS_OK;
}
// -----------------------------------------------------------
HTMLStyleSheetImpl::HTMLStyleSheetImpl(void) HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
: nsIHTMLStyleSheet(), : nsIHTMLStyleSheet(),
@ -837,6 +966,28 @@ HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
nsresult nsresult
HTMLStyleSheetImpl::Init() HTMLStyleSheetImpl::Init()
{ {
if (!gHaveMarqueePref) {
// Set |gHaveMarqueePref| now, so we don't recheck if something fails.
gHaveMarqueePref = PR_TRUE;
nsresult rv;
nsCOMPtr<nsIPrefService> prefService = do_GetService(kPrefServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPrefBranch> branch;
rv = prefService->GetBranch(kMarqueePrefBranch, getter_AddRefs(branch));
if (NS_SUCCEEDED(rv) && branch) {
branch->GetBoolPref(kMarqueePrefName, &gEnableMarquee);
nsCOMPtr<nsIPrefBranchInternal> branchInternal
= do_QueryInterface(branch);
if (branchInternal) {
nsCOMPtr<nsIObserver> observer = new MarqueePrefObserver();
if (observer) {
branchInternal->AddObserver(kMarqueePrefName, observer, PR_FALSE);
}
}
}
}
}
mTableTbodyRule = new TableTbodyRule(this); mTableTbodyRule = new TableTbodyRule(this);
if (!mTableTbodyRule) if (!mTableTbodyRule)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -862,6 +1013,15 @@ HTMLStyleSheetImpl::Init()
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mTableTHRule); NS_ADDREF(mTableTHRule);
if (gEnableMarquee) {
mMarqueeDisableRule = nsnull;
} else {
mMarqueeDisableRule = new MarqueeDisableRule(this);
if (!mMarqueeDisableRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mMarqueeDisableRule);
}
mDocumentColorRule = new HTMLDocumentColorRule(this); mDocumentColorRule = new HTMLDocumentColorRule(this);
if (!mDocumentColorRule) if (!mDocumentColorRule)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -909,6 +1069,10 @@ HTMLStyleSheetImpl::~HTMLStyleSheetImpl()
mTableTHRule->mSheet = nsnull; mTableTHRule->mSheet = nsnull;
NS_RELEASE(mTableTHRule); NS_RELEASE(mTableTHRule);
} }
if (nsnull != mMarqueeDisableRule) {
mMarqueeDisableRule->mSheet = nsnull;
NS_RELEASE(mMarqueeDisableRule);
}
if (mMappedAttrTable.ops) if (mMappedAttrTable.ops)
PL_DHashTableFinish(&mMappedAttrTable); PL_DHashTableFinish(&mMappedAttrTable);
} }
@ -1020,6 +1184,10 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
if (aData->mCompatMode == eCompatibility_NavQuirks) if (aData->mCompatMode == eCompatibility_NavQuirks)
ruleWalker->Forward(mDocumentColorRule); ruleWalker->Forward(mDocumentColorRule);
} }
else if (tag == nsHTMLAtoms::marquee) {
if (mMarqueeDisableRule)
ruleWalker->Forward(mMarqueeDisableRule);
}
} // end html element } // end html element
// just get the style rules from the content // just get the style rules from the content
@ -1408,8 +1576,7 @@ HTMLStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("HTMLStyleSheet");
tag = getter_AddRefs(NS_NewAtom("HTMLStyleSheet"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(HTMLStyleSheetImpl); aSize = sizeof(HTMLStyleSheetImpl);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -1428,47 +1595,47 @@ HTMLStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
if(mLinkRule && uniqueItems->AddItem((void*)mLinkRule)){ if(mLinkRule && uniqueItems->AddItem((void*)mLinkRule)){
localSize = sizeof(*mLinkRule); localSize = sizeof(*mLinkRule);
tag = getter_AddRefs(NS_NewAtom("LinkRule")); tag = do_GetAtom("LinkRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(mVisitedRule && uniqueItems->AddItem((void*)mVisitedRule)){ if(mVisitedRule && uniqueItems->AddItem((void*)mVisitedRule)){
localSize = sizeof(*mVisitedRule); localSize = sizeof(*mVisitedRule);
tag = getter_AddRefs(NS_NewAtom("VisitedRule")); tag = do_GetAtom("VisitedRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(mActiveRule && uniqueItems->AddItem((void*)mActiveRule)){ if(mActiveRule && uniqueItems->AddItem((void*)mActiveRule)){
localSize = sizeof(*mActiveRule); localSize = sizeof(*mActiveRule);
tag = getter_AddRefs(NS_NewAtom("ActiveRule")); tag = do_GetAtom("ActiveRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mDocumentColorRule)){ if(uniqueItems->AddItem((void*)mDocumentColorRule)){
localSize = sizeof(*mDocumentColorRule); localSize = sizeof(*mDocumentColorRule);
tag = getter_AddRefs(NS_NewAtom("DocumentColorRule")); tag = do_GetAtom("DocumentColorRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableTbodyRule)){ if(uniqueItems->AddItem((void*)mTableTbodyRule)){
localSize = sizeof(*mTableTbodyRule); localSize = sizeof(*mTableTbodyRule);
tag = getter_AddRefs(NS_NewAtom("TableTbodyRule")); tag = do_GetAtom("TableTbodyRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableRowRule)){ if(uniqueItems->AddItem((void*)mTableRowRule)){
localSize = sizeof(*mTableRowRule); localSize = sizeof(*mTableRowRule);
tag = getter_AddRefs(NS_NewAtom("TableRowRule")); tag = do_GetAtom("TableRowRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableColgroupRule)){ if(uniqueItems->AddItem((void*)mTableColgroupRule)){
localSize = sizeof(*mTableColgroupRule); localSize = sizeof(*mTableColgroupRule);
tag = getter_AddRefs(NS_NewAtom("TableColgroupRule")); tag = do_GetAtom("TableColgroupRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableColRule)){ if(uniqueItems->AddItem((void*)mTableColRule)){
localSize = sizeof(*mTableColRule); localSize = sizeof(*mTableColRule);
tag = getter_AddRefs(NS_NewAtom("TableColRule")); tag = do_GetAtom("TableColRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableTHRule)){ if(uniqueItems->AddItem((void*)mTableTHRule)){
localSize = sizeof(*mTableTHRule); localSize = sizeof(*mTableTHRule);
tag = getter_AddRefs(NS_NewAtom("TableTHRule")); tag = do_GetAtom("TableTHRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }

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

@ -205,6 +205,7 @@ HTML_ATOM(longdesc, "longdesc")
HTML_ATOM(map, "map") HTML_ATOM(map, "map")
HTML_ATOM(marginheight, "marginheight") HTML_ATOM(marginheight, "marginheight")
HTML_ATOM(marginwidth, "marginwidth") HTML_ATOM(marginwidth, "marginwidth")
HTML_ATOM(marquee, "marquee")
HTML_ATOM(maxlength, "maxlength") HTML_ATOM(maxlength, "maxlength")
HTML_ATOM(mayscript, "mayscript") HTML_ATOM(mayscript, "mayscript")
HTML_ATOM(media, "media") HTML_ATOM(media, "media")

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

@ -61,8 +61,13 @@
#include "nsIStyleSet.h" #include "nsIStyleSet.h"
#include "nsISizeOfHandler.h" #include "nsISizeOfHandler.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranchInternal.h"
#include "nsIObserver.h"
static NS_DEFINE_CID(kCSSFrameConstructorCID, NS_CSSFRAMECONSTRUCTOR_CID); static NS_DEFINE_CID(kCSSFrameConstructorCID, NS_CSSFRAMECONSTRUCTOR_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID);
class HTMLColorRule : public nsIStyleRule { class HTMLColorRule : public nsIStyleRule {
public: public:
@ -170,8 +175,7 @@ void HTMLColorRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("HTMLColorRule");
tag = getter_AddRefs(NS_NewAtom("HTMLColorRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -258,8 +262,7 @@ void HTMLDocumentColorRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &a
} }
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("HTMLDocumentColorRule");
tag = getter_AddRefs(NS_NewAtom("HTMLDocumentColorRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -271,6 +274,89 @@ void HTMLDocumentColorRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &a
} }
#endif #endif
class MarqueeDisableRule : public nsIStyleRule {
public:
MarqueeDisableRule(nsIHTMLStyleSheet* aSheet);
virtual ~MarqueeDisableRule();
NS_DECL_ISUPPORTS
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const;
// The new mapping function.
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
#ifdef DEBUG
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize);
#endif
nsIHTMLStyleSheet* mSheet;
};
MarqueeDisableRule::MarqueeDisableRule(nsIHTMLStyleSheet* aSheet)
: mSheet(aSheet)
{
NS_INIT_ISUPPORTS();
}
MarqueeDisableRule::~MarqueeDisableRule()
{
}
NS_IMPL_ISUPPORTS1(MarqueeDisableRule, nsIStyleRule)
NS_IMETHODIMP
MarqueeDisableRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
{
NS_IF_ADDREF(mSheet);
aSheet = mSheet;
return NS_OK;
}
NS_IMETHODIMP
MarqueeDisableRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSID == eStyleStruct_Display) {
if (aRuleData->mDisplayData->mDisplay.GetUnit() == eCSSUnit_Null)
aRuleData->mDisplayData->mBinding = nsCSSValue(eCSSUnit_None);
}
return NS_OK;
}
#ifdef DEBUG
NS_IMETHODIMP
MarqueeDisableRule::List(FILE* out, PRInt32 aIndent) const
{
return NS_OK;
}
void MarqueeDisableRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
{
NS_ASSERTION(aSizeOfHandler != nsnull, "SizeOf handler cannot be null");
// first get the unique items collection
UNIQUE_STYLE_ITEMS(uniqueItems);
if(! uniqueItems->AddItem((void*)this) ){
// object has already been accounted for
return;
}
// get or create a tag for this instance
nsCOMPtr<nsIAtom> tag = do_GetAtom("MarqueeDisableRule");
// get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize);
if(mSheet){
PRUint32 localSize=0;
mSheet->SizeOf(aSizeOfHandler, localSize);
}
}
#endif
class GenericTableRule: public nsIStyleRule { class GenericTableRule: public nsIStyleRule {
public: public:
GenericTableRule(nsIHTMLStyleSheet* aSheet); GenericTableRule(nsIHTMLStyleSheet* aSheet);
@ -355,8 +441,7 @@ void GenericTableRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
} }
// get or create a tag for this instance // get or create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("GenericTableRule");
tag = getter_AddRefs(NS_NewAtom("GenericTableRule"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(*this); aSize = sizeof(*this);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -808,6 +893,7 @@ protected:
HTMLColorRule* mVisitedRule; HTMLColorRule* mVisitedRule;
HTMLColorRule* mActiveRule; HTMLColorRule* mActiveRule;
HTMLDocumentColorRule* mDocumentColorRule; HTMLDocumentColorRule* mDocumentColorRule;
MarqueeDisableRule* mMarqueeDisableRule;
TableTbodyRule* mTableTbodyRule; TableTbodyRule* mTableTbodyRule;
TableRowRule* mTableRowRule; TableRowRule* mTableRowRule;
TableColgroupRule* mTableColgroupRule; TableColgroupRule* mTableColgroupRule;
@ -819,6 +905,49 @@ protected:
PLDHashTable mMappedAttrTable; PLDHashTable mMappedAttrTable;
}; };
static PRBool gEnableMarquee = PR_FALSE;
static PRBool gHaveMarqueePref = PR_FALSE;
static const char kMarqueePrefBranch[] = "browser.display.";
static const char kMarqueePrefName[] = "enable_marquee";
class MarqueePrefObserver : public nsIObserver
{
public:
MarqueePrefObserver();
virtual ~MarqueePrefObserver();
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
};
MarqueePrefObserver::MarqueePrefObserver()
{
NS_INIT_ISUPPORTS();
NS_ASSERTION(gHaveMarqueePref == PR_TRUE, "oops");
}
MarqueePrefObserver::~MarqueePrefObserver()
{
gHaveMarqueePref = PR_FALSE;
}
NS_IMPL_ISUPPORTS1(MarqueePrefObserver, nsIObserver)
NS_IMETHODIMP
MarqueePrefObserver::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
NS_ASSERTION(nsDependentString(aData) ==
NS_ConvertASCIItoUCS2(kMarqueePrefName),
"wrong pref");
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(aSubject);
branch->GetBoolPref(kMarqueePrefName, &gEnableMarquee);
return NS_OK;
}
// -----------------------------------------------------------
HTMLStyleSheetImpl::HTMLStyleSheetImpl(void) HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
: nsIHTMLStyleSheet(), : nsIHTMLStyleSheet(),
@ -837,6 +966,28 @@ HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
nsresult nsresult
HTMLStyleSheetImpl::Init() HTMLStyleSheetImpl::Init()
{ {
if (!gHaveMarqueePref) {
// Set |gHaveMarqueePref| now, so we don't recheck if something fails.
gHaveMarqueePref = PR_TRUE;
nsresult rv;
nsCOMPtr<nsIPrefService> prefService = do_GetService(kPrefServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPrefBranch> branch;
rv = prefService->GetBranch(kMarqueePrefBranch, getter_AddRefs(branch));
if (NS_SUCCEEDED(rv) && branch) {
branch->GetBoolPref(kMarqueePrefName, &gEnableMarquee);
nsCOMPtr<nsIPrefBranchInternal> branchInternal
= do_QueryInterface(branch);
if (branchInternal) {
nsCOMPtr<nsIObserver> observer = new MarqueePrefObserver();
if (observer) {
branchInternal->AddObserver(kMarqueePrefName, observer, PR_FALSE);
}
}
}
}
}
mTableTbodyRule = new TableTbodyRule(this); mTableTbodyRule = new TableTbodyRule(this);
if (!mTableTbodyRule) if (!mTableTbodyRule)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -862,6 +1013,15 @@ HTMLStyleSheetImpl::Init()
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mTableTHRule); NS_ADDREF(mTableTHRule);
if (gEnableMarquee) {
mMarqueeDisableRule = nsnull;
} else {
mMarqueeDisableRule = new MarqueeDisableRule(this);
if (!mMarqueeDisableRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mMarqueeDisableRule);
}
mDocumentColorRule = new HTMLDocumentColorRule(this); mDocumentColorRule = new HTMLDocumentColorRule(this);
if (!mDocumentColorRule) if (!mDocumentColorRule)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -909,6 +1069,10 @@ HTMLStyleSheetImpl::~HTMLStyleSheetImpl()
mTableTHRule->mSheet = nsnull; mTableTHRule->mSheet = nsnull;
NS_RELEASE(mTableTHRule); NS_RELEASE(mTableTHRule);
} }
if (nsnull != mMarqueeDisableRule) {
mMarqueeDisableRule->mSheet = nsnull;
NS_RELEASE(mMarqueeDisableRule);
}
if (mMappedAttrTable.ops) if (mMappedAttrTable.ops)
PL_DHashTableFinish(&mMappedAttrTable); PL_DHashTableFinish(&mMappedAttrTable);
} }
@ -1020,6 +1184,10 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
if (aData->mCompatMode == eCompatibility_NavQuirks) if (aData->mCompatMode == eCompatibility_NavQuirks)
ruleWalker->Forward(mDocumentColorRule); ruleWalker->Forward(mDocumentColorRule);
} }
else if (tag == nsHTMLAtoms::marquee) {
if (mMarqueeDisableRule)
ruleWalker->Forward(mMarqueeDisableRule);
}
} // end html element } // end html element
// just get the style rules from the content // just get the style rules from the content
@ -1408,8 +1576,7 @@ HTMLStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
PRUint32 localSize=0; PRUint32 localSize=0;
// create a tag for this instance // create a tag for this instance
nsCOMPtr<nsIAtom> tag; nsCOMPtr<nsIAtom> tag = do_GetAtom("HTMLStyleSheet");
tag = getter_AddRefs(NS_NewAtom("HTMLStyleSheet"));
// get the size of an empty instance and add to the sizeof handler // get the size of an empty instance and add to the sizeof handler
aSize = sizeof(HTMLStyleSheetImpl); aSize = sizeof(HTMLStyleSheetImpl);
aSizeOfHandler->AddSize(tag,aSize); aSizeOfHandler->AddSize(tag,aSize);
@ -1428,47 +1595,47 @@ HTMLStyleSheetImpl::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize)
if(mLinkRule && uniqueItems->AddItem((void*)mLinkRule)){ if(mLinkRule && uniqueItems->AddItem((void*)mLinkRule)){
localSize = sizeof(*mLinkRule); localSize = sizeof(*mLinkRule);
tag = getter_AddRefs(NS_NewAtom("LinkRule")); tag = do_GetAtom("LinkRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(mVisitedRule && uniqueItems->AddItem((void*)mVisitedRule)){ if(mVisitedRule && uniqueItems->AddItem((void*)mVisitedRule)){
localSize = sizeof(*mVisitedRule); localSize = sizeof(*mVisitedRule);
tag = getter_AddRefs(NS_NewAtom("VisitedRule")); tag = do_GetAtom("VisitedRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(mActiveRule && uniqueItems->AddItem((void*)mActiveRule)){ if(mActiveRule && uniqueItems->AddItem((void*)mActiveRule)){
localSize = sizeof(*mActiveRule); localSize = sizeof(*mActiveRule);
tag = getter_AddRefs(NS_NewAtom("ActiveRule")); tag = do_GetAtom("ActiveRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mDocumentColorRule)){ if(uniqueItems->AddItem((void*)mDocumentColorRule)){
localSize = sizeof(*mDocumentColorRule); localSize = sizeof(*mDocumentColorRule);
tag = getter_AddRefs(NS_NewAtom("DocumentColorRule")); tag = do_GetAtom("DocumentColorRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableTbodyRule)){ if(uniqueItems->AddItem((void*)mTableTbodyRule)){
localSize = sizeof(*mTableTbodyRule); localSize = sizeof(*mTableTbodyRule);
tag = getter_AddRefs(NS_NewAtom("TableTbodyRule")); tag = do_GetAtom("TableTbodyRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableRowRule)){ if(uniqueItems->AddItem((void*)mTableRowRule)){
localSize = sizeof(*mTableRowRule); localSize = sizeof(*mTableRowRule);
tag = getter_AddRefs(NS_NewAtom("TableRowRule")); tag = do_GetAtom("TableRowRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableColgroupRule)){ if(uniqueItems->AddItem((void*)mTableColgroupRule)){
localSize = sizeof(*mTableColgroupRule); localSize = sizeof(*mTableColgroupRule);
tag = getter_AddRefs(NS_NewAtom("TableColgroupRule")); tag = do_GetAtom("TableColgroupRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableColRule)){ if(uniqueItems->AddItem((void*)mTableColRule)){
localSize = sizeof(*mTableColRule); localSize = sizeof(*mTableColRule);
tag = getter_AddRefs(NS_NewAtom("TableColRule")); tag = do_GetAtom("TableColRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }
if(uniqueItems->AddItem((void*)mTableTHRule)){ if(uniqueItems->AddItem((void*)mTableTHRule)){
localSize = sizeof(*mTableTHRule); localSize = sizeof(*mTableTHRule);
tag = getter_AddRefs(NS_NewAtom("TableTHRule")); tag = do_GetAtom("TableTHRule");
aSizeOfHandler->AddSize(tag,localSize); aSizeOfHandler->AddSize(tag,localSize);
} }

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

@ -89,6 +89,7 @@ pref("browser.display.force_inline_alttext", false); // true = force ALT text fo
// 2 = add extra leading both internal leading and external leading are zero // 2 = add extra leading both internal leading and external leading are zero
pref("browser.display.normal_lineheight_calc_control", 2); pref("browser.display.normal_lineheight_calc_control", 2);
pref("browser.display.show_image_placeholders", true); // true = show image placeholders while image is loaded and when image is broken pref("browser.display.show_image_placeholders", true); // true = show image placeholders while image is loaded and when image is broken
pref("browser.display.enable_marquee", false);
pref("browser.anchor_color", "#0000EE"); pref("browser.anchor_color", "#0000EE");
pref("browser.visited_color", "#551A8B"); pref("browser.visited_color", "#551A8B");
pref("browser.underline_anchors", true); pref("browser.underline_anchors", true);