Call RemoveMappingsForFrameSubtree() before destroying an "internal" popup frame. b=372685 r+sr=bzbarsky blocking1.9=dsicore

This commit is contained in:
mats.palmgren@bredband.net 2007-10-06 06:53:05 -07:00
Родитель c9122f3571
Коммит 95bcc0e95f
6 изменённых файлов: 130 добавлений и 39 удалений

Просмотреть файл

@ -44,5 +44,9 @@ include $(DEPTH)/config/autoconf.mk
DIRS = base
ifdef MOZ_MOCHITEST
DIRS += test
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -86,16 +86,6 @@
const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
static nsPopupSetFrame*
GetPopupSetFrame(nsPresContext* aPresContext)
{
nsIRootBox* rootBox = nsIRootBox::GetRootBox(aPresContext->PresShell());
if (!rootBox)
return nsnull;
return rootBox->GetPopupSetFrame();
}
// NS_NewMenuPopupFrame
//
// Wrapper for creating a new menu popup container
@ -630,7 +620,6 @@ nsMenuPopupFrame::GetRootViewForPopup(nsIFrame* aStartFrame)
{
nsIView* view = aStartFrame->GetClosestView();
NS_ASSERTION(view, "frame must have a closest view!");
nsIView* rootView = nsnull;
while (view) {
// Walk up the view hierarchy looking for a view whose widget has a
// window type of eWindowType_popup - in other words a popup window

Просмотреть файл

@ -23,6 +23,7 @@
* Original Author: David W. Hyatt (hyatt@netscape.com)
* Pierre Phaneuf <pp@ludusdesign.com>
* Dean Tessman <dean_tessman@hotmail.com>
* Mats Palmgren <mats.palmgren@bredband.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -38,37 +39,21 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsGkAtoms.h"
#include "nsPopupSetFrame.h"
#include "nsIMenuParent.h"
#include "nsMenuFrame.h"
#include "nsBoxFrame.h"
#include "nsGkAtoms.h"
#include "nsCOMPtr.h"
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsPresContext.h"
#include "nsStyleContext.h"
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
#include "nsMenuPopupFrame.h"
#include "nsMenuBarFrame.h"
#include "nsIView.h"
#include "nsIWidget.h"
#include "nsIDocument.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMElement.h"
#include "nsISupportsArray.h"
#include "nsIDOMText.h"
#include "nsBoxLayoutState.h"
#include "nsIScrollableFrame.h"
#include "nsCSSFrameConstructor.h"
#include "nsGUIEvent.h"
#include "nsIRootBox.h"
#define NS_MENU_POPUP_LIST_INDEX 0
nsPopupFrameList::nsPopupFrameList(nsIContent* aPopupContent, nsPopupFrameList* aNext)
:mNextPopup(aNext),
mPopupFrame(nsnull),
@ -104,6 +89,12 @@ nsPopupSetFrame::Init(nsIContent* aContent,
return rv;
}
nsIAtom*
nsPopupSetFrame::GetType() const
{
return nsGkAtoms::popupSetFrame;
}
NS_IMETHODIMP
nsPopupSetFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
@ -148,10 +139,12 @@ nsPopupSetFrame::SetInitialChildList(nsIAtom* aListName,
void
nsPopupSetFrame::Destroy()
{
nsCSSFrameConstructor* frameConstructor =
PresContext()->PresShell()->FrameConstructor();
// remove each popup from the list as we go.
while (mPopupList) {
if (mPopupList->mPopupFrame)
mPopupList->mPopupFrame->Destroy();
DestroyPopupFrame(frameConstructor, mPopupList->mPopupFrame);
nsPopupFrameList* temp = mPopupList;
mPopupList = mPopupList->mNextPopup;
@ -245,7 +238,8 @@ nsPopupSetFrame::RemovePopupFrame(nsIFrame* aPopup)
mPopupList = currEntry->mNextPopup;
// Destroy the frame.
currEntry->mPopupFrame->Destroy();
DestroyPopupFrame(PresContext()->PresShell()->FrameConstructor(),
currEntry->mPopupFrame);
// Delete the entry.
currEntry->mNextPopup = nsnull;
@ -302,3 +296,10 @@ nsPopupSetFrame::AddPopupFrame(nsIFrame* aPopup)
return NS_OK;
}
void
nsPopupSetFrame::DestroyPopupFrame(nsCSSFrameConstructor* aFc, nsIFrame* aPopup)
{
aFc->RemoveMappingsForFrameSubtree(aPopup);
aPopup->Destroy();
}

Просмотреть файл

@ -43,17 +43,12 @@
#ifndef nsPopupSetFrame_h__
#define nsPopupSetFrame_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsGkAtoms.h"
#include "nsBoxFrame.h"
#include "nsFrameList.h"
#include "nsMenuPopupFrame.h"
#include "nsIMenuParent.h"
#include "nsITimer.h"
#include "nsISupportsArray.h"
class nsCSSFrameConstructor;
nsIFrame* NS_NewPopupSetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
@ -93,7 +88,7 @@ public:
// Used to destroy our popup frames.
virtual void Destroy();
virtual nsIAtom* GetType() const { return nsGkAtoms::popupSetFrame; }
virtual nsIAtom* GetType() const;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const
@ -107,6 +102,7 @@ protected:
nsresult AddPopupFrameList(nsIFrame* aPopupFrameList);
nsresult AddPopupFrame(nsIFrame* aPopup);
nsresult RemovePopupFrame(nsIFrame* aPopup);
void DestroyPopupFrame(nsCSSFrameConstructor* aFc, nsIFrame* aPopup);
nsPopupFrameList* mPopupList;

Просмотреть файл

@ -0,0 +1,51 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = layout/xul/test
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = test_bug372685.xul \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Test for Bug 372685">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=372685
-->
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<menuitem id="a" style="display: -moz-stack;">
<box id="b" style="display: -moz-popup; ">
<box id="c" style="position: fixed;"></box>
</box>
</menuitem>
<script class="testbody" type="application/javascript">
<![CDATA[
function removestyles(i){
document.getElementById('a').removeAttribute('style');
var x=document.getElementById('html_body').offsetHeight;
is(0, 0, "this is a crash test, so always ok if we survive this far");
SimpleTest.finish();
}
function do_test() {
setTimeout(removestyles,200);
}
SimpleTest.waitForExplicitFinish();
]]>
</script>
<body id="html_body" xmlns="http://www.w3.org/1999/xhtml">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=372685">Mozilla Bug 372685</a>
<p id="display"></p>
<pre id="test">
</pre>
<script>
addLoadEvent(do_test);
</script>
</body>
</window>