2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* base class for rendering objects that do not have child lists */
|
|
|
|
|
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
|
2014-07-24 01:30:07 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLeafFrame::~nsLeafFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsLeafFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* virtual */ nscoord
|
2014-07-24 10:03:25 -07:00
|
|
|
nsLeafFrame::GetMinISize(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
2014-07-24 10:03:26 -07:00
|
|
|
result = GetIntrinsicISize();
|
2007-03-22 10:30:00 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2014-07-24 10:03:25 -07:00
|
|
|
nsLeafFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
2014-07-24 10:03:26 -07:00
|
|
|
result = GetIntrinsicISize();
|
2007-03-22 10:30:00 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-08-24 07:34:51 -07:00
|
|
|
/* virtual */
|
|
|
|
LogicalSize
|
2011-04-07 18:04:40 -07:00
|
|
|
nsLeafFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2014-08-24 07:34:51 -07:00
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder,
|
|
|
|
const LogicalSize& aPadding,
|
|
|
|
bool aShrinkWrap)
|
2008-01-27 12:24:06 -08:00
|
|
|
{
|
2014-08-24 07:34:51 -07:00
|
|
|
const WritingMode wm = GetWritingMode();
|
|
|
|
LogicalSize result(wm, GetIntrinsicISize(), GetIntrinsicBSize());
|
|
|
|
return result.ConvertTo(aWM, wm);
|
2008-01-27 12:24:06 -08:00
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLeafFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsLeafFrame");
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
|
|
|
("enter nsLeafFrame::Reflow: aMaxSize=%d,%d",
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
|
|
|
|
|
2008-01-20 18:03:08 -08:00
|
|
|
DoReflow(aPresContext, aMetrics, aReflowState, aStatus);
|
|
|
|
|
|
|
|
FinishAndStoreOverflow(&aMetrics);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-12 17:47:53 -07:00
|
|
|
void
|
2008-01-20 18:03:08 -08:00
|
|
|
nsLeafFrame::DoReflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2008-01-27 12:24:06 -08:00
|
|
|
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"Shouldn't have unconstrained stuff here "
|
|
|
|
"Thanks to the rules of reflow");
|
|
|
|
NS_ASSERTION(NS_INTRINSICSIZE != aReflowState.ComputedHeight(),
|
|
|
|
"Shouldn't have unconstrained stuff here "
|
2014-07-24 01:30:07 -07:00
|
|
|
"thanks to ComputeAutoSize");
|
|
|
|
|
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
LogicalSize finalSize(wm,
|
|
|
|
aReflowState.ComputedISize(),
|
|
|
|
aReflowState.ComputedBSize());
|
|
|
|
|
|
|
|
AddBordersAndPadding(aReflowState, finalSize);
|
|
|
|
aMetrics.SetSize(wm, finalSize);
|
2008-01-27 12:24:06 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
2008-01-20 18:03:08 -08:00
|
|
|
("exit nsLeafFrame::DoReflow: size=%d,%d",
|
2014-07-24 01:30:07 -07:00
|
|
|
aMetrics.ISize(wm), aMetrics.BSize(wm)));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
|
|
|
|
2010-10-06 21:25:46 -07:00
|
|
|
aMetrics.SetOverflowAreasToDesiredBounds();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2014-07-24 10:03:26 -07:00
|
|
|
nsLeafFrame::GetIntrinsicBSize()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-01-27 12:24:06 -08:00
|
|
|
NS_NOTREACHED("Someone didn't override Reflow or ComputeAutoSize");
|
2007-03-22 10:30:00 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX how should border&padding effect baseline alignment?
|
|
|
|
// => descent = borderPadding.bottom for example
|
|
|
|
void
|
|
|
|
nsLeafFrame::AddBordersAndPadding(const nsHTMLReflowState& aReflowState,
|
2014-07-24 01:30:07 -07:00
|
|
|
LogicalSize& aSize)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-07-24 01:30:07 -07:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
aSize.ISize(wm) += aReflowState.ComputedLogicalBorderPadding().IStartEnd(wm);
|
|
|
|
aSize.BSize(wm) += aReflowState.ComputedLogicalBorderPadding().BStartEnd(wm);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLeafFrame::SizeToAvailSize(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
|
|
{
|
2014-07-24 01:30:07 -07:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
LogicalSize size(wm, aReflowState.AvailableISize(), // FRAME
|
|
|
|
aReflowState.AvailableBSize());
|
|
|
|
aDesiredSize.SetSize(wm, size);
|
2010-10-06 21:25:46 -07:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2007-03-22 10:30:00 -07:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
|
|
|
}
|