diff --git a/mozilla/content/base/public/nsIStyleSheetLinkingElement.h b/mozilla/content/base/public/nsIStyleSheetLinkingElement.h index ee78986cab4..3ac13ba22af 100644 --- a/mozilla/content/base/public/nsIStyleSheetLinkingElement.h +++ b/mozilla/content/base/public/nsIStyleSheetLinkingElement.h @@ -90,9 +90,11 @@ public: * from one document to another). * @param aObserver observer to notify once the stylesheet is loaded. * It might be notified before the function returns. + * @param aForceUpdate If true, force the update even if the URI did not change */ NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument, - nsICSSLoaderObserver* aObserver) = 0; + nsICSSLoaderObserver* aObserver, + PRBool aForceUpdate = PR_FALSE) = 0; /** * Tells this element whether to update the stylesheet when the diff --git a/mozilla/content/base/src/nsStyleLinkElement.cpp b/mozilla/content/base/src/nsStyleLinkElement.cpp index 4d0f52b38f6..e2faf551f68 100644 --- a/mozilla/content/base/src/nsStyleLinkElement.cpp +++ b/mozilla/content/base/src/nsStyleLinkElement.cpp @@ -189,7 +189,8 @@ const PRBool kBlockByDefault=PR_TRUE; NS_IMETHODIMP nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument, - nsICSSLoaderObserver* aObserver) + nsICSSLoaderObserver* aObserver, + PRBool aForceUpdate) { if (mStyleSheet && aOldDocument) { // We're removing the link element from the document, unload the @@ -228,7 +229,7 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument, PRBool isInline; GetStyleSheetURL(&isInline, getter_AddRefs(uri)); - if (mStyleSheet && !isInline && uri) { + if (!aForceUpdate && mStyleSheet && !isInline && uri) { nsCOMPtr oldURI; mStyleSheet->GetSheetURI(getter_AddRefs(oldURI)); diff --git a/mozilla/content/base/src/nsStyleLinkElement.h b/mozilla/content/base/src/nsStyleLinkElement.h index f8aa93a7baa..d46d40e4e71 100644 --- a/mozilla/content/base/src/nsStyleLinkElement.h +++ b/mozilla/content/base/src/nsStyleLinkElement.h @@ -64,8 +64,12 @@ public: NS_IMETHOD SetStyleSheet(nsIStyleSheet* aStyleSheet); NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet); NS_IMETHOD InitStyleLinkElement(nsIParser *aParser, PRBool aDontLoadStyle); + // If aForceUpdate == PR_TRUE will force the update even if the URI has not + // changed. This should be used in cases when something about the content + // that affects the resulting sheet changed but the URI may not have changed. NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument = nsnull, - nsICSSLoaderObserver* aObserver = nsnull); + nsICSSLoaderObserver* aObserver = nsnull, + PRBool aForceUpdate = PR_FALSE); NS_IMETHOD SetEnableUpdates(PRBool aEnableUpdates); NS_IMETHOD GetCharset(nsAString& aCharset); virtual void SetLineNumber(PRUint32 aLineNumber); diff --git a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp index 90298906c1c..8ab0685f6cc 100644 --- a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp @@ -295,7 +295,12 @@ nsHTMLLinkElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify); if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); + UpdateStyleSheet(nsnull, nsnull, + aNameSpaceID == kNameSpaceID_None && + (aName == nsHTMLAtoms::rel || + aName == nsHTMLAtoms::title || + aName == nsHTMLAtoms::media || + aName == nsHTMLAtoms::type)); } return rv; @@ -308,7 +313,12 @@ nsHTMLLinkElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify); if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); + UpdateStyleSheet(nsnull, nsnull, + aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsHTMLAtoms::rel || + aAttribute == nsHTMLAtoms::title || + aAttribute == nsHTMLAtoms::media || + aAttribute == nsHTMLAtoms::type)); } return rv; diff --git a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp index 1ed5682d4c3..0caa76d7576 100644 --- a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp @@ -240,7 +240,11 @@ nsHTMLStyleElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify); if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); + UpdateStyleSheet(nsnull, nsnull, + aNameSpaceID == kNameSpaceID_None && + (aName == nsHTMLAtoms::title || + aName == nsHTMLAtoms::media || + aName == nsHTMLAtoms::type)); } return rv; @@ -253,7 +257,11 @@ nsHTMLStyleElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify); if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); + UpdateStyleSheet(nsnull, nsnull, + aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsHTMLAtoms::title || + aAttribute == nsHTMLAtoms::media || + aAttribute == nsHTMLAtoms::type)); } return rv; diff --git a/mozilla/content/svg/content/src/nsSVGStyleElement.cpp b/mozilla/content/svg/content/src/nsSVGStyleElement.cpp index 913e200a2cd..985abd7cc43 100644 --- a/mozilla/content/svg/content/src/nsSVGStyleElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGStyleElement.cpp @@ -211,7 +211,11 @@ nsSVGStyleElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify); if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); + UpdateStyleSheet(nsnull, nsnull, + aNameSpaceID == kNameSpaceID_None && + (aName == nsSVGAtoms::title || + aName == nsSVGAtoms::media || + aName == nsSVGAtoms::type)); } return rv; @@ -224,7 +228,11 @@ nsSVGStyleElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute, aNotify); if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); + UpdateStyleSheet(nsnull, nsnull, + aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsSVGAtoms::title || + aAttribute == nsSVGAtoms::media || + aAttribute == nsSVGAtoms::type)); } return rv; diff --git a/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp b/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp index c83017e596a..1cec89e4fe6 100644 --- a/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp +++ b/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp @@ -138,7 +138,7 @@ nsXMLStylesheetPI::SetNodeValue(const nsAString& aNodeValue) { nsresult rv = nsGenericDOMDataNode::SetNodeValue(aNodeValue); if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); + UpdateStyleSheet(nsnull, nsnull, PR_TRUE); } return rv; }