From 8897e07fddf9910cc834b61e8a331d94ef408da0 Mon Sep 17 00:00:00 2001 From: "jag%tty.nl" Date: Fri, 21 Apr 2006 11:13:41 +0000 Subject: [PATCH] Bug 334829: FindFrameWithContent() can't find certain frames If the hint frame's location in the frame tree doesn't match its element's location in the content tree, the hint is useless, and we don't correctly reboot the search without the hint. Add a flag to make the reboot work. Patch courtesy of Danger Inc., r=dbaron, sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@195051 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 4d9194a3be1..d68735d526c 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -11260,11 +11260,16 @@ nsCSSFrameConstructor::FindFrameWithContent(nsFrameManager* aFrameManager, // Search for the frame in each child list that aParentFrame supports nsIAtom* listName = nsnull; PRInt32 listIndex = 0; + PRBool searchAgain; + do { #ifdef NOISY_FINDFRAME FFWC_doLoop++; #endif - nsIFrame* kidFrame=nsnull; + nsIFrame* kidFrame = nsnull; + + searchAgain = PR_FALSE; + // if we were given an hint, try to use it here to find a good // previous frame to start our search (|kidFrame|). if (aHint) { @@ -11356,17 +11361,20 @@ nsCSSFrameConstructor::FindFrameWithContent(nsFrameManager* aFrameManager, } if (aHint) { - // If we get here, and we had a hint, then we didn't find a - // frame. The hint may have been a floated or absolutely - // positioned frame, in which case we'd be off in the weeds - // looking through something other than primary frame - // list. Reboot the search from scratch, without the hint, but - // using the null child list again. + // If we get here, and we had a hint, then we didn't find a frame. + // The hint may have been a frame whose location in the frame tree + // doesn't match the location of its corresponding element in the + // DOM tree, e.g. a floated or absolutely positioned frame, or e.g. + // a frame, in which case we'd be off in the weeds looking + // through something other than the primary frame list. + // Reboot the search from scratch, without the hint, but using the + // null child list again. aHint = nsnull; + searchAgain = PR_TRUE; } else { listName = aParentFrame->GetAdditionalChildListName(listIndex++); } - } while(listName); + } while(listName || searchAgain); // We didn't find a matching frame. If aFrame has a next-in-flow, // then continue looking there