mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
fixed BodyFixupRule::MapStyleInto to respect background color properly
code-reviewed by Peter Linss
This commit is contained in:
parent
9fc632198d
commit
c1f02ff5b3
@ -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<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDocument> 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;
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
if (presShell) {
|
||||
nsCOMPtr<nsIDocument> 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;
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user