Make sure to update the sheet even if the URI has not changed if something else

that matters (type, media, etc) has changed.  Bug 303313, r+sr=peterv


git-svn-id: svn://10.0.0.236/trunk@185844 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2005-12-09 19:20:42 +00:00
parent 09fb0311d4
commit ca7e6121f6
7 changed files with 44 additions and 11 deletions

View File

@@ -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

View File

@@ -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<nsIURI> oldURI;
mStyleSheet->GetSheetURI(getter_AddRefs(oldURI));

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}