1998-10-08 08:38:41 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// YY need to pass isMultiple before create called
|
|
|
|
|
|
|
|
//#include "nsFormControlFrame.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
|
|
|
#include "nsLegendFrame.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMHTMLFieldSetElement.h"
|
|
|
|
#include "nsIDOMHTMLLegendElement.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
//#include "nsIDOMHTMLCollection.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
//#include "prtypes.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
//#include "nsIRadioButton.h"
|
|
|
|
//#include "nsWidgetsCID.h"
|
|
|
|
//#include "nsSize.h"
|
1998-11-03 23:33:43 +03:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
//#include "nsIView.h"
|
|
|
|
//#include "nsIListWidget.h"
|
|
|
|
//#include "nsIComboBox.h"
|
|
|
|
//#include "nsIListBox.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsStyleUtil.h"
|
|
|
|
#include "nsFont.h"
|
1999-06-02 01:52:11 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID);
|
|
|
|
static NS_DEFINE_IID(kIDOMHTMLFieldSetElementIID, NS_IDOMHTMLFIELDSETELEMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMHTMLLegendElementIID, NS_IDOMHTMLLEGENDELEMENT_IID);
|
|
|
|
|
|
|
|
class nsLegendFrame;
|
|
|
|
|
|
|
|
class nsFieldSetFrame : public nsHTMLContainerFrame {
|
|
|
|
public:
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsFieldSetFrame();
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1998-11-10 09:05:32 +03:00
|
|
|
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList);
|
1998-10-08 08:38:41 +04:00
|
|
|
|
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
|
|
|
NS_METHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-11-19 20:22:29 +03:00
|
|
|
|
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
|
|
|
return MakeFrameName("FieldSet", aResult);
|
|
|
|
}
|
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
|
|
|
|
|
|
|
nsIFrame* mLegendFrame;
|
|
|
|
nsIFrame* mContentFrame;
|
1999-06-02 01:52:11 +04:00
|
|
|
nsRect mLegendRect;
|
|
|
|
nscoord mLegendSpace;
|
1998-10-08 08:38:41 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_NewFieldSetFrame(nsIFrame** aNewFrame)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsFieldSetFrame* it = new nsFieldSetFrame;
|
|
|
|
if (!it) {
|
1998-10-08 08:38:41 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-10-08 08:38:41 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsFieldSetFrame::nsFieldSetFrame()
|
|
|
|
: nsHTMLContainerFrame()
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
1999-06-02 01:52:11 +04:00
|
|
|
mContentFrame = nsnull;
|
1998-10-08 08:38:41 +04:00
|
|
|
mLegendFrame = nsnull;
|
1999-06-02 01:52:11 +04:00
|
|
|
mLegendSpace = 0;
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-10 09:05:32 +03:00
|
|
|
nsFieldSetFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
|
|
|
// cache our display type
|
|
|
|
const nsStyleDisplay* styleDisplay;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
|
1999-06-02 01:52:11 +04:00
|
|
|
|
|
|
|
PRUint8 flags = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay) ? NS_BLOCK_SHRINK_WRAP : 0;
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_NewAreaFrame(&mContentFrame, flags);
|
1999-01-16 01:52:05 +03:00
|
|
|
mFrames.SetFrames(mContentFrame);
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
// Resolve style and initialize the frame
|
1999-02-11 18:56:23 +03:00
|
|
|
nsIStyleContext* styleContext;
|
1999-05-05 01:35:05 +04:00
|
|
|
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::fieldsetContentPseudo,
|
|
|
|
mStyleContext, PR_FALSE, &styleContext);
|
1999-02-25 06:27:57 +03:00
|
|
|
mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull);
|
1999-05-05 01:35:05 +04:00
|
|
|
mFrames.FirstChild()->SetNextSibling(nsnull);
|
1998-10-08 08:38:41 +04:00
|
|
|
NS_RELEASE(styleContext);
|
|
|
|
|
|
|
|
nsIFrame* newChildList = aChildList;
|
|
|
|
|
1999-05-05 01:35:05 +04:00
|
|
|
// Set the geometric and content parent for each of the child frames
|
|
|
|
// that will go into the area frame's child list.
|
|
|
|
// The legend frame does not go into the list
|
|
|
|
nsIFrame* lastNewFrame = nsnull;
|
1998-11-19 01:14:55 +03:00
|
|
|
for (nsIFrame* frame = aChildList; nsnull != frame;) {
|
1998-10-08 08:38:41 +04:00
|
|
|
nsIFrame* legendFrame = nsnull;
|
|
|
|
nsresult result = frame->QueryInterface(kLegendFrameCID, (void**)&legendFrame);
|
1999-05-05 01:35:05 +04:00
|
|
|
if (NS_SUCCEEDED(result) && legendFrame) {
|
|
|
|
if (mLegendFrame) { // we already have a legend, destroy it
|
|
|
|
frame->GetNextSibling(&frame);
|
|
|
|
if (lastNewFrame) {
|
|
|
|
lastNewFrame->SetNextSibling(frame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aChildList = frame;
|
|
|
|
}
|
1999-07-22 06:24:52 +04:00
|
|
|
legendFrame->Destroy(aPresContext);
|
1999-05-05 01:35:05 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
frame->GetNextSibling(&nextFrame);
|
|
|
|
if (lastNewFrame) {
|
|
|
|
lastNewFrame->SetNextSibling(nextFrame);
|
|
|
|
} else {
|
|
|
|
newChildList = nextFrame;
|
|
|
|
}
|
|
|
|
frame->SetParent(this);
|
|
|
|
mFrames.FirstChild()->SetNextSibling(frame);
|
|
|
|
mLegendFrame = frame;
|
|
|
|
mLegendFrame->SetNextSibling(nsnull);
|
|
|
|
frame = nextFrame;
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
1999-05-05 01:35:05 +04:00
|
|
|
} else {
|
1999-01-16 01:52:05 +03:00
|
|
|
frame->SetParent(mFrames.FirstChild());
|
1999-05-05 01:35:05 +04:00
|
|
|
lastNewFrame = frame;
|
1999-02-10 09:13:38 +03:00
|
|
|
frame->GetNextSibling(&frame);
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Queue up the frames for the content frame
|
1999-01-16 01:52:05 +03:00
|
|
|
return mFrames.FirstChild()->SetInitialChildList(aPresContext, nsnull, newChildList);
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// this is identical to nsHTMLContainerFrame::Paint except for the background and border.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFieldSetFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
1999-03-26 03:39:35 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
1998-12-18 18:54:23 +03:00
|
|
|
// Paint our background and border
|
|
|
|
const nsStyleDisplay* disp =
|
|
|
|
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
|
|
|
|
if (disp->mVisible && mRect.width && mRect.height) {
|
|
|
|
PRIntn skipSides = GetSkipSides();
|
|
|
|
const nsStyleColor* color =
|
|
|
|
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
1999-10-20 04:46:21 +04:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
nsMargin border;
|
1999-07-28 08:48:34 +04:00
|
|
|
if (!spacing->GetBorder(border)) {
|
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
1999-06-02 01:52:11 +04:00
|
|
|
|
|
|
|
nscoord yoff = 0;
|
|
|
|
|
1999-08-06 04:48:26 +04:00
|
|
|
// if the border is smaller than the legend. Move the border down
|
1999-06-02 01:52:11 +04:00
|
|
|
// to be centered on the legend.
|
|
|
|
if (border.top < mLegendRect.height)
|
|
|
|
yoff = (mLegendRect.height - border.top)/2;
|
|
|
|
|
|
|
|
nsRect rect(0, yoff, mRect.width, mRect.height - yoff);
|
1998-12-18 18:54:23 +03:00
|
|
|
|
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
1999-01-15 21:25:58 +03:00
|
|
|
aDirtyRect, rect, *color, *spacing, 0, 0);
|
1999-06-02 01:52:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
if (mLegendFrame) {
|
|
|
|
|
|
|
|
// we should probably use PaintBorderEdges to do this but for now just use clipping
|
|
|
|
// to achieve the same effect.
|
|
|
|
PRBool clipState;
|
|
|
|
|
|
|
|
// draw left side
|
|
|
|
nsRect clipRect(rect);
|
|
|
|
clipRect.width = mLegendRect.x - rect.x;
|
|
|
|
clipRect.height = border.top;
|
|
|
|
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
|
|
|
|
|
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
|
|
|
|
|
|
|
|
// draw right side
|
|
|
|
clipRect = rect;
|
|
|
|
clipRect.x = mLegendRect.x + mLegendRect.width;
|
|
|
|
clipRect.width -= (mLegendRect.x + mLegendRect.width);
|
|
|
|
clipRect.height = border.top;
|
|
|
|
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
|
|
|
|
|
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
|
|
|
|
|
|
|
|
// draw bottom
|
|
|
|
|
|
|
|
clipRect = rect;
|
|
|
|
clipRect.y += border.top;
|
|
|
|
clipRect.height = mRect.height - (yoff + border.top);
|
|
|
|
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
|
|
|
|
|
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, nsRect(0,0,mRect.width, mRect.height), *spacing, mStyleContext, skipSides);
|
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-03-26 03:39:35 +03:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-10-08 08:38:41 +04:00
|
|
|
nsIView* view;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetView(&aPresContext, &view);
|
1998-10-08 08:38:41 +04:00
|
|
|
if (nsnull != view) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,0,255));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
}
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-23 06:48:01 +03:00
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-23 06:48:01 +03:00
|
|
|
nsFieldSetFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-08 08:38:41 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-02-23 06:48:01 +03:00
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
1999-02-23 06:48:01 +03:00
|
|
|
// availSize could have unconstrained values, don't perform any addition on them
|
1999-10-31 06:39:24 +03:00
|
|
|
nsSize availSize(aReflowState.mComputedWidth, aReflowState.availableHeight);
|
1999-02-23 06:48:01 +03:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// get our border and padding
|
|
|
|
const nsMargin &borderPadding = aReflowState.mComputedBorderPadding;
|
1999-08-06 04:48:26 +04:00
|
|
|
const nsMargin &padding = aReflowState.mComputedPadding;
|
|
|
|
nsMargin border = borderPadding - padding;
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// Figure out how big the legend is if there is one.
|
|
|
|
nsMargin legendMargin(0,0,0,0);
|
|
|
|
|
|
|
|
// if there is a legend frame flow it.
|
|
|
|
if (mLegendFrame) {
|
|
|
|
nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
|
|
|
|
mLegendFrame, nsSize(NS_INTRINSICSIZE,NS_INTRINSICSIZE));
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// always give the legend as much size as it needs
|
1999-07-20 07:41:03 +04:00
|
|
|
legendReflowState.mComputedWidth = NS_INTRINSICSIZE;
|
|
|
|
legendReflowState.mComputedHeight = NS_INTRINSICSIZE;
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus);
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// get the legend's margin
|
1998-10-08 08:38:41 +04:00
|
|
|
nsIStyleContext* legendSC = nsnull;
|
1999-02-10 03:42:56 +03:00
|
|
|
mLegendFrame->GetStyleContext(&legendSC);
|
1998-10-08 08:38:41 +04:00
|
|
|
if (legendSC) {
|
|
|
|
const nsStyleSpacing* legendSpacing =
|
|
|
|
(const nsStyleSpacing*)legendSC->GetStyleData(eStyleStruct_Spacing);
|
1999-06-02 01:52:11 +04:00
|
|
|
legendSpacing->GetMargin(legendMargin);
|
1998-10-08 08:38:41 +04:00
|
|
|
NS_RELEASE(legendSC);
|
|
|
|
}
|
1999-02-23 06:48:01 +03:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// figure out the legend's rectangle
|
|
|
|
mLegendRect.width = aDesiredSize.width + legendMargin.left + legendMargin.right;
|
|
|
|
mLegendRect.height = aDesiredSize.height + legendMargin.top + legendMargin.bottom;
|
|
|
|
mLegendRect.x = borderPadding.left;
|
|
|
|
mLegendRect.y = 0;
|
1999-08-06 04:48:26 +04:00
|
|
|
mLegendSpace = 0;
|
|
|
|
if (mLegendRect.height > border.top) {
|
|
|
|
// center the border on the legend
|
|
|
|
mLegendSpace = mLegendRect.height - borderPadding.top;
|
|
|
|
} else {
|
|
|
|
mLegendRect.y = (border.top - mLegendRect.height)/2;
|
|
|
|
}
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-08-06 04:48:26 +04:00
|
|
|
// if we are contrained then remove the legend from our available height.
|
|
|
|
if (NS_INTRINSICSIZE != availSize.height) {
|
|
|
|
if (availSize.height >= mLegendSpace)
|
|
|
|
availSize.height -= mLegendSpace;
|
|
|
|
}
|
1999-06-02 01:52:11 +04:00
|
|
|
|
1999-08-06 04:48:26 +04:00
|
|
|
// don't get any smaller than the legend
|
|
|
|
if (NS_INTRINSICSIZE != availSize.width) {
|
|
|
|
if (availSize.width < mLegendRect.width)
|
|
|
|
availSize.width = mLegendRect.width;
|
|
|
|
}
|
1999-06-02 01:52:11 +04:00
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// Try to reflow the area frame into the available space.
|
|
|
|
nsHTMLReflowState contentReflowState(aPresContext, aReflowState,
|
|
|
|
mContentFrame, availSize);
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
ReflowChild(mContentFrame, aPresContext, aDesiredSize, contentReflowState, aStatus);
|
1998-10-08 08:38:41 +04:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// set the rect. make sure we add the margin back in.
|
|
|
|
nsRect contentRect(borderPadding.left,borderPadding.top + mLegendSpace,aDesiredSize.width ,aDesiredSize.height);
|
1999-02-23 06:48:01 +03:00
|
|
|
|
1999-06-02 01:52:11 +04:00
|
|
|
// Place the content area frame.
|
1999-10-26 08:44:41 +04:00
|
|
|
mContentFrame->SetRect(&aPresContext, contentRect);
|
1999-06-02 01:52:11 +04:00
|
|
|
|
1999-08-06 04:48:26 +04:00
|
|
|
if (mLegendFrame)
|
|
|
|
{
|
|
|
|
PRInt32 align = ((nsLegendFrame*)mLegendFrame)->GetAlign();
|
|
|
|
|
|
|
|
switch(align) {
|
|
|
|
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
|
|
|
mLegendRect.x = contentRect.width - mLegendRect.width + borderPadding.left;
|
|
|
|
break;
|
|
|
|
case NS_STYLE_TEXT_ALIGN_CENTER:
|
|
|
|
mLegendRect.x = contentRect.width/2 - mLegendRect.width/2 + borderPadding.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
// place the legend
|
|
|
|
nsRect actualLegendRect(mLegendRect);
|
|
|
|
actualLegendRect.Deflate(legendMargin);
|
1999-10-26 08:44:41 +04:00
|
|
|
mLegendFrame->SetRect(&aPresContext, actualLegendRect);
|
1999-08-06 04:48:26 +04:00
|
|
|
}
|
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
// Return our size and our result
|
1999-07-20 07:41:03 +04:00
|
|
|
if (aReflowState.mComputedHeight == NS_INTRINSICSIZE) {
|
1999-06-02 01:52:11 +04:00
|
|
|
aDesiredSize.height = mLegendSpace +
|
|
|
|
borderPadding.top +
|
|
|
|
aDesiredSize.height +
|
|
|
|
borderPadding.bottom;
|
|
|
|
} else {
|
|
|
|
nscoord min = borderPadding.top + borderPadding.bottom + mLegendRect.height;
|
1999-07-20 07:41:03 +04:00
|
|
|
aDesiredSize.height = aReflowState.mComputedHeight + borderPadding.top + borderPadding.bottom;
|
1999-06-02 01:52:11 +04:00
|
|
|
if (aDesiredSize.height < min)
|
|
|
|
aDesiredSize.height = min;
|
|
|
|
}
|
1999-02-23 06:48:01 +03:00
|
|
|
|
1999-07-20 07:41:03 +04:00
|
|
|
if (aReflowState.mComputedWidth == NS_INTRINSICSIZE) {
|
1999-06-02 01:52:11 +04:00
|
|
|
aDesiredSize.width = borderPadding.left +
|
|
|
|
aDesiredSize.width +
|
|
|
|
borderPadding.right;
|
|
|
|
} else {
|
|
|
|
nscoord min = borderPadding.left + borderPadding.right + mLegendRect.width;
|
1999-07-20 07:41:03 +04:00
|
|
|
aDesiredSize.width = aReflowState.mComputedWidth + borderPadding.left + borderPadding.right;
|
1999-06-02 01:52:11 +04:00
|
|
|
if (aDesiredSize.width < min)
|
|
|
|
aDesiredSize.width = min;
|
1999-04-06 08:47:18 +04:00
|
|
|
}
|
1999-06-02 01:52:11 +04:00
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
1999-06-02 01:52:11 +04:00
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
1999-06-02 01:52:11 +04:00
|
|
|
// if the legend it wider use it
|
|
|
|
if (aDesiredSize.maxElementSize->width < mLegendRect.width)
|
|
|
|
aDesiredSize.maxElementSize->width = mLegendRect.width;
|
|
|
|
|
|
|
|
// add in padding.
|
|
|
|
aDesiredSize.maxElementSize->width += borderPadding.left + borderPadding.right;
|
|
|
|
|
|
|
|
// height is border + legend
|
|
|
|
aDesiredSize.maxElementSize->height += borderPadding.top + borderPadding.bottom + mLegendRect.height;
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsFieldSetFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|