diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 21ab10e7331..f22a8d4dcdf 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -8507,6 +8507,30 @@ GetAdjustedParentFrame(nsIFrame* aParentFrame, static void InvalidateCanvasIfNeeded(nsIFrame* aFrame); +#ifdef MOZ_XUL + +static +nsIListBoxObject* +MaybeGetListBoxBodyFrame(nsIContent* aContainer, nsIContent* aChild) +{ + NS_PRECONDITION(aContainer, "Must have container here"); + if (aContainer->IsNodeOfType(nsINode::eXUL) && + aChild->IsNodeOfType(nsINode::eXUL) && + aContainer->Tag() == nsGkAtoms::listbox && + aChild->Tag() == nsGkAtoms::listitem) { + nsCOMPtr xulElement = do_QueryInterface(aContainer); + nsCOMPtr boxObject; + xulElement->GetBoxObject(getter_AddRefs(boxObject)); + nsCOMPtr listBoxObject = do_QueryInterface(boxObject); + if (listBoxObject) { + return listBoxObject->GetListBoxBody(PR_FALSE); + } + } + + return nsnull; +} +#endif + static PRBool IsSpecialFramesetChild(nsIContent* aContent) { @@ -8608,7 +8632,13 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, PRUint32 containerCount = aContainer->GetChildCount(); for (PRUint32 i = aNewIndexInContainer; i < containerCount; i++) { nsIContent *child = aContainer->GetChildAt(i); - if (mPresShell->GetPrimaryFrameFor(child)) { + if (mPresShell->GetPrimaryFrameFor(child) +#ifdef MOZ_XUL + // Except listboxes suck, so do NOT skip anything here if + // we plan to notify a listbox. + && !MaybeGetListBoxBodyFrame(aContainer, child) +#endif + ) { // Already have a frame for this content; a previous ContentInserted // in this loop must have reconstructed its insertion parent. Skip // it. @@ -8844,34 +8874,25 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext, PRBool aUseXBLForms, content_operation aOperation) { - if (!aContainer) + if (!aContainer) { return PR_FALSE; + } - if (aContainer->IsNodeOfType(nsINode::eXUL) && - aChild->IsNodeOfType(nsINode::eXUL) && - aContainer->Tag() == nsGkAtoms::listbox && - aChild->Tag() == nsGkAtoms::listitem) { - nsCOMPtr xulElement = do_QueryInterface(aContainer); - nsCOMPtr boxObject; - xulElement->GetBoxObject(getter_AddRefs(boxObject)); - nsCOMPtr listBoxObject = do_QueryInterface(boxObject); - if (listBoxObject) { - nsIListBoxObject* listboxBody = listBoxObject->GetListBoxBody(PR_FALSE); - if (listboxBody) { - nsListBoxBodyFrame *listBoxBodyFrame = static_cast(listboxBody); - if (aOperation == CONTENT_REMOVED) { - // Except if we have an aChildFrame and its parent is not the right - // thing, then we don't do this. Pseudo frames are so much fun.... - if (!aChildFrame || aChildFrame->GetParent() == listBoxBodyFrame) { - listBoxBodyFrame->OnContentRemoved(aPresContext, aChildFrame, - aIndexInContainer); - return PR_TRUE; - } - } else { - listBoxBodyFrame->OnContentInserted(aPresContext, aChild); - return PR_TRUE; - } + nsIListBoxObject* listboxBody = + MaybeGetListBoxBodyFrame(aContainer, aChild); + if (listboxBody) { + nsListBoxBodyFrame *listBoxBodyFrame = static_cast(listboxBody); + if (aOperation == CONTENT_REMOVED) { + // Except if we have an aChildFrame and its parent is not the right + // thing, then we don't do this. Pseudo frames are so much fun.... + if (!aChildFrame || aChildFrame->GetParent() == listBoxBodyFrame) { + listBoxBodyFrame->OnContentRemoved(aPresContext, aChildFrame, + aIndexInContainer); + return PR_TRUE; } + } else { + listBoxBodyFrame->OnContentInserted(aPresContext, aChild); + return PR_TRUE; } } diff --git a/mozilla/layout/base/tests/Makefile.in b/mozilla/layout/base/tests/Makefile.in index b0281bfb57c..aecd8ff5715 100644 --- a/mozilla/layout/base/tests/Makefile.in +++ b/mozilla/layout/base/tests/Makefile.in @@ -92,6 +92,8 @@ _TEST_FILES = \ test_bug416896.html \ test_bug420499.xul \ test_bug423523.html \ + test_bug495648.xul \ + bug495648.rdf \ $(NULL) # test_bug396024.html is currently disabled because it interacts badly with # the "You can't print-preview while the page is loading" dialog. diff --git a/mozilla/layout/base/tests/bug495648.rdf b/mozilla/layout/base/tests/bug495648.rdf new file mode 100644 index 00000000000..b7045aa70a5 --- /dev/null +++ b/mozilla/layout/base/tests/bug495648.rdf @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mozilla/layout/base/tests/test_bug495648.xul b/mozilla/layout/base/tests/test_bug495648.xul new file mode 100644 index 00000000000..56f771efccd --- /dev/null +++ b/mozilla/layout/base/tests/test_bug495648.xul @@ -0,0 +1,46 @@ + + + + + + + + + +