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
|
|
|
/* -*- Mode: C++; tab-width: 8; 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/. */
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsLeafBoxFrame.h"
|
|
|
|
#include "nsBoxFrame.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsIContent.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-06-22 04:48:49 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsViewManager.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2000-06-22 04:48:49 +04:00
|
|
|
|
2014-08-24 18:34:51 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
//
|
2005-10-27 01:46:39 +04:00
|
|
|
// NS_NewLeafBoxFrame
|
2000-03-31 11:02:06 +04:00
|
|
|
//
|
2005-10-27 01:46:39 +04:00
|
|
|
// Creates a new Toolbar frame and returns it
|
2000-03-31 11:02:06 +04:00
|
|
|
//
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewLeafBoxFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2015-01-06 12:27:56 +03:00
|
|
|
return new (aPresShell) nsLeafBoxFrame(aContext);
|
2009-09-12 20:49:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsLeafBoxFrame)
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2002-09-10 01:32:33 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-05-15 08:12:31 +04:00
|
|
|
void
|
|
|
|
nsLeafBoxFrame::GetBoxName(nsAutoString& aName)
|
|
|
|
{
|
|
|
|
GetFrameName(aName);
|
|
|
|
}
|
2002-09-10 01:32:33 +04:00
|
|
|
#endif
|
2000-05-15 08:12:31 +04:00
|
|
|
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
/**
|
|
|
|
* Initialize us. This is a good time to get the alignment of the box
|
|
|
|
*/
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsLeafBoxFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2013-03-20 05:47:48 +04:00
|
|
|
nsLeafFrame::Init(aContent, aParent, aPrevInFlow);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2012-04-17 02:32:12 +04:00
|
|
|
if (GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER) {
|
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
|
|
}
|
|
|
|
|
2007-06-19 03:22:46 +04:00
|
|
|
UpdateMouseThrough();
|
2001-12-04 02:41:13 +03:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLeafBoxFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-06-19 03:22:46 +04:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2007-06-19 03:22:46 +04:00
|
|
|
{
|
|
|
|
nsresult rv = nsLeafFrame::AttributeChanged(aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
if (aAttribute == nsGkAtoms::mousethrough)
|
2007-06-19 03:22:46 +04:00
|
|
|
UpdateMouseThrough();
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsLeafBoxFrame::UpdateMouseThrough()
|
|
|
|
{
|
|
|
|
if (mContent) {
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::never, &nsGkAtoms::always, nullptr};
|
2007-06-19 03:22:46 +04:00
|
|
|
switch (mContent->FindAttrValueIn(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::mousethrough,
|
|
|
|
strings, eCaseMatters)) {
|
2010-11-30 17:59:46 +03:00
|
|
|
case 0: AddStateBits(NS_FRAME_MOUSE_THROUGH_NEVER); break;
|
|
|
|
case 1: AddStateBits(NS_FRAME_MOUSE_THROUGH_ALWAYS); break;
|
|
|
|
case 2: {
|
|
|
|
RemoveStateBits(NS_FRAME_MOUSE_THROUGH_ALWAYS);
|
|
|
|
RemoveStateBits(NS_FRAME_MOUSE_THROUGH_NEVER);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-19 03:22:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsLeafBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
// REVIEW: GetFrameForPoint used to not report events for the background
|
|
|
|
// layer, whereas this code will put an event receiver for this frame in the
|
|
|
|
// BlockBorderBackground() list. But I don't see any need to preserve
|
|
|
|
// that anomalous behaviour. The important thing I'm preserving is that
|
|
|
|
// leaf boxes continue to receive events in the foreground layer.
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
if (!aBuilder->IsForEventDelivery() || !IsVisibleForPainting(aBuilder))
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayEventReceiver(aBuilder, this));
|
2000-03-31 11:02:06 +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
|
|
|
/* virtual */ nscoord
|
2017-06-09 22:14:53 +03:00
|
|
|
nsLeafBoxFrame::GetMinISize(gfxContext *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;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext(), 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
|
|
|
|
2015-03-03 19:38:49 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2016-04-21 07:28:31 +03:00
|
|
|
LogicalSize minSize(wm, GetXULMinSize(state));
|
2015-03-03 19:38:49 +03:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
// GetXULMinSize returns border-box size, and we want to return content
|
2015-03-03 19:38:49 +03:00
|
|
|
// inline-size. Since Reflow uses the reflow state's border and padding, we
|
2016-04-21 07:28:31 +03:00
|
|
|
// actually just want to subtract what GetXULMinSize added, which is the
|
2016-04-21 07:28:32 +03:00
|
|
|
// result of GetXULBorderAndPadding.
|
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
|
|
|
nsMargin bp;
|
2016-04-21 07:28:32 +03:00
|
|
|
GetXULBorderAndPadding(bp);
|
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
|
|
|
|
2015-03-03 19:38:49 +03:00
|
|
|
result = minSize.ISize(wm) - LogicalMargin(wm, bp).IStartEnd(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
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2017-06-09 22:14:53 +03:00
|
|
|
nsLeafBoxFrame::GetPrefISize(gfxContext *aRenderingContext)
|
2000-03-31 11:02:06 +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
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2015-03-03 19:38:49 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2016-04-21 07:28:31 +03:00
|
|
|
LogicalSize prefSize(wm, GetXULPrefSize(state));
|
2015-03-03 19:38:49 +03:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
// GetXULPrefSize returns border-box size, and we want to return content
|
2015-03-03 19:38:49 +03:00
|
|
|
// inline-size. Since Reflow uses the reflow state's border and padding, we
|
2016-04-21 07:28:31 +03:00
|
|
|
// actually just want to subtract what GetXULPrefSize added, which is the
|
2016-04-21 07:28:32 +03:00
|
|
|
// result of GetXULBorderAndPadding.
|
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
|
|
|
nsMargin bp;
|
2016-04-21 07:28:32 +03:00
|
|
|
GetXULBorderAndPadding(bp);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2015-03-03 19:38:49 +03:00
|
|
|
result = prefSize.ISize(wm) - LogicalMargin(wm, bp).IStartEnd(wm);
|
2000-03-31 11:02:06 +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
|
|
|
return result;
|
2000-03-31 11:02:06 +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
|
|
|
nscoord
|
2014-07-24 21:03:26 +04:00
|
|
|
nsLeafBoxFrame::GetIntrinsicISize()
|
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
|
|
|
{
|
|
|
|
// No intrinsic width
|
|
|
|
return 0;
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2014-08-24 18:34:51 +04:00
|
|
|
LogicalSize
|
2017-06-09 22:14:53 +03:00
|
|
|
nsLeafBoxFrame::ComputeAutoSize(gfxContext* aRenderingContext,
|
2016-11-05 04:57:06 +03:00
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder,
|
|
|
|
const LogicalSize& aPadding,
|
|
|
|
ComputeSizeFlags aFlags)
|
2008-01-27 23:24:06 +03:00
|
|
|
{
|
|
|
|
// Important: NOT calling our direct superclass here!
|
2014-08-24 18:34:51 +04:00
|
|
|
return nsFrame::ComputeAutoSize(aRenderingContext, aWM,
|
|
|
|
aCBSize, aAvailableISize,
|
2016-11-05 04:57:06 +03:00
|
|
|
aMargin, aBorder, aPadding, aFlags);
|
2008-01-27 23:24:06 +03:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2000-03-31 11:02:06 +04:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2002-02-14 03:08:08 +03:00
|
|
|
// This is mostly a copy of nsBoxFrame::Reflow().
|
|
|
|
// We aren't able to share an implementation because of the frame
|
|
|
|
// class hierarchy. If you make changes here, please keep
|
|
|
|
// nsBoxFrame::Reflow in sync.
|
|
|
|
|
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("nsLeafBoxFrame");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2002-02-14 03:08:08 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(aReflowInput.ComputedWidth() >=0 &&
|
|
|
|
aReflowInput.ComputedHeight() >= 0, "Computed Size < 0");
|
2002-02-14 03:08:08 +03:00
|
|
|
|
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
printf("\n-------------Starting LeafBoxFrame Reflow ----------------------------\n");
|
|
|
|
printf("%p ** nsLBF::Reflow %d R: ", this, myCounter++);
|
2016-07-21 13:36:39 +03:00
|
|
|
switch (aReflowInput.reason) {
|
2002-02-14 03:08:08 +03:00
|
|
|
case eReflowReason_Initial:
|
|
|
|
printf("Ini");break;
|
|
|
|
case eReflowReason_Incremental:
|
|
|
|
printf("Inc");break;
|
|
|
|
case eReflowReason_Resize:
|
|
|
|
printf("Rsz");break;
|
|
|
|
case eReflowReason_StyleChange:
|
|
|
|
printf("Sty");break;
|
|
|
|
case eReflowReason_Dirty:
|
|
|
|
printf("Drt ");
|
|
|
|
break;
|
2016-07-21 13:36:39 +03:00
|
|
|
default:printf("<unknown>%d", aReflowInput.reason);break;
|
2002-02-14 03:08:08 +03:00
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
printSize("AW", aReflowInput.AvailableWidth());
|
|
|
|
printSize("AH", aReflowInput.AvailableHeight());
|
|
|
|
printSize("CW", aReflowInput.ComputedWidth());
|
|
|
|
printSize("CH", aReflowInput.ComputedHeight());
|
2002-02-14 03:08:08 +03:00
|
|
|
|
|
|
|
printf(" *\n");
|
|
|
|
|
|
|
|
#endif
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2017-02-14 12:55:48 +03:00
|
|
|
aStatus.Reset();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// create the layout state
|
2016-07-21 13:36:39 +03:00
|
|
|
nsBoxLayoutState state(aPresContext, aReflowInput.mRenderingContext);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsSize computedSize(aReflowInput.ComputedWidth(),aReflowInput.ComputedHeight());
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
nsMargin m;
|
2016-07-21 13:36:39 +03:00
|
|
|
m = aReflowInput.ComputedPhysicalBorderPadding();
|
2002-02-14 03:08:08 +03:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
//GetXULBorderAndPadding(m);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// this happens sometimes. So lets handle it gracefully.
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ComputedHeight() == 0) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize minSize = GetXULMinSize(state);
|
2000-03-31 11:02:06 +04:00
|
|
|
computedSize.height = minSize.height - m.top - m.bottom;
|
|
|
|
}
|
|
|
|
|
2002-02-14 03:08:08 +03:00
|
|
|
nsSize prefSize(0,0);
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if we are told to layout intrinic then get our preferred size.
|
|
|
|
if (computedSize.width == NS_INTRINSICSIZE || computedSize.height == NS_INTRINSICSIZE) {
|
2016-04-21 07:28:31 +03:00
|
|
|
prefSize = GetXULPrefSize(state);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize minSize = GetXULMinSize(state);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize maxSize = GetXULMaxSize(state);
|
2008-01-05 08:49:44 +03:00
|
|
|
prefSize = BoundsCheck(minSize, prefSize, maxSize);
|
2002-02-14 03:08:08 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2002-02-14 03:08:08 +03:00
|
|
|
// get our desiredSize
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ComputedWidth() == NS_INTRINSICSIZE) {
|
2002-02-14 03:08:08 +03:00
|
|
|
computedSize.width = prefSize.width;
|
|
|
|
} else {
|
|
|
|
computedSize.width += m.left + m.right;
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.ComputedHeight() == NS_INTRINSICSIZE) {
|
2002-02-14 03:08:08 +03:00
|
|
|
computedSize.height = prefSize.height;
|
|
|
|
} else {
|
|
|
|
computedSize.height += m.top + m.bottom;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2002-02-14 03:08:08 +03:00
|
|
|
// handle reflow state min and max sizes
|
2012-08-27 23:46:23 +04:00
|
|
|
// XXXbz the width handling here seems to be wrong, since
|
|
|
|
// mComputedMin/MaxWidth is a content-box size, whole
|
|
|
|
// computedSize.width is a border-box size...
|
2016-07-21 13:36:39 +03:00
|
|
|
if (computedSize.width > aReflowInput.ComputedMaxWidth())
|
|
|
|
computedSize.width = aReflowInput.ComputedMaxWidth();
|
2002-02-14 03:08:08 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
if (computedSize.width < aReflowInput.ComputedMinWidth())
|
|
|
|
computedSize.width = aReflowInput.ComputedMinWidth();
|
2002-02-14 03:08:08 +03:00
|
|
|
|
2012-08-27 23:46:23 +04:00
|
|
|
// Now adjust computedSize.height for our min and max computed
|
|
|
|
// height. The only problem is that those are content-box sizes,
|
|
|
|
// while computedSize.height is a border-box size. So subtract off
|
|
|
|
// m.TopBottom() before adjusting, then readd it.
|
2013-01-15 16:22:03 +04:00
|
|
|
computedSize.height = std::max(0, computedSize.height - m.TopBottom());
|
2012-08-27 23:46:23 +04:00
|
|
|
computedSize.height = NS_CSS_MINMAX(computedSize.height,
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.ComputedMinHeight(),
|
|
|
|
aReflowInput.ComputedMaxHeight());
|
2012-08-27 23:46:23 +04:00
|
|
|
computedSize.height += m.TopBottom();
|
2002-02-14 03:08:08 +03:00
|
|
|
|
|
|
|
nsRect r(mRect.x, mRect.y, computedSize.width, computedSize.height);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
SetXULBounds(state, r);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// layout our children
|
2016-04-21 07:28:32 +03:00
|
|
|
XULLayout(state);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// ok our child could have gotten bigger. So lets get its bounds
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = mRect.width;
|
|
|
|
aDesiredSize.Height() = mRect.height;
|
2016-04-21 07:28:32 +03:00
|
|
|
aDesiredSize.SetBlockStartAscent(GetXULBoxAscent(state));
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
// the overflow rect is set in SetXULBounds() above
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.mOverflowAreas = GetOverflowAreas();
|
2004-07-16 20:56:21 +04:00
|
|
|
|
2002-02-14 03:08:08 +03:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
{
|
2013-12-27 21:59:52 +04:00
|
|
|
printf("%p ** nsLBF(done) W:%d H:%d ", this, aDesiredSize.Width(), aDesiredSize.Height());
|
2002-02-14 03:08:08 +03:00
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (maxElementWidth) {
|
2017-07-06 15:00:35 +03:00
|
|
|
printf("MW:%d\n", *maxElementWidth);
|
2002-02-14 03:08:08 +03:00
|
|
|
} else {
|
2017-07-06 15:00:35 +03:00
|
|
|
printf("MW:?\n");
|
2002-02-14 03:08:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsLeafBoxFrame::GetFrameName(nsAString& aResult) const
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("LeafBox"), aResult);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2001-09-15 04:45:54 +04:00
|
|
|
#endif
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2009-08-05 05:38:10 +04:00
|
|
|
nsLeafBoxFrame::CharacterDataChanged(CharacterDataChangeInfo* aInfo)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2014-07-24 21:03:26 +04:00
|
|
|
MarkIntrinsicISizesDirty();
|
2009-08-05 05:38:10 +04:00
|
|
|
return nsLeafFrame::CharacterDataChanged(aInfo);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
/* virtual */ nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsLeafBoxFrame::GetXULPrefSize(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2016-04-21 07:28:31 +03:00
|
|
|
return nsBox::GetXULPrefSize(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
/* virtual */ nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsLeafBoxFrame::GetXULMinSize(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2016-04-21 07:28:31 +03:00
|
|
|
return nsBox::GetXULMinSize(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
/* virtual */ nsSize
|
2016-04-21 07:28:31 +03:00
|
|
|
nsLeafBoxFrame::GetXULMaxSize(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2016-04-21 07:28:31 +03:00
|
|
|
return nsBox::GetXULMaxSize(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
/* virtual */ nscoord
|
2016-04-21 07:28:31 +03:00
|
|
|
nsLeafBoxFrame::GetXULFlex()
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2016-04-21 07:28:31 +03:00
|
|
|
return nsBox::GetXULFlex();
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
/* virtual */ nscoord
|
2016-04-21 07:28:32 +03:00
|
|
|
nsLeafBoxFrame::GetXULBoxAscent(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2016-04-21 07:28:32 +03:00
|
|
|
return nsBox::GetXULBoxAscent(aState);
|
2004-09-28 22:37:50 +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
|
|
|
/* virtual */ void
|
2014-07-24 21:03:26 +04:00
|
|
|
nsLeafBoxFrame::MarkIntrinsicISizesDirty()
|
2004-09-28 22:37:50 +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
|
|
|
// Don't call base class method, since everything it does is within an
|
2016-04-21 07:28:30 +03:00
|
|
|
// IsXULBoxWrapped check.
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-04-21 07:28:35 +03:00
|
|
|
nsLeafBoxFrame::DoXULLayout(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2016-04-21 07:28:35 +03:00
|
|
|
return nsBox::DoXULLayout(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|