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
|
|
|
|
2015-01-06 12:27:56 +03:00
|
|
|
nsLeafBoxFrame::nsLeafBoxFrame(nsStyleContext* aContext)
|
2010-11-30 17:59:46 +03:00
|
|
|
: nsLeafFrame(aContext)
|
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);
|
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::mousethrough)
|
|
|
|
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
|
2014-07-24 21:03:25 +04:00
|
|
|
nsLeafBoxFrame::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;
|
|
|
|
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();
|
|
|
|
LogicalSize minSize(wm, GetMinSize(state));
|
|
|
|
|
|
|
|
// GetMinSize returns border-box size, and we want to return content
|
|
|
|
// inline-size. Since Reflow uses the reflow state's border and padding, we
|
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
|
|
|
// actually just want to subtract what GetMinSize added, which is the
|
|
|
|
// result of GetBorderAndPadding.
|
|
|
|
nsMargin bp;
|
|
|
|
GetBorderAndPadding(bp);
|
|
|
|
|
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
|
2014-07-24 21:03:25 +04:00
|
|
|
nsLeafBoxFrame::GetPrefISize(nsRenderingContext *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();
|
|
|
|
LogicalSize prefSize(wm, GetPrefSize(state));
|
|
|
|
|
|
|
|
// GetPrefSize returns border-box size, and we want to return content
|
|
|
|
// inline-size. Since Reflow uses the reflow state's border and padding, we
|
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
|
|
|
// actually just want to subtract what GetPrefSize added, which is the
|
|
|
|
// result of GetBorderAndPadding.
|
|
|
|
nsMargin bp;
|
|
|
|
GetBorderAndPadding(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
|
2011-04-08 05:04:40 +04:00
|
|
|
nsLeafBoxFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2014-08-24 18:34:51 +04:00
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder,
|
|
|
|
const LogicalSize& aPadding,
|
|
|
|
bool aShrinkWrap)
|
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,
|
2008-01-27 23:24:06 +03:00
|
|
|
aMargin, aBorder, aPadding, aShrinkWrap);
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsLeafBoxFrame::Reflow(nsPresContext* aPresContext,
|
2000-03-31 11:02:06 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
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");
|
2002-03-03 22:53:56 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2002-02-14 03:08:08 +03:00
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
NS_ASSERTION(aReflowState.ComputedWidth() >=0 &&
|
|
|
|
aReflowState.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++);
|
|
|
|
switch (aReflowState.reason) {
|
|
|
|
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;
|
|
|
|
default:printf("<unknown>%d", aReflowState.reason);break;
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
printSize("AW", aReflowState.AvailableWidth());
|
|
|
|
printSize("AH", aReflowState.AvailableHeight());
|
2007-01-26 03:05:12 +03:00
|
|
|
printSize("CW", aReflowState.ComputedWidth());
|
2007-08-02 22:08:05 +04:00
|
|
|
printSize("CH", aReflowState.ComputedHeight());
|
2002-02-14 03:08:08 +03:00
|
|
|
|
|
|
|
printf(" *\n");
|
|
|
|
|
|
|
|
#endif
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
// create the layout state
|
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
|
|
|
nsBoxLayoutState state(aPresContext, aReflowState.rendContext);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.ComputedHeight());
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
nsMargin m;
|
2013-12-27 21:59:21 +04:00
|
|
|
m = aReflowState.ComputedPhysicalBorderPadding();
|
2002-02-14 03:08:08 +03:00
|
|
|
|
|
|
|
//GetBorderAndPadding(m);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// this happens sometimes. So lets handle it gracefully.
|
2007-08-02 22:08:05 +04:00
|
|
|
if (aReflowState.ComputedHeight() == 0) {
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize minSize = GetMinSize(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) {
|
2007-01-08 05:57:59 +03:00
|
|
|
prefSize = GetPrefSize(state);
|
2007-01-08 06:56:06 +03:00
|
|
|
nsSize minSize = GetMinSize(state);
|
|
|
|
nsSize maxSize = GetMaxSize(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
|
2007-01-26 03:05:12 +03:00
|
|
|
if (aReflowState.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
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
if (aReflowState.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...
|
2013-12-27 21:59:21 +04:00
|
|
|
if (computedSize.width > aReflowState.ComputedMaxWidth())
|
|
|
|
computedSize.width = aReflowState.ComputedMaxWidth();
|
2002-02-14 03:08:08 +03:00
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
if (computedSize.width < aReflowState.ComputedMinWidth())
|
|
|
|
computedSize.width = aReflowState.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,
|
2013-12-27 21:59:21 +04:00
|
|
|
aReflowState.ComputedMinHeight(),
|
|
|
|
aReflowState.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
|
|
|
|
|
|
|
SetBounds(state, r);
|
|
|
|
|
|
|
|
// layout our children
|
|
|
|
Layout(state);
|
|
|
|
|
|
|
|
// 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;
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(GetBoxAscent(state));
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2009-04-06 04:31:50 +04:00
|
|
|
// the overflow rect is set in SetBounds() 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) {
|
|
|
|
printf("MW:%d\n", *maxElementWidth);
|
2002-02-14 03:08:08 +03:00
|
|
|
} else {
|
2003-01-09 17:26:32 +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
|
|
|
|
2007-07-04 02:11:28 +04:00
|
|
|
nsIAtom*
|
|
|
|
nsLeafBoxFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::leafBoxFrame;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
nsLeafBoxFrame::GetPrefSize(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2007-01-08 05:57:59 +03:00
|
|
|
return nsBox::GetPrefSize(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
/* virtual */ nsSize
|
|
|
|
nsLeafBoxFrame::GetMinSize(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2007-01-08 05:57:59 +03:00
|
|
|
return nsBox::GetMinSize(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
/* virtual */ nsSize
|
|
|
|
nsLeafBoxFrame::GetMaxSize(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2007-01-08 05:57:59 +03:00
|
|
|
return nsBox::GetMaxSize(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
/* virtual */ nscoord
|
|
|
|
nsLeafBoxFrame::GetFlex(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2007-01-31 19:02:42 +03:00
|
|
|
return nsBox::GetFlex(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
/* virtual */ nscoord
|
|
|
|
nsLeafBoxFrame::GetBoxAscent(nsBoxLayoutState& aState)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2007-01-31 19:02:42 +03:00
|
|
|
return nsBox::GetBoxAscent(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
|
|
|
|
// IsBoxWrapped check.
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLeafBoxFrame::DoLayout(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
return nsBox::DoLayout(aState);
|
|
|
|
}
|