本文整理汇总了C++中nsHTMLReflowMetrics::SetMEWToActualWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowMetrics::SetMEWToActualWidth方法的具体用法?C++ nsHTMLReflowMetrics::SetMEWToActualWidth怎么用?C++ nsHTMLReflowMetrics::SetMEWToActualWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowMetrics
的用法示例。
在下文中一共展示了nsHTMLReflowMetrics::SetMEWToActualWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDesiredSize
NS_IMETHODIMP
nsLeafFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsLeafFrame", aReflowState.reason);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsLeafFrame::Reflow: aMaxSize=%d,%d",
aReflowState.availableWidth, aReflowState.availableHeight));
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
// XXX add in code to check for width/height being set via css
// and if set use them instead of calling GetDesiredSize.
GetDesiredSize(aPresContext, aReflowState, aMetrics);
nsMargin borderPadding;
AddBordersAndPadding(aPresContext, aReflowState, aMetrics, borderPadding);
if (aMetrics.mComputeMEW) {
aMetrics.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("exit nsLeafFrame::Reflow: size=%d,%d",
aMetrics.width, aMetrics.height));
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
return NS_OK;
}
示例2: if
NS_IMETHODIMP
SpacerFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("SpacerFrame", aReflowState.reason);
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
aStatus = NS_FRAME_COMPLETE;
// By default, we have no area
aMetrics.width = 0;
aMetrics.height = 0;
aMetrics.ascent = 0;
aMetrics.descent = 0;
const nsStylePosition* position = GetStylePosition();
PRUint8 type = GetType();
switch (type) {
case TYPE_WORD:
break;
case TYPE_LINE:
aStatus = NS_INLINE_LINE_BREAK_AFTER(NS_FRAME_COMPLETE);
if (eStyleUnit_Coord == position->mHeight.GetUnit()) {
aMetrics.width = position->mHeight.GetCoordValue();
}
aMetrics.ascent = aMetrics.height;
break;
case TYPE_IMAGE:
// width
nsStyleUnit unit = position->mWidth.GetUnit();
if (eStyleUnit_Coord == unit) {
aMetrics.width = position->mWidth.GetCoordValue();
}
else if (eStyleUnit_Percent == unit)
{
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth)
{
float factor = position->mWidth.GetPercentValue();
aMetrics.width = NSToCoordRound (factor * aReflowState.availableWidth);
}
}
// height
unit = position->mHeight.GetUnit();
if (eStyleUnit_Coord == unit) {
aMetrics.height = position->mHeight.GetCoordValue();
}
else if (eStyleUnit_Percent == unit)
{
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight)
{
float factor = position->mHeight.GetPercentValue();
aMetrics.width = NSToCoordRound (factor * aReflowState.availableHeight);
}
}
// accent
aMetrics.ascent = aMetrics.height;
break;
}
if (aMetrics.width || aMetrics.height) {
// Make sure that the other dimension is non-zero
if (!aMetrics.width) aMetrics.width = 1;
if (!aMetrics.height) aMetrics.height = 1;
}
if (aMetrics.mComputeMEW) {
aMetrics.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
return NS_OK;
}