зеркало из https://github.com/mozilla/gecko-dev.git
Bug 371839. Assertions that scan all continuations should bail out if the continuation chain is too long, so they don't add O(N) to algorithmic complexity. r=bzbarsky
This commit is contained in:
Родитель
74625ec81b
Коммит
181dea6c00
|
@ -131,20 +131,26 @@ nsIFrame* nsSplittableFrame::GetLastContinuation() const
|
|||
#ifdef DEBUG
|
||||
PRBool nsSplittableFrame::IsInPrevContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2)
|
||||
{
|
||||
while (aFrame1) {
|
||||
PRInt32 iterations = 0;
|
||||
while (aFrame1 && iterations < 10) {
|
||||
// Bail out after 10 iterations so we don't bog down debug builds too much
|
||||
if (aFrame1 == aFrame2)
|
||||
return PR_TRUE;
|
||||
aFrame1 = aFrame1->GetPrevContinuation();
|
||||
++iterations;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsSplittableFrame::IsInNextContinuationChain(nsIFrame* aFrame1, nsIFrame* aFrame2)
|
||||
{
|
||||
while (aFrame1) {
|
||||
PRInt32 iterations = 0;
|
||||
while (aFrame1 && iterations < 10) {
|
||||
// Bail out after 10 iterations so we don't bog down debug builds too much
|
||||
if (aFrame1 == aFrame2)
|
||||
return PR_TRUE;
|
||||
aFrame1 = aFrame1->GetNextContinuation();
|
||||
++iterations;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
|
@ -5958,10 +5958,19 @@ nsTextFrame::SetLength(PRInt32 aLength)
|
|||
f = static_cast<nsTextFrame*>(f->GetNextInFlow());
|
||||
}
|
||||
#ifdef DEBUG
|
||||
f = static_cast<nsTextFrame*>(this->GetFirstContinuation());
|
||||
while (f) {
|
||||
f = this;
|
||||
PRInt32 iterations = 0;
|
||||
while (f && iterations < 10) {
|
||||
f->GetContentLength(); // Assert if negative length
|
||||
f = static_cast<nsTextFrame*>(f->GetNextContinuation());
|
||||
++iterations;
|
||||
}
|
||||
f = this;
|
||||
iterations = 0;
|
||||
while (f && iterations < 10) {
|
||||
f->GetContentLength(); // Assert if negative length
|
||||
f = static_cast<nsTextFrame*>(f->GetPrevContinuation());
|
||||
++iterations;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче