diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp
index 56878f8f1182..be27d407bffc 100644
--- a/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/content/html/content/src/nsHTMLBodyElement.cpp
@@ -466,12 +466,6 @@ BodyFixupRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont
const nsStyleColor* styleColor;
styleColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);
- // Fixup default presentation colors (NAV QUIRK)
- if (nsnull != styleColor) {
- aPresContext->SetDefaultColor(styleColor->mColor);
- aPresContext->SetDefaultBackgroundColor(styleColor->mBackgroundColor);
- }
-
// Use the CSS precedence rules for dealing with BODY background: if the value
// of the 'background' property for the HTML element is different from
// 'transparent' then use it, else use the value of the 'background' property
@@ -511,6 +505,29 @@ BodyFixupRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont
NS_RELEASE(parentContext);
}
+ nsCOMPtr presShell;
+ aPresContext->GetShell(getter_AddRefs(presShell));
+ if (presShell) {
+ nsCOMPtr doc;
+ presShell->GetDocument(getter_AddRefs(doc));
+ if (doc) {
+ nsIHTMLContentContainer* htmlContainer;
+ if (NS_OK == doc->QueryInterface(kIHTMLContentContainerIID,
+ (void**)&htmlContainer)) {
+ nsIHTMLStyleSheet* styleSheet;
+ if (NS_OK == htmlContainer->GetAttributeStyleSheet(&styleSheet)) {
+ styleSheet->SetDocumentForegroundColor(styleColor->mColor);
+ if (!(styleColor->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {
+ styleSheet->SetDocumentBackgroundColor(styleColor->mBackgroundColor);
+ }
+ NS_RELEASE(styleSheet);
+ }
+ NS_RELEASE(htmlContainer);
+ }
+ }
+ }
+
+
return NS_OK;
}
diff --git a/content/html/style/src/nsHTMLStyleSheet.cpp b/content/html/style/src/nsHTMLStyleSheet.cpp
index 99d477f5e8ef..c5c8b39ec571 100644
--- a/content/html/style/src/nsHTMLStyleSheet.cpp
+++ b/content/html/style/src/nsHTMLStyleSheet.cpp
@@ -693,6 +693,10 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
if (eCompatibility_NavQuirks == mode) {
+ if (mDocumentColorRule) {
+ aResults->AppendElement(mDocumentColorRule);
+ matchCount++;
+ }
aResults->AppendElement(mTableBackgroundRule);
matchCount++;
}
diff --git a/layout/html/content/src/nsHTMLBodyElement.cpp b/layout/html/content/src/nsHTMLBodyElement.cpp
index 56878f8f1182..be27d407bffc 100644
--- a/layout/html/content/src/nsHTMLBodyElement.cpp
+++ b/layout/html/content/src/nsHTMLBodyElement.cpp
@@ -466,12 +466,6 @@ BodyFixupRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont
const nsStyleColor* styleColor;
styleColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color);
- // Fixup default presentation colors (NAV QUIRK)
- if (nsnull != styleColor) {
- aPresContext->SetDefaultColor(styleColor->mColor);
- aPresContext->SetDefaultBackgroundColor(styleColor->mBackgroundColor);
- }
-
// Use the CSS precedence rules for dealing with BODY background: if the value
// of the 'background' property for the HTML element is different from
// 'transparent' then use it, else use the value of the 'background' property
@@ -511,6 +505,29 @@ BodyFixupRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont
NS_RELEASE(parentContext);
}
+ nsCOMPtr presShell;
+ aPresContext->GetShell(getter_AddRefs(presShell));
+ if (presShell) {
+ nsCOMPtr doc;
+ presShell->GetDocument(getter_AddRefs(doc));
+ if (doc) {
+ nsIHTMLContentContainer* htmlContainer;
+ if (NS_OK == doc->QueryInterface(kIHTMLContentContainerIID,
+ (void**)&htmlContainer)) {
+ nsIHTMLStyleSheet* styleSheet;
+ if (NS_OK == htmlContainer->GetAttributeStyleSheet(&styleSheet)) {
+ styleSheet->SetDocumentForegroundColor(styleColor->mColor);
+ if (!(styleColor->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {
+ styleSheet->SetDocumentBackgroundColor(styleColor->mBackgroundColor);
+ }
+ NS_RELEASE(styleSheet);
+ }
+ NS_RELEASE(htmlContainer);
+ }
+ }
+ }
+
+
return NS_OK;
}
diff --git a/layout/html/style/src/nsHTMLStyleSheet.cpp b/layout/html/style/src/nsHTMLStyleSheet.cpp
index 99d477f5e8ef..c5c8b39ec571 100644
--- a/layout/html/style/src/nsHTMLStyleSheet.cpp
+++ b/layout/html/style/src/nsHTMLStyleSheet.cpp
@@ -693,6 +693,10 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
if (eCompatibility_NavQuirks == mode) {
+ if (mDocumentColorRule) {
+ aResults->AppendElement(mDocumentColorRule);
+ matchCount++;
+ }
aResults->AppendElement(mTableBackgroundRule);
matchCount++;
}
diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp
index 99d477f5e8ef..c5c8b39ec571 100644
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -693,6 +693,10 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
nsCompatibility mode;
aPresContext->GetCompatibilityMode(&mode);
if (eCompatibility_NavQuirks == mode) {
+ if (mDocumentColorRule) {
+ aResults->AppendElement(mDocumentColorRule);
+ matchCount++;
+ }
aResults->AppendElement(mTableBackgroundRule);
matchCount++;
}