Bug 655263. Remove views from decks. r=roc

This commit is contained in:
Timothy Nikkel 2011-10-26 18:57:55 -05:00
Родитель e13ceed986
Коммит 406398810f
2 изменённых файлов: 10 добавлений и 83 удалений

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

@ -96,7 +96,7 @@ nsDeckFrame::AttributeChanged(PRInt32 aNameSpaceID,
// if the index changed hide the old element and make the new element visible
if (aAttribute == nsGkAtoms::selectedIndex) {
IndexChanged(PresContext());
IndexChanged();
}
return rv;
@ -114,68 +114,14 @@ nsDeckFrame::Init(nsIContent* aContent,
return rv;
}
static void
CreateViewsForFrames(const nsFrameList& aFrames)
void
nsDeckFrame::HideBox(nsIBox* aBox)
{
for (nsFrameList::Enumerator f(aFrames); !f.AtEnd(); f.Next()) {
nsContainerFrame::CreateViewForFrame(f.get(), true);
}
}
NS_IMETHODIMP
nsDeckFrame::SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList)
{
CreateViewsForFrames(aChildList);
return nsBoxFrame::SetInitialChildList(aListID, aChildList);
}
NS_IMETHODIMP
nsDeckFrame::AppendFrames(ChildListID aListID,
nsFrameList& aFrameList)
{
CreateViewsForFrames(aFrameList);
return nsBoxFrame::AppendFrames(aListID, aFrameList);
}
NS_IMETHODIMP
nsDeckFrame::InsertFrames(ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
CreateViewsForFrames(aFrameList);
return nsBoxFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
nsIPresShell::ClearMouseCapture(aBox);
}
void
nsDeckFrame::HideBox(nsPresContext* aPresContext, nsIBox* aBox)
{
nsIView* view = aBox->GetView();
if (view) {
nsIViewManager* viewManager = view->GetViewManager();
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, nsRect(0, 0, 0, 0));
nsIPresShell::ClearMouseCapture(aBox);
}
}
void
nsDeckFrame::ShowBox(nsPresContext* aPresContext, nsIBox* aBox)
{
nsRect rect = aBox->GetRect();
nsIView* view = aBox->GetView();
if (view) {
nsIViewManager* viewManager = view->GetViewManager();
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
}
}
void
nsDeckFrame::IndexChanged(nsPresContext* aPresContext)
nsDeckFrame::IndexChanged()
{
//did the index change?
PRInt32 index = GetSelectedIndex();
@ -188,14 +134,9 @@ nsDeckFrame::IndexChanged(nsPresContext* aPresContext)
// hide the currently showing box
nsIBox* currentBox = GetSelectedBox();
if (currentBox) // only hide if it exists
HideBox(aPresContext, currentBox);
HideBox(currentBox);
mIndex = index;
// show the new box
nsIBox* newBox = GetSelectedBox();
if (newBox) // only show if it exists
ShowBox(aPresContext, newBox);
}
PRInt32
@ -271,10 +212,8 @@ nsDeckFrame::DoLayout(nsBoxLayoutState& aState)
while (box)
{
// make collapsed children not show up
if (count == mIndex)
ShowBox(aState.PresContext(), box);
else
HideBox(aState.PresContext(), box);
if (count != mIndex)
HideBox(box);
box = box->GetNextBox();
count++;

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

@ -76,16 +76,6 @@ public:
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
// Override SetInitialChildList/AppendFrames/InsertFrames to
// create views for our child frames if necessary
NS_IMETHOD SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(ChildListID aListID,
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(ChildListID aListID,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList);
virtual nsIAtom* GetType() const;
#ifdef NS_DEBUG
@ -101,11 +91,9 @@ public:
protected:
// REVIEW: Sorry, I couldn't resist devirtualizing these.
void IndexChanged(nsPresContext* aPresContext);
void IndexChanged();
PRInt32 GetSelectedIndex();
void HideBox(nsPresContext* aPresContext, nsIBox* aBox);
void ShowBox(nsPresContext* aPresContext, nsIBox* aBox);
void HideBox(nsIBox* aBox);
private: