Bug 212504. Removal of the default namespace arguments from CSSStyleSheet and CSSLoader.

r=bzbarsky@mit.edu, sr=dbaron@dbaron.org
This commit is contained in:
caillon%returnzero.com 2003-07-18 01:26:47 +00:00
Родитель 9ed679232e
Коммит 7495519180
20 изменённых файлов: 101 добавлений и 158 удалений

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

@ -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);
}

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

@ -4876,7 +4876,6 @@ HTMLContentSink::ProcessStyleLink(nsIHTMLContent* aElement,
PRBool doneLoading;
result = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia,
kNameSpaceID_Unknown,
((blockParser) ? mParser : nsnull),
doneLoading,
this);

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

@ -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

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

@ -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,

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

@ -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<nsICSSStyleSheet> 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<nsICSSStyleSheet> 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<nsICSSStyleSheet> 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<nsICSSStyleSheet> 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, "");

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

@ -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);

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

@ -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;

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

@ -783,7 +783,6 @@ public:
nsISupportsArray* mOrderedRules;
nsCOMPtr<nsINameSpace> 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<nsINameSpace> 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
{

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

@ -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<nsICSSStyleSheet> 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)

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

@ -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);

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

@ -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)) {

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

@ -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<nsIURI> uri;
@ -2231,7 +2229,13 @@ nsresult PresShell::CreatePreferenceStyleSheet(void)
result = mPrefStyleSheet->Init(uri);
if (NS_SUCCEEDED(result)) {
mPrefStyleSheet->SetComplete();
mPrefStyleSheet->SetDefaultNameSpaceID(kNameSpaceID_XHTML);
nsCOMPtr<nsIDOMCSSStyleSheet> 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<nsIDOMCSSStyleSheet> 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);
}
}
}

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

@ -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<nsIURI> uri;
@ -2231,7 +2229,13 @@ nsresult PresShell::CreatePreferenceStyleSheet(void)
result = mPrefStyleSheet->Init(uri);
if (NS_SUCCEEDED(result)) {
mPrefStyleSheet->SetComplete();
mPrefStyleSheet->SetDefaultNameSpaceID(kNameSpaceID_XHTML);
nsCOMPtr<nsIDOMCSSStyleSheet> 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<nsIDOMCSSStyleSheet> 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);
}
}
}

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

@ -534,8 +534,13 @@ GetMathMLAttributeStyleSheet(nsIPresContext* aPresContext,
if (!cssSheet)
return;
cssSheet->Init(uri);
nsCOMPtr<nsIDOMCSSStyleSheet> 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<nsIStyleSheet> 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;

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

@ -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<nsICSSStyleSheet> 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<nsICSSStyleSheet> 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<nsICSSStyleSheet> 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<nsICSSStyleSheet> 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, "");

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

@ -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);

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

@ -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;

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

@ -783,7 +783,6 @@ public:
nsISupportsArray* mOrderedRules;
nsCOMPtr<nsINameSpace> 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<nsINameSpace> 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
{

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

@ -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

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

@ -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,