Back out patch for bug 161109 that implemented a pref for disabling marquee. b=161109 r=hixie a=asa

This commit is contained in:
dbaron@fas.harvard.edu
2002-10-30 14:31:32 +00:00
parent 439f771331
commit f9d8824f57
3 changed files with 0 additions and 343 deletions

View File

@@ -61,13 +61,8 @@
#include "nsIStyleSet.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(kPrefServiceCID, NS_PREFSERVICE_CID);
class HTMLColorRule : public nsIStyleRule {
public:
@@ -274,89 +269,6 @@ void HTMLDocumentColorRule::SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &a
}
#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 {
public:
GenericTableRule(nsIHTMLStyleSheet* aSheet);
@@ -893,7 +805,6 @@ protected:
HTMLColorRule* mVisitedRule;
HTMLColorRule* mActiveRule;
HTMLDocumentColorRule* mDocumentColorRule;
MarqueeDisableRule* mMarqueeDisableRule;
TableTbodyRule* mTableTbodyRule;
TableRowRule* mTableRowRule;
TableColgroupRule* mTableColgroupRule;
@@ -905,49 +816,6 @@ protected:
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)
: nsIHTMLStyleSheet(),
@@ -966,28 +834,6 @@ HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
nsresult
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);
if (!mTableTbodyRule)
return NS_ERROR_OUT_OF_MEMORY;
@@ -1013,15 +859,6 @@ HTMLStyleSheetImpl::Init()
return NS_ERROR_OUT_OF_MEMORY;
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);
if (!mDocumentColorRule)
return NS_ERROR_OUT_OF_MEMORY;
@@ -1069,10 +906,6 @@ HTMLStyleSheetImpl::~HTMLStyleSheetImpl()
mTableTHRule->mSheet = nsnull;
NS_RELEASE(mTableTHRule);
}
if (nsnull != mMarqueeDisableRule) {
mMarqueeDisableRule->mSheet = nsnull;
NS_RELEASE(mMarqueeDisableRule);
}
if (mMappedAttrTable.ops)
PL_DHashTableFinish(&mMappedAttrTable);
}
@@ -1184,10 +1017,6 @@ HTMLStyleSheetImpl::RulesMatching(ElementRuleProcessorData* aData,
if (aData->mCompatMode == eCompatibility_NavQuirks)
ruleWalker->Forward(mDocumentColorRule);
}
else if (tag == nsHTMLAtoms::marquee) {
if (mMarqueeDisableRule)
ruleWalker->Forward(mMarqueeDisableRule);
}
} // end html element
// just get the style rules from the content