diff --git a/mozilla/content/base/src/nsStyleSet.cpp b/mozilla/content/base/src/nsStyleSet.cpp index 44921c48b5e..8c9d8f7e25c 100644 --- a/mozilla/content/base/src/nsStyleSet.cpp +++ b/mozilla/content/base/src/nsStyleSet.cpp @@ -17,7 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): + * Daniel Glazman */ #include "nsCOMPtr.h" #include "nsIStyleSet.h" @@ -40,6 +41,9 @@ #include "nsIStyleRuleSupplier.h" #include "nsRuleNode.h" #include "nsIRuleWalker.h" +#include "nsIBodySuper.h" +#include "nsIHTMLDocument.h" +#include "nsIDOMHTMLBodyElement.h" #ifdef MOZ_PERF_METRICS #include "nsITimeRecorder.h" @@ -117,6 +121,8 @@ public: virtual nsresult GetRuleTree(nsIRuleNode** aResult); virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext); + virtual nsresult RemoveBodyFixupRule(nsIDocument *aDocument); + NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aStyleContext, nsIStyleContext* aNewParentContext, @@ -1033,6 +1039,24 @@ StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, return NS_OK; } +nsresult +StyleSetImpl::RemoveBodyFixupRule(nsIDocument *aDocument) +{ + nsresult rv = NS_OK; + nsCOMPtr htmlDoc = do_QueryInterface(aDocument); + if (htmlDoc) { + nsCOMPtr node; + htmlDoc->GetBodyElement(getter_AddRefs(node)); + if (node) { + nsCOMPtr bodyElement = do_QueryInterface(node); + bodyElement->RemoveBodyFixupRule(); + return NS_OK; + } + } + return rv; +} + + NS_IMETHODIMP StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aStyleContext, diff --git a/mozilla/content/html/content/public/MANIFEST b/mozilla/content/html/content/public/MANIFEST index 0f440c76d57..0d41fea9ca2 100644 --- a/mozilla/content/html/content/public/MANIFEST +++ b/mozilla/content/html/content/public/MANIFEST @@ -1,6 +1,7 @@ # # This is a list of local files which get copied to the mozilla:dist:content directory # +nsIBodySuper.h nsIForm.h nsIFormControl.h nsILink.h diff --git a/mozilla/content/html/content/public/Makefile.in b/mozilla/content/html/content/public/Makefile.in index 52247c742d5..1147364a4da 100644 --- a/mozilla/content/html/content/public/Makefile.in +++ b/mozilla/content/html/content/public/Makefile.in @@ -29,6 +29,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = layout EXPORTS = \ + nsIBodySuper.h \ nsIFormControl.h \ nsIForm.h \ nsILink.h \ diff --git a/mozilla/content/html/content/public/makefile.win b/mozilla/content/html/content/public/makefile.win index f65680caa0c..f56ef674632 100644 --- a/mozilla/content/html/content/public/makefile.win +++ b/mozilla/content/html/content/public/makefile.win @@ -22,7 +22,7 @@ DEPTH=..\..\..\.. EXPORTS=nsIFormControl.h nsIForm.h nsILink.h \ - nsISelectElement.h nsIScriptElement.h + nsISelectElement.h nsIScriptElement.h nsIBodySuper.h MODULE=raptor diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 2b0988598e4..174b4695a0b 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Daniel Glazman */ #include "nsCOMPtr.h" #include "nsIDOMHTMLBodyElement.h" @@ -51,6 +52,7 @@ #include "nsIView.h" #include "nsLayoutAtoms.h" #include "nsIRuleWalker.h" +#include "nsIBodySuper.h" //---------------------------------------------------------------------- @@ -110,19 +112,24 @@ public: //---------------------------------------------------------------------- // special subclass of inner class to override set document -class nsBodySuper: public nsGenericHTMLContainerElement +class nsBodySuper: public nsGenericHTMLContainerElement, + public nsIBodySuper { public: nsBodySuper(); virtual ~nsBodySuper(); + NS_DECL_ISUPPORTS_INHERITED + NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers); + NS_IMETHOD RemoveBodyFixupRule(); BodyRule* mContentStyleRule; BodyFixupRule* mInlineStyleRule; }; +NS_IMPL_ISUPPORTS_INHERITED(nsBodySuper, nsGenericHTMLContainerElement, nsIBodySuper) nsBodySuper::nsBodySuper() : nsGenericHTMLContainerElement(), mContentStyleRule(nsnull), @@ -166,6 +173,17 @@ nsBodySuper::SetDocument(nsIDocument* aDocument, PRBool aDeep, aCompileEventHandlers); } +NS_IMETHODIMP +nsBodySuper::RemoveBodyFixupRule(void) +{ + if (mInlineStyleRule) { + mInlineStyleRule->mPart = nsnull; + mInlineStyleRule->mSheet = nsnull; + NS_RELEASE(mInlineStyleRule); + } + return NS_OK; +} + //---------------------------------------------------------------------- class nsHTMLBodyElement : public nsBodySuper, @@ -711,7 +729,7 @@ nsHTMLBodyElement::~nsHTMLBodyElement() // QueryInterface implementation for nsHTMLBodyElement NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLBodyElement, - nsGenericHTMLContainerElement) + nsBodySuper) NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLBodyElement) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLBodyElement) NS_HTML_CONTENT_INTERFACE_MAP_END diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 81545adcc8b..98e71cb85db 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -3530,7 +3530,7 @@ nsHTMLDocument::GetBodyContent() return PR_FALSE; } -nsresult +NS_IMETHODIMP nsHTMLDocument::GetBodyElement(nsIDOMHTMLBodyElement** aBody) { if (mBodyContent == nsnull && PR_FALSE == GetBodyContent()) { diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 4937f96faab..7c7f982c2e5 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -187,7 +187,7 @@ protected: nsresult GetSourceDocumentURL(JSContext* cx, nsIURI** sourceURL); PRBool GetBodyContent(); - nsresult GetBodyElement(nsIDOMHTMLBodyElement** aBody); + NS_IMETHOD GetBodyElement(nsIDOMHTMLBodyElement** aBody); NS_IMETHOD GetDomainURI(nsIURI **uri); diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h index 730e720939b..c99065dab58 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -35,6 +35,7 @@ class nsIHTMLStyleSheet; class nsIStyleSheet; class nsICSSLoader; class nsIContent; +class nsIDOMHTMLBodyElement; /* b2a848b0-d0a9-11d1-89b1-006008911b81 */ #define NS_IHTMLDOCUMENT_IID \ @@ -75,6 +76,8 @@ public: NS_IMETHOD GetFormControlElements(nsIDOMNodeList** aReturn) = 0; + NS_IMETHOD GetBodyElement(nsIDOMHTMLBodyElement** aBody) = 0; + }; #endif /* nsIHTMLDocument_h___ */ diff --git a/mozilla/content/html/style/src/nsRuleNode.cpp b/mozilla/content/html/style/src/nsRuleNode.cpp index 78f9d733099..ccb9d0ef594 100644 --- a/mozilla/content/html/style/src/nsRuleNode.cpp +++ b/mozilla/content/html/style/src/nsRuleNode.cpp @@ -20,6 +20,7 @@ * Original Author: David W. Hyatt (hyatt@netscape.com) * * Contributor(s): + * Daniel Glazman */ #include "nsRuleNode.h" @@ -899,6 +900,8 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID& aSID, nsIStyleContext* aContext, // branch that they never need to examine their rules for this particular struct type // ever again. PropagateInheritBit(bit, ruleNode); + if (eStyleStruct_Background == aSID && aRuleData->mPostResolveCallback) + (*aRuleData->mPostResolveCallback) ((nsStyleStruct *)startStruct, aRuleData); return startStruct; } else if (!startStruct && ((!isReset && (detail == eRuleNone || detail == eRulePartialInherited)) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index dd6b8ecc745..1595381b756 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -21,6 +21,7 @@ * Steve Clark * Håkan Waara * Dan Rosen + * Daniel Glazman * * IBM Corporation * @@ -5088,6 +5089,12 @@ PresShell::StyleSheetDisabledStateChanged(nsIDocument *aDocument, } if (NS_FAILED(rv)) return rv; + if (aDisabled) { + // If the stylesheet is disabled, remove existing BodyFixupRule for + // bug 88681 + rv = mStyleSet->RemoveBodyFixupRule(aDocument); + if (NS_FAILED(rv)) return rv; + } // rebuild the frame-world return ReconstructFrames(); } diff --git a/mozilla/layout/base/public/nsIStyleSet.h b/mozilla/layout/base/public/nsIStyleSet.h index 9a76e1a0efd..c7dc01188d3 100644 --- a/mozilla/layout/base/public/nsIStyleSet.h +++ b/mozilla/layout/base/public/nsIStyleSet.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Daniel Glazman */ #ifndef nsStyleSet_h___ #define nsStyleSet_h___ @@ -82,6 +83,8 @@ public: virtual nsresult GetRuleTree(nsIRuleNode** aResult) = 0; + virtual nsresult RemoveBodyFixupRule(nsIDocument *aDocument) = 0; + // ClearCachedStyleData is used to invalidate portions of both the style context tree // and rule tree without destroying the actual nodes in the two trees. |aRule| provides // a hint as to which rule has changed, and all subtree data pruning will occur rooted diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index dd6b8ecc745..1595381b756 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -21,6 +21,7 @@ * Steve Clark * Håkan Waara * Dan Rosen + * Daniel Glazman * * IBM Corporation * @@ -5088,6 +5089,12 @@ PresShell::StyleSheetDisabledStateChanged(nsIDocument *aDocument, } if (NS_FAILED(rv)) return rv; + if (aDisabled) { + // If the stylesheet is disabled, remove existing BodyFixupRule for + // bug 88681 + rv = mStyleSet->RemoveBodyFixupRule(aDocument); + if (NS_FAILED(rv)) return rv; + } // rebuild the frame-world return ReconstructFrames(); } diff --git a/mozilla/layout/style/nsStyleSet.cpp b/mozilla/layout/style/nsStyleSet.cpp index 44921c48b5e..8c9d8f7e25c 100644 --- a/mozilla/layout/style/nsStyleSet.cpp +++ b/mozilla/layout/style/nsStyleSet.cpp @@ -17,7 +17,8 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): + * Daniel Glazman */ #include "nsCOMPtr.h" #include "nsIStyleSet.h" @@ -40,6 +41,9 @@ #include "nsIStyleRuleSupplier.h" #include "nsRuleNode.h" #include "nsIRuleWalker.h" +#include "nsIBodySuper.h" +#include "nsIHTMLDocument.h" +#include "nsIDOMHTMLBodyElement.h" #ifdef MOZ_PERF_METRICS #include "nsITimeRecorder.h" @@ -117,6 +121,8 @@ public: virtual nsresult GetRuleTree(nsIRuleNode** aResult); virtual nsresult ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, nsIStyleContext* aContext); + virtual nsresult RemoveBodyFixupRule(nsIDocument *aDocument); + NS_IMETHOD ReParentStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aStyleContext, nsIStyleContext* aNewParentContext, @@ -1033,6 +1039,24 @@ StyleSetImpl::ClearStyleData(nsIPresContext* aPresContext, nsIStyleRule* aRule, return NS_OK; } +nsresult +StyleSetImpl::RemoveBodyFixupRule(nsIDocument *aDocument) +{ + nsresult rv = NS_OK; + nsCOMPtr htmlDoc = do_QueryInterface(aDocument); + if (htmlDoc) { + nsCOMPtr node; + htmlDoc->GetBodyElement(getter_AddRefs(node)); + if (node) { + nsCOMPtr bodyElement = do_QueryInterface(node); + bodyElement->RemoveBodyFixupRule(); + return NS_OK; + } + } + return rv; +} + + NS_IMETHODIMP StyleSetImpl::ReParentStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aStyleContext,