From e69f301e3226dbb7a27ac6c144e48ebc9ecbd610 Mon Sep 17 00:00:00 2001 From: "caillon%returnzero.com" Date: Fri, 18 Jul 2003 01:26:47 +0000 Subject: [PATCH] Bug 212504. Removal of the default namespace arguments from CSSStyleSheet and CSSLoader. r=bzbarsky@mit.edu, sr=dbaron@dbaron.org git-svn-id: svn://10.0.0.236/trunk@144937 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/base/src/nsStyleLinkElement.cpp | 3 - .../html/document/src/nsHTMLContentSink.cpp | 1 - .../content/html/style/public/nsICSSLoader.h | 3 - .../html/style/public/nsICSSStyleSheet.h | 2 - .../content/html/style/src/nsCSSLoader.cpp | 19 ++---- mozilla/content/html/style/src/nsCSSLoader.h | 4 -- .../content/html/style/src/nsCSSParser.cpp | 2 +- .../html/style/src/nsCSSStyleSheet.cpp | 24 +------ .../content/xbl/src/nsXBLResourceLoader.cpp | 8 +-- .../xml/document/src/nsXMLContentSink.cpp | 2 +- .../xul/document/src/nsXULContentSink.cpp | 2 +- mozilla/layout/base/nsPresShell.cpp | 63 +++++++++++-------- mozilla/layout/html/base/src/nsPresShell.cpp | 63 +++++++++++-------- .../layout/mathml/base/src/nsMathMLFrame.cpp | 9 ++- mozilla/layout/style/nsCSSLoader.cpp | 19 ++---- mozilla/layout/style/nsCSSLoader.h | 4 -- mozilla/layout/style/nsCSSParser.cpp | 2 +- mozilla/layout/style/nsCSSStyleSheet.cpp | 24 +------ mozilla/layout/style/nsICSSLoader.h | 3 - mozilla/layout/style/nsICSSStyleSheet.h | 2 - 20 files changed, 101 insertions(+), 158 deletions(-) diff --git a/mozilla/content/base/src/nsStyleLinkElement.cpp b/mozilla/content/base/src/nsStyleLinkElement.cpp index cc6df9dd9f9..51baad46db9 100644 --- a/mozilla/content/base/src/nsStyleLinkElement.cpp +++ b/mozilla/content/base/src/nsStyleLinkElement.cpp @@ -33,7 +33,6 @@ #include "nsIDOMStyleSheet.h" #include "nsIDOMText.h" #include "nsIHTMLContentContainer.h" -#include "nsINameSpaceManager.h" #include "nsIUnicharInputStream.h" #include "nsNetUtil.h" #include "nsUnicharUtils.h" @@ -310,13 +309,11 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument, // Now that we have a url and a unicode input stream, parse the // style sheet. rv = loader->LoadInlineStyle(thisContent, uin, title, media, - kNameSpaceID_Unknown, ((blockParser) ? parser.get() : nsnull), doneLoading, aObserver); } else { rv = loader->LoadStyleLink(thisContent, uri, title, media, - kNameSpaceID_Unknown, ((blockParser) ? parser.get() : nsnull), doneLoading, aObserver); } diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 26f76c636b7..c66afd459ad 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -4876,7 +4876,6 @@ HTMLContentSink::ProcessStyleLink(nsIHTMLContent* aElement, PRBool doneLoading; result = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, - kNameSpaceID_Unknown, ((blockParser) ? mParser : nsnull), doneLoading, this); diff --git a/mozilla/content/html/style/public/nsICSSLoader.h b/mozilla/content/html/style/public/nsICSSLoader.h index 55c13f7b9a0..59be067c817 100644 --- a/mozilla/content/html/style/public/nsICSSLoader.h +++ b/mozilla/content/html/style/public/nsICSSLoader.h @@ -87,7 +87,6 @@ public: nsIUnicharInputStream* aStream, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) = 0; @@ -101,7 +100,6 @@ public: nsIURI* aURL, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) = 0; @@ -110,7 +108,6 @@ public: NS_IMETHOD LoadChildSheet(nsICSSStyleSheet* aParentSheet, nsIURI* aURL, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsICSSImportRule* aRule) = 0; // Load a user agent or user sheet. The sheet is loaded diff --git a/mozilla/content/html/style/public/nsICSSStyleSheet.h b/mozilla/content/html/style/public/nsICSSStyleSheet.h index 86b8ed94989..e78eae41fdb 100644 --- a/mozilla/content/html/style/public/nsICSSStyleSheet.h +++ b/mozilla/content/html/style/public/nsICSSStyleSheet.h @@ -87,8 +87,6 @@ public: // get head of namespace chain for sheet NS_IMETHOD GetNameSpace(nsINameSpace*& aNameSpace) const = 0; - // set default namespace for sheet (may be overridden by @namespace) - NS_IMETHOD SetDefaultNameSpaceID(PRInt32 aDefaultNameSpaceID) = 0; NS_IMETHOD Clone(nsICSSStyleSheet* aCloneParent, nsICSSImportRule* aCloneOwnerRule, diff --git a/mozilla/content/html/style/src/nsCSSLoader.cpp b/mozilla/content/html/style/src/nsCSSLoader.cpp index 95768a1a602..0f278cbe818 100644 --- a/mozilla/content/html/style/src/nsCSSLoader.cpp +++ b/mozilla/content/html/style/src/nsCSSLoader.cpp @@ -31,7 +31,6 @@ #include "nsIDOMNode.h" #include "nsIDOMWindow.h" #include "nsIDocument.h" -#include "nsINameSpaceManager.h" #include "nsIUnicharInputStream.h" #include "nsIConverterInputStream.h" #include "nsICharsetAlias.h" @@ -958,7 +957,6 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI, nsresult CSSLoaderImpl::CreateSheet(nsIURI* aURI, nsIContent* aLinkingContent, - PRUint32 aDefaultNameSpaceID, PRBool aSyncLoad, StyleSheetState& aSheetState, nsICSSStyleSheet** aSheet) @@ -1039,8 +1037,6 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI, rv = NS_NewCSSStyleSheet(aSheet); // Don't init the sheet here, but in // ParseSheet once we know the final URI NS_ENSURE_SUCCESS(rv, rv); - - (*aSheet)->SetDefaultNameSpaceID(aDefaultNameSpaceID); } NS_ASSERTION(*aSheet, "We should have a sheet by now!"); @@ -1563,7 +1559,6 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement, nsIUnicharInputStream* aStream, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) @@ -1586,8 +1581,8 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement, StyleSheetState state; nsCOMPtr sheet; - nsresult rv = CreateSheet(nsnull, aElement, aDefaultNameSpaceID, PR_FALSE, - state, getter_AddRefs(sheet)); + nsresult rv = CreateSheet(nsnull, aElement, PR_FALSE, state, + getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_ASSERTION(state == eSheetNeedsParser, "Inline sheets should not be cached"); @@ -1620,7 +1615,6 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, nsIURI* aURL, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) @@ -1651,7 +1645,7 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, StyleSheetState state; nsCOMPtr sheet; - rv = CreateSheet(aURL, aElement, aDefaultNameSpaceID, PR_FALSE, state, + rv = CreateSheet(aURL, aElement, PR_FALSE, state, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); @@ -1705,7 +1699,6 @@ NS_IMETHODIMP CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet, nsIURI* aURL, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsICSSImportRule* aParentRule) { LOG(("CSSLoaderImpl::LoadChildSheet")); @@ -1761,7 +1754,7 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet, // loop) do so nsCOMPtr sheet; StyleSheetState state; - rv = CreateSheet(aURL, nsnull, aDefaultNameSpaceID, + rv = CreateSheet(aURL, nsnull, parentData ? parentData->mSyncLoad : PR_FALSE, state, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); @@ -1833,8 +1826,8 @@ CSSLoaderImpl::InternalLoadAgentSheet(nsIURI* aURL, nsCOMPtr sheet; PRBool syncLoad = (aObserver == nsnull); - nsresult rv = CreateSheet(aURL, nsnull, kNameSpaceID_Unknown, syncLoad, - state, getter_AddRefs(sheet)); + nsresult rv = CreateSheet(aURL, nsnull, syncLoad, state, + getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_NAMED_LITERAL_STRING(empty, ""); diff --git a/mozilla/content/html/style/src/nsCSSLoader.h b/mozilla/content/html/style/src/nsCSSLoader.h index 2f0c603b53e..8ca10f71b79 100644 --- a/mozilla/content/html/style/src/nsCSSLoader.h +++ b/mozilla/content/html/style/src/nsCSSLoader.h @@ -260,7 +260,6 @@ public: nsIUnicharInputStream* aIn, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver); @@ -269,7 +268,6 @@ public: nsIURI* aURL, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver); @@ -277,7 +275,6 @@ public: NS_IMETHOD LoadChildSheet(nsICSSStyleSheet* aParentSheet, nsIURI* aURL, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsICSSImportRule* aRule); NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSStyleSheet** aSheet); @@ -312,7 +309,6 @@ private: // must be non-null then. nsresult CreateSheet(nsIURI* aURI, nsIContent* aLinkingContent, - PRUint32 aDefaultNameSpaceID, PRBool aSyncLoad, StyleSheetState& aSheetState, nsICSSStyleSheet** aSheet); diff --git a/mozilla/content/html/style/src/nsCSSParser.cpp b/mozilla/content/html/style/src/nsCSSParser.cpp index f487ece3b77..cb275b9626d 100644 --- a/mozilla/content/html/style/src/nsCSSParser.cpp +++ b/mozilla/content/html/style/src/nsCSSParser.cpp @@ -1162,7 +1162,7 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe return PR_FALSE; } - mChildLoader->LoadChildSheet(mSheet, url, aMedia, kNameSpaceID_Unknown, rule); + mChildLoader->LoadChildSheet(mSheet, url, aMedia, rule); } return PR_TRUE; diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index ad3591f55ae..704bfcf1024 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -783,7 +783,6 @@ public: nsISupportsArray* mOrderedRules; nsCOMPtr mNameSpace; - PRInt32 mDefaultNameSpaceID; PRPackedBool mComplete; }; @@ -858,7 +857,6 @@ public: NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) const; NS_IMETHOD GetNameSpace(nsINameSpace*& aNameSpace) const; - NS_IMETHOD SetDefaultNameSpaceID(PRInt32 aDefaultNameSpaceID); NS_IMETHOD Clone(nsICSSStyleSheet* aCloneParent, nsICSSImportRule* aCloneOwnerRule, @@ -1465,7 +1463,6 @@ CSSStyleSheetInner::CSSStyleSheetInner(nsICSSStyleSheet* aParentSheet) : mSheets(), mOrderedRules(nsnull), mNameSpace(nsnull), - mDefaultNameSpaceID(kNameSpaceID_None), mComplete(PR_FALSE) { MOZ_COUNT_CTOR(CSSStyleSheetInner); @@ -1491,7 +1488,6 @@ CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy, : mSheets(), mURL(aCopy.mURL), mNameSpace(nsnull), - mDefaultNameSpaceID(aCopy.mDefaultNameSpaceID), mComplete(aCopy.mComplete) { MOZ_COUNT_CTOR(CSSStyleSheetInner); @@ -1586,14 +1582,7 @@ CSSStyleSheetInner::RebuildNameSpaces(void) { nsContentUtils::GetNSManagerWeakRef()-> CreateRootNameSpace(getter_AddRefs(mNameSpace)); - if (kNameSpaceID_Unknown != mDefaultNameSpaceID) { - nsCOMPtr defaultNameSpace; - mNameSpace->CreateChildNameSpace(nsnull, mDefaultNameSpaceID, - getter_AddRefs(defaultNameSpace)); - if (defaultNameSpace) { - mNameSpace = defaultNameSpace; - } - } + if (mOrderedRules) { mOrderedRules->EnumerateForwards(CreateNameSpace, address_of(mNameSpace)); } @@ -2243,17 +2232,6 @@ CSSStyleSheetImpl::GetNameSpace(nsINameSpace*& aNameSpace) const return NS_OK; } -NS_IMETHODIMP -CSSStyleSheetImpl::SetDefaultNameSpaceID(PRInt32 aDefaultNameSpaceID) -{ - if (mInner) { - mInner->mDefaultNameSpaceID = aDefaultNameSpaceID; - mInner->RebuildNameSpaces(); - } - return NS_OK; -} - - NS_IMETHODIMP CSSStyleSheetImpl::StyleSheetCount(PRInt32& aCount) const { diff --git a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp index c6c3f3015ef..c9c4e5b425a 100644 --- a/mozilla/content/xbl/src/nsXBLResourceLoader.cpp +++ b/mozilla/content/xbl/src/nsXBLResourceLoader.cpp @@ -55,7 +55,6 @@ #include "nsIHTMLContentContainer.h" #include "nsNetUtil.h" #include "nsXBLAtoms.h" -#include "nsINameSpaceManager.h" #include "nsIFrameManager.h" #include "nsStyleContext.h" #include "nsXBLPrototypeBinding.h" @@ -146,10 +145,11 @@ nsXBLResourceLoader::LoadResources(PRBool* aResult) // Always load chrome synchronously PRBool chrome; + nsresult rv; if (NS_SUCCEEDED(url->SchemeIs("chrome", &chrome)) && chrome) { nsCOMPtr sheet; - nsresult rv = cssLoader->LoadAgentSheet(url, getter_AddRefs(sheet)); + rv = cssLoader->LoadAgentSheet(url, getter_AddRefs(sheet)); NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!"); if (NS_SUCCEEDED(rv)) { @@ -161,8 +161,8 @@ nsXBLResourceLoader::LoadResources(PRBool* aResult) { PRBool doneLoading; NS_NAMED_LITERAL_STRING(empty, ""); - nsresult rv = cssLoader->LoadStyleLink(nsnull, url, empty, empty, kNameSpaceID_Unknown, - nsnull, doneLoading, this); + rv = cssLoader->LoadStyleLink(nsnull, url, empty, empty, + nsnull, doneLoading, this); NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!"); if (!doneLoading) diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 9a039df99c5..3d9201af023 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -837,7 +837,7 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement, return NS_OK; // The URL is bad, move along, don't propagate the error (for now) } PRBool doneLoading; - rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, kNameSpaceID_Unknown, + rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, ((!aAlternate) ? mParser : nsnull), doneLoading, this); diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 84ddc75632c..7d3f80ba696 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -562,7 +562,7 @@ XULContentSinkImpl::ProcessStyleLink(nsIContent* aElement, return NS_ERROR_FAILURE; // doc went away! PRBool doneLoading; - rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, kNameSpaceID_Unknown, + rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, ((blockParser) ? mParser : nsnull), doneLoading, nsnull); if (NS_SUCCEEDED(rv) && blockParser && (! doneLoading)) { diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 218eda248e3..ac5c27fae1d 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1290,7 +1290,7 @@ protected: nsresult GetSelectionForCopy(nsISelection** outSelection); - nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintaina ref, may be null + nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintain a ref, may be null PRUint32 mUpdateCount; // normal reflow commands nsVoidArray mReflowCommands; @@ -2210,7 +2210,7 @@ nsresult PresShell::ClearPreferenceStyleRules(void) printf("PrefStyleSheet removed\n"); #endif // clear the sheet pointer: it is strictly historical now - NS_IF_RELEASE(mPrefStyleSheet); + NS_RELEASE(mPrefStyleSheet); } } return result; @@ -2218,10 +2218,8 @@ nsresult PresShell::ClearPreferenceStyleRules(void) nsresult PresShell::CreatePreferenceStyleSheet(void) { - NS_ASSERTION(mPrefStyleSheet==nsnull, "prefStyleSheet already exists"); - nsresult result = NS_OK; - - result = nsComponentManager::CreateInstance(kCSSStyleSheetCID,nsnull,NS_GET_IID(nsICSSStyleSheet),(void**)&mPrefStyleSheet); + NS_ASSERTION(!mPrefStyleSheet, "prefStyleSheet already exists"); + nsresult result = CallCreateInstance(kCSSStyleSheetCID, &mPrefStyleSheet); if (NS_SUCCEEDED(result)) { NS_ASSERTION(mPrefStyleSheet, "null but no error"); nsCOMPtr uri; @@ -2231,7 +2229,13 @@ nsresult PresShell::CreatePreferenceStyleSheet(void) result = mPrefStyleSheet->Init(uri); if (NS_SUCCEEDED(result)) { mPrefStyleSheet->SetComplete(); - mPrefStyleSheet->SetDefaultNameSpaceID(kNameSpaceID_XHTML); + nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet)); + if (sheet) { + PRUint32 index; + result = sheet->InsertRule(NS_LITERAL_STRING("@namespace url(http://www.w3.org/1999/xhtml);"), + 0, &index); + NS_ENSURE_SUCCESS(result, result); + } mStyleSet->InsertUserStyleSheetBefore(mPrefStyleSheet, nsnull); } } @@ -2246,6 +2250,11 @@ nsresult PresShell::CreatePreferenceStyleSheet(void) return result; } +// XXX We want these after the @namespace rule. Does order matter +// for these rules, or can we call nsICSSStyleRule::StyleRuleCount() +// and just "append"? +static PRUint32 sInsertPrefSheetRulesAt = 1; + nsresult PresShell::SetPrefColorRules(void) { NS_ASSERTION(mPresContext,"null prescontext not allowed"); @@ -2299,13 +2308,13 @@ nsresult PresShell::SetPrefColorRules(void) NS_LITERAL_STRING("background:") + strBackgroundColor + NS_LITERAL_STRING(" !important; }"), - 0,&index); + sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); /////////////////////////////////////////////////////////////// // - everything else inherits the color, and has transparent background result = sheet->InsertRule(NS_LITERAL_STRING("* {color: inherit !important; border-color: -moz-use-text-color !important; background: transparent !important;} "), - 0,&index); + sInsertPrefSheetRulesAt, &index); } } } @@ -2331,7 +2340,7 @@ PresShell::SetPrefNoScriptRule() nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&rv)); NS_ENSURE_SUCCESS(rv, rv); PRUint32 index = 0; - rv = sheet->InsertRule(NS_LITERAL_STRING("noscript{display:block}"), 0, &index); + rv = sheet->InsertRule(NS_LITERAL_STRING("noscript{display:block}"), sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; @@ -2381,35 +2390,35 @@ nsresult PresShell::SetPrefLinkRules(void) mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); /////////////////////////////////////////////////////////////// - // - links: '*:link {color: #RRGGBB [!important];}' + // - links: '*|*:link {color: #RRGGBB [!important];}' ColorToString(linkColor,strColor); NS_NAMED_LITERAL_STRING(notImportantStr, "}"); NS_NAMED_LITERAL_STRING(importantStr, "!important}"); const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; - result = sheet->InsertRule(NS_LITERAL_STRING("*:link{color:") + + result = sheet->InsertRule(NS_LITERAL_STRING("*|*:link{color:") + strColor + ruleClose, - 0,&index); + sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); /////////////////////////////////////////////////////////////// - // - visited links '*:visited {color: #RRGGBB [!important];}' + // - visited links '*|*:visited {color: #RRGGBB [!important];}' ColorToString(visitedColor,strColor); // insert the rule - result = sheet->InsertRule(NS_LITERAL_STRING("*:visited{color:") + + result = sheet->InsertRule(NS_LITERAL_STRING("*|*:visited{color:") + strColor + ruleClose, - 0,&index); + sInsertPrefSheetRulesAt, &index); /////////////////////////////////////////////////////////////// - // - active links '*:-moz-any-link {color: red [!important];}' + // - active links '*|*:-moz-any-link {color: red [!important];}' // This has to be here (i.e. we can't just rely on the rule in the UA stylesheet) // because this entire stylesheet is at the user level (not UA level) and so // the two rules above override the rule in the UA stylesheet regardless of the // weights of the respective rules. - result = sheet->InsertRule(NS_LITERAL_STRING("*:-moz-any-link:active{color:red") + + result = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link:active{color:red") + ruleClose, - 0,&index); + sInsertPrefSheetRulesAt, &index); } if (NS_SUCCEEDED(result)) { @@ -2429,17 +2438,17 @@ nsresult PresShell::SetPrefLinkRules(void) printf (" - Creating rules for enabling link underlines\n"); #endif // make a rule to make text-decoration: underline happen for links - strRule.Append(NS_LITERAL_STRING("*:-moz-any-link{text-decoration:underline}")); + strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:underline}")); } else { #ifdef DEBUG_attinasi printf (" - Creating rules for disabling link underlines\n"); #endif // make a rule to make text-decoration: none happen for links - strRule.Append(NS_LITERAL_STRING("*:-moz-any-link{text-decoration:none}")); + strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:none}")); } // ...now insert the rule - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } } } @@ -2487,7 +2496,7 @@ nsresult PresShell::SetPrefFocusRules(void) strRule.Append(strColor); strRule.Append(NS_LITERAL_STRING(" !important; } ")); // insert the rules - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } PRUint8 focusRingWidth = 1; result = mPresContext->GetFocusRingWidth(&focusRingWidth); @@ -2498,12 +2507,12 @@ nsresult PresShell::SetPrefFocusRules(void) PRUint32 index = 0; nsAutoString strRule; if (!focusRingOnAnything) - strRule.Append(NS_LITERAL_STRING(":link:focus, :visited")); // If we only want focus rings on the normal things like links + strRule.Append(NS_LITERAL_STRING("*|*:link:focus, *|*:visited")); // If we only want focus rings on the normal things like links strRule.Append(NS_LITERAL_STRING(":focus {-moz-outline: ")); // For example 3px dotted WindowText (maximum 4) strRule.AppendInt(focusRingWidth); strRule.Append(NS_LITERAL_STRING("px dotted WindowText !important; } ")); // For example 3px dotted WindowText // insert the rules - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); if (focusRingWidth != 1) { // If the focus ring width is different from the default, fix buttons with rings @@ -2512,13 +2521,13 @@ nsresult PresShell::SetPrefFocusRules(void) strRule.Append(NS_LITERAL_STRING("input[type=\"submit\"]::-moz-focus-inner { padding: 1px 2px 1px 2px; border: ")); strRule.AppendInt(focusRingWidth); strRule.Append(NS_LITERAL_STRING("px dotted transparent !important; } ")); - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); strRule.Assign(NS_LITERAL_STRING("button:focus::-moz-focus-inner, input[type=\"reset\"]:focus::-moz-focus-inner,")); strRule.Append(NS_LITERAL_STRING("input[type=\"button\"]:focus::-moz-focus-inner, input[type=\"submit\"]:focus::-moz-focus-inner {")); strRule.Append(NS_LITERAL_STRING("border-color: ButtonText !important; }")); - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } } } diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 218eda248e3..ac5c27fae1d 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1290,7 +1290,7 @@ protected: nsresult GetSelectionForCopy(nsISelection** outSelection); - nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintaina ref, may be null + nsICSSStyleSheet* mPrefStyleSheet; // mStyleSet owns it but we maintain a ref, may be null PRUint32 mUpdateCount; // normal reflow commands nsVoidArray mReflowCommands; @@ -2210,7 +2210,7 @@ nsresult PresShell::ClearPreferenceStyleRules(void) printf("PrefStyleSheet removed\n"); #endif // clear the sheet pointer: it is strictly historical now - NS_IF_RELEASE(mPrefStyleSheet); + NS_RELEASE(mPrefStyleSheet); } } return result; @@ -2218,10 +2218,8 @@ nsresult PresShell::ClearPreferenceStyleRules(void) nsresult PresShell::CreatePreferenceStyleSheet(void) { - NS_ASSERTION(mPrefStyleSheet==nsnull, "prefStyleSheet already exists"); - nsresult result = NS_OK; - - result = nsComponentManager::CreateInstance(kCSSStyleSheetCID,nsnull,NS_GET_IID(nsICSSStyleSheet),(void**)&mPrefStyleSheet); + NS_ASSERTION(!mPrefStyleSheet, "prefStyleSheet already exists"); + nsresult result = CallCreateInstance(kCSSStyleSheetCID, &mPrefStyleSheet); if (NS_SUCCEEDED(result)) { NS_ASSERTION(mPrefStyleSheet, "null but no error"); nsCOMPtr uri; @@ -2231,7 +2229,13 @@ nsresult PresShell::CreatePreferenceStyleSheet(void) result = mPrefStyleSheet->Init(uri); if (NS_SUCCEEDED(result)) { mPrefStyleSheet->SetComplete(); - mPrefStyleSheet->SetDefaultNameSpaceID(kNameSpaceID_XHTML); + nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet)); + if (sheet) { + PRUint32 index; + result = sheet->InsertRule(NS_LITERAL_STRING("@namespace url(http://www.w3.org/1999/xhtml);"), + 0, &index); + NS_ENSURE_SUCCESS(result, result); + } mStyleSet->InsertUserStyleSheetBefore(mPrefStyleSheet, nsnull); } } @@ -2246,6 +2250,11 @@ nsresult PresShell::CreatePreferenceStyleSheet(void) return result; } +// XXX We want these after the @namespace rule. Does order matter +// for these rules, or can we call nsICSSStyleRule::StyleRuleCount() +// and just "append"? +static PRUint32 sInsertPrefSheetRulesAt = 1; + nsresult PresShell::SetPrefColorRules(void) { NS_ASSERTION(mPresContext,"null prescontext not allowed"); @@ -2299,13 +2308,13 @@ nsresult PresShell::SetPrefColorRules(void) NS_LITERAL_STRING("background:") + strBackgroundColor + NS_LITERAL_STRING(" !important; }"), - 0,&index); + sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); /////////////////////////////////////////////////////////////// // - everything else inherits the color, and has transparent background result = sheet->InsertRule(NS_LITERAL_STRING("* {color: inherit !important; border-color: -moz-use-text-color !important; background: transparent !important;} "), - 0,&index); + sInsertPrefSheetRulesAt, &index); } } } @@ -2331,7 +2340,7 @@ PresShell::SetPrefNoScriptRule() nsCOMPtr sheet(do_QueryInterface(mPrefStyleSheet,&rv)); NS_ENSURE_SUCCESS(rv, rv); PRUint32 index = 0; - rv = sheet->InsertRule(NS_LITERAL_STRING("noscript{display:block}"), 0, &index); + rv = sheet->InsertRule(NS_LITERAL_STRING("noscript{display:block}"), sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; @@ -2381,35 +2390,35 @@ nsresult PresShell::SetPrefLinkRules(void) mPresContext->GetCachedBoolPref(kPresContext_UseDocumentColors, useDocColors); /////////////////////////////////////////////////////////////// - // - links: '*:link {color: #RRGGBB [!important];}' + // - links: '*|*:link {color: #RRGGBB [!important];}' ColorToString(linkColor,strColor); NS_NAMED_LITERAL_STRING(notImportantStr, "}"); NS_NAMED_LITERAL_STRING(importantStr, "!important}"); const nsAString& ruleClose = useDocColors ? notImportantStr : importantStr; - result = sheet->InsertRule(NS_LITERAL_STRING("*:link{color:") + + result = sheet->InsertRule(NS_LITERAL_STRING("*|*:link{color:") + strColor + ruleClose, - 0,&index); + sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); /////////////////////////////////////////////////////////////// - // - visited links '*:visited {color: #RRGGBB [!important];}' + // - visited links '*|*:visited {color: #RRGGBB [!important];}' ColorToString(visitedColor,strColor); // insert the rule - result = sheet->InsertRule(NS_LITERAL_STRING("*:visited{color:") + + result = sheet->InsertRule(NS_LITERAL_STRING("*|*:visited{color:") + strColor + ruleClose, - 0,&index); + sInsertPrefSheetRulesAt, &index); /////////////////////////////////////////////////////////////// - // - active links '*:-moz-any-link {color: red [!important];}' + // - active links '*|*:-moz-any-link {color: red [!important];}' // This has to be here (i.e. we can't just rely on the rule in the UA stylesheet) // because this entire stylesheet is at the user level (not UA level) and so // the two rules above override the rule in the UA stylesheet regardless of the // weights of the respective rules. - result = sheet->InsertRule(NS_LITERAL_STRING("*:-moz-any-link:active{color:red") + + result = sheet->InsertRule(NS_LITERAL_STRING("*|*:-moz-any-link:active{color:red") + ruleClose, - 0,&index); + sInsertPrefSheetRulesAt, &index); } if (NS_SUCCEEDED(result)) { @@ -2429,17 +2438,17 @@ nsresult PresShell::SetPrefLinkRules(void) printf (" - Creating rules for enabling link underlines\n"); #endif // make a rule to make text-decoration: underline happen for links - strRule.Append(NS_LITERAL_STRING("*:-moz-any-link{text-decoration:underline}")); + strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:underline}")); } else { #ifdef DEBUG_attinasi printf (" - Creating rules for disabling link underlines\n"); #endif // make a rule to make text-decoration: none happen for links - strRule.Append(NS_LITERAL_STRING("*:-moz-any-link{text-decoration:none}")); + strRule.Append(NS_LITERAL_STRING("*|*:-moz-any-link{text-decoration:none}")); } // ...now insert the rule - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } } } @@ -2487,7 +2496,7 @@ nsresult PresShell::SetPrefFocusRules(void) strRule.Append(strColor); strRule.Append(NS_LITERAL_STRING(" !important; } ")); // insert the rules - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } PRUint8 focusRingWidth = 1; result = mPresContext->GetFocusRingWidth(&focusRingWidth); @@ -2498,12 +2507,12 @@ nsresult PresShell::SetPrefFocusRules(void) PRUint32 index = 0; nsAutoString strRule; if (!focusRingOnAnything) - strRule.Append(NS_LITERAL_STRING(":link:focus, :visited")); // If we only want focus rings on the normal things like links + strRule.Append(NS_LITERAL_STRING("*|*:link:focus, *|*:visited")); // If we only want focus rings on the normal things like links strRule.Append(NS_LITERAL_STRING(":focus {-moz-outline: ")); // For example 3px dotted WindowText (maximum 4) strRule.AppendInt(focusRingWidth); strRule.Append(NS_LITERAL_STRING("px dotted WindowText !important; } ")); // For example 3px dotted WindowText // insert the rules - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); if (focusRingWidth != 1) { // If the focus ring width is different from the default, fix buttons with rings @@ -2512,13 +2521,13 @@ nsresult PresShell::SetPrefFocusRules(void) strRule.Append(NS_LITERAL_STRING("input[type=\"submit\"]::-moz-focus-inner { padding: 1px 2px 1px 2px; border: ")); strRule.AppendInt(focusRingWidth); strRule.Append(NS_LITERAL_STRING("px dotted transparent !important; } ")); - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); NS_ENSURE_SUCCESS(result, result); strRule.Assign(NS_LITERAL_STRING("button:focus::-moz-focus-inner, input[type=\"reset\"]:focus::-moz-focus-inner,")); strRule.Append(NS_LITERAL_STRING("input[type=\"button\"]:focus::-moz-focus-inner, input[type=\"submit\"]:focus::-moz-focus-inner {")); strRule.Append(NS_LITERAL_STRING("border-color: ButtonText !important; }")); - result = sheet->InsertRule(strRule,0,&index); + result = sheet->InsertRule(strRule, sInsertPrefSheetRulesAt, &index); } } } diff --git a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp index 280197d5b4c..84567999617 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLFrame.cpp @@ -534,8 +534,13 @@ GetMathMLAttributeStyleSheet(nsIPresContext* aPresContext, if (!cssSheet) return; cssSheet->Init(uri); + nsCOMPtr domSheet(do_QueryInterface(cssSheet)); + if (domSheet) { + PRUint32 index; + domSheet->InsertRule(NS_LITERAL_STRING("@namespace url(http://www.w3.org/1998/Math/MathML);"), + 0, &index); + } cssSheet->SetTitle(NS_ConvertASCIItoUCS2(kTitle)); - cssSheet->SetDefaultNameSpaceID(kNameSpaceID_MathML); nsCOMPtr sheet(do_QueryInterface(cssSheet)); // all done, no further activity from the net involved, so we better do this @@ -666,7 +671,7 @@ nsMathMLFrame::MapAttributesIntoCSS(nsIPresContext* aPresContext, // insert the rule (note: when the sheet already has @namespace and // friends, insert after them, e.g., at the end, otherwise it won't work) // For MathML 2, insert at the end to give it precedence - PRInt32 pos = (map->compatibility == kMathMLversion2) ? count : 0; + PRInt32 pos = (map->compatibility == kMathMLversion2) ? count : 1; PRUint32 index; domSheet->InsertRule(cssRule, pos, &index); ++ruleCount; diff --git a/mozilla/layout/style/nsCSSLoader.cpp b/mozilla/layout/style/nsCSSLoader.cpp index 95768a1a602..0f278cbe818 100644 --- a/mozilla/layout/style/nsCSSLoader.cpp +++ b/mozilla/layout/style/nsCSSLoader.cpp @@ -31,7 +31,6 @@ #include "nsIDOMNode.h" #include "nsIDOMWindow.h" #include "nsIDocument.h" -#include "nsINameSpaceManager.h" #include "nsIUnicharInputStream.h" #include "nsIConverterInputStream.h" #include "nsICharsetAlias.h" @@ -958,7 +957,6 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI, nsresult CSSLoaderImpl::CreateSheet(nsIURI* aURI, nsIContent* aLinkingContent, - PRUint32 aDefaultNameSpaceID, PRBool aSyncLoad, StyleSheetState& aSheetState, nsICSSStyleSheet** aSheet) @@ -1039,8 +1037,6 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI, rv = NS_NewCSSStyleSheet(aSheet); // Don't init the sheet here, but in // ParseSheet once we know the final URI NS_ENSURE_SUCCESS(rv, rv); - - (*aSheet)->SetDefaultNameSpaceID(aDefaultNameSpaceID); } NS_ASSERTION(*aSheet, "We should have a sheet by now!"); @@ -1563,7 +1559,6 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement, nsIUnicharInputStream* aStream, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) @@ -1586,8 +1581,8 @@ CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement, StyleSheetState state; nsCOMPtr sheet; - nsresult rv = CreateSheet(nsnull, aElement, aDefaultNameSpaceID, PR_FALSE, - state, getter_AddRefs(sheet)); + nsresult rv = CreateSheet(nsnull, aElement, PR_FALSE, state, + getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_ASSERTION(state == eSheetNeedsParser, "Inline sheets should not be cached"); @@ -1620,7 +1615,6 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, nsIURI* aURL, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) @@ -1651,7 +1645,7 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement, StyleSheetState state; nsCOMPtr sheet; - rv = CreateSheet(aURL, aElement, aDefaultNameSpaceID, PR_FALSE, state, + rv = CreateSheet(aURL, aElement, PR_FALSE, state, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); @@ -1705,7 +1699,6 @@ NS_IMETHODIMP CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet, nsIURI* aURL, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsICSSImportRule* aParentRule) { LOG(("CSSLoaderImpl::LoadChildSheet")); @@ -1761,7 +1754,7 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet, // loop) do so nsCOMPtr sheet; StyleSheetState state; - rv = CreateSheet(aURL, nsnull, aDefaultNameSpaceID, + rv = CreateSheet(aURL, nsnull, parentData ? parentData->mSyncLoad : PR_FALSE, state, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); @@ -1833,8 +1826,8 @@ CSSLoaderImpl::InternalLoadAgentSheet(nsIURI* aURL, nsCOMPtr sheet; PRBool syncLoad = (aObserver == nsnull); - nsresult rv = CreateSheet(aURL, nsnull, kNameSpaceID_Unknown, syncLoad, - state, getter_AddRefs(sheet)); + nsresult rv = CreateSheet(aURL, nsnull, syncLoad, state, + getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_NAMED_LITERAL_STRING(empty, ""); diff --git a/mozilla/layout/style/nsCSSLoader.h b/mozilla/layout/style/nsCSSLoader.h index 2f0c603b53e..8ca10f71b79 100644 --- a/mozilla/layout/style/nsCSSLoader.h +++ b/mozilla/layout/style/nsCSSLoader.h @@ -260,7 +260,6 @@ public: nsIUnicharInputStream* aIn, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver); @@ -269,7 +268,6 @@ public: nsIURI* aURL, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver); @@ -277,7 +275,6 @@ public: NS_IMETHOD LoadChildSheet(nsICSSStyleSheet* aParentSheet, nsIURI* aURL, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsICSSImportRule* aRule); NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSStyleSheet** aSheet); @@ -312,7 +309,6 @@ private: // must be non-null then. nsresult CreateSheet(nsIURI* aURI, nsIContent* aLinkingContent, - PRUint32 aDefaultNameSpaceID, PRBool aSyncLoad, StyleSheetState& aSheetState, nsICSSStyleSheet** aSheet); diff --git a/mozilla/layout/style/nsCSSParser.cpp b/mozilla/layout/style/nsCSSParser.cpp index f487ece3b77..cb275b9626d 100644 --- a/mozilla/layout/style/nsCSSParser.cpp +++ b/mozilla/layout/style/nsCSSParser.cpp @@ -1162,7 +1162,7 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe return PR_FALSE; } - mChildLoader->LoadChildSheet(mSheet, url, aMedia, kNameSpaceID_Unknown, rule); + mChildLoader->LoadChildSheet(mSheet, url, aMedia, rule); } return PR_TRUE; diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index ad3591f55ae..704bfcf1024 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -783,7 +783,6 @@ public: nsISupportsArray* mOrderedRules; nsCOMPtr mNameSpace; - PRInt32 mDefaultNameSpaceID; PRPackedBool mComplete; }; @@ -858,7 +857,6 @@ public: NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) const; NS_IMETHOD GetNameSpace(nsINameSpace*& aNameSpace) const; - NS_IMETHOD SetDefaultNameSpaceID(PRInt32 aDefaultNameSpaceID); NS_IMETHOD Clone(nsICSSStyleSheet* aCloneParent, nsICSSImportRule* aCloneOwnerRule, @@ -1465,7 +1463,6 @@ CSSStyleSheetInner::CSSStyleSheetInner(nsICSSStyleSheet* aParentSheet) : mSheets(), mOrderedRules(nsnull), mNameSpace(nsnull), - mDefaultNameSpaceID(kNameSpaceID_None), mComplete(PR_FALSE) { MOZ_COUNT_CTOR(CSSStyleSheetInner); @@ -1491,7 +1488,6 @@ CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy, : mSheets(), mURL(aCopy.mURL), mNameSpace(nsnull), - mDefaultNameSpaceID(aCopy.mDefaultNameSpaceID), mComplete(aCopy.mComplete) { MOZ_COUNT_CTOR(CSSStyleSheetInner); @@ -1586,14 +1582,7 @@ CSSStyleSheetInner::RebuildNameSpaces(void) { nsContentUtils::GetNSManagerWeakRef()-> CreateRootNameSpace(getter_AddRefs(mNameSpace)); - if (kNameSpaceID_Unknown != mDefaultNameSpaceID) { - nsCOMPtr defaultNameSpace; - mNameSpace->CreateChildNameSpace(nsnull, mDefaultNameSpaceID, - getter_AddRefs(defaultNameSpace)); - if (defaultNameSpace) { - mNameSpace = defaultNameSpace; - } - } + if (mOrderedRules) { mOrderedRules->EnumerateForwards(CreateNameSpace, address_of(mNameSpace)); } @@ -2243,17 +2232,6 @@ CSSStyleSheetImpl::GetNameSpace(nsINameSpace*& aNameSpace) const return NS_OK; } -NS_IMETHODIMP -CSSStyleSheetImpl::SetDefaultNameSpaceID(PRInt32 aDefaultNameSpaceID) -{ - if (mInner) { - mInner->mDefaultNameSpaceID = aDefaultNameSpaceID; - mInner->RebuildNameSpaces(); - } - return NS_OK; -} - - NS_IMETHODIMP CSSStyleSheetImpl::StyleSheetCount(PRInt32& aCount) const { diff --git a/mozilla/layout/style/nsICSSLoader.h b/mozilla/layout/style/nsICSSLoader.h index 55c13f7b9a0..59be067c817 100644 --- a/mozilla/layout/style/nsICSSLoader.h +++ b/mozilla/layout/style/nsICSSLoader.h @@ -87,7 +87,6 @@ public: nsIUnicharInputStream* aStream, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) = 0; @@ -101,7 +100,6 @@ public: nsIURI* aURL, const nsAString& aTitle, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsIParser* aParserToUnblock, PRBool& aCompleted, nsICSSLoaderObserver* aObserver) = 0; @@ -110,7 +108,6 @@ public: NS_IMETHOD LoadChildSheet(nsICSSStyleSheet* aParentSheet, nsIURI* aURL, const nsAString& aMedia, - PRInt32 aDefaultNameSpaceID, nsICSSImportRule* aRule) = 0; // Load a user agent or user sheet. The sheet is loaded diff --git a/mozilla/layout/style/nsICSSStyleSheet.h b/mozilla/layout/style/nsICSSStyleSheet.h index 86b8ed94989..e78eae41fdb 100644 --- a/mozilla/layout/style/nsICSSStyleSheet.h +++ b/mozilla/layout/style/nsICSSStyleSheet.h @@ -87,8 +87,6 @@ public: // get head of namespace chain for sheet NS_IMETHOD GetNameSpace(nsINameSpace*& aNameSpace) const = 0; - // set default namespace for sheet (may be overridden by @namespace) - NS_IMETHOD SetDefaultNameSpaceID(PRInt32 aDefaultNameSpaceID) = 0; NS_IMETHOD Clone(nsICSSStyleSheet* aCloneParent, nsICSSImportRule* aCloneOwnerRule,