2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 08:38:41 +04:00
|
|
|
|
2014-01-16 06:20:20 +04:00
|
|
|
#include "nsFieldSetFrame.h"
|
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-04-18 00:16:14 +04:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2014-10-20 13:55:48 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsLegendFrame.h"
|
|
|
|
#include "nsCSSRendering.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsIFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2016-02-24 10:01:12 +03:00
|
|
|
#include "mozilla/RestyleManager.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2013-10-23 02:46:40 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2013-11-23 13:48:26 +04:00
|
|
|
#include "mozilla/Maybe.h"
|
1998-10-08 08:38:41 +04:00
|
|
|
|
2012-01-25 05:21:29 +04:00
|
|
|
using namespace mozilla;
|
2014-10-20 13:55:48 +04:00
|
|
|
using namespace mozilla::gfx;
|
2015-02-10 10:27:40 +03:00
|
|
|
using namespace mozilla::image;
|
2012-01-25 05:21:29 +04:00
|
|
|
using namespace mozilla::layout;
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewFieldSetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsFieldSetFrame(aContext);
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFieldSetFrame)
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsFieldSetFrame::nsFieldSetFrame(nsStyleContext* aContext)
|
2011-12-28 00:18:48 +04:00
|
|
|
: nsContainerFrame(aContext)
|
2015-01-19 14:43:58 +03:00
|
|
|
, mLegendRect(GetWritingMode())
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2005-01-25 03:06:38 +03:00
|
|
|
mLegendSpace = 0;
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsFieldSetFrame::GetType() const
|
2002-12-03 19:02:42 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::fieldSetFrame;
|
2002-12-03 19:02:42 +03:00
|
|
|
}
|
|
|
|
|
2014-01-16 06:20:20 +04:00
|
|
|
nsRect
|
|
|
|
nsFieldSetFrame::VisualBorderRectRelativeToSelf() const
|
|
|
|
{
|
2015-01-19 14:43:58 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2016-11-18 11:28:38 +03:00
|
|
|
Side legendSide = wm.PhysicalSide(eLogicalSideBStart);
|
2015-01-19 14:43:58 +03:00
|
|
|
nscoord legendBorder = StyleBorder()->GetComputedBorderWidth(legendSide);
|
|
|
|
LogicalRect r(wm, LogicalPoint(wm, 0, 0), GetLogicalSize(wm));
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = r.Size(wm).GetPhysicalSize(wm);
|
2015-01-19 14:43:58 +03:00
|
|
|
if (legendBorder < mLegendRect.BSize(wm)) {
|
|
|
|
nscoord off = (mLegendRect.BSize(wm) - legendBorder) / 2;
|
|
|
|
r.BStart(wm) += off;
|
|
|
|
r.BSize(wm) -= off;
|
2014-01-16 06:20:20 +04:00
|
|
|
}
|
2015-07-16 12:07:57 +03:00
|
|
|
return r.GetPhysicalRect(wm, containerSize);
|
2014-01-16 06:20:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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 05:29:17 +03:00
|
|
|
class nsDisplayFieldSetBorderBackground : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayFieldSetBorderBackground(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsFieldSetFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayFieldSetBorderBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayFieldSetBorderBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayFieldSetBorderBackground);
|
|
|
|
}
|
|
|
|
#endif
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsRenderingContext* aCtx) override;
|
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override;
|
2013-06-26 20:43:26 +04:00
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsRegion *aInvalidRegion) override;
|
2016-11-29 23:52:30 +03:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) override;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("FieldSetBorderBackground", TYPE_FIELDSET_BORDER_BACKGROUND)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
1999-06-02 01:52:11 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void
|
|
|
|
nsDisplayFieldSetBorderBackground::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2015-02-10 10:27:40 +03:00
|
|
|
DrawResult result = static_cast<nsFieldSetFrame*>(mFrame)->
|
2016-04-28 21:09:06 +03:00
|
|
|
PaintBorder(aBuilder, *aCtx, ToReferenceFrame(), mVisibleRect);
|
2015-02-10 10:27:40 +03:00
|
|
|
|
|
|
|
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDisplayItemGeometry*
|
|
|
|
nsDisplayFieldSetBorderBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
|
|
|
return new nsDisplayItemGenericImageGeometry(this, aBuilder);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2005-01-25 03:06:38 +03:00
|
|
|
|
2013-06-26 20:43:26 +04:00
|
|
|
void
|
|
|
|
nsDisplayFieldSetBorderBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion *aInvalidRegion)
|
|
|
|
{
|
2015-02-10 10:27:40 +03:00
|
|
|
auto geometry =
|
|
|
|
static_cast<const nsDisplayItemGenericImageGeometry*>(aGeometry);
|
|
|
|
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages() &&
|
|
|
|
geometry->ShouldInvalidateToSyncDecodeImages()) {
|
|
|
|
bool snap;
|
|
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
|
|
}
|
2013-06-26 20:43:26 +04:00
|
|
|
|
|
|
|
nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2016-11-29 23:52:30 +03:00
|
|
|
nsRect
|
|
|
|
nsDisplayFieldSetBorderBackground::GetBounds(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap)
|
|
|
|
{
|
|
|
|
// Just go ahead and claim our frame's overflow rect as the bounds, because we
|
|
|
|
// may have border-image-outset or other features that cause borders to extend
|
|
|
|
// outside the border rect. We could try to duplicate all the complexity
|
|
|
|
// nsDisplayBorder has here, but keeping things in sync would be a pain, and
|
|
|
|
// this code is not typically performance-sensitive.
|
|
|
|
*aSnap = false;
|
|
|
|
return Frame()->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03: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-18 00:16:14 +04:00
|
|
|
if (!(GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) &&
|
|
|
|
IsVisibleForPainting(aBuilder)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
if (StyleEffects()->mBoxShadow) {
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayBoxShadowOuter(aBuilder, this));
|
2009-02-10 11:45:13 +03:00
|
|
|
}
|
2009-02-05 11:22:02 +03:00
|
|
|
|
2016-04-28 21:09:06 +03:00
|
|
|
nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
|
|
|
|
aBuilder, this, VisualBorderRectRelativeToSelf(),
|
|
|
|
aLists.BorderBackground(),
|
|
|
|
/* aAllowWillPaintBorderOptimization = */ false);
|
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayFieldSetBorderBackground(aBuilder, this));
|
1999-06-02 01:52:11 +04:00
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplayOutlineUnconditional(aBuilder, aLists);
|
2006-09-19 08:26:20 +04:00
|
|
|
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsFieldSetFrame");
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2013-04-18 00:16:14 +04:00
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
DisplayOverflowContainers(aBuilder, aDirtyRect, aLists);
|
|
|
|
}
|
|
|
|
|
2006-12-11 00:53:53 +03:00
|
|
|
nsDisplayListCollection contentDisplayItems;
|
2013-04-18 00:16:14 +04: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-11 00:53:53 +03:00
|
|
|
// and append them later.
|
2013-04-18 00:16:14 +04:00
|
|
|
BuildDisplayListForChild(aBuilder, inner, aDirtyRect, contentDisplayItems);
|
2006-12-11 00:53:53 +03:00
|
|
|
}
|
2013-04-18 00:16:14 +04:00
|
|
|
if (nsIFrame* legend = GetLegend()) {
|
2007-12-01 11:32:51 +03:00
|
|
|
// The legend's background goes on our BlockBorderBackgrounds list because
|
|
|
|
// it's a block child.
|
|
|
|
nsDisplayListSet set(aLists, aLists.BlockBorderBackgrounds());
|
2013-04-18 00:16:14 +04:00
|
|
|
BuildDisplayListForChild(aBuilder, legend, aDirtyRect, set);
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
2013-04-18 00:16:14 +04: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-11 00:53:53 +03:00
|
|
|
contentDisplayItems.MoveTo(aLists);
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2015-02-10 10:27:40 +03:00
|
|
|
DrawResult
|
2016-04-28 21:09:06 +03:00
|
|
|
nsFieldSetFrame::PaintBorder(
|
2015-10-23 05:54:49 +03:00
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRenderingContext& aRenderingContext,
|
|
|
|
nsPoint aPt,
|
|
|
|
const nsRect& aDirtyRect)
|
2005-02-02 03:32:11 +03:00
|
|
|
{
|
2016-11-29 23:52:30 +03:00
|
|
|
// If the border is smaller than the legend, move the border down
|
|
|
|
// to be centered on the legend. We call VisualBorderRectRelativeToSelf() to
|
|
|
|
// compute the border positioning.
|
2010-09-08 02:20:35 +04:00
|
|
|
// FIXME: This means border-radius clamping is incorrect; we should
|
|
|
|
// override nsIFrame::GetBorderRadii.
|
2016-11-29 23:52:30 +03:00
|
|
|
nsRect rect = VisualBorderRectRelativeToSelf() + aPt;
|
2013-04-18 00:16:14 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2015-10-23 05:54:49 +03:00
|
|
|
PaintBorderFlags borderFlags = aBuilder->ShouldSyncDecodeImages()
|
|
|
|
? PaintBorderFlags::SYNC_DECODE_IMAGES
|
|
|
|
: PaintBorderFlags();
|
|
|
|
|
2016-04-28 21:09:06 +03:00
|
|
|
DrawResult result = DrawResult::SUCCESS;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2009-02-10 11:45:13 +03:00
|
|
|
nsCSSRendering::PaintBoxShadowInner(presContext, aRenderingContext,
|
2016-01-06 03:08:17 +03:00
|
|
|
this, rect);
|
2009-02-10 11:45:13 +03:00
|
|
|
|
2015-01-19 14:43:58 +03:00
|
|
|
if (nsIFrame* legend = GetLegend()) {
|
2016-11-29 23:52:30 +03:00
|
|
|
// We want to avoid drawing our border under the legend, so clip out the
|
|
|
|
// legend while drawing our border. We don't want to use mLegendRect here,
|
|
|
|
// because we do want to draw our border under the legend's inline-start and
|
|
|
|
// -end margins. And we use GetNormalRect(), not GetRect(), because we do
|
|
|
|
// not want relative positioning applied to the legend to change how our
|
|
|
|
// border looks.
|
|
|
|
nsRect legendRect = legend->GetNormalRect() + aPt;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
|
2016-11-29 23:52:30 +03:00
|
|
|
// We set up a clip path which has our rect clockwise and the legend rect
|
|
|
|
// counterclockwise, with FILL_WINDING as the fill rule. That will allow us
|
|
|
|
// to paint within our rect but outside the legend rect. For "our rect" we
|
|
|
|
// use our visual overflow rect (relative to ourselves, so it's not affected
|
|
|
|
// by transforms), because we can have borders sticking outside our border
|
|
|
|
// box (e.g. due to border-image-outset).
|
|
|
|
RefPtr<PathBuilder> pathBuilder =
|
|
|
|
drawTarget->CreatePathBuilder(FillRule::FILL_WINDING);
|
2014-10-20 13:55:48 +04:00
|
|
|
int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
|
2016-11-29 23:52:30 +03:00
|
|
|
AppendRectToPath(pathBuilder,
|
|
|
|
NSRectToSnappedRect(GetVisualOverflowRectRelativeToSelf() + aPt,
|
|
|
|
appUnitsPerDevPixel,
|
|
|
|
*drawTarget),
|
|
|
|
true);
|
|
|
|
AppendRectToPath(pathBuilder,
|
|
|
|
NSRectToSnappedRect(legendRect, appUnitsPerDevPixel,
|
|
|
|
*drawTarget),
|
|
|
|
false);
|
|
|
|
RefPtr<Path> clipPath = pathBuilder->Finish();
|
2014-10-20 13:55:48 +04:00
|
|
|
|
2016-11-29 23:52:30 +03:00
|
|
|
gfxContext* gfx = aRenderingContext.ThebesContext();
|
2015-01-19 14:43:58 +03:00
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
gfx->Save();
|
2016-11-29 23:52:30 +03:00
|
|
|
gfx->Clip(clipPath);
|
2015-10-23 05:54:49 +03:00
|
|
|
result &=
|
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, mStyleContext, borderFlags);
|
2014-10-20 13:55:48 +04:00
|
|
|
gfx->Restore();
|
2006-01-26 05:29:17 +03:00
|
|
|
} else {
|
2015-10-23 05:54:49 +03:00
|
|
|
result &=
|
|
|
|
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, nsRect(aPt, mRect.Size()),
|
|
|
|
mStyleContext, borderFlags);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2015-02-10 10:27:40 +03:00
|
|
|
|
|
|
|
return result;
|
2005-02-02 03:32:11 +03:00
|
|
|
}
|
1999-02-23 06:48:01 +03: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 08:38:33 +03:00
|
|
|
nscoord
|
2014-07-24 21:03:26 +04: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 08:38:33 +03:00
|
|
|
{
|
2008-03-14 23:48:23 +03:00
|
|
|
nscoord legendWidth = 0;
|
|
|
|
nscoord contentWidth = 0;
|
2013-04-18 00:16:14 +04:00
|
|
|
if (nsIFrame* legend = GetLegend()) {
|
2008-03-14 23:48:23 +03:00
|
|
|
legendWidth =
|
2013-04-18 00:16:14 +04:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, legend, aType);
|
2008-03-14 23:48:23 +03: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 08:38:33 +03:00
|
|
|
|
2013-04-18 00:16:14 +04:00
|
|
|
if (nsIFrame* inner = GetInner()) {
|
2013-10-23 02:46:40 +04: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 23:48:23 +03:00
|
|
|
contentWidth =
|
2013-10-23 02:46:40 +04:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, inner, aType,
|
|
|
|
nsLayoutUtils::IGNORE_PADDING);
|
2008-03-14 23:48:23 +03:00
|
|
|
}
|
2013-10-23 02:46:40 +04:00
|
|
|
|
2013-01-15 16:22:03 +04: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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nscoord
|
2014-07-24 21:03:25 +04: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 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
2014-07-24 21:03:26 +04: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 08:38:33 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2014-07-24 21:03:25 +04: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 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
2014-07-24 21:03:26 +04: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 08:38:33 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-08-24 18:34:44 +04:00
|
|
|
/* virtual */
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2005-01-25 03:06:38 +03:00
|
|
|
nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
1999-02-23 06:48:01 +03:00
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 08:38:41 +04:00
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsFieldSetFrame");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2002-01-31 08:09:13 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_PRECONDITION(aReflowInput.ComputedISize() != NS_INTRINSICSIZE,
|
2015-01-15 14:56:51 +03:00
|
|
|
"Should have a precomputed inline-size!");
|
|
|
|
|
2000-01-09 05:05:25 +03:00
|
|
|
// Initialize OUT parameter
|
2003-05-23 00:56:35 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2013-04-18 00:16:14 +04:00
|
|
|
nsOverflowAreas ocBounds;
|
|
|
|
nsReflowStatus ocStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (GetPrevInFlow()) {
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOverflowContainerChildren(aPresContext, aReflowInput, ocBounds, 0,
|
2013-04-18 00:16:14 +04:00
|
|
|
ocStatus);
|
|
|
|
}
|
|
|
|
|
2005-01-25 03:06:38 +03:00
|
|
|
//------------ Handle Incremental Reflow -----------------
|
2013-04-18 00:16:14 +04:00
|
|
|
bool reflowInner;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool reflowLegend;
|
2013-04-18 00:16:14 +04:00
|
|
|
nsIFrame* legend = GetLegend();
|
|
|
|
nsIFrame* inner = GetInner();
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ShouldReflowAllKids()) {
|
2013-04-18 00:16:14 +04: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 08:38:33 +03:00
|
|
|
} else {
|
2013-04-18 00:16:14 +04:00
|
|
|
reflowInner = inner && NS_SUBTREE_DIRTY(inner);
|
|
|
|
reflowLegend = legend && NS_SUBTREE_DIRTY(legend);
|
2005-01-25 03:06:38 +03:00
|
|
|
}
|
2000-01-09 05:05:25 +03:00
|
|
|
|
2009-05-08 05:55:22 +04: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-23 02:46:40 +04: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.
|
2015-01-19 14:43:58 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
WritingMode innerWM = inner ? inner->GetWritingMode() : wm;
|
|
|
|
WritingMode legendWM = legend ? legend->GetWritingMode() : wm;
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalSize innerAvailSize = aReflowInput.ComputedSizeWithPadding(innerWM);
|
|
|
|
LogicalSize legendAvailSize = aReflowInput.ComputedSizeWithPadding(legendWM);
|
2014-07-24 12:28:46 +04:00
|
|
|
innerAvailSize.BSize(innerWM) = legendAvailSize.BSize(legendWM) =
|
|
|
|
NS_UNCONSTRAINEDSIZE;
|
2002-01-31 08:09:13 +03:00
|
|
|
|
2005-01-25 03:06:38 +03:00
|
|
|
// get our border and padding
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalMargin border = aReflowInput.ComputedLogicalBorderPadding() -
|
|
|
|
aReflowInput.ComputedLogicalPadding();
|
2000-01-09 05:05:25 +03:00
|
|
|
|
2015-01-19 14:43:58 +03:00
|
|
|
// Figure out how big the legend is if there is one.
|
2005-01-25 03:06:38 +03:00
|
|
|
// get the legend's margin
|
2015-01-19 14:43:58 +03:00
|
|
|
LogicalMargin legendMargin(wm);
|
2005-01-25 03:06:38 +03:00
|
|
|
// reflow the legend only if needed
|
2016-07-21 13:36:39 +03:00
|
|
|
Maybe<ReflowInput> legendReflowInput;
|
2013-11-23 13:48:26 +04:00
|
|
|
if (legend) {
|
2016-07-21 13:36:39 +03:00
|
|
|
legendReflowInput.emplace(aPresContext, aReflowInput, legend,
|
2014-07-24 12:28:46 +04:00
|
|
|
legendAvailSize);
|
2013-11-23 13:48:26 +04: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 08:38:33 +03:00
|
|
|
if (reflowLegend) {
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOutput legendDesiredSize(aReflowInput);
|
2000-02-11 00:36:28 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
// We'll move the legend to its proper place later, so the position
|
|
|
|
// and containerSize passed here are unimportant.
|
|
|
|
const nsSize dummyContainerSize;
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowChild(legend, aPresContext, legendDesiredSize, *legendReflowInput,
|
2015-07-16 12:07:57 +03:00
|
|
|
wm, LogicalPoint(wm), dummyContainerSize,
|
|
|
|
NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2000-05-16 02:51:42 +04:00
|
|
|
#ifdef NOISY_REFLOW
|
2014-07-24 12:30:07 +04:00
|
|
|
printf(" returned (%d, %d)\n",
|
|
|
|
legendDesiredSize.Width(), legendDesiredSize.Height());
|
2000-05-16 02:51:42 +04: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 08:38:33 +03:00
|
|
|
// figure out the legend's rectangle
|
2015-01-19 14:43:58 +03:00
|
|
|
legendMargin = legend->GetLogicalUsedMargin(wm);
|
|
|
|
mLegendRect =
|
|
|
|
LogicalRect(wm, 0, 0,
|
|
|
|
legendDesiredSize.ISize(wm) + legendMargin.IStartEnd(wm),
|
|
|
|
legendDesiredSize.BSize(wm) + legendMargin.BStartEnd(wm));
|
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 08:38:33 +03:00
|
|
|
nscoord oldSpace = mLegendSpace;
|
|
|
|
mLegendSpace = 0;
|
2015-02-11 12:43:03 +03:00
|
|
|
if (mLegendRect.BSize(wm) > border.BStart(wm)) {
|
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 08:38:33 +03:00
|
|
|
// center the border on the legend
|
2015-02-11 12:43:03 +03:00
|
|
|
mLegendSpace = mLegendRect.BSize(wm) - border.BStart(wm);
|
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 08:38:33 +03:00
|
|
|
} else {
|
2015-01-19 14:43:58 +03:00
|
|
|
mLegendRect.BStart(wm) =
|
2015-02-11 12:43:03 +03:00
|
|
|
(border.BStart(wm) - mLegendRect.BSize(wm)) / 2;
|
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 08:38:33 +03:00
|
|
|
}
|
2000-01-09 05:05:25 +03:00
|
|
|
|
2015-01-19 14:43:58 +03:00
|
|
|
// if the legend space changes then we need to reflow the
|
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 08:38:33 +03:00
|
|
|
// content area as well.
|
2013-04-18 00:16:14 +04: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 08:38:33 +03:00
|
|
|
}
|
2000-05-16 02:51:42 +04:00
|
|
|
|
2014-01-17 05:34:44 +04:00
|
|
|
FinishReflowChild(legend, aPresContext, legendDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
legendReflowInput.ptr(), wm, LogicalPoint(wm),
|
2015-07-16 12:07:57 +03:00
|
|
|
dummyContainerSize, NS_FRAME_NO_MOVE_FRAME);
|
2013-04-18 00:16:14 +04:00
|
|
|
} else if (!legend) {
|
2011-04-19 07:07:23 +04:00
|
|
|
mLegendRect.SetEmpty();
|
2005-01-25 03:06:38 +03:00
|
|
|
mLegendSpace = 0;
|
2008-07-09 19:42:44 +04:00
|
|
|
} else {
|
|
|
|
// mLegendSpace and mLegendRect haven't changed, but we need
|
|
|
|
// the used margin when placing the legend.
|
2015-01-19 14:43:58 +03:00
|
|
|
legendMargin = legend->GetLogicalUsedMargin(wm);
|
2008-07-09 19:42:44 +04:00
|
|
|
}
|
2000-01-09 05:05:25 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
// This containerSize is incomplete as yet: it does not include the size
|
|
|
|
// of the |inner| frame itself.
|
|
|
|
nsSize containerSize = (LogicalSize(wm, 0, mLegendSpace) +
|
|
|
|
border.Size(wm)).GetPhysicalSize(wm);
|
2005-01-25 03:06:38 +03:00
|
|
|
// reflow the content frame only if needed
|
2013-04-18 00:16:14 +04:00
|
|
|
if (reflowInner) {
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput kidReflowInput(aPresContext, aReflowInput, inner,
|
2015-06-04 13:43:02 +03:00
|
|
|
innerAvailSize, nullptr,
|
2016-07-21 13:36:35 +03:00
|
|
|
ReflowInput::CALLER_WILL_INIT);
|
2013-10-23 02:46:40 +04:00
|
|
|
// Override computed padding, in case it's percentage padding
|
2016-07-21 13:36:39 +03:00
|
|
|
kidReflowInput.Init(aPresContext, nullptr, nullptr,
|
|
|
|
&aReflowInput.ComputedPhysicalPadding());
|
2007-11-08 07:04:32 +03: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).
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ComputedBSize() != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
kidReflowInput.SetComputedBSize(
|
|
|
|
std::max(0, aReflowInput.ComputedBSize() - mLegendSpace));
|
2007-11-08 07:04:32 +03: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 08:38:33 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ComputedMinBSize() > 0) {
|
|
|
|
kidReflowInput.ComputedMinBSize() =
|
|
|
|
std::max(0, aReflowInput.ComputedMinBSize() - mLegendSpace);
|
2013-10-23 02:46:40 +04:00
|
|
|
}
|
2008-08-08 09:18:00 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ComputedMaxBSize() != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
kidReflowInput.ComputedMaxBSize() =
|
|
|
|
std::max(0, aReflowInput.ComputedMaxBSize() - mLegendSpace);
|
2008-08-08 09:18:00 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOutput kidDesiredSize(kidReflowInput,
|
2013-12-27 21:59:52 +04: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 08:38:33 +03:00
|
|
|
// Reflow the frame
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(kidReflowInput.ComputedPhysicalMargin() == nsMargin(0,0,0,0),
|
2007-11-08 07:04:32 +03:00
|
|
|
"Margins on anonymous fieldset child not supported!");
|
2015-02-11 12:43:03 +03:00
|
|
|
LogicalPoint pt(wm, border.IStart(wm), border.BStart(wm) + mLegendSpace);
|
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
// We don't know the correct containerSize until we have reflowed |inner|,
|
|
|
|
// so we use a dummy value for now; FinishReflowChild will fix the position
|
|
|
|
// if necessary.
|
|
|
|
const nsSize dummyContainerSize;
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowChild(inner, aPresContext, kidDesiredSize, kidReflowInput,
|
2015-07-16 12:07:57 +03:00
|
|
|
wm, pt, dummyContainerSize, 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-10 01:02:40 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
// Update containerSize to account for size of the inner frame, so that
|
|
|
|
// FinishReflowChild can position it correctly.
|
|
|
|
containerSize += kidDesiredSize.PhysicalSize();
|
2014-01-17 05:34:44 +04:00
|
|
|
FinishReflowChild(inner, aPresContext, kidDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
&kidReflowInput, wm, pt, containerSize, 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 08:38:33 +03:00
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus);
|
2015-07-16 12:07:57 +03:00
|
|
|
} else if (inner) {
|
|
|
|
// |inner| didn't need to be reflowed but we do need to include its size
|
|
|
|
// in containerSize.
|
|
|
|
containerSize += inner->GetSize();
|
2015-02-11 12:43:03 +03:00
|
|
|
}
|
2015-01-19 14:43:58 +03:00
|
|
|
|
|
|
|
LogicalRect contentRect(wm);
|
2013-04-18 00:16:14 +04:00
|
|
|
if (inner) {
|
2013-10-23 02:46:40 +04:00
|
|
|
// We don't support margins on inner, so our content rect is just the
|
2015-07-16 12:07:57 +03:00
|
|
|
// inner's border-box. (We don't really care about container size at this
|
|
|
|
// point, as we'll figure out the actual positioning later.)
|
|
|
|
contentRect = inner->GetLogicalRect(wm, containerSize);
|
2005-01-25 03:06:38 +03: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-10 01:02:40 +03:00
|
|
|
|
2013-10-23 02:46:40 +04:00
|
|
|
// Our content rect must fill up the available width
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalSize availSize = aReflowInput.ComputedSizeWithPadding(wm);
|
2015-01-19 14:43:58 +03:00
|
|
|
if (availSize.ISize(wm) > contentRect.ISize(wm)) {
|
|
|
|
contentRect.ISize(wm) = innerAvailSize.ISize(wm);
|
2005-01-25 03:06:38 +03:00
|
|
|
}
|
|
|
|
|
2013-04-18 00:16:14 +04:00
|
|
|
if (legend) {
|
2015-01-19 14:43:58 +03:00
|
|
|
// The legend is positioned inline-wards within the inner's content rect
|
2013-10-23 02:46:40 +04:00
|
|
|
// (so that padding on the fieldset affects the legend position).
|
2015-01-19 14:43:58 +03:00
|
|
|
LogicalRect innerContentRect = contentRect;
|
2016-07-21 13:36:39 +03:00
|
|
|
innerContentRect.Deflate(wm, aReflowInput.ComputedLogicalPadding());
|
2015-01-19 14:43:58 +03:00
|
|
|
// If the inner content rect is larger than the legend, we can align the
|
|
|
|
// legend.
|
|
|
|
if (innerContentRect.ISize(wm) > mLegendRect.ISize(wm)) {
|
2016-05-18 14:49:33 +03:00
|
|
|
// NOTE legend @align values are: left/right/center/top/bottom.
|
|
|
|
// GetLogicalAlign converts left/right to start/end for the given WM.
|
|
|
|
// @see HTMLLegendElement::ParseAttribute, nsLegendFrame::GetLogicalAlign
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t align = static_cast<nsLegendFrame*>
|
2016-05-18 14:49:33 +03:00
|
|
|
(legend->GetContentInsertionFrame())->GetLogicalAlign(wm);
|
2013-10-23 02:46:40 +04:00
|
|
|
switch (align) {
|
2015-01-19 14:43:58 +03:00
|
|
|
case NS_STYLE_TEXT_ALIGN_END:
|
|
|
|
mLegendRect.IStart(wm) =
|
|
|
|
innerContentRect.IEnd(wm) - mLegendRect.ISize(wm);
|
2005-01-25 03:06:38 +03:00
|
|
|
break;
|
|
|
|
case NS_STYLE_TEXT_ALIGN_CENTER:
|
2007-02-07 10:46:44 +03:00
|
|
|
// Note: rounding removed; there doesn't seem to be any need
|
2015-01-19 14:43:58 +03:00
|
|
|
mLegendRect.IStart(wm) = innerContentRect.IStart(wm) +
|
|
|
|
(innerContentRect.ISize(wm) - mLegendRect.ISize(wm)) / 2;
|
2013-10-23 02:46:40 +04:00
|
|
|
break;
|
2016-05-18 14:49:33 +03:00
|
|
|
case NS_STYLE_TEXT_ALIGN_START:
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_TOP:
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
2015-01-19 14:43:58 +03:00
|
|
|
mLegendRect.IStart(wm) = innerContentRect.IStart(wm);
|
2005-01-25 03:06:38 +03:00
|
|
|
break;
|
2016-05-18 14:49:33 +03:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unexpected GetLogicalAlign value");
|
2005-01-25 03:06:38 +03:00
|
|
|
}
|
2000-01-09 05:05:25 +03:00
|
|
|
} else {
|
2016-11-29 23:52:55 +03:00
|
|
|
// otherwise just start-align it.
|
2015-01-19 14:43:58 +03:00
|
|
|
mLegendRect.IStart(wm) = innerContentRect.IStart(wm);
|
2000-01-09 05:05:25 +03:00
|
|
|
}
|
2013-11-23 13:48:26 +04:00
|
|
|
|
2005-01-25 03:06:38 +03:00
|
|
|
// place the legend
|
2015-01-19 14:43:58 +03:00
|
|
|
LogicalRect actualLegendRect = mLegendRect;
|
|
|
|
actualLegendRect.Deflate(wm, legendMargin);
|
|
|
|
LogicalPoint actualLegendPos(actualLegendRect.Origin(wm));
|
2015-02-23 00:48:28 +03:00
|
|
|
|
|
|
|
// Note that legend's writing mode may be different from the fieldset's,
|
|
|
|
// so we need to convert offsets before applying them to it (bug 1134534).
|
|
|
|
LogicalMargin offsets =
|
2016-07-21 13:36:39 +03:00
|
|
|
legendReflowInput->ComputedLogicalOffsets().
|
|
|
|
ConvertTo(wm, legendReflowInput->GetWritingMode());
|
2016-07-21 13:36:35 +03:00
|
|
|
ReflowInput::ApplyRelativePositioning(legend, wm, offsets,
|
2015-02-23 00:48:28 +03:00
|
|
|
&actualLegendPos,
|
2015-07-16 12:07:57 +03:00
|
|
|
containerSize);
|
2015-02-23 00:48:28 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
legend->SetPosition(wm, actualLegendPos, containerSize);
|
2013-11-23 13:48:26 +04:00
|
|
|
nsContainerFrame::PositionFrameView(legend);
|
|
|
|
nsContainerFrame::PositionChildViews(legend);
|
2005-01-25 03:06:38 +03:00
|
|
|
}
|
|
|
|
|
2014-02-15 06:00:09 +04:00
|
|
|
// Return our size and our result.
|
2015-02-11 12:43:03 +03:00
|
|
|
LogicalSize finalSize(wm, contentRect.ISize(wm) + border.IStartEnd(wm),
|
|
|
|
mLegendSpace + border.BStartEnd(wm) +
|
|
|
|
(inner ? inner->BSize(wm) : 0));
|
2015-01-19 14:43:58 +03:00
|
|
|
aDesiredSize.SetSize(wm, finalSize);
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2015-01-19 14:43:58 +03:00
|
|
|
|
|
|
|
if (legend) {
|
2013-04-18 00:16:14 +04:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, legend);
|
2015-01-19 14:43:58 +03:00
|
|
|
}
|
|
|
|
if (inner) {
|
2013-04-18 00:16:14 +04:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, inner);
|
2015-01-19 14:43:58 +03:00
|
|
|
}
|
2013-04-18 00:16:14 +04:00
|
|
|
|
|
|
|
// Merge overflow container bounds and status.
|
|
|
|
aDesiredSize.mOverflowAreas.UnionWith(ocBounds);
|
|
|
|
NS_MergeReflowStatusInto(&aStatus, ocStatus);
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
2005-01-25 03:06:38 +03:00
|
|
|
|
2012-08-29 09:39:31 +04:00
|
|
|
InvalidateFrame();
|
2005-01-25 03:06:38 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1998-10-08 08:38:41 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:59 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsFieldSetFrame::SetInitialChildList(ChildListID aListID,
|
|
|
|
nsFrameList& aChildList)
|
|
|
|
{
|
2016-01-28 02:11:00 +03:00
|
|
|
nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
|
|
|
MOZ_ASSERT(aListID != kPrincipalList || GetInner(),
|
|
|
|
"Setting principal child list should populate our inner frame");
|
2014-05-28 23:36:59 +04:00
|
|
|
}
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsFieldSetFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2013-11-06 11:06:18 +04:00
|
|
|
MOZ_CRASH("nsFieldSetFrame::AppendFrames not supported");
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsFieldSetFrame::InsertFrames(ChildListID aListID,
|
2005-01-25 03:06:38 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2013-11-06 11:06:18 +04:00
|
|
|
MOZ_CRASH("nsFieldSetFrame::InsertFrames not supported");
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsFieldSetFrame::RemoveFrame(ChildListID aListID,
|
2005-01-25 03:06:38 +03:00
|
|
|
nsIFrame* aOldFrame)
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2013-11-06 11:06:18 +04:00
|
|
|
MOZ_CRASH("nsFieldSetFrame::RemoveFrame not supported");
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
2014-05-28 23:36:59 +04:00
|
|
|
#endif
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2002-02-16 04:34:42 +03:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-29 01:53:44 +04:00
|
|
|
a11y::AccType
|
|
|
|
nsFieldSetFrame::AccessibleType()
|
2002-02-16 04:34:42 +03:00
|
|
|
{
|
2012-12-18 05:25:52 +04:00
|
|
|
return a11y::eHTMLGroupboxType;
|
2002-02-16 04:34:42 +03:00
|
|
|
}
|
|
|
|
#endif
|
2005-01-25 03:06:38 +03:00
|
|
|
|
2009-08-03 18:42:59 +04:00
|
|
|
nscoord
|
2014-06-17 16:19:38 +04:00
|
|
|
nsFieldSetFrame::GetLogicalBaseline(WritingMode aWritingMode) const
|
2009-08-03 18:42:59 +04:00
|
|
|
{
|
2013-04-18 00:16:14 +04:00
|
|
|
nsIFrame* inner = GetInner();
|
2015-07-16 12:07:57 +03:00
|
|
|
return inner->BStart(aWritingMode, GetParent()->GetSize()) +
|
2014-06-17 16:19:38 +04:00
|
|
|
inner->GetLogicalBaseline(aWritingMode);
|
2009-08-03 18:42:59 +04:00
|
|
|
}
|