mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 748692. Don't reparse inline stylesheets on random attribute changes. r=sicking
This commit is contained in:
parent
94b5beb86f
commit
11bf7acee3
@ -274,20 +274,23 @@ nsHTMLLinkElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
Link::ResetLinkState(!!aNotify);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None &&
|
||||
(aName == nsGkAtoms::href ||
|
||||
aName == nsGkAtoms::rel ||
|
||||
aName == nsGkAtoms::title ||
|
||||
aName == nsGkAtoms::media ||
|
||||
aName == nsGkAtoms::type)) {
|
||||
bool dropSheet = false;
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::rel &&
|
||||
GetStyleSheet()) {
|
||||
if (aName == nsGkAtoms::rel && GetStyleSheet()) {
|
||||
PRUint32 linkTypes = nsStyleLinkElement::ParseLinkTypes(aValue);
|
||||
dropSheet = !(linkTypes & STYLESHEET);
|
||||
}
|
||||
|
||||
UpdateStyleSheetInternal(nsnull,
|
||||
dropSheet ||
|
||||
(aNameSpaceID == kNameSpaceID_None &&
|
||||
(aName == nsGkAtoms::title ||
|
||||
aName == nsGkAtoms::media ||
|
||||
aName == nsGkAtoms::type)));
|
||||
(aName == nsGkAtoms::title ||
|
||||
aName == nsGkAtoms::media ||
|
||||
aName == nsGkAtoms::type));
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -299,13 +302,15 @@ nsHTMLLinkElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute,
|
||||
aNotify);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
UpdateStyleSheetInternal(nsnull,
|
||||
aNameSpaceID == kNameSpaceID_None &&
|
||||
(aAttribute == nsGkAtoms::rel ||
|
||||
aAttribute == nsGkAtoms::title ||
|
||||
aAttribute == nsGkAtoms::media ||
|
||||
aAttribute == nsGkAtoms::type));
|
||||
// Since removing href or rel makes us no longer link to a
|
||||
// stylesheet, force updates for those too.
|
||||
if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None &&
|
||||
(aAttribute == nsGkAtoms::href ||
|
||||
aAttribute == nsGkAtoms::rel ||
|
||||
aAttribute == nsGkAtoms::title ||
|
||||
aAttribute == nsGkAtoms::media ||
|
||||
aAttribute == nsGkAtoms::type)) {
|
||||
UpdateStyleSheetInternal(nsnull, true);
|
||||
}
|
||||
|
||||
// The ordering of the parent class's UnsetAttr call and Link::ResetLinkState
|
||||
|
@ -237,12 +237,11 @@ nsHTMLStyleElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
|
||||
aValue, aNotify);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
UpdateStyleSheetInternal(nsnull,
|
||||
aNameSpaceID == kNameSpaceID_None &&
|
||||
(aName == nsGkAtoms::title ||
|
||||
aName == nsGkAtoms::media ||
|
||||
aName == nsGkAtoms::type));
|
||||
if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None &&
|
||||
(aName == nsGkAtoms::title ||
|
||||
aName == nsGkAtoms::media ||
|
||||
aName == nsGkAtoms::type)) {
|
||||
UpdateStyleSheetInternal(nsnull, true);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -254,12 +253,11 @@ nsHTMLStyleElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute,
|
||||
aNotify);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
UpdateStyleSheetInternal(nsnull,
|
||||
aNameSpaceID == kNameSpaceID_None &&
|
||||
(aAttribute == nsGkAtoms::title ||
|
||||
aAttribute == nsGkAtoms::media ||
|
||||
aAttribute == nsGkAtoms::type));
|
||||
if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None &&
|
||||
(aAttribute == nsGkAtoms::title ||
|
||||
aAttribute == nsGkAtoms::media ||
|
||||
aAttribute == nsGkAtoms::type)) {
|
||||
UpdateStyleSheetInternal(nsnull, true);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
9
layout/reftests/bugs/748692-1-ref.html
Normal file
9
layout/reftests/bugs/748692-1-ref.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<style>
|
||||
body { color: green; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
This text should be green
|
||||
</body>
|
13
layout/reftests/bugs/748692-1a.html
Normal file
13
layout/reftests/bugs/748692-1a.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<style>
|
||||
body { color: red; }
|
||||
</style>
|
||||
<script>
|
||||
document.styleSheets[0].insertRule("body { color: green; }", 1);
|
||||
document.querySelector("style").className = "foo";
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
This text should be green
|
||||
</body>
|
13
layout/reftests/bugs/748692-1b.html
Normal file
13
layout/reftests/bugs/748692-1b.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<style class="foo">
|
||||
body { color: red; }
|
||||
</style>
|
||||
<script>
|
||||
document.styleSheets[0].insertRule("body { color: green; }", 1);
|
||||
document.querySelector("style").removeAttribute("class");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
This text should be green
|
||||
</body>
|
@ -1704,3 +1704,5 @@ needs-focus == 731726-1.html 731726-1-ref.html
|
||||
== 751012-1a.html 751012-1-ref.html
|
||||
== 751012-1b.html 751012-1-ref.html
|
||||
== 690643-1.html 690643-1-ref.html
|
||||
== 748692-1a.html 748692-1-ref.html
|
||||
== 748692-1b.html 748692-1-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user