mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
Numberous fixes
This commit is contained in:
parent
29a4df5a10
commit
f19bc0e464
@ -34,6 +34,7 @@
|
||||
#include "nsScrollFrame.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIBox.h"
|
||||
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
|
||||
@ -577,7 +578,16 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext,
|
||||
// Reflow the child and get its desired size. Let it be as high as it
|
||||
// wants
|
||||
PRBool unconstrainedWidth = (NS_UNCONSTRAINEDSIZE == scrollAreaSize.width);
|
||||
nsSize kidReflowSize(scrollAreaSize.width, NS_UNCONSTRAINEDSIZE);
|
||||
|
||||
nscoord theHeight;
|
||||
nsIBox* box;
|
||||
nsresult result = kidFrame->QueryInterface(kIBoxIID, (void**)&box);
|
||||
if (NS_SUCCEEDED(result))
|
||||
theHeight = scrollAreaSize.height;
|
||||
else
|
||||
theHeight = NS_INTRINSICSIZE;
|
||||
|
||||
nsSize kidReflowSize(scrollAreaSize.width, theHeight);
|
||||
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
|
||||
kidFrame, kidReflowSize);
|
||||
nsHTMLReflowMetrics kidDesiredSize(aDesiredSize.maxElementSize);
|
||||
@ -589,7 +599,7 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext,
|
||||
aReflowState.mComputedPadding.left -
|
||||
aReflowState.mComputedPadding.right;
|
||||
}
|
||||
kidReflowState.mComputedHeight = NS_AUTOHEIGHT;
|
||||
kidReflowState.mComputedHeight = theHeight;
|
||||
|
||||
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
|
||||
aStatus);
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
void DrawVerticalSpring( nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, nscoord x, nscoord y, nscoord size, nscoord springSize);
|
||||
void DrawKnob( nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, nscoord x, nscoord y, nscoord springSize);
|
||||
void AddInDebugInset( nsIPresContext& aPresContext, PRBool aIsHorizontal, nsMargin& inset);
|
||||
void CollapseChild(nsIFrame* frame);
|
||||
|
||||
// XXX for the moment we can only handle 100 children.
|
||||
// Should use a dynamic array.
|
||||
@ -191,6 +192,20 @@ nsBoxFrame::GetRedefinedMinPrefMax(nsIFrame* aFrame, nsCalculatedBoxInfo& aSize)
|
||||
// convert to a percent.
|
||||
aSize.flex = value.ToFloat(&error)/float(100.0);
|
||||
}
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, value))
|
||||
{
|
||||
value.Trim("%");
|
||||
// convert to a percent.
|
||||
aSize.prefSize.width = value.ToInteger(&error);
|
||||
}
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::height, value))
|
||||
{
|
||||
value.Trim("%");
|
||||
// convert to a percent.
|
||||
aSize.prefSize.height = value.ToInteger(&error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -705,29 +720,38 @@ nsBoxFrame::ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCal
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void
|
||||
nsBoxFrameImpl::CollapseChildren(nsIFrame* frame)
|
||||
nsBoxFrameImpl::CollapseChild(nsIFrame* frame)
|
||||
{
|
||||
nscoord count = 0;
|
||||
while (nsnull != frame)
|
||||
{
|
||||
nsRect rect(0,0,0,0);
|
||||
childFrame->SetRect(nsRect(0,0,0,0));
|
||||
// make the view really small as well
|
||||
nsIView* view = nsnull;
|
||||
childFrame->GetView(&view);
|
||||
frame->GetRect(rect);
|
||||
if (rect.width > 0 || rect.height > 0) {
|
||||
// shrink the frame
|
||||
frame->SizeTo(0,0);
|
||||
|
||||
if (view) {
|
||||
view->SetDimensions(0,0,PR_FALSE);
|
||||
// shrink the view
|
||||
nsIView* view = nsnull;
|
||||
frame->GetView(&view);
|
||||
|
||||
// if we find a view stop right here. All views under it
|
||||
// will be clipped.
|
||||
if (view) {
|
||||
view->SetDimensions(0,0,PR_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
// collapse the child
|
||||
nsIFrame* child = nsnull;
|
||||
frame->FirstChild(nsnull, &child);
|
||||
|
||||
while (nsnull != child)
|
||||
{
|
||||
CollapseChild(child);
|
||||
nsresult rv = child->GetNextSibling(&child);
|
||||
NS_ASSERTION(rv == NS_OK,"failed to get next child");
|
||||
}
|
||||
}
|
||||
|
||||
CollapseChildren(childFrame);
|
||||
rv = childFrame->GetNextSibling(&childFrame);
|
||||
NS_ASSERTION(rv == NS_OK,"failed to get next child");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
@ -749,17 +773,7 @@ nsBoxFrame::PlaceChildren(nsRect& boxRect)
|
||||
|
||||
// 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);
|
||||
}
|
||||
mImpl->CollapseChild(childFrame);
|
||||
} else {
|
||||
const nsStyleSpacing* spacing;
|
||||
rv = childFrame->GetStyleData(eStyleStruct_Spacing,
|
||||
@ -1229,6 +1243,56 @@ nsBoxFrame::LayoutChildrenInRect(nsRect& size)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ok if we want to resize a child we will know the actual size in pixels we want it to be.
|
||||
* This is not the preferred size. But they only way we can change a child is my manipulating its
|
||||
* preferred size. So give the actual pixel size this return method will return figure out the preferred
|
||||
* size and set it.
|
||||
*/
|
||||
void
|
||||
nsBoxFrame::ResizeChildTo(nscoord aChildIndex, nscoord aNewSize)
|
||||
{
|
||||
// get all the variables we need
|
||||
nscoord min = GET_WIDTH(mSprings[aChildIndex].minSize);
|
||||
nscoord max = GET_WIDTH(mSprings[aChildIndex].maxSize);
|
||||
nscoord c = GET_WIDTH(mSprings[aChildIndex].calculatedSize);
|
||||
nscoord pref = GET_WIDTH(mSprings[aChildIndex].prefSize);
|
||||
float flex = mSprings[aChildIndex].flex;
|
||||
float stretchFactor = float(c-pref)/flex;
|
||||
|
||||
// check bounds
|
||||
if (aNewSize < min)
|
||||
aNewSize = min;
|
||||
else if (aNewSize > max)
|
||||
aNewSize = max;
|
||||
|
||||
// determine the new pref size
|
||||
pref = aNewSize - NSToIntFloor(flex/stretchFactor);
|
||||
|
||||
// find the child at the index
|
||||
nsIFrame* childFrame = mFrames.FirstChild();
|
||||
nscoord count = 0;
|
||||
while (nsnull != childFrame)
|
||||
{
|
||||
if (count == aChildIndex)
|
||||
break;
|
||||
|
||||
nsresult rv;
|
||||
rv = childFrame->GetNextSibling(&childFrame);
|
||||
NS_ASSERTION(rv == NS_OK,"failed to get next child");
|
||||
count++;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
childFrame->GetContent(getter_AddRefs(content));
|
||||
|
||||
|
||||
// set its preferred size.
|
||||
char ch[50];
|
||||
sprintf(ch,"%d",pref);
|
||||
content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, ch, PR_TRUE);
|
||||
}
|
||||
|
||||
// Marks the frame as dirty and generates an incremental reflow
|
||||
// command targeted at this frame
|
||||
nsresult
|
||||
|
@ -107,7 +107,9 @@ public:
|
||||
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
||||
|
||||
PRBool IsHorizontal() const { return mHorizontal; }
|
||||
virtual PRBool IsHorizontal() const { return mHorizontal; }
|
||||
|
||||
virtual void ResizeChildTo(nscoord aChildIndex, nscoord aNewSize);
|
||||
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
|
@ -36,10 +36,16 @@
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsXULAtoms.h"
|
||||
#include "nsIReflowCommand.h"
|
||||
#include "nsSliderFrame.h"
|
||||
//#include "nsSliderFrame.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsDocument.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
|
||||
|
||||
//
|
||||
// NS_NewToolbarFrame
|
||||
@ -65,7 +71,6 @@ NS_NewGrippyFrame ( nsIFrame** aNewFrame )
|
||||
nsGrippyFrame::nsGrippyFrame():mCollapsed(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsGrippyFrame::MouseClicked(nsIPresContext& aPresContext)
|
||||
{
|
||||
@ -113,8 +118,21 @@ nsGrippyFrame::MouseClicked(nsIPresContext& aPresContext)
|
||||
mCollapsedChild->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::style, style, PR_TRUE);
|
||||
|
||||
mCollapsed = !mCollapsed;
|
||||
|
||||
/*
|
||||
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);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsIFrame*
|
||||
nsGrippyFrame::GetChildBeforeAfter(nsIFrame* start, PRBool before)
|
||||
{
|
||||
|
@ -44,15 +44,17 @@ public:
|
||||
static nsIFrame* GetChildAt(nsIFrame* parent, PRInt32 index);
|
||||
static PRInt32 IndexOf(nsIFrame* parent, nsIFrame* child);
|
||||
static PRInt32 CountFrames(nsIFrame* aFrame);
|
||||
nsGrippyFrame();
|
||||
nsGrippyFrame();
|
||||
|
||||
protected:
|
||||
virtual void MouseClicked(nsIPresContext& aPresContext);
|
||||
|
||||
private:
|
||||
|
||||
PRBool mCollapsed;
|
||||
nsString mCollapsedChildStyle;
|
||||
nsCOMPtr<nsIContent> mCollapsedChild;
|
||||
|
||||
|
||||
PRBool mDidDrag;
|
||||
}; // class nsTabFrame
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user