2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-10-08 04:38:41 +00:00
|
|
|
|
2014-01-16 02:20:20 +00:00
|
|
|
#include "nsFieldSetFrame.h"
|
|
|
|
|
2013-04-17 20:16:14 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
#include "nsLegendFrame.h"
|
|
|
|
#include "nsCSSRendering.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
1998-10-08 04:38:41 +00:00
|
|
|
#include "nsIFrame.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "RestyleManager.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2013-10-22 22:46:40 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2012-10-26 13:32:10 +00:00
|
|
|
#include "mozilla/Likely.h"
|
2013-11-23 09:48:26 +00:00
|
|
|
#include "mozilla/Maybe.h"
|
1998-10-08 04:38:41 +00:00
|
|
|
|
2012-01-25 01:21:29 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::layout;
|
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
nsContainerFrame*
|
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)
|
2011-12-27 20:18:48 +00:00
|
|
|
: nsContainerFrame(aContext)
|
1998-10-08 04:38:41 +00:00
|
|
|
{
|
2005-01-25 00:06:38 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-01-16 02:20:20 +00:00
|
|
|
nsRect
|
|
|
|
nsFieldSetFrame::VisualBorderRectRelativeToSelf() const
|
|
|
|
{
|
|
|
|
nscoord topBorder = StyleBorder()->GetComputedBorderWidth(NS_SIDE_TOP);
|
|
|
|
nsRect r(nsPoint(0,0), GetSize());
|
|
|
|
if (topBorder < mLegendRect.height) {
|
|
|
|
nscoord yoff = (mLegendRect.height - topBorder) / 2;
|
|
|
|
r.y += yoff;
|
|
|
|
r.height -= yoff;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsFieldSetFrame::GetInner() const
|
|
|
|
{
|
|
|
|
nsIFrame* last = mFrames.LastChild();
|
|
|
|
if (last &&
|
|
|
|
last->StyleContext()->GetPseudo() == nsCSSAnonBoxes::fieldsetContent) {
|
|
|
|
return last;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mFrames.LastChild() == mFrames.FirstChild());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsFieldSetFrame::GetLegend() const
|
|
|
|
{
|
|
|
|
if (mFrames.FirstChild() == GetInner()) {
|
|
|
|
MOZ_ASSERT(mFrames.LastChild() == mFrames.FirstChild());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mFrames.FirstChild() &&
|
|
|
|
mFrames.FirstChild()->GetContentInsertionFrame()->GetType() ==
|
|
|
|
nsGkAtoms::legendFrame);
|
|
|
|
return mFrames.FirstChild();
|
|
|
|
}
|
|
|
|
|
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,
|
2014-02-24 14:41:56 +00:00
|
|
|
HitTestState* aState,
|
|
|
|
nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE;
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 14:41:56 +00:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2013-06-26 16:43:26 +00:00
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
|
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
|
|
|
|
2013-06-26 16:43:26 +00:00
|
|
|
void
|
|
|
|
nsDisplayFieldSetBorderBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion *aInvalidRegion)
|
|
|
|
{
|
|
|
|
AddInvalidRegionForSyncDecodeBackgroundImages(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
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
|
2013-04-17 20:16:14 +00:00
|
|
|
if (!(GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) &&
|
|
|
|
IsVisibleForPainting(aBuilder)) {
|
2013-02-16 21:51:02 +00:00
|
|
|
if (StyleBorder()->mBoxShadow) {
|
2013-02-14 11:08:08 +00:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayBoxShadowOuter(aBuilder, this));
|
2009-02-10 08:45:13 +00:00
|
|
|
}
|
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.
|
2013-02-14 11:08:08 +00:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayFieldSetBorderBackground(aBuilder, this));
|
1999-06-01 21:52:11 +00:00
|
|
|
|
2013-02-14 11:08:08 +00:00
|
|
|
DisplayOutlineUnconditional(aBuilder, aLists);
|
2006-09-19 04:26:20 +00:00
|
|
|
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsFieldSetFrame");
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 20:16:14 +00:00
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
DisplayOverflowContainers(aBuilder, aDirtyRect, aLists);
|
|
|
|
}
|
|
|
|
|
2006-12-10 21:53:53 +00:00
|
|
|
nsDisplayListCollection contentDisplayItems;
|
2013-04-17 20:16:14 +00:00
|
|
|
if (nsIFrame* inner = GetInner()) {
|
|
|
|
// Collect the inner frame's display items into their own collection.
|
|
|
|
// We need to be calling BuildDisplayList on it before the legend in
|
|
|
|
// case it contains out-of-flow frames whose placeholders are in the
|
|
|
|
// legend. However, we want the inner frame's display items to be
|
|
|
|
// after the legend's display items in z-order, so we need to save them
|
2006-12-10 21:53:53 +00:00
|
|
|
// and append them later.
|
2013-04-17 20:16:14 +00:00
|
|
|
BuildDisplayListForChild(aBuilder, inner, aDirtyRect, contentDisplayItems);
|
2006-12-10 21:53:53 +00:00
|
|
|
}
|
2013-04-17 20:16:14 +00:00
|
|
|
if (nsIFrame* legend = GetLegend()) {
|
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());
|
2013-04-17 20:16:14 +00:00
|
|
|
BuildDisplayListForChild(aBuilder, legend, aDirtyRect, set);
|
1998-10-08 04:38:41 +00:00
|
|
|
}
|
2013-04-17 20:16:14 +00:00
|
|
|
// Put the inner frame's display items on the master list. Note that this
|
|
|
|
// moves its border/background display items to our BorderBackground() list,
|
|
|
|
// which isn't really correct, but it's OK because the inner frame is
|
|
|
|
// anonymous and can't have its own border and background.
|
2006-12-10 21:53:53 +00:00
|
|
|
contentDisplayItems.MoveTo(aLists);
|
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,
|
2012-08-22 15:56:38 +00:00
|
|
|
nsPoint aPt, const nsRect& aDirtyRect, uint32_t aBGFlags)
|
2005-02-02 00:32:11 +00:00
|
|
|
{
|
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.
|
2013-04-17 20:16:14 +00:00
|
|
|
nsRect rect = VisualBorderRectRelativeToSelf();
|
|
|
|
nscoord yoff = rect.y;
|
|
|
|
rect += aPt;
|
|
|
|
nsPresContext* presContext = PresContext();
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2013-04-17 20:16:14 +00:00
|
|
|
if (nsIFrame* legend = GetLegend()) {
|
2013-04-17 20:16:14 +00:00
|
|
|
nscoord topBorder = StyleBorder()->GetComputedBorderWidth(NS_SIDE_TOP);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// Use the rect of the legend frame, not mLegendRect, so we draw our
|
|
|
|
// border under the legend's left and right margins.
|
2013-04-17 20:16:14 +00:00
|
|
|
nsRect legendRect = legend->GetRect() + aPt;
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2014-09-11 06:48:10 +00:00
|
|
|
aRenderingContext.ThebesContext()->Save();
|
2011-04-08 01:04:40 +00:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
2013-02-04 16:17:20 +00:00
|
|
|
aDirtyRect, rect, mStyleContext);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2014-09-11 06:48:10 +00:00
|
|
|
aRenderingContext.ThebesContext()->Restore();
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
// draw right side
|
|
|
|
clipRect = rect;
|
|
|
|
clipRect.x = legendRect.XMost();
|
|
|
|
clipRect.width = rect.XMost() - legendRect.XMost();
|
|
|
|
clipRect.height = topBorder;
|
|
|
|
|
2014-09-11 06:48:10 +00:00
|
|
|
aRenderingContext.ThebesContext()->Save();
|
2011-04-08 01:04:40 +00:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
2013-02-04 16:17:20 +00:00
|
|
|
aDirtyRect, rect, mStyleContext);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2014-09-11 06:48:10 +00:00
|
|
|
aRenderingContext.ThebesContext()->Restore();
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
// draw bottom
|
|
|
|
clipRect = rect;
|
|
|
|
clipRect.y += topBorder;
|
|
|
|
clipRect.height = mRect.height - (yoff + topBorder);
|
|
|
|
|
2014-09-11 06:48:10 +00:00
|
|
|
aRenderingContext.ThebesContext()->Save();
|
2011-04-08 01:04:40 +00:00
|
|
|
aRenderingContext.IntersectClip(clipRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
2013-02-04 16:17:20 +00:00
|
|
|
aDirtyRect, rect, mStyleContext);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2014-09-11 06:48:10 +00:00
|
|
|
aRenderingContext.ThebesContext()->Restore();
|
2006-01-26 02:29:17 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
|
|
|
aDirtyRect,
|
|
|
|
nsRect(aPt, mRect.Size()),
|
2013-02-04 16:17:20 +00:00
|
|
|
mStyleContext);
|
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
|
2014-07-24 17:03:26 +00:00
|
|
|
nsFieldSetFrame::GetIntrinsicISize(nsRenderingContext* aRenderingContext,
|
|
|
|
nsLayoutUtils::IntrinsicISizeType 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;
|
2013-04-17 20:16:14 +00:00
|
|
|
if (nsIFrame* legend = GetLegend()) {
|
2008-03-14 20:48:23 +00:00
|
|
|
legendWidth =
|
2013-04-17 20:16:14 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, legend, aType);
|
2008-03-14 20:48:23 +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
|
|
|
|
2013-04-17 20:16:14 +00:00
|
|
|
if (nsIFrame* inner = GetInner()) {
|
2013-10-22 22:46:40 +00:00
|
|
|
// Ignore padding on the inner, since the padding will be applied to the
|
|
|
|
// outer instead, and the padding computed for the inner is wrong
|
|
|
|
// for percentage padding.
|
2008-03-14 20:48:23 +00:00
|
|
|
contentWidth =
|
2013-10-22 22:46:40 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, inner, aType,
|
|
|
|
nsLayoutUtils::IGNORE_PADDING);
|
2008-03-14 20:48:23 +00:00
|
|
|
}
|
2013-10-22 22:46:40 +00:00
|
|
|
|
2013-01-15 12:22:03 +00:00
|
|
|
return std::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
|
2014-07-24 17:03:25 +00:00
|
|
|
nsFieldSetFrame::GetMinISize(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);
|
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
result = GetIntrinsicISize(aRenderingContext, nsLayoutUtils::MIN_ISIZE);
|
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
|
2014-07-24 17:03:25 +00:00
|
|
|
nsFieldSetFrame::GetPrefISize(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);
|
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
result = GetIntrinsicISize(aRenderingContext, nsLayoutUtils::PREF_ISIZE);
|
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;
|
|
|
|
}
|
|
|
|
|
2014-08-24 14:34:44 +00:00
|
|
|
/* virtual */
|
|
|
|
LogicalSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFieldSetFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
2014-08-24 14:34:44 +00:00
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder,
|
|
|
|
const LogicalSize& aPadding,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
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
|
|
|
{
|
2014-08-24 14:34:44 +00:00
|
|
|
LogicalSize result =
|
|
|
|
nsContainerFrame::ComputeSize(aRenderingContext, aWM,
|
|
|
|
aCBSize, aAvailableISize,
|
2012-03-16 18:01:05 +00:00
|
|
|
aMargin, aBorder, aPadding, aFlags);
|
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
|
|
|
|
2014-08-24 14:34:44 +00:00
|
|
|
// XXX The code below doesn't make sense if the caller's writing mode
|
|
|
|
// is orthogonal to this frame's. Not sure yet what should happen then;
|
|
|
|
// for now, just bail out.
|
|
|
|
if (aWM.IsVertical() != GetWritingMode().IsVertical()) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// Fieldsets never shrink below their min width.
|
2012-01-25 01:21:29 +00:00
|
|
|
|
|
|
|
// If we're a container for font size inflation, then shrink
|
|
|
|
// wrapping inside of us should not apply font size inflation.
|
2012-05-21 05:18:27 +00:00
|
|
|
AutoMaybeDisableFontInflation an(this);
|
2012-01-25 01:21:29 +00:00
|
|
|
|
2014-08-24 14:34:44 +00:00
|
|
|
nscoord minISize = GetMinISize(aRenderingContext);
|
|
|
|
if (minISize > result.ISize(aWM)) {
|
|
|
|
result.ISize(aWM) = minISize;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
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;
|
|
|
|
|
2013-04-17 20:16:14 +00:00
|
|
|
nsOverflowAreas ocBounds;
|
|
|
|
nsReflowStatus ocStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
ReflowOverflowContainerChildren(aPresContext, aReflowState, ocBounds, 0,
|
|
|
|
ocStatus);
|
|
|
|
}
|
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
//------------ Handle Incremental Reflow -----------------
|
2013-04-17 20:16:14 +00:00
|
|
|
bool reflowInner;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool reflowLegend;
|
2013-04-17 20:16:14 +00:00
|
|
|
nsIFrame* legend = GetLegend();
|
|
|
|
nsIFrame* inner = GetInner();
|
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()) {
|
2013-04-17 20:16:14 +00:00
|
|
|
reflowInner = inner != nullptr;
|
|
|
|
reflowLegend = legend != nullptr;
|
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
|
|
|
} else {
|
2013-04-17 20:16:14 +00:00
|
|
|
reflowInner = inner && NS_SUBTREE_DIRTY(inner);
|
|
|
|
reflowLegend = legend && NS_SUBTREE_DIRTY(legend);
|
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.
|
2013-10-22 22:46:40 +00:00
|
|
|
// Since we're not applying our padding in this frame, we need to add it here
|
|
|
|
// to compute the available width for our children.
|
2014-07-24 08:28:46 +00:00
|
|
|
WritingMode innerWM = inner ? inner->GetWritingMode() : GetWritingMode();
|
|
|
|
WritingMode legendWM = legend ? legend->GetWritingMode() : GetWritingMode();
|
|
|
|
LogicalSize innerAvailSize = aReflowState.ComputedSizeWithPadding(innerWM);
|
|
|
|
LogicalSize legendAvailSize = aReflowState.ComputedSizeWithPadding(legendWM);
|
|
|
|
innerAvailSize.BSize(innerWM) = legendAvailSize.BSize(legendWM) =
|
|
|
|
NS_UNCONSTRAINEDSIZE;
|
2013-04-17 20:16:14 +00:00
|
|
|
NS_ASSERTION(!inner ||
|
2008-03-14 20:48:23 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aReflowState.rendContext,
|
2013-04-17 20:16:14 +00:00
|
|
|
inner,
|
2014-07-24 17:03:26 +00:00
|
|
|
nsLayoutUtils::MIN_ISIZE) <=
|
2014-07-24 08:28:46 +00:00
|
|
|
innerAvailSize.ISize(innerWM),
|
|
|
|
"Bogus availSize.ISize; should be bigger");
|
2013-04-17 20:16:14 +00:00
|
|
|
NS_ASSERTION(!legend ||
|
2008-03-14 20:48:23 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aReflowState.rendContext,
|
2013-04-17 20:16:14 +00:00
|
|
|
legend,
|
2014-07-24 17:03:26 +00:00
|
|
|
nsLayoutUtils::MIN_ISIZE) <=
|
2014-07-24 08:28:46 +00:00
|
|
|
legendAvailSize.ISize(legendWM),
|
|
|
|
"Bogus availSize.ISize; should be bigger");
|
2002-01-31 05:09:13 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
// get our border and padding
|
2013-12-27 17:59:21 +00:00
|
|
|
nsMargin border = aReflowState.ComputedPhysicalBorderPadding() - aReflowState.ComputedPhysicalPadding();
|
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
|
2013-11-23 09:48:26 +00:00
|
|
|
Maybe<nsHTMLReflowState> legendReflowState;
|
|
|
|
if (legend) {
|
2014-08-13 22:42:15 +00:00
|
|
|
legendReflowState.emplace(aPresContext, aReflowState, legend,
|
2014-07-24 08:28:46 +00:00
|
|
|
legendAvailSize);
|
2013-11-23 09:48:26 +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 (reflowLegend) {
|
2013-12-31 13:50:31 +00:00
|
|
|
nsHTMLReflowMetrics legendDesiredSize(aReflowState);
|
2000-02-10 21:36:28 +00:00
|
|
|
|
2014-08-13 22:42:15 +00:00
|
|
|
ReflowChild(legend, aPresContext, legendDesiredSize, *legendReflowState,
|
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
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2000-05-15 22:51:42 +00:00
|
|
|
#ifdef NOISY_REFLOW
|
2014-07-24 08:30:07 +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
|
2013-04-17 20:16:14 +00:00
|
|
|
legendMargin = legend->GetUsedMargin();
|
2013-12-27 17:59:52 +00:00
|
|
|
mLegendRect.width = legendDesiredSize.Width() + legendMargin.left + legendMargin.right;
|
|
|
|
mLegendRect.height = legendDesiredSize.Height() + legendMargin.top + legendMargin.bottom;
|
2013-10-22 22:46:40 +00:00
|
|
|
mLegendRect.x = 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
|
|
|
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.
|
2013-04-17 20:16:14 +00:00
|
|
|
if (mLegendSpace != oldSpace && inner) {
|
|
|
|
reflowInner = true;
|
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
|
|
|
}
|
2000-05-15 22:51:42 +00:00
|
|
|
|
2014-01-17 01:34:44 +00:00
|
|
|
FinishReflowChild(legend, aPresContext, legendDesiredSize,
|
2014-08-13 22:42:15 +00:00
|
|
|
legendReflowState.ptr(), 0, 0, NS_FRAME_NO_MOVE_FRAME);
|
2013-04-17 20:16:14 +00:00
|
|
|
} else if (!legend) {
|
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.
|
2013-04-17 20:16:14 +00:00
|
|
|
legendMargin = legend->GetUsedMargin();
|
2008-07-09 15:42:44 +00:00
|
|
|
}
|
2000-01-09 02:05:25 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
// reflow the content frame only if needed
|
2013-04-17 20:16:14 +00:00
|
|
|
if (reflowInner) {
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, inner,
|
2014-07-24 08:28:46 +00:00
|
|
|
innerAvailSize, -1, -1,
|
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2013-10-22 22:46:40 +00:00
|
|
|
// Override computed padding, in case it's percentage padding
|
|
|
|
kidReflowState.Init(aPresContext, -1, -1, nullptr,
|
2013-12-27 17:59:21 +00:00
|
|
|
&aReflowState.ComputedPhysicalPadding());
|
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) {
|
2013-10-22 22:46:40 +00:00
|
|
|
kidReflowState.SetComputedHeight(
|
|
|
|
std::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
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
if (aReflowState.ComputedMinHeight() > 0) {
|
|
|
|
kidReflowState.ComputedMinHeight() =
|
|
|
|
std::max(0, aReflowState.ComputedMinHeight() - mLegendSpace);
|
2013-10-22 22:46:40 +00:00
|
|
|
}
|
2008-08-08 05:18:00 +00:00
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
if (aReflowState.ComputedMaxHeight() != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
kidReflowState.ComputedMaxHeight() =
|
|
|
|
std::max(0, aReflowState.ComputedMaxHeight() - mLegendSpace);
|
2008-08-08 05:18:00 +00:00
|
|
|
}
|
|
|
|
|
2013-12-31 13:50:31 +00:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(kidReflowState,
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.mFlags);
|
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
|
|
|
// Reflow the frame
|
2013-12-27 17:59:21 +00:00
|
|
|
NS_ASSERTION(kidReflowState.ComputedPhysicalMargin() == nsMargin(0,0,0,0),
|
2007-11-08 04:04:32 +00:00
|
|
|
"Margins on anonymous fieldset child not supported!");
|
2013-10-22 22:46:40 +00:00
|
|
|
nsPoint pt(border.left, border.top + mLegendSpace);
|
2013-04-17 20:16:14 +00:00
|
|
|
ReflowChild(inner, 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
|
|
|
|
2014-01-17 01:34:44 +00:00
|
|
|
FinishReflowChild(inner, aPresContext, kidDesiredSize,
|
|
|
|
&kidReflowState, 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
|
|
|
|
2014-07-24 08:28:46 +00:00
|
|
|
LogicalRect contentRect(innerWM);
|
2013-04-17 20:16:14 +00:00
|
|
|
if (inner) {
|
2013-10-22 22:46:40 +00:00
|
|
|
// We don't support margins on inner, so our content rect is just the
|
|
|
|
// inner's border-box.
|
2014-07-24 08:28:46 +00:00
|
|
|
contentRect = inner->GetLogicalRect(aReflowState.ComputedWidth());
|
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
|
|
|
|
2013-10-22 22:46:40 +00:00
|
|
|
// Our content rect must fill up the available width
|
2014-07-24 08:28:46 +00:00
|
|
|
if (innerAvailSize.ISize(innerWM) > contentRect.ISize(innerWM)) {
|
|
|
|
contentRect.ISize(innerWM) = innerAvailSize.ISize(innerWM);
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 08:28:46 +00:00
|
|
|
//XXX temporary!
|
|
|
|
nsRect physicalContentRect =
|
|
|
|
contentRect.GetPhysicalRect(innerWM, aReflowState.ComputedWidth());
|
2013-04-17 20:16:14 +00:00
|
|
|
if (legend) {
|
2013-10-22 22:46:40 +00:00
|
|
|
// the legend is postioned horizontally within the inner's content rect
|
|
|
|
// (so that padding on the fieldset affects the legend position).
|
2014-07-24 08:28:46 +00:00
|
|
|
nsRect innerContentRect = physicalContentRect;
|
2013-12-27 17:59:21 +00:00
|
|
|
innerContentRect.Deflate(aReflowState.ComputedPhysicalPadding());
|
2013-10-22 22:46:40 +00:00
|
|
|
// if the inner content rect is larger than the legend, we can align the legend
|
|
|
|
if (innerContentRect.width > mLegendRect.width) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t align = static_cast<nsLegendFrame*>
|
2013-04-17 20:16:14 +00:00
|
|
|
(legend->GetContentInsertionFrame())->GetAlign();
|
2005-01-25 00:06:38 +00:00
|
|
|
|
2013-10-22 22:46:40 +00:00
|
|
|
switch (align) {
|
2005-01-25 00:06:38 +00:00
|
|
|
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
2013-10-22 22:46:40 +00:00
|
|
|
mLegendRect.x = innerContentRect.XMost() - mLegendRect.width;
|
2005-01-25 00:06:38 +00:00
|
|
|
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
|
2013-10-22 22:46:40 +00:00
|
|
|
mLegendRect.x = innerContentRect.width / 2 - mLegendRect.width / 2 + innerContentRect.x;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mLegendRect.x = innerContentRect.x;
|
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
|
2013-10-22 22:46:40 +00:00
|
|
|
mLegendRect.x = innerContentRect.x;
|
|
|
|
innerContentRect.width = mLegendRect.width;
|
2014-07-24 08:28:46 +00:00
|
|
|
physicalContentRect.width = mLegendRect.width +
|
|
|
|
aReflowState.ComputedPhysicalPadding().LeftRight();
|
2000-01-09 02:05:25 +00:00
|
|
|
}
|
2013-11-23 09:48:26 +00:00
|
|
|
|
2005-01-25 00:06:38 +00:00
|
|
|
// place the legend
|
|
|
|
nsRect actualLegendRect(mLegendRect);
|
|
|
|
actualLegendRect.Deflate(legendMargin);
|
2013-11-23 09:48:26 +00:00
|
|
|
nsPoint actualLegendPos(actualLegendRect.TopLeft());
|
2014-08-13 22:42:15 +00:00
|
|
|
legendReflowState->ApplyRelativePositioning(&actualLegendPos);
|
2013-11-23 09:48:26 +00:00
|
|
|
legend->SetPosition(actualLegendPos);
|
|
|
|
nsContainerFrame::PositionFrameView(legend);
|
|
|
|
nsContainerFrame::PositionChildViews(legend);
|
2005-01-25 00:06:38 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 02:00:09 +00:00
|
|
|
// Return our size and our result.
|
2014-07-24 08:30:07 +00:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
nsSize finalSize(physicalContentRect.width + border.LeftRight(),
|
|
|
|
mLegendSpace + border.TopBottom() +
|
|
|
|
(inner ? inner->GetRect().height : 0));
|
|
|
|
aDesiredSize.SetSize(wm, LogicalSize(wm, finalSize));
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2013-04-17 20:16:14 +00:00
|
|
|
if (legend)
|
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, legend);
|
|
|
|
if (inner)
|
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, inner);
|
2013-04-17 20:16:14 +00:00
|
|
|
|
|
|
|
// Merge overflow container bounds and status.
|
|
|
|
aDesiredSize.mOverflowAreas.UnionWith(ocBounds);
|
|
|
|
NS_MergeReflowStatusInto(&aStatus, ocStatus);
|
|
|
|
|
2011-05-11 23:53:34 +00:00
|
|
|
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2005-01-25 00:06:38 +00:00
|
|
|
|
2012-08-29 05:39:31 +00:00
|
|
|
InvalidateFrame();
|
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
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:59 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsFieldSetFrame::SetInitialChildList(ChildListID aListID,
|
|
|
|
nsFrameList& aChildList)
|
|
|
|
{
|
|
|
|
nsContainerFrame::SetInitialChildList(kPrincipalList, aChildList);
|
|
|
|
MOZ_ASSERT(GetInner());
|
|
|
|
}
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsFieldSetFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2013-11-06 07:06:18 +00:00
|
|
|
MOZ_CRASH("nsFieldSetFrame::AppendFrames not supported");
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsFieldSetFrame::InsertFrames(ChildListID aListID,
|
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
|
|
|
{
|
2013-11-06 07:06:18 +00:00
|
|
|
MOZ_CRASH("nsFieldSetFrame::InsertFrames not supported");
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsFieldSetFrame::RemoveFrame(ChildListID aListID,
|
2005-01-25 00:06:38 +00:00
|
|
|
nsIFrame* aOldFrame)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2013-11-06 07:06:18 +00:00
|
|
|
MOZ_CRASH("nsFieldSetFrame::RemoveFrame not supported");
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
2014-05-28 19:36:59 +00:00
|
|
|
#endif
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2002-02-16 01:34:42 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 21:53:44 +00:00
|
|
|
a11y::AccType
|
|
|
|
nsFieldSetFrame::AccessibleType()
|
2002-02-16 01:34:42 +00:00
|
|
|
{
|
2012-12-18 01:25:52 +00:00
|
|
|
return a11y::eHTMLGroupboxType;
|
2002-02-16 01:34:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
2005-01-25 00:06:38 +00:00
|
|
|
|
2009-08-03 14:42:59 +00:00
|
|
|
nscoord
|
2014-06-17 12:19:38 +00:00
|
|
|
nsFieldSetFrame::GetLogicalBaseline(WritingMode aWritingMode) const
|
2009-08-03 14:42:59 +00:00
|
|
|
{
|
2013-04-17 20:16:14 +00:00
|
|
|
nsIFrame* inner = GetInner();
|
2014-06-17 12:19:38 +00:00
|
|
|
return inner->BStart(aWritingMode, GetParent()->GetSize().width) +
|
|
|
|
inner->GetLogicalBaseline(aWritingMode);
|
2009-08-03 14:42:59 +00:00
|
|
|
}
|