From 3740f9b3fec72c3bbeaa98700c0ec34ddd31faf3 Mon Sep 17 00:00:00 2001 From: "peterv%netscape.com" Date: Wed, 30 May 2001 20:35:20 +0000 Subject: [PATCH] Fix for bug 83078 (document.write of 'LINK' (ext. stylesheet) causes duplicate content). Call UpdateAllContexts when a stylesheet is add/removed/enabled/disabled. r=harishd, sr=jst, a=chofmann. --- .../html/document/src/nsHTMLContentSink.cpp | 59 ++++++++++++------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 7814ab4aa2c0..0048e444e4ea 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -235,7 +235,8 @@ public: NS_IMETHOD_(void) Notify(nsITimer *timer); // nsICSSLoaderObserver - NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet*aSheet, PRBool aNotify); + NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet* aSheet, + PRBool aNotify) { return NS_OK; }; // nsIDocumentObserver NS_IMETHOD BeginUpdate(nsIDocument *aDocument); @@ -275,12 +276,12 @@ public: nsIContent* aChild, PRInt32 aIndexInContainer) { return NS_OK; } NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet) { return NS_OK; } + nsIStyleSheet* aStyleSheet); NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument, - nsIStyleSheet* aStyleSheet) { return NS_OK; } + nsIStyleSheet* aStyleSheet); NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet, - PRBool aDisabled) { return NS_OK; } + PRBool aDisabled); NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument, nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule, @@ -3948,22 +3949,6 @@ HTMLContentSink::ProcessLink(nsIHTMLContent* aElement, const nsAReadableString& return result; } -NS_IMETHODIMP -HTMLContentSink::StyleSheetLoaded(nsICSSStyleSheet* aSheet, - PRBool aDidNotify) -{ - // If there was a notification done for this style sheet, we know - // that frames have been created for all content seen so far - // (processing of a new style sheet causes recreation of the frame - // model). As a result, all contexts should update their notion of - // how much frame creation has happened. - if (aDidNotify) { - UpdateAllContexts(); - } - - return NS_OK; -} - nsresult HTMLContentSink::ProcessStyleLink(nsIHTMLContent* aElement, const nsString& aHref, const nsString& aRel, @@ -4417,6 +4402,40 @@ HTMLContentSink::EndUpdate(nsIDocument *aDocument) return NS_OK; } +NS_IMETHODIMP +HTMLContentSink::StyleSheetAdded(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet) +{ + // Processing of a new style sheet causes recreation of the frame + // model. As a result, all contexts should update their notion of + // how much frame creation has happened. + UpdateAllContexts(); + return NS_OK; +} + +NS_IMETHODIMP +HTMLContentSink::StyleSheetRemoved(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet) +{ + // Removing a style sheet causes recreation of the frame model. + // As a result, all contexts should update their notion of how + // much frame creation has happened. + UpdateAllContexts(); + return NS_OK; +} + +NS_IMETHODIMP +HTMLContentSink::StyleSheetDisabledStateChanged(nsIDocument *aDocument, + nsIStyleSheet* aStyleSheet, + PRBool aDisabled) +{ + // Disabling/enabling a style sheet causes recreation of the frame + // model. As a result, all contexts should update their notion of + // how much frame creation has happened. + UpdateAllContexts(); + return NS_OK; +} + nsresult HTMLContentSink::ResumeParsing() {