2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-08 04:38:41 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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/
|
1998-10-08 04:38:41 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
1998-10-08 04:38:41 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* 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"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-10-08 04:38:41 +00:00
|
|
|
|
|
|
|
// 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 "nsIFrame.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIAtom.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2005-01-25 00:06:38 +00:00
|
|
|
#include "nsFrameManager.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsFont.h"
|
1999-06-01 21:52:11 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2002-02-16 01:34:42 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-01-28 04:38:14 +00:00
|
|
|
#include "nsAccessibilityService.h"
|
2002-02-16 01:34:42 +00:00
|
|
|
#endif
|
|
|
|
#include "nsIServiceManager.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
|
|
|
|
class nsLegendFrame;
|
|
|
|
|
|
|
|
class nsFieldSetFrame : public nsHTMLContainerFrame {
|
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
1998-10-08 04:38:41 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsFieldSetFrame(nsStyleContext* aContext);
|
1998-10-08 04:38:41 +00:00
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList);
|
1998-10-08 04:38:41 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_HIDDEN_(nscoord)
|
2011-04-08 01:04:40 +00:00
|
|
|
GetIntrinsicWidth(nsRenderingContext* aRenderingContext,
|
2008-03-14 20:48:23 +00:00
|
|
|
nsLayoutUtils::IntrinsicWidthType);
|
2011-04-08 01:04:40 +00:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext);
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext);
|
|
|
|
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
|
|
|
PRBool aShrinkWrap);
|
2009-08-03 14:42:59 +00:00
|
|
|
virtual nscoord GetBaseline() const;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-08 04:38:41 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2005-01-25 00:06:38 +00:00
|
|
|
nsReflowStatus& aStatus);
|
1998-10-08 04:38:41 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
1998-11-19 17:22:29 +00:00
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
void PaintBorderBackground(nsRenderingContext& aRenderingContext,
|
2009-09-12 22:44:18 +00:00
|
|
|
nsPoint aPt, const nsRect& aDirtyRect, PRUint32 aBGFlags);
|
2005-01-25 00:06:38 +00:00
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
NS_IMETHOD AppendFrames(nsIAtom* aListName,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2005-02-07 01:58:25 +00:00
|
|
|
NS_IMETHOD InsertFrames(nsIAtom* aListName,
|
2005-01-25 00:06:38 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList);
|
2005-02-07 01:58:25 +00:00
|
|
|
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
|
2005-01-25 00:06:38 +00:00
|
|
|
nsIFrame* aOldFrame);
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
virtual nsIAtom* GetType() const;
|
2005-06-12 20:33:35 +00:00
|
|
|
virtual PRBool IsContainingBlock() const;
|
2002-12-03 16:02:42 +00:00
|
|
|
|
2002-02-16 03:23:18 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
virtual already_AddRefed<nsAccessible> CreateAccessible();
|
2002-02-16 03:23:18 +00:00
|
|
|
#endif
|
2002-02-16 01:34:42 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
2001-11-14 01:33:42 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FieldSet"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-11-19 17:22:29 +00:00
|
|
|
|
1998-10-08 04:38:41 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
2010-04-02 06:07:43 +00:00
|
|
|
void ReparentFrameList(const nsFrameList& aFrameList);
|
1998-10-08 04:38:41 +00:00
|
|
|
|
|
|
|
nsIFrame* mLegendFrame;
|
|
|
|
nsIFrame* mContentFrame;
|
1999-06-01 21:52:11 +00:00
|
|
|
nsRect mLegendRect;
|
|
|
|
nscoord mLegendSpace;
|
1998-10-08 04:38:41 +00:00
|
|
|
};
|
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewFieldSetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-10-08 04:38:41 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsFieldSetFrame(aContext);
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFieldSetFrame)
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsFieldSetFrame::nsFieldSetFrame(nsStyleContext* aContext)
|
|
|
|
: nsHTMLContainerFrame(aContext)
|
1998-10-08 04:38:41 +00:00
|
|
|
{
|
2005-01-25 00:06:38 +00:00
|
|
|
mContentFrame = nsnull;
|
|
|
|
mLegendFrame = nsnull;
|
|
|
|
mLegendSpace = 0;
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsFieldSetFrame::GetType() const
|
2002-12-03 16:02:42 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::fieldSetFrame;
|
2002-12-03 16:02:42 +00:00
|
|
|
}
|
|
|
|
|
2005-06-12 20:33:35 +00:00
|
|
|
PRBool
|
|
|
|
nsFieldSetFrame::IsContainingBlock() const
|
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-10-08 04:38:41 +00:00
|
|
|
NS_IMETHODIMP
|
2006-04-10 00:16:29 +00:00
|
|
|
nsFieldSetFrame::SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
1998-10-08 04:38:41 +00:00
|
|
|
{
|
2005-01-02 14:30:24 +00:00
|
|
|
// Get the content and legend frames.
|
2009-07-28 12:53:20 +00:00
|
|
|
if (!aChildList.OnlyChild()) {
|
|
|
|
NS_ASSERTION(aChildList.GetLength() == 2, "Unexpected child list");
|
|
|
|
mContentFrame = aChildList.LastChild();
|
|
|
|
mLegendFrame = aChildList.FirstChild();
|
2005-01-02 14:30:24 +00:00
|
|
|
} else {
|
2009-07-28 12:53:20 +00:00
|
|
|
mContentFrame = aChildList.FirstChild();
|
2005-01-02 14:30:24 +00:00
|
|
|
mLegendFrame = nsnull;
|
|
|
|
}
|
2000-01-09 02:05:25 +00:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
// Queue up the frames for the content frame
|
2006-04-10 00:16:29 +00:00
|
|
|
return nsHTMLContainerFrame::SetInitialChildList(nsnull, aChildList);
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
class nsDisplayFieldSetBorderBackground : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayFieldSetBorderBackground(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsFieldSetFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayFieldSetBorderBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayFieldSetBorderBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayFieldSetBorderBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 00:31:26 +00:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("FieldSetBorderBackground", TYPE_FIELDSET_BORDER_BACKGROUND)
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
1999-06-01 21:52:11 +00:00
|
|
|
|
2010-04-08 00:31:26 +00:00
|
|
|
void nsDisplayFieldSetBorderBackground::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
|
|
|
// aPt is guaranteed to be in this item's bounds. We do the hit test based on the
|
|
|
|
// frame bounds even though our background doesn't cover the whole frame.
|
|
|
|
// It's not clear whether this is correct.
|
2010-04-08 00:31:26 +00:00
|
|
|
aOutFrames->AppendElement(mFrame);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
1999-06-01 21:52:11 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void
|
|
|
|
nsDisplayFieldSetBorderBackground::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsFieldSetFrame*>(mFrame)->
|
2010-08-13 10:01:58 +00:00
|
|
|
PaintBorderBackground(*aCtx, ToReferenceFrame(),
|
2009-09-07 00:35:14 +00:00
|
|
|
mVisibleRect, aBuilder->GetBackgroundPaintFlags());
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2005-01-25 00:06:38 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) {
|
|
|
|
// Paint our background and border in a special way.
|
|
|
|
// REVIEW: We don't really need to check frame emptiness here; if it's empty,
|
|
|
|
// the background/border display item won't do anything, and if it isn't empty,
|
|
|
|
// we need to paint the outline
|
|
|
|
if (IsVisibleForPainting(aBuilder)) {
|
2009-02-10 08:45:13 +00:00
|
|
|
if (GetStyleBorder()->mBoxShadow) {
|
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayBoxShadowOuter(aBuilder, this));
|
2009-02-10 08:45:13 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2009-02-05 08:22:02 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// don't bother checking to see if we really have a border or background.
|
|
|
|
// we usually will have a border.
|
2009-02-10 08:45:13 +00:00
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayFieldSetBorderBackground(aBuilder, this));
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-06-01 21:52:11 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
rv = DisplayOutlineUnconditional(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2006-09-19 04:26:20 +00:00
|
|
|
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsFieldSetFrame");
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
|
2006-12-10 21:53:53 +00:00
|
|
|
nsDisplayListCollection contentDisplayItems;
|
|
|
|
if (mContentFrame) {
|
|
|
|
// Collect mContentFrame's display items into their own collection. We need
|
|
|
|
// to be calling BuildDisplayList on mContentFrame before mLegendFrame in
|
|
|
|
// case it contains out-of-flow frames whose placeholders are under
|
|
|
|
// mLegendFrame. However, we want mContentFrame's display items to be
|
|
|
|
// after mLegendFrame's display items in z-order, so we need to save them
|
|
|
|
// and append them later.
|
|
|
|
nsresult rv = BuildDisplayListForChild(aBuilder, mContentFrame, aDirtyRect,
|
|
|
|
contentDisplayItems);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
if (mLegendFrame) {
|
2007-12-01 08:32:51 +00:00
|
|
|
// The legend's background goes on our BlockBorderBackgrounds list because
|
|
|
|
// it's a block child.
|
|
|
|
nsDisplayListSet set(aLists, aLists.BlockBorderBackgrounds());
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult rv = BuildDisplayListForChild(aBuilder, mLegendFrame, aDirtyRect, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
2006-12-10 21:53:53 +00:00
|
|
|
// Put mContentFrame's display items on the master list. Note that
|
|
|
|
// this moves mContentFrame's border/background display items to our
|
|
|
|
// BorderBackground() list, which isn't really correct, but it's OK because
|
|
|
|
// mContentFrame is anonymous and can't have its own border and background.
|
|
|
|
contentDisplayItems.MoveTo(aLists);
|
|
|
|
return NS_OK;
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
|
2009-09-12 22:44:18 +00:00
|
|
|
nsPoint aPt, const nsRect& aDirtyRect, PRUint32 aBGFlags)
|
2005-02-02 00:32:11 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
PRIntn skipSides = GetSkipSides();
|
|
|
|
const nsStyleBorder* borderStyle = GetStyleBorder();
|
|
|
|
|
2008-07-17 06:30:25 +00:00
|
|
|
nscoord topBorder = borderStyle->GetActualBorderWidth(NS_SIDE_TOP);
|
2006-01-26 02:29:17 +00:00
|
|
|
nscoord yoff = 0;
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// if the border is smaller than the legend. Move the border down
|
|
|
|
// to be centered on the legend.
|
2010-09-07 22:20:35 +00:00
|
|
|
// FIXME: This means border-radius clamping is incorrect; we should
|
|
|
|
// override nsIFrame::GetBorderRadii.
|
2006-01-26 02:29:17 +00:00
|
|
|
if (topBorder < mLegendRect.height)
|
|
|
|
yoff = (mLegendRect.height - topBorder)/2;
|
|
|
|
|
|
|
|
nsRect rect(aPt.x, aPt.y + yoff, mRect.width, mRect.height - yoff);
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
|
2009-09-12 22:44:18 +00:00
|
|
|
aDirtyRect, rect, aBGFlags);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2009-02-10 08:45:13 +00:00
|
|
|
nsCSSRendering::PaintBoxShadowInner(presContext, aRenderingContext,
|
|
|
|
this, rect, aDirtyRect);
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
if (mLegendFrame) {
|
|
|
|
|
|
|
|
// Use the rect of the legend frame, not mLegendRect, so we draw our
|
|
|
|
// border under the legend's left and right margins.
|
|
|
|
nsRect legendRect = mLegendFrame->GetRect() + aPt;
|
|
|
|
|
|
|
|
// we should probably use PaintBorderEdges to do this but for now just use clipping
|
|
|
|
// to achieve the same effect.
|
|
|
|
|
|
|
|
// draw left side
|
|
|
|
nsRect clipRect(rect);
|
|
|
|
clipRect.width = legendRect.x - rect.x;
|
|
|
|
clipRect.height = topBorder;
|
|
|
|
|
|
|
|
aRenderingContext.PushState();
|
2011-04-08 01:04:40 +00:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
2010-04-03 01:58:26 +00:00
|
|
|
aDirtyRect, rect, mStyleContext, skipSides);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
|
|
|
|
|
|
|
|
|
|
|
// draw right side
|
|
|
|
clipRect = rect;
|
|
|
|
clipRect.x = legendRect.XMost();
|
|
|
|
clipRect.width = rect.XMost() - legendRect.XMost();
|
|
|
|
clipRect.height = topBorder;
|
|
|
|
|
|
|
|
aRenderingContext.PushState();
|
2011-04-08 01:04:40 +00:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
2010-04-03 01:58:26 +00:00
|
|
|
aDirtyRect, rect, mStyleContext, skipSides);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
|
|
|
|
|
|
|
|
|
|
|
// draw bottom
|
|
|
|
clipRect = rect;
|
|
|
|
clipRect.y += topBorder;
|
|
|
|
clipRect.height = mRect.height - (yoff + topBorder);
|
|
|
|
|
|
|
|
aRenderingContext.PushState();
|
2011-04-08 01:04:40 +00:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
2010-04-03 01:58:26 +00:00
|
|
|
aDirtyRect, rect, mStyleContext, skipSides);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
aRenderingContext.PopState();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
|
|
|
aDirtyRect,
|
|
|
|
nsRect(aPt, mRect.Size()),
|
2010-04-03 01:58:26 +00:00
|
|
|
mStyleContext, skipSides);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2005-02-02 00:32:11 +00:00
|
|
|
}
|
1999-02-23 03:48:01 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFieldSetFrame::GetIntrinsicWidth(nsRenderingContext* aRenderingContext,
|
2008-03-14 20:48:23 +00:00
|
|
|
nsLayoutUtils::IntrinsicWidthType aType)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2008-03-14 20:48:23 +00:00
|
|
|
nscoord legendWidth = 0;
|
|
|
|
nscoord contentWidth = 0;
|
|
|
|
if (mLegendFrame) {
|
|
|
|
legendWidth =
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, mLegendFrame,
|
|
|
|
aType);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2008-03-14 20:48:23 +00:00
|
|
|
if (mContentFrame) {
|
|
|
|
contentWidth =
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, mContentFrame,
|
|
|
|
aType);
|
|
|
|
}
|
|
|
|
|
2009-09-16 15:01:36 +00:00
|
|
|
return NS_MAX(legendWidth, contentWidth);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFieldSetFrame::GetMinWidth(nsRenderingContext* aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
2008-03-14 20:48:23 +00:00
|
|
|
result = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::MIN_WIDTH);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFieldSetFrame::GetPrefWidth(nsRenderingContext* aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
2008-03-14 20:48:23 +00:00
|
|
|
result = GetIntrinsicWidth(aRenderingContext, nsLayoutUtils::PREF_WIDTH);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFieldSetFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
|
|
|
PRBool aShrinkWrap)
|
|
|
|
{
|
|
|
|
nsSize result =
|
|
|
|
nsHTMLContainerFrame::ComputeSize(aRenderingContext, aCBSize,
|
|
|
|
aAvailableWidth,
|
|
|
|
aMargin, aBorder, aPadding, aShrinkWrap);
|
|
|
|
|
|
|
|
// Fieldsets never shrink below their min width.
|
|
|
|
nscoord minWidth = GetMinWidth(aRenderingContext);
|
|
|
|
if (minWidth > result.width)
|
|
|
|
result.width = minWidth;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-10-08 04:38:41 +00:00
|
|
|
NS_IMETHODIMP
|
2005-01-25 00:06:38 +00:00
|
|
|
nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
|
1999-02-23 03:48:01 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-08 04:38:41 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-02-23 03:48:01 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 04:38:41 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsFieldSetFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2002-01-31 05:09:13 +00:00
|
|
|
|
2007-01-26 00:05:12 +00:00
|
|
|
NS_PRECONDITION(aReflowState.ComputedWidth() != NS_INTRINSICSIZE,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
"Should have a precomputed width!");
|
|
|
|
|
2000-01-09 02:05:25 +00:00
|
|
|
// Initialize OUT parameter
|
2003-05-22 20:56:35 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
//------------ Handle Incremental Reflow -----------------
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool reflowContent;
|
|
|
|
PRBool reflowLegend;
|
2000-01-09 02:05:25 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (aReflowState.ShouldReflowAllKids()) {
|
|
|
|
reflowContent = mContentFrame != nsnull;
|
|
|
|
reflowLegend = mLegendFrame != nsnull;
|
|
|
|
} else {
|
2007-05-06 19:16:51 +00:00
|
|
|
reflowContent = mContentFrame && NS_SUBTREE_DIRTY(mContentFrame);
|
|
|
|
reflowLegend = mLegendFrame && NS_SUBTREE_DIRTY(mLegendFrame);
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
2000-01-09 02:05:25 +00:00
|
|
|
|
2009-05-08 01:55:22 +00:00
|
|
|
// We don't allow fieldsets to break vertically. If we did, we'd
|
|
|
|
// need logic here to push and pull overflow frames.
|
|
|
|
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ASSERTION(!mContentFrame ||
|
2008-03-14 20:48:23 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aReflowState.rendContext,
|
|
|
|
mContentFrame,
|
|
|
|
nsLayoutUtils::MIN_WIDTH) <=
|
|
|
|
availSize.width,
|
|
|
|
"Bogus availSize.width; should be bigger");
|
|
|
|
NS_ASSERTION(!mLegendFrame ||
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aReflowState.rendContext,
|
|
|
|
mLegendFrame,
|
|
|
|
nsLayoutUtils::MIN_WIDTH) <=
|
|
|
|
availSize.width,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
"Bogus availSize.width; should be bigger");
|
2002-01-31 05:09:13 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
// get our border and padding
|
|
|
|
const nsMargin &borderPadding = aReflowState.mComputedBorderPadding;
|
2008-07-09 15:42:44 +00:00
|
|
|
nsMargin border = borderPadding - aReflowState.mComputedPadding;
|
2000-01-09 02:05:25 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
// Figure out how big the legend is if there is one.
|
|
|
|
// get the legend's margin
|
|
|
|
nsMargin legendMargin(0,0,0,0);
|
|
|
|
// reflow the legend only if needed
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (reflowLegend) {
|
|
|
|
nsHTMLReflowState legendReflowState(aPresContext, aReflowState,
|
2008-03-14 20:48:23 +00:00
|
|
|
mLegendFrame, availSize);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics legendDesiredSize;
|
2000-02-10 21:36:28 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
ReflowChild(mLegendFrame, aPresContext, legendDesiredSize, legendReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2000-05-15 22:51:42 +00:00
|
|
|
#ifdef NOISY_REFLOW
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf(" returned (%d, %d)\n", legendDesiredSize.width, legendDesiredSize.height);
|
2000-05-15 22:51:42 +00:00
|
|
|
#endif
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// figure out the legend's rectangle
|
2008-07-09 15:42:44 +00:00
|
|
|
legendMargin = mLegendFrame->GetUsedMargin();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
mLegendRect.width = legendDesiredSize.width + legendMargin.left + legendMargin.right;
|
|
|
|
mLegendRect.height = legendDesiredSize.height + legendMargin.top + legendMargin.bottom;
|
|
|
|
mLegendRect.x = borderPadding.left;
|
|
|
|
mLegendRect.y = 0;
|
2005-01-25 00:06:38 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord oldSpace = mLegendSpace;
|
|
|
|
mLegendSpace = 0;
|
|
|
|
if (mLegendRect.height > border.top) {
|
|
|
|
// center the border on the legend
|
|
|
|
mLegendSpace = mLegendRect.height - border.top;
|
|
|
|
} else {
|
|
|
|
mLegendRect.y = (border.top - mLegendRect.height)/2;
|
|
|
|
}
|
2000-01-09 02:05:25 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// if the legend space changes then we need to reflow the
|
|
|
|
// content area as well.
|
|
|
|
if (mLegendSpace != oldSpace && mContentFrame) {
|
|
|
|
reflowContent = PR_TRUE;
|
|
|
|
}
|
2000-05-15 22:51:42 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
FinishReflowChild(mLegendFrame, aPresContext, &legendReflowState,
|
|
|
|
legendDesiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME);
|
|
|
|
} else if (!mLegendFrame) {
|
2011-04-19 03:07:23 +00:00
|
|
|
mLegendRect.SetEmpty();
|
2005-01-25 00:06:38 +00:00
|
|
|
mLegendSpace = 0;
|
2008-07-09 15:42:44 +00:00
|
|
|
} else {
|
|
|
|
// mLegendSpace and mLegendRect haven't changed, but we need
|
|
|
|
// the used margin when placing the legend.
|
|
|
|
legendMargin = mLegendFrame->GetUsedMargin();
|
|
|
|
}
|
2000-01-09 02:05:25 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
// reflow the content frame only if needed
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (reflowContent) {
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, mContentFrame,
|
|
|
|
availSize);
|
2007-11-08 04:04:32 +00:00
|
|
|
// Our child is "height:100%" but we actually want its height to be reduced
|
|
|
|
// by the amount of content-height the legend is eating up, unless our
|
|
|
|
// height is unconstrained (in which case the child's will be too).
|
|
|
|
if (aReflowState.ComputedHeight() != NS_UNCONSTRAINEDSIZE) {
|
2009-09-16 15:01:36 +00:00
|
|
|
kidReflowState.SetComputedHeight(NS_MAX(0, aReflowState.ComputedHeight() - mLegendSpace));
|
2007-11-08 04:04:32 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2008-08-08 05:18:00 +00:00
|
|
|
kidReflowState.mComputedMinHeight =
|
2009-09-16 15:01:36 +00:00
|
|
|
NS_MAX(0, aReflowState.mComputedMinHeight - mLegendSpace);
|
2008-08-08 05:18:00 +00:00
|
|
|
|
|
|
|
if (aReflowState.mComputedMaxHeight != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
kidReflowState.mComputedMaxHeight =
|
2009-09-16 15:01:36 +00:00
|
|
|
NS_MAX(0, aReflowState.mComputedMaxHeight - mLegendSpace);
|
2008-08-08 05:18:00 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(aDesiredSize.mFlags);
|
|
|
|
// Reflow the frame
|
2007-11-08 04:04:32 +00:00
|
|
|
NS_ASSERTION(kidReflowState.mComputedMargin == nsMargin(0,0,0,0),
|
|
|
|
"Margins on anonymous fieldset child not supported!");
|
|
|
|
nsPoint pt(borderPadding.left, borderPadding.top + mLegendSpace);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
ReflowChild(mContentFrame, aPresContext, kidDesiredSize, kidReflowState,
|
2007-11-08 04:04:32 +00:00
|
|
|
pt.x, pt.y, 0, aStatus);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
FinishReflowChild(mContentFrame, aPresContext, &kidReflowState,
|
2007-11-08 04:04:32 +00:00
|
|
|
kidDesiredSize, pt.x, pt.y, 0);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus);
|
2007-11-08 04:04:32 +00:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2007-11-08 04:04:32 +00:00
|
|
|
nsRect contentRect(0,0,0,0);
|
|
|
|
if (mContentFrame) {
|
2008-07-09 15:42:44 +00:00
|
|
|
// We don't support margins on mContentFrame, so our "content rect" is just
|
2007-11-08 04:04:32 +00:00
|
|
|
// its rect.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
contentRect = mContentFrame->GetRect();
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
// use the computed width if the inner content does not fill it
|
2007-01-26 00:05:12 +00:00
|
|
|
if (aReflowState.ComputedWidth() > contentRect.width) {
|
|
|
|
contentRect.width = aReflowState.ComputedWidth();
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mLegendFrame) {
|
|
|
|
// if the content rect is larger then the legend we can align the legend
|
|
|
|
if (contentRect.width > mLegendRect.width) {
|
2008-07-09 15:42:44 +00:00
|
|
|
PRInt32 align = static_cast<nsLegendFrame*>(mLegendFrame)->GetAlign();
|
2005-01-25 00:06:38 +00:00
|
|
|
|
|
|
|
switch(align) {
|
|
|
|
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
|
|
|
mLegendRect.x = contentRect.width - mLegendRect.width + borderPadding.left;
|
|
|
|
break;
|
|
|
|
case NS_STYLE_TEXT_ALIGN_CENTER:
|
2007-02-07 07:46:44 +00:00
|
|
|
// Note: rounding removed; there doesn't seem to be any need
|
|
|
|
mLegendRect.x = contentRect.width / 2 - mLegendRect.width / 2 + borderPadding.left;
|
2005-01-25 00:06:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-01-09 02:05:25 +00:00
|
|
|
} else {
|
2008-07-09 15:42:44 +00:00
|
|
|
// otherwise make place for the legend
|
2005-01-25 00:06:38 +00:00
|
|
|
contentRect.width = mLegendRect.width;
|
2000-01-09 02:05:25 +00:00
|
|
|
}
|
2005-01-25 00:06:38 +00:00
|
|
|
// place the legend
|
|
|
|
nsRect actualLegendRect(mLegendRect);
|
|
|
|
actualLegendRect.Deflate(legendMargin);
|
|
|
|
|
|
|
|
nsPoint curOrigin = mLegendFrame->GetPosition();
|
|
|
|
|
|
|
|
// only if the origin changed
|
|
|
|
if ((curOrigin.x != mLegendRect.x) || (curOrigin.y != mLegendRect.y)) {
|
|
|
|
mLegendFrame->SetPosition(nsPoint(actualLegendRect.x , actualLegendRect.y));
|
|
|
|
nsContainerFrame::PositionFrameView(mLegendFrame);
|
|
|
|
|
|
|
|
// We need to recursively process the legend frame's
|
|
|
|
// children since we're moving the frame after Reflow.
|
|
|
|
nsContainerFrame::PositionChildViews(mLegendFrame);
|
2004-10-14 17:37:54 +00:00
|
|
|
}
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return our size and our result
|
2007-08-02 18:08:05 +00:00
|
|
|
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
|
2005-01-25 00:06:38 +00:00
|
|
|
aDesiredSize.height = mLegendSpace +
|
2007-08-02 18:08:05 +00:00
|
|
|
borderPadding.TopBottom() +
|
|
|
|
contentRect.height;
|
2005-01-25 00:06:38 +00:00
|
|
|
} else {
|
2007-08-02 18:08:05 +00:00
|
|
|
nscoord min = borderPadding.TopBottom() + mLegendRect.height;
|
|
|
|
aDesiredSize.height =
|
|
|
|
aReflowState.ComputedHeight() + borderPadding.TopBottom();
|
2005-01-25 00:06:38 +00:00
|
|
|
if (aDesiredSize.height < min)
|
|
|
|
aDesiredSize.height = min;
|
|
|
|
}
|
2007-08-02 18:08:05 +00:00
|
|
|
aDesiredSize.width = contentRect.width + borderPadding.LeftRight();
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2005-01-25 00:06:38 +00:00
|
|
|
if (mLegendFrame)
|
2010-10-07 04:25:46 +00:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, mLegendFrame);
|
2005-01-25 00:06:38 +00:00
|
|
|
if (mContentFrame)
|
2010-10-07 04:25:46 +00:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, mContentFrame);
|
2005-01-25 00:06:38 +00:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
Invalidate(aDesiredSize.VisualOverflow());
|
2005-01-25 00:06:38 +00:00
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-08 04:38:41 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsFieldSetFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-15 04:12:31 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsFieldSetFrame::AppendFrames(nsIAtom* aListName,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2009-07-30 17:23:32 +00:00
|
|
|
// aFrameList is not allowed to contain "the legend" for this fieldset
|
2010-04-02 06:07:43 +00:00
|
|
|
ReparentFrameList(aFrameList);
|
2009-07-30 17:23:32 +00:00
|
|
|
return mContentFrame->AppendFrames(aListName, aFrameList);
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsFieldSetFrame::InsertFrames(nsIAtom* aListName,
|
2005-01-25 00:06:38 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this ||
|
|
|
|
aPrevFrame->GetParent() == mContentFrame,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
2009-07-30 17:23:32 +00:00
|
|
|
// aFrameList is not allowed to contain "the legend" for this fieldset
|
2010-04-02 06:07:43 +00:00
|
|
|
ReparentFrameList(aFrameList);
|
2009-07-30 17:23:32 +00:00
|
|
|
if (NS_UNLIKELY(aPrevFrame == mLegendFrame)) {
|
|
|
|
aPrevFrame = nsnull;
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
2009-07-30 17:23:32 +00:00
|
|
|
return mContentFrame->InsertFrames(aListName, aPrevFrame, aFrameList);
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsFieldSetFrame::RemoveFrame(nsIAtom* aListName,
|
2005-01-25 00:06:38 +00:00
|
|
|
nsIFrame* aOldFrame)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2005-01-25 00:06:38 +00:00
|
|
|
// For reference, see bug 70648, bug 276104 and bug 236071.
|
2009-06-12 02:01:05 +00:00
|
|
|
NS_ASSERTION(aOldFrame != mLegendFrame, "Cannot remove mLegendFrame here");
|
2005-02-07 01:58:25 +00:00
|
|
|
return mContentFrame->RemoveFrame(aListName, aOldFrame);
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
2002-02-16 01:34:42 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsFieldSetFrame::CreateAccessible()
|
2002-02-16 01:34:42 +00:00
|
|
|
{
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2002-02-16 01:34:42 +00:00
|
|
|
if (accService) {
|
2010-06-28 12:02:03 +00:00
|
|
|
return accService->CreateHTMLGroupboxAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2002-02-16 01:34:42 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 12:02:03 +00:00
|
|
|
return nsnull;
|
2002-02-16 01:34:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
2005-01-25 00:06:38 +00:00
|
|
|
|
|
|
|
void
|
2010-04-02 06:07:43 +00:00
|
|
|
nsFieldSetFrame::ReparentFrameList(const nsFrameList& aFrameList)
|
2005-01-25 00:06:38 +00:00
|
|
|
{
|
2007-03-30 21:11:41 +00:00
|
|
|
nsFrameManager* frameManager = PresContext()->FrameManager();
|
2009-07-30 17:23:32 +00:00
|
|
|
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
|
|
|
|
NS_ASSERTION(mLegendFrame || e.get()->GetType() != nsGkAtoms::legendFrame,
|
2009-06-12 02:01:05 +00:00
|
|
|
"The fieldset's legend is not allowed in this list");
|
2009-07-30 17:23:32 +00:00
|
|
|
e.get()->SetParent(mContentFrame);
|
2010-04-02 06:07:43 +00:00
|
|
|
frameManager->ReparentStyleContext(e.get());
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-03 14:42:59 +00:00
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsFieldSetFrame::GetBaseline() const
|
|
|
|
{
|
|
|
|
// We know mContentFrame is a block, so calling GetBaseline() on it will do
|
|
|
|
// the right thing (that being to return the baseline of the last line).
|
|
|
|
NS_ASSERTION(nsLayoutUtils::GetAsBlock(mContentFrame),
|
|
|
|
"Unexpected mContentFrame");
|
|
|
|
return mContentFrame->GetPosition().y + mContentFrame->GetBaseline();
|
|
|
|
}
|