Bug 493968. Correctly keep track of all the kids of a cloned sheet, not just the last one. r=roc, r+sr=dbaron pending.

This commit is contained in:
Boris Zbarsky 2009-05-26 15:40:49 -04:00
parent dddd44794e
commit 6df71d93aa
5 changed files with 39 additions and 3 deletions

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<style>body { color: green; }</style>
</head>
<body>
This should be green
</body>
</html>

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<style>body { color: red; }</style>
<link rel="stylesheet" href="data:text/css,@import 'data:text/css,body { color: green }'; @import 'data:text/css,foopy {}';" id="r">
<link rel="stylesheet" href="data:text/css,@import 'data:text/css,body { color: green }'; @import 'data:text/css,foopy {}';">
<script>
// Force a unique inner for the second linked sheet
document.styleSheets[2].cssRules[0];
// Ditch the first sheet
var r = document.getElementById("r");
r.parentNode.removeChild(r);
</script>
</head>
<body>
This should be green
</body>
</html>

View File

@ -1239,3 +1239,4 @@ fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs
== 490173-1.html 490173-1-ref.html
== 490173-2.html 490173-2-ref.html
== 491323-1.xul 491323-1-ref.xul
== 493968-1.html 493968-1-ref.html

View File

@ -813,8 +813,8 @@ struct ChildSheetListBuilder {
}
};
static PRBool
RebuildChildList(nsICSSRule* aRule, void* aBuilder)
PRBool
nsCSSStyleSheet::RebuildChildList(nsICSSRule* aRule, void* aBuilder)
{
PRInt32 type;
aRule->GetType(type);
@ -848,6 +848,7 @@ RebuildChildList(nsICSSRule* aRule, void* aBuilder)
(*builder->sheetSlot) = static_cast<nsCSSStyleSheet*>(cssSheet.get());
builder->SetParentLinks(*builder->sheetSlot);
builder->sheetSlot = &(*builder->sheetSlot)->mNext;
return PR_TRUE;
}
@ -869,7 +870,7 @@ nsCSSStyleSheetInner::nsCSSStyleSheetInner(nsCSSStyleSheetInner& aCopy,
mOrderedRules.EnumerateForwards(SetStyleSheetReference, aPrimarySheet);
ChildSheetListBuilder builder = { &mFirstChild, aPrimarySheet };
mOrderedRules.EnumerateForwards(RebuildChildList, &builder);
mOrderedRules.EnumerateForwards(nsCSSStyleSheet::RebuildChildList, &builder);
RebuildNameSpaces();
}

View File

@ -183,6 +183,10 @@ public:
// nsIDOMCSSStyleSheet interface
NS_DECL_NSIDOMCSSSTYLESHEET
// Function used as a callback to rebuild our inner's child sheet
// list after we clone a unique inner for ourselves.
static PRBool RebuildChildList(nsICSSRule* aRule, void* aBuilder);
private:
nsCSSStyleSheet(const nsCSSStyleSheet& aCopy,
nsICSSStyleSheet* aParentToUse,