本文整理汇总了C++中nsBoxLayoutState::GetRenderingContext方法的典型用法代码示例。如果您正苦于以下问题:C++ nsBoxLayoutState::GetRenderingContext方法的具体用法?C++ nsBoxLayoutState::GetRenderingContext怎么用?C++ nsBoxLayoutState::GetRenderingContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsBoxLayoutState
的用法示例。
在下文中一共展示了nsBoxLayoutState::GetRenderingContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: origin
NS_IMETHODIMP
nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
{
if (mNeedsReflowCallback) {
nsIReflowCallback* cb = new nsAsyncAccesskeyUpdate(this);
if (cb) {
PresContext()->PresShell()->PostReflowCallback(cb);
}
mNeedsReflowCallback = PR_FALSE;
}
mState |= NS_STATE_NEED_LAYOUT;
nsresult rv = nsLeafBoxFrame::DoLayout(aBoxLayoutState);
const nsStyleText* textStyle = GetStyleText();
if (textStyle->mTextShadow) {
nsPoint origin(0,0);
nsRect textRect = CalcTextRect(*aBoxLayoutState.GetRenderingContext(), origin);
nsRect overflowRect(nsLayoutUtils::GetTextShadowRectsUnion(textRect, this));
overflowRect.UnionRect(overflowRect, nsRect(nsPoint(0, 0), GetSize()));
FinishAndStoreOverflow(&overflowRect, GetSize());
}
return rv;
}
示例2: maxSize
nsSize
nsBox::GetMaxSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize maxSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
DISPLAY_MAX_SIZE(this, maxSize);
if (IsCollapsed(aState))
return maxSize;
AddBorderAndPadding(maxSize);
nsIBox::AddCSSMaxSize(aState, this, maxSize);
return maxSize;
}
示例3: min
nsSize
nsBox::GetMinSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize min(0,0);
DISPLAY_MIN_SIZE(this, min);
if (IsCollapsed(aState))
return min;
AddBorderAndPadding(min);
nsIBox::AddCSSMinSize(aState, this, min);
return min;
}
示例4: GetTextSize
void
nsTextBoxFrame::CalcTextSize(nsBoxLayoutState& aBoxLayoutState)
{
if (mNeedsRecalc)
{
nsSize size;
nsPresContext* presContext = aBoxLayoutState.PresContext();
nsIRenderingContext* rendContext = aBoxLayoutState.GetRenderingContext();
if (rendContext) {
GetTextSize(presContext, *rendContext,
mTitle, size, mAscent);
mTextSize = size;
mNeedsRecalc = PR_FALSE;
}
}
}
示例5: maxSize
nsSize
nsBox::GetXULMaxSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize maxSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
DISPLAY_MAX_SIZE(this, maxSize);
if (IsXULCollapsed())
return maxSize;
AddBorderAndPadding(maxSize);
bool widthSet, heightSet;
nsIFrame::AddXULMaxSize(this, maxSize, widthSet, heightSet);
return maxSize;
}
示例6: min
nsSize
nsBox::GetXULMinSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize min(0,0);
DISPLAY_MIN_SIZE(this, min);
if (IsXULCollapsed())
return min;
AddBorderAndPadding(min);
bool widthSet, heightSet;
nsIFrame::AddXULMinSize(aState, this, min, widthSet, heightSet);
return min;
}
示例7: pref
nsSize
nsBox::GetPrefSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize pref(0,0);
DISPLAY_PREF_SIZE(this, pref);
if (IsCollapsed(aState))
return pref;
AddBorderAndPadding(pref);
nsIBox::AddCSSPrefSize(aState, this, pref);
nsSize minSize = GetMinSize(aState);
nsSize maxSize = GetMaxSize(aState);
return BoundsCheck(minSize, pref, maxSize);
}
示例8: pref
nsSize
nsBox::GetXULPrefSize(nsBoxLayoutState& aState)
{
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
nsSize pref(0,0);
DISPLAY_PREF_SIZE(this, pref);
if (IsXULCollapsed())
return pref;
AddBorderAndPadding(pref);
bool widthSet, heightSet;
nsIFrame::AddXULPrefSize(this, pref, widthSet, heightSet);
nsSize minSize = GetXULMinSize(aState);
nsSize maxSize = GetXULMaxSize(aState);
return BoundsCheck(minSize, pref, maxSize);
}
示例9: margin
nscoord
nsListBoxBodyFrame::ComputeIntrinsicISize(nsBoxLayoutState& aBoxLayoutState)
{
if (mStringWidth != -1)
return mStringWidth;
nscoord largestWidth = 0;
int32_t index = 0;
nsCOMPtr<nsIDOMElement> firstRowEl;
GetItemAtIndex(index, getter_AddRefs(firstRowEl));
nsCOMPtr<nsIContent> firstRowContent(do_QueryInterface(firstRowEl));
if (firstRowContent) {
RefPtr<nsStyleContext> styleContext;
nsPresContext *presContext = aBoxLayoutState.PresContext();
styleContext = presContext->StyleSet()->
ResolveStyleFor(firstRowContent->AsElement(), nullptr,
ConsumeStyleBehavior::DontConsume,
LazyComputeBehavior::Allow);
nscoord width = 0;
nsMargin margin(0,0,0,0);
if (styleContext->StylePadding()->GetPadding(margin))
width += margin.LeftRight();
width += styleContext->StyleBorder()->GetComputedBorder().LeftRight();
if (styleContext->StyleMargin()->GetMargin(margin))
width += margin.LeftRight();
FlattenedChildIterator iter(mContent);
for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
if (child->IsXULElement(nsGkAtoms::listitem)) {
nsRenderingContext* rendContext = aBoxLayoutState.GetRenderingContext();
if (rendContext) {
nsAutoString value;
uint32_t textCount = child->GetChildCount();
for (uint32_t j = 0; j < textCount; ++j) {
nsIContent* text = child->GetChildAt(j);
if (text && text->IsNodeOfType(nsINode::eTEXT)) {
text->AppendTextTo(value);
}
}
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForStyleContext(styleContext);
nscoord textWidth =
nsLayoutUtils::AppUnitWidthOfStringBidi(value, this, *fm,
*rendContext);
textWidth += width;
if (textWidth > largestWidth)
largestWidth = textWidth;
}
}
}
}
mStringWidth = largestWidth;
return mStringWidth;
}
示例10: if
PRBool
nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
{
PRBool widthSet = PR_FALSE;
PRBool heightSet = PR_FALSE;
PRBool canOverride = PR_TRUE;
// See if a native theme wants to supply a minimum size.
const nsStyleDisplay* display = aBox->GetStyleDisplay();
if (display->mAppearance) {
nsITheme *theme = aState.PresContext()->GetTheme();
if (theme && theme->ThemeSupportsWidget(aState.PresContext(), aBox, display->mAppearance)) {
nsIntSize size;
nsIRenderingContext* rendContext = aState.GetRenderingContext();
if (rendContext) {
theme->GetMinimumWidgetSize(rendContext, aBox,
display->mAppearance, &size, &canOverride);
if (size.width) {
aSize.width = aState.PresContext()->DevPixelsToAppUnits(size.width);
widthSet = PR_TRUE;
}
if (size.height) {
aSize.height = aState.PresContext()->DevPixelsToAppUnits(size.height);
heightSet = PR_TRUE;
}
}
}
}
// add in the css min, max, pref
const nsStylePosition* position = aBox->GetStylePosition();
// same for min size. Unfortunately min size is always set to 0. So for now
// we will assume 0 means not set.
if (position->mMinWidth.GetUnit() == eStyleUnit_Coord) {
nscoord min = position->mMinWidth.GetCoordValue();
if (min && (!widthSet || (min > aSize.width && canOverride))) {
aSize.width = min;
widthSet = PR_TRUE;
}
} else if (position->mMinWidth.GetUnit() == eStyleUnit_Percent) {
NS_ASSERTION(position->mMinWidth.GetPercentValue() == 0.0f,
"Non-zero percentage values not currently supported");
aSize.width = 0;
widthSet = PR_TRUE;
}
// XXX Handle eStyleUnit_Enumerated?
// (Handling the eStyleUnit_Enumerated types requires
// GetPrefSize/GetMinSize methods that don't consider
// (min-/max-/)(width/height) properties.
if (position->mMinHeight.GetUnit() == eStyleUnit_Coord) {
nscoord min = position->mMinHeight.GetCoordValue();
if (min && (!heightSet || (min > aSize.height && canOverride))) {
aSize.height = min;
heightSet = PR_TRUE;
}
} else if (position->mMinHeight.GetUnit() == eStyleUnit_Percent) {
NS_ASSERTION(position->mMinHeight.GetPercentValue() == 0.0f,
"Non-zero percentage values not currently supported");
aSize.height = 0;
heightSet = PR_TRUE;
}
nsIContent* content = aBox->GetContent();
if (content) {
nsAutoString value;
PRInt32 error;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::minwidth, value);
if (!value.IsEmpty())
{
value.Trim("%");
nscoord val =
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
if (val > aSize.width)
aSize.width = val;
widthSet = PR_TRUE;
}
content->GetAttr(kNameSpaceID_None, nsGkAtoms::minheight, value);
if (!value.IsEmpty())
{
value.Trim("%");
nscoord val =
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
if (val > aSize.height)
aSize.height = val;
heightSet = PR_TRUE;
}
}
return (widthSet && heightSet);
}
示例11: margin
nscoord
nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState)
{
if (mStringWidth != -1)
return mStringWidth;
nscoord largestWidth = 0;
PRInt32 index = 0;
nsCOMPtr<nsIDOMElement> firstRowEl;
GetItemAtIndex(index, getter_AddRefs(firstRowEl));
nsCOMPtr<nsIContent> firstRowContent(do_QueryInterface(firstRowEl));
if (firstRowContent) {
nsRefPtr<nsStyleContext> styleContext;
nsPresContext *presContext = aBoxLayoutState.PresContext();
styleContext = presContext->StyleSet()->
ResolveStyleFor(firstRowContent->AsElement(), nsnull);
nscoord width = 0;
nsMargin margin(0,0,0,0);
if (styleContext->GetStylePadding()->GetPadding(margin))
width += margin.LeftRight();
width += styleContext->GetStyleBorder()->GetActualBorder().LeftRight();
if (styleContext->GetStyleMargin()->GetMargin(margin))
width += margin.LeftRight();
ChildIterator iter, last;
PRUint32 i = 0;
for (ChildIterator::Init(mContent, &iter, &last);
iter != last && i < 100;
++iter, ++i) {
nsIContent *child = (*iter);
if (child->Tag() == nsGkAtoms::listitem) {
nsRenderingContext* rendContext = aBoxLayoutState.GetRenderingContext();
if (rendContext) {
nsAutoString value;
PRUint32 textCount = child->GetChildCount();
for (PRUint32 j = 0; j < textCount; ++j) {
nsIContent* text = child->GetChildAt(j);
if (text && text->IsNodeOfType(nsINode::eTEXT)) {
text->AppendTextTo(value);
}
}
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForStyleContext(styleContext,
getter_AddRefs(fm));
rendContext->SetFont(fm);
nscoord textWidth =
nsLayoutUtils::GetStringWidth(this, rendContext, value.get(), value.Length());
textWidth += width;
if (textWidth > largestWidth)
largestWidth = textWidth;
}
}
}
}
mStringWidth = largestWidth;
return mStringWidth;
}
示例12: margin
nscoord
nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState)
{
if (mStringWidth != -1)
return mStringWidth;
nscoord largestWidth = 0;
PRInt32 index = 0;
nsCOMPtr<nsIDOMElement> firstRowEl;
GetItemAtIndex(index, getter_AddRefs(firstRowEl));
nsCOMPtr<nsIContent> firstRowContent(do_QueryInterface(firstRowEl));
if (firstRowContent) {
nsRefPtr<nsStyleContext> styleContext;
nsPresContext *presContext = aBoxLayoutState.PresContext();
styleContext = presContext->StyleSet()->
ResolveStyleFor(firstRowContent, nsnull);
nscoord width = 0;
nsMargin margin(0,0,0,0);
if (styleContext->GetStylePadding()->GetPadding(margin))
width += margin.LeftRight();
width += styleContext->GetStyleBorder()->GetBorder().LeftRight();
if (styleContext->GetStyleMargin()->GetMargin(margin))
width += margin.LeftRight();
nsIContent* listbox = mContent->GetBindingParent();
NS_ENSURE_TRUE(listbox, largestWidth);
PRUint32 childCount = listbox->GetChildCount();
for (PRUint32 i = 0; i < childCount && i < 100; ++i) {
nsIContent *child = listbox->GetChildAt(i);
if (child->Tag() == nsGkAtoms::listitem) {
nsIRenderingContext* rendContext = aBoxLayoutState.GetRenderingContext();
if (rendContext) {
nsAutoString value;
PRUint32 textCount = child->GetChildCount();
for (PRUint32 j = 0; j < textCount; ++j) {
nsIContent* text = child->GetChildAt(j);
if (text && text->IsNodeOfType(nsINode::eTEXT)) {
text->AppendTextTo(value);
}
}
nsLayoutUtils::SetFontFromStyle(rendContext, styleContext);
nscoord textWidth =
nsLayoutUtils::GetStringWidth(this, rendContext, value.get(), value.Length());
textWidth += width;
if (textWidth > largestWidth)
largestWidth = textWidth;
}
}
}
}
mStringWidth = largestWidth;
return mStringWidth;
}