Fixed DeckFrame not to use pseudo element for visibility.
This commit is contained in:
evaughan%netscape.com 1999-09-10 23:38:58 +00:00
Родитель 09e4b5658c
Коммит 3859c99e44
8 изменённых файлов: 59 добавлений и 125 удалений

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

@ -97,6 +97,7 @@ XUL_ATOM(tab, "tab")
XUL_ATOM(tabpanel, "tabpanel")
XUL_ATOM(tabpage, "tabpage")
XUL_ATOM(tabbox, "tabbox")
XUL_ATOM(index, "index")
XUL_ATOM(maxpos, "maxpos")
XUL_ATOM(curpos, "curpos")
XUL_ATOM(scrollbarbutton, "scrollbarbutton")

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

@ -114,7 +114,6 @@ public:
}
void GetDebugInset(nsMargin& inset);
void CollapseChild(nsIFrame* frame);
void AdjustChildren(nsIPresContext& aPresContext, nsBoxFrame* aBox);
void UpdatePseudoElements(nsIPresContext& aPresContext);
@ -513,7 +512,7 @@ printf("\n");
//-----------------------------------------------------------------------------------
// set the x,y locations of each of our children. Taking into acount their margins, our border,
// and insets.
PlaceChildren(rect);
PlaceChildren(aPresContext,rect);
//-----------------------------------------------------------------------------------
//------------------------- Add our border and insets in ----------------------------
@ -810,7 +809,7 @@ nsBoxFrame::ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCal
void
nsBoxFrameInner::CollapseChild(nsIFrame* frame)
nsBoxFrame::CollapseChild(nsIFrame* frame)
{
nsRect rect(0,0,0,0);
frame->GetRect(rect);
@ -848,7 +847,7 @@ nsBoxFrameInner::CollapseChild(nsIFrame* frame)
* their margins
*/
nsresult
nsBoxFrame::PlaceChildren(nsRect& boxRect)
nsBoxFrame::PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect)
{
// ------- set the childs positions ---------
nscoord x = boxRect.x;
@ -862,7 +861,7 @@ nsBoxFrame::PlaceChildren(nsRect& boxRect)
// make collapsed children not show up
if (mSprings[count].collapsed) {
mInner->CollapseChild(childFrame);
CollapseChild(childFrame);
} else {
const nsStyleSpacing* spacing;
rv = childFrame->GetStyleData(eStyleStruct_Spacing,
@ -1461,13 +1460,6 @@ nsBoxFrame::GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aR
// just use the size we already have.
if (mSprings[count].needsRecalc)
{
// get the size of the child. This is the min, max, preferred, and spring constant
// it does not include its border.
rv = GetChildBoxInfo(aPresContext, aReflowState, childFrame, mSprings[count]);
NS_ASSERTION(rv == NS_OK,"failed to child box info");
if (NS_FAILED(rv))
return rv;
// see if the child is collapsed
const nsStyleDisplay* disp;
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)disp));
@ -1476,6 +1468,13 @@ nsBoxFrame::GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aR
if (disp->mVisible == NS_STYLE_VISIBILITY_COLLAPSE)
mSprings[count].collapsed = PR_TRUE;
else {
// get the size of the child. This is the min, max, preferred, and spring constant
// it does not include its border.
rv = GetChildBoxInfo(aPresContext, aReflowState, childFrame, mSprings[count]);
NS_ASSERTION(rv == NS_OK,"failed to child box info");
if (NS_FAILED(rv))
return rv;
// add in the child's margin and border/padding if there is one.
const nsStyleSpacing* spacing;
nsresult rv = childFrame->GetStyleData(eStyleStruct_Spacing,

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

@ -152,7 +152,7 @@ protected:
PRBool& needsRedraw,
nsString& aReason);
virtual nsresult PlaceChildren(nsRect& boxRect);
virtual nsresult PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect);
virtual void ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void LayoutChildrenInRect(nsRect& size);
virtual void AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo);
@ -163,6 +163,7 @@ protected:
virtual PRIntn GetSkipSides() const { return 0; }
virtual void GetInset(nsMargin& margin);
virtual void CollapseChild(nsIFrame* frame);
nsresult GenerateDirtyReflowCommand(nsIPresContext& aPresContext,
nsIPresShell& aPresShell);

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

