Don't calculate stuff with dirty lists. Bug 367243, r=mats, sr=dbaron, a=jay

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_0_BRANCH@218792 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2007-01-23 05:32:16 +00:00
parent 22f61a8722
commit 23d37d3cd2
3 changed files with 28 additions and 8 deletions

View File

@@ -2160,15 +2160,22 @@ nsCSSFrameConstructor::CreateGeneratedFrameFor(nsIFrame* aParentFram
return NS_ERROR_OUT_OF_MEMORY;
counterList->Insert(node);
if (counterList->IsLast(node))
node->Calc(counterList);
else {
counterList->SetDirty();
CountersDirty();
PRBool dirty = counterList->IsDirty();
if (!dirty) {
if (counterList->IsLast(node)) {
node->Calc(counterList);
node->GetText(contentString);
}
// In all other cases (list already dirty or node not at the end),
// just start with an empty string for now and when we recalculate
// the list we'll change the value to the right one.
else {
counterList->SetDirty();
CountersDirty();
}
}
textPtr = &node->mText; // text node assigned below
node->GetText(contentString);
}
break;

View File

@@ -44,6 +44,8 @@
// Should be called immediately after calling |Insert|.
void nsCounterUseNode::Calc(nsCounterList *aList)
{
NS_ASSERTION(!aList->IsDirty(),
"Why are we calculating with a dirty list?");
mValueAfter = aList->ValueBefore(this);
}
@@ -51,6 +53,8 @@ void nsCounterUseNode::Calc(nsCounterList *aList)
// Should be called immediately after calling |Insert|.
void nsCounterChangeNode::Calc(nsCounterList *aList)
{
NS_ASSERTION(!aList->IsDirty(),
"Why are we calculating with a dirty list?");
if (mType == RESET) {
mValueAfter = mChangeValue;
} else {
@@ -233,7 +237,12 @@ nsCounterManager::AddResetOrIncrement(nsIFrame *aFrame, PRInt32 aIndex,
// list.
return PR_TRUE;
}
node->Calc(counterList);
// Don't call Calc() if the list is already dirty -- it'll be recalculated
// anyway, and trying to calculate with a dirty list doesn't work.
if (NS_LIKELY(!counterList->IsDirty())) {
node->Calc(counterList);
}
return PR_FALSE;
}

View File

@@ -187,7 +187,11 @@ public:
void Insert(nsCounterNode* aNode) {
nsGenConList::Insert(aNode);
SetScope(aNode);
// Don't SetScope if we're dirty -- we'll reset all the scopes anyway,
// and we can't usefully compute scopes right now.
if (NS_LIKELY(!IsDirty())) {
SetScope(aNode);
}
}
nsCounterNode* First() {