@ -67,6 +67,7 @@ nsDeckFrame::Init(nsIPresContext& aPresContext,
{
// Get the element's tag
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
//CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
return rv;
}
@ -82,8 +83,15 @@ nsDeckFrame::AttributeChanged(nsIPresContext* aPresContext,
// if the index changed hide the old element and make the now element visible
if (aAttribute == nsHTMLAtoms::value) {
if (aAttribute == nsHTMLAtoms::index) {
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIReflowCommand> reflowCmd;
nsresult rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this,
nsIReflowCommand::StyleChanged);
if (NS_SUCCEEDED(rv))
shell->AppendReflowCommand(reflowCmd);
}
@ -106,7 +114,7 @@ nsDeckFrame::GetSelectedFrame()
// get the index attribute
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value))
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::index, value))
{
PRInt32 error;
@ -195,11 +203,6 @@ nsDeckFrame::SetInitialChildList(nsIPresContext& aPresContext,
{
nsresult r = nsBoxFrame::SetInitialChildList(aPresContext, aListName, aChildList);
// now that all the children are added. ReResolve our children
// so we hide everything that is hidden in the deck
ReResolveStyleContext(&aPresContext, mStyleContext,
NS_STYLE_HINT_REFLOW,
nsnull, nsnull);
return r;
}
@ -230,99 +233,21 @@ nsDeckFrame::AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo)
aInfo.maxSize.height = aChildInfo.maxSize.height;
}
NS_IMETHODIMP
nsDeckFrame :: ReResolveStyleContext ( nsIPresContext* aPresContext, nsIStyleContext* aParentContext,
PRInt32 aParentChange, nsStyleChangeList* aChangeList,
PRInt32* aLocalChange)
nsresult
nsDeckFrame::PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect)
{
// calculate our style context
PRInt32 ourChange = aParentChange;
nsresult result = nsFrame::ReResolveStyleContext(aPresContext, aParentContext,
ourChange, aChangeList, &ourChange);
if (NS_FAILED(result)) {
return result;
}
// get our hidden pseudo
nsCOMPtr<nsIAtom> hide ( getter_AddRefs(NS_NewAtom(":-moz-deck-hidden")) );
nsIStyleContext* newSC;
// get a style content for the hidden pseudo element
aPresContext->ResolvePseudoStyleContextFor(mContent,
hide,
mStyleContext,
PR_FALSE, &newSC);
// get the index from the tab
int index = 0;
// get the index attribute
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value))
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::index, value))
{
PRInt32 error;
// convert it to an integer
index = value.ToInteger(&error);
}
if (aLocalChange) {
*aLocalChange = ourChange;
}
// resolve all our children that are not selected with the hidden pseudo elements
// style context
nsIFrame* childFrame = mFrames.FirstChild();
PRInt32 count = 0;
while (nsnull != childFrame)
{
nsIStyleContext* oldS = nsnull;
nsIStyleContext* newS = nsnull;
if (count == index)
{
childFrame->GetStyleContext(&oldS);
childFrame->ReResolveStyleContext(aPresContext, mStyleContext,
ourChange, aChangeList, &ourChange);
} else {
// use hidden style context
childFrame->GetStyleContext(&oldS);
childFrame->ReResolveStyleContext(aPresContext, newSC,
ourChange, aChangeList, &ourChange);
}
childFrame->GetStyleContext(&newS);
//CaptureStyleChangeFor(childFrame, oldS, newS,
// ourChange, aChangeList, &ourChange);
if (oldS != newS)
{
if (aChangeList)
aChangeList->AppendChange(childFrame, NS_STYLE_HINT_VISUAL);
}
NS_RELEASE(oldS);
NS_RELEASE(newS);
childFrame->GetNextSibling(&childFrame);
count++;
}
return result;
} // ReResolveStyleContext
nsresult
nsDeckFrame::PlaceChildren(nsRect& boxRect)
{
// ------- set the childs positions ---------
nsIFrame* childFrame = mFrames.FirstChild();
nscoord count = 0;
@ -330,24 +255,36 @@ nsDeckFrame::PlaceChildren(nsRect& boxRect)
{
nsresult rv;
/*
// see if the child has a view. If it doesn't make one for it.
nsIView* childView = nsnull;
childFrame->GetView(&childView);
if (childView == nsnull) {
nsCOMPtr<nsIStyleContext> context;
childFrame->GetStyleContext(getter_AddRefs(context));
CreateViewForFrame(aPresContext,childFrame,context,PR_TRUE);
childFrame->GetView(&childView);
NS_ASSERTION(childView != nsnull, "Deck could not create a view for its child!!!");
}
*/
//nsCOMPtr<nsIViewManager> vm;
// childView->GetViewManager(*getter_AddRefs(vm));
// make collapsed children not show up
if (mSprings[count].collapsed) {
childFrame->SetRect(nsRect(0,0,0,0));
// make the view really small as well
nsIView* view = nsnull;
childFrame->GetView(&view);
if (view) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->ResizeView(view, 0,0);
}
if (mSprings[count].collapsed || count != index) {
CollapseChild(childFrame);
// } if (count != index) {
// if the child is not in view then make sure its view is 0 so it clips
// out all its children.
//vm->ResizeView(childView, 0,0);
//childFrame->SizeTo(0,0);
//childView->SetParent(nsnull);
} else {
nsRect rect;
childFrame->MoveTo(rect.x, rect.y);
////nsIView* pv;
//GetView(&pv);
//childView->SetParent(pv);
childFrame->MoveTo(boxRect.x, boxRect.y);
}
rv = childFrame->GetNextSibling(&childFrame);

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

@ -38,12 +38,6 @@ public:
NS_IMETHOD ReResolveStyleContext ( nsIPresContext* aPresContext,
nsIStyleContext* aParentContext,
PRInt32 aParentChange,
nsStyleChangeList* aChangeList,
PRInt32* aLocalChange) ;
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
@ -75,7 +69,7 @@ public:
protected:
virtual nsIFrame* GetSelectedFrame();
virtual nsresult PlaceChildren(nsRect& boxRect);
virtual nsresult PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect);
virtual void ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void LayoutChildrenInRect(nsRect& size);
virtual void AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo);

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

@ -225,6 +225,7 @@ nsSplitterFrame::nsSplitterFrame()
nsSplitterFrame::~nsSplitterFrame()
{
mImpl->RemoveListener();
mImpl->Release();
}

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

@ -100,7 +100,7 @@ nsTabFrame::MouseClicked(nsIPresContext* aPresContext)
char value[100];
sprintf(value, "%d", index);
tabpanel->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value, PR_TRUE);
tabpanel->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::index, value, PR_TRUE);
}

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

@ -97,6 +97,7 @@ XUL_ATOM(tab, "tab")
XUL_ATOM(tabpanel, "tabpanel")
XUL_ATOM(tabpage, "tabpage")
XUL_ATOM(tabbox, "tabbox")
XUL_ATOM(index, "index")
XUL_ATOM(maxpos, "maxpos")
XUL_ATOM(curpos, "curpos")
XUL_ATOM(scrollbarbutton, "scrollbarbutton")