本文整理汇总了C++中nsRenderingContext类的典型用法代码示例。如果您正苦于以下问题:C++ nsRenderingContext类的具体用法?C++ nsRenderingContext怎么用?C++ nsRenderingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsRenderingContext类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rect
void
nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
nsPoint aPt)
{
nsPresContext* pc = PresContext();
if (!mPD->mPrintSettings) {
if (pc->Type() == nsPresContext::eContext_PrintPreview || pc->IsDynamic())
mPD->mPrintSettings = pc->GetPrintSettings();
if (!mPD->mPrintSettings)
return;
}
nsRect rect(aPt, mRect.Size());
aRenderingContext.SetColor(NS_RGB(0,0,0));
// Get the FontMetrics to determine width.height of strings
nsRefPtr<nsFontMetrics> fontMet;
pc->DeviceContext()->GetMetricsFor(*mPD->mHeadFootFont, nullptr,
pc->GetUserFontSet(),
*getter_AddRefs(fontMet));
aRenderingContext.SetFont(fontMet);
nscoord ascent = 0;
nscoord visibleHeight = 0;
if (fontMet) {
visibleHeight = fontMet->MaxHeight();
ascent = fontMet->MaxAscent();
}
// print document headers and footers
nsXPIDLString headerLeft, headerCenter, headerRight;
mPD->mPrintSettings->GetHeaderStrLeft(getter_Copies(headerLeft));
mPD->mPrintSettings->GetHeaderStrCenter(getter_Copies(headerCenter));
mPD->mPrintSettings->GetHeaderStrRight(getter_Copies(headerRight));
DrawHeaderFooter(aRenderingContext, eHeader,
headerLeft, headerCenter, headerRight,
rect, ascent, visibleHeight);
nsXPIDLString footerLeft, footerCenter, footerRight;
mPD->mPrintSettings->GetFooterStrLeft(getter_Copies(footerLeft));
mPD->mPrintSettings->GetFooterStrCenter(getter_Copies(footerCenter));
mPD->mPrintSettings->GetFooterStrRight(getter_Copies(footerRight));
DrawHeaderFooter(aRenderingContext, eFooter,
footerLeft, footerCenter, footerRight,
rect, ascent, visibleHeight);
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:48,代码来源:nsPageFrame.cpp
示例2: Draw
void DefaultArea::Draw(nsIFrame* aFrame, nsRenderingContext& aRC)
{
if (mHasFocus) {
nsRect r = aFrame->GetRect();
r.MoveTo(0, 0);
nscoord x1 = r.x;
nscoord y1 = r.y;
const nscoord kOnePixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord x2 = r.XMost() - kOnePixel;
nscoord y2 = r.YMost() - kOnePixel;
// XXX aRC.DrawRect(r) result is ugly, that's why we use DrawLine.
aRC.DrawLine(x1, y1, x1, y2);
aRC.DrawLine(x1, y2, x2, y2);
aRC.DrawLine(x1, y1, x2, y1);
aRC.DrawLine(x2, y1, x2, y2);
}
}
开发者ID:,项目名称:,代码行数:17,代码来源:
示例3: PresContext
//------------------------------------------------------------------------------
void
nsSimplePageSequenceFrame::PaintPageSequence(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt) {
nsRect rect = aDirtyRect;
float scale = PresContext()->GetPrintPreviewScale();
aRenderingContext.PushState();
nsPoint framePos = aPt;
aRenderingContext.Translate(framePos);
rect -= framePos;
aRenderingContext.Scale(scale, scale);
rect.ScaleRoundOut(1.0f / scale);
// Now the rect and the rendering coordinates are are relative to this frame.
// Loop over the pages and paint them.
nsIFrame* child = GetFirstChild(nsnull);
while (child) {
nsPoint pt = child->GetPosition();
// The rendering context has to be translated before each call to PaintFrame
aRenderingContext.PushState();
aRenderingContext.Translate(pt);
nsLayoutUtils::PaintFrame(&aRenderingContext, child,
nsRegion(rect - pt), NS_RGBA(0,0,0,0),
nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES);
aRenderingContext.PopState();
child = child->GetNextSibling();
}
aRenderingContext.PopState();
}
开发者ID:,项目名称:,代码行数:31,代码来源:
示例4: Equals
/* static */ void
nsMathMLFrame::GetRuleThickness(nsRenderingContext& aRenderingContext,
nsFontMetrics* aFontMetrics,
nscoord& aRuleThickness)
{
// get the bounding metrics of the overbar char, the rendering context
// is assumed to have been set with the font of the current style context
NS_ASSERTION(aRenderingContext.FontMetrics()->Font().
Equals(aFontMetrics->Font()),
"unexpected state");
nscoord xHeight = aFontMetrics->XHeight();
PRUnichar overBar = 0x00AF;
nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&overBar, 1);
aRuleThickness = bm.ascent + bm.descent;
if (aRuleThickness <= 0 || aRuleThickness >= xHeight) {
// fall-back to the other version
GetRuleThickness(aFontMetrics, aRuleThickness);
}
}
开发者ID:jraff,项目名称:mozilla-central,代码行数:20,代码来源:nsMathMLFrame.cpp
示例5: NS_ASSERTION
void
nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext,
nsPoint aPt)
{
NS_ASSERTION(GetStateBits() & NS_FRAME_SELECTED_CONTENT,
"Should only be called for selected cells");
PRInt16 displaySelection;
nsPresContext* presContext = PresContext();
displaySelection = DisplaySelection(presContext);
if (displaySelection) {
nsRefPtr<nsFrameSelection> frameSelection =
presContext->PresShell()->FrameSelection();
if (frameSelection->GetTableCellSelection()) {
nscolor bordercolor;
if (displaySelection == nsISelectionController::SELECTION_DISABLED) {
bordercolor = NS_RGB(176,176,176);// disabled color
}
else {
bordercolor =
LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground);
}
nscoord threePx = nsPresContext::CSSPixelsToAppUnits(3);
if ((mRect.width > threePx) && (mRect.height > threePx))
{
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
bordercolor = EnsureDifferentColors(bordercolor,
GetStyleBackground()->mBackgroundColor);
nsRenderingContext::AutoPushTranslation
translate(&aRenderingContext, aPt);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aRenderingContext.SetColor(bordercolor);
aRenderingContext.DrawLine(onePixel, 0, mRect.width, 0);
aRenderingContext.DrawLine(0, onePixel, 0, mRect.height);
aRenderingContext.DrawLine(onePixel, mRect.height, mRect.width, mRect.height);
aRenderingContext.DrawLine(mRect.width, onePixel, mRect.width, mRect.height);
//middle
aRenderingContext.DrawRect(onePixel, onePixel, mRect.width-onePixel,
mRect.height-onePixel);
//shading
aRenderingContext.DrawLine(2*onePixel, mRect.height-2*onePixel,
mRect.width-onePixel, mRect.height- (2*onePixel));
aRenderingContext.DrawLine(mRect.width - (2*onePixel), 2*onePixel,
mRect.width - (2*onePixel), mRect.height-onePixel);
}
}
}
}
开发者ID:moussa1,项目名称:mozilla-central,代码行数:49,代码来源:nsTableCellFrame.cpp
示例6: if
// exported routine that both munderover and msubsup share.
// munderover uses this when movablelimits is set.
nsresult
nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
nscoord aScriptSpace)
{
// force the scriptSpace to be atleast 1 pixel
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aScriptSpace = NS_MAX(onePixel, aScriptSpace);
////////////////////////////////////
// Get the children's desired sizes
nsHTMLReflowMetrics baseSize;
nsHTMLReflowMetrics subScriptSize;
nsHTMLReflowMetrics supScriptSize;
nsBoundingMetrics bmBase, bmSubScript, bmSupScript;
nsIFrame* subScriptFrame = nsnull;
nsIFrame* supScriptFrame = nsnull;
nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild();
if (baseFrame)
subScriptFrame = baseFrame->GetNextSibling();
if (subScriptFrame)
supScriptFrame = subScriptFrame->GetNextSibling();
if (!baseFrame || !subScriptFrame || !supScriptFrame ||
supScriptFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript);
GetReflowAndBoundingMetricsFor(supScriptFrame, supScriptSize, bmSupScript);
// get the subdrop from the subscript font
nscoord subDrop;
GetSubDropFromChild(subScriptFrame, subDrop);
// parameter v, Rule 18a, App. G, TeXbook
nscoord minSubScriptShift = bmBase.descent + subDrop;
// get the supdrop from the supscript font
nscoord supDrop;
GetSupDropFromChild(supScriptFrame, supDrop);
// parameter u, Rule 18a, App. G, TeXbook
nscoord minSupScriptShift = bmBase.ascent - supDrop;
//////////////////
// Place Children
//////////////////
//////////////////////////////////////////////////
// Get subscript shift
// slightly different from nsMathMLmsubFrame.cpp
//////////////////////////////////////////////////
// subScriptShift{1,2}
// = minimum amount to shift the subscript down
// = sub{1,2} in TeXbook
// subScriptShift1 = subscriptshift attribute * x-height
nscoord subScriptShift1, subScriptShift2;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
// get x-height (an ex)
nscoord xHeight = fm->XHeight();
nscoord ruleSize;
GetRuleThickness (aRenderingContext, fm, ruleSize);
// Get subScriptShift{1,2} default from font
GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
if (0 < aUserSubScriptShift) {
// the user has set the subscriptshift attribute
float scaler = ((float) subScriptShift2) / subScriptShift1;
subScriptShift1 = NS_MAX(subScriptShift1, aUserSubScriptShift);
subScriptShift2 = NSToCoordRound(scaler * subScriptShift1);
}
// get a tentative value for subscriptshift
// Rule 18d, App. G, TeXbook
nscoord subScriptShift =
NS_MAX(minSubScriptShift,NS_MAX(subScriptShift1,subScriptShift2));
//////////////////////////////////////////////////
// Get supscript shift
// same code from nsMathMLmsupFrame.cpp
//////////////////////////////////////////////////
// get min supscript shift limit from x-height
// = d(x) + 1/4 * sigma_5, Rule 18c, App. G, TeXbook
nscoord minShiftFromXHeight = (nscoord)
(bmSupScript.descent + (1.0f/4.0f) * xHeight);
//.........这里部分代码省略.........
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:101,代码来源:nsMathMLmsubsupFrame.cpp
示例7: legendRect
DrawResult
nsFieldSetFrame::PaintBorderBackground(
nsDisplayListBuilder* aBuilder,
nsRenderingContext& aRenderingContext,
nsPoint aPt,
const nsRect& aDirtyRect)
{
// if the border is smaller than the legend. Move the border down
// to be centered on the legend.
// FIXME: This means border-radius clamping is incorrect; we should
// override nsIFrame::GetBorderRadii.
WritingMode wm = GetWritingMode();
nsRect rect = VisualBorderRectRelativeToSelf();
nscoord off = wm.IsVertical() ? rect.x : rect.y;
rect += aPt;
nsPresContext* presContext = PresContext();
uint32_t bgFlags = aBuilder->GetBackgroundPaintFlags();
PaintBorderFlags borderFlags = aBuilder->ShouldSyncDecodeImages()
? PaintBorderFlags::SYNC_DECODE_IMAGES
: PaintBorderFlags();
DrawResult result =
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
aDirtyRect, rect, bgFlags);
nsCSSRendering::PaintBoxShadowInner(presContext, aRenderingContext,
this, rect, aDirtyRect);
if (nsIFrame* legend = GetLegend()) {
css::Side legendSide = wm.PhysicalSide(eLogicalSideBStart);
nscoord legendBorderWidth =
StyleBorder()->GetComputedBorderWidth(legendSide);
// Use the rect of the legend frame, not mLegendRect, so we draw our
// border under the legend's inline-start and -end margins.
LogicalRect legendRect(wm, legend->GetRect() + aPt, rect.Size());
// Compute clipRect using logical coordinates, so that the legend space
// will be clipped out of the appropriate physical side depending on mode.
LogicalRect clipRect = LogicalRect(wm, rect, rect.Size());
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
// draw inline-start portion of the block-start side of the border
clipRect.ISize(wm) = legendRect.IStart(wm) - clipRect.IStart(wm);
clipRect.BSize(wm) = legendBorderWidth;
gfx->Save();
gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.Size()),
appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, borderFlags);
gfx->Restore();
// draw inline-end portion of the block-start side of the border
clipRect = LogicalRect(wm, rect, rect.Size());
clipRect.ISize(wm) = clipRect.IEnd(wm) - legendRect.IEnd(wm);
clipRect.IStart(wm) = legendRect.IEnd(wm);
clipRect.BSize(wm) = legendBorderWidth;
gfx->Save();
gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.Size()),
appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, borderFlags);
gfx->Restore();
// draw remainder of the border (omitting the block-start side)
clipRect = LogicalRect(wm, rect, rect.Size());
clipRect.BStart(wm) += legendBorderWidth;
clipRect.BSize(wm) = BSize(wm) - (off + legendBorderWidth);
gfx->Save();
gfx->Clip(NSRectToSnappedRect(clipRect.GetPhysicalRect(wm, rect.Size()),
appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, borderFlags);
gfx->Restore();
} else {
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, nsRect(aPt, mRect.Size()),
mStyleContext, borderFlags);
}
return result;
}
开发者ID:bolt-dev,项目名称:gecko-dev,代码行数:92,代码来源:nsFieldSetFrame.cpp
示例8: if
// exported routine that both munderover and mmultiscripts share.
// munderover uses this when movablelimits is set.
nsresult
nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
nscoord aScriptSpace)
{
nsIAtom* tag = aFrame->GetContent()->Tag();
// This function deals with both munderover etc. as well as msubsup etc.
// As the former behaves identically to the later, we treat it as such
// to avoid additional checks later.
if (tag == nsGkAtoms::mover_)
tag = nsGkAtoms::msup_;
else if (tag == nsGkAtoms::munder_)
tag = nsGkAtoms::msub_;
else if (tag == nsGkAtoms::munderover_)
tag = nsGkAtoms::msubsup_;
nsBoundingMetrics bmFrame;
nscoord minShiftFromXHeight, subDrop, supDrop;
////////////////////////////////////////
// Initialize super/sub shifts that
// depend only on the current font
////////////////////////////////////////
nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild();
if (!baseFrame) {
if (tag == nsGkAtoms::mmultiscripts_)
aFrame->ReportErrorToConsole("NoBase");
else
aFrame->ReportChildCountError();
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
}
// get x-height (an ex)
const nsStyleFont* font = aFrame->StyleFont();
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
nscoord xHeight = fm->XHeight();
nscoord ruleSize;
GetRuleThickness (aRenderingContext, fm, ruleSize);
// force the scriptSpace to be at least 1 pixel
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aScriptSpace = std::max(onePixel, aScriptSpace);
/////////////////////////////////////
// first the shift for the subscript
// subScriptShift{1,2}
// = minimum amount to shift the subscript down
// = sub{1,2} in TeXbook
// subScriptShift1 = subscriptshift attribute * x-height
nscoord subScriptShift1, subScriptShift2;
// Get subScriptShift{1,2} default from font
GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
nscoord subScriptShift;
if (tag == nsGkAtoms::msub_) {
subScriptShift = subScriptShift1;
} else {
subScriptShift = std::max(subScriptShift1, subScriptShift2);
}
if (0 < aUserSubScriptShift) {
// the user has set the subscriptshift attribute
subScriptShift = std::max(subScriptShift, aUserSubScriptShift);
}
/////////////////////////////////////
// next the shift for the superscript
// supScriptShift{1,2,3}
// = minimum amount to shift the supscript up
// = sup{1,2,3} in TeX
// supScriptShift1 = superscriptshift attribute * x-height
// Note that there are THREE values for supscript shifts depending
// on the current style
nscoord supScriptShift1, supScriptShift2, supScriptShift3;
// Set supScriptShift{1,2,3} default from font
GetSupScriptShifts (fm, supScriptShift1, supScriptShift2, supScriptShift3);
// get sup script shift depending on current script level and display style
// Rule 18c, App. G, TeXbook
nsPresentationData presentationData;
aFrame->GetPresentationData(presentationData);
nscoord supScriptShift;
if (font->mScriptLevel == 0 &&
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例9: DrawSingleImage
DrawResult
nsImageBoxFrame::PaintImage(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt,
uint32_t aFlags)
{
nsRect constraintRect;
GetClientRect(constraintRect);
constraintRect += aPt;
if (!mImageRequest) {
// This probably means we're drawn by a native theme.
return DrawResult::SUCCESS;
}
// don't draw if the image is not dirty
// XXX(seth): Can this actually happen anymore?
nsRect dirty;
if (!dirty.IntersectRect(aDirtyRect, constraintRect)) {
return DrawResult::TEMPORARY_ERROR;
}
nsCOMPtr<imgIContainer> imgCon;
mImageRequest->GetImage(getter_AddRefs(imgCon));
if (!imgCon) {
return DrawResult::NOT_READY;
}
bool hasSubRect = !mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0);
Maybe<nsPoint> anchorPoint;
nsRect dest;
if (!mUseSrcAttr) {
// Our image (if we have one) is coming from the CSS property
// 'list-style-image' (combined with '-moz-image-region'). For now, ignore
// 'object-fit' & 'object-position' in this case, and just fill our rect.
// XXXdholbert Should we even honor these properties in this case? They only
// apply to replaced elements, and I'm not sure we count as a replaced
// element when our image data is determined by CSS.
dest = constraintRect;
} else {
// Determine dest rect based on intrinsic size & ratio, along with
// 'object-fit' & 'object-position' properties:
IntrinsicSize intrinsicSize;
nsSize intrinsicRatio;
if (mIntrinsicSize.width > 0 && mIntrinsicSize.height > 0) {
// Image has a valid size; use it as intrinsic size & ratio.
intrinsicSize.width.SetCoordValue(mIntrinsicSize.width);
intrinsicSize.height.SetCoordValue(mIntrinsicSize.height);
intrinsicRatio = mIntrinsicSize;
} else {
// Image doesn't have a (valid) intrinsic size.
// Try to look up intrinsic ratio and use that at least.
imgCon->GetIntrinsicRatio(&intrinsicRatio);
}
anchorPoint.emplace();
dest = nsLayoutUtils::ComputeObjectDestRect(constraintRect,
intrinsicSize,
intrinsicRatio,
StylePosition(),
anchorPoint.ptr());
}
return nsLayoutUtils::DrawSingleImage(
*aRenderingContext.ThebesContext(),
PresContext(), imgCon,
nsLayoutUtils::GetGraphicsFilterForFrame(this),
dest, dirty, nullptr, aFlags,
anchorPoint.ptrOr(nullptr),
hasSubRect ? &mSubRect : nullptr);
}
开发者ID:paulmadore,项目名称:luckyde,代码行数:73,代码来源:nsImageBoxFrame.cpp
示例10: DidReflowChildren
/* virtual */ nsresult
nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
bool aWidthOnly)
{
///////////////
// Measure the size of our content using the base class to format like an
// inferred mrow.
nsHTMLReflowMetrics baseSize;
nsresult rv =
nsMathMLContainerFrame::Place(aRenderingContext, false, baseSize);
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
DidReflowChildren(GetFirstPrincipalChild());
return rv;
}
nsBoundingMetrics bmBase = baseSize.mBoundingMetrics;
nscoord dx_left = 0, dx_right = 0;
nsBoundingMetrics bmLongdivChar, bmRadicalChar;
nscoord radicalAscent = 0, radicalDescent = 0;
nscoord longdivAscent = 0, longdivDescent = 0;
nscoord psi = 0;
///////////////
// Thickness of bars and font metrics
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord mEmHeight;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
GetRuleThickness(aRenderingContext, fm, mRuleThickness);
GetEmHeight(fm, mEmHeight);
PRUnichar one = '1';
nsBoundingMetrics bmOne = aRenderingContext.GetBoundingMetrics(&one, 1);
///////////////
// General rules: the menclose element takes the size of the enclosed content.
// We add a padding when needed.
// determine padding & psi
nscoord padding = 3 * mRuleThickness;
nscoord delta = padding % onePixel;
if (delta)
padding += onePixel - delta; // round up
if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) {
nscoord phi;
// Rule 11, App. G, TeXbook
// psi = clearance between rule and content
if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
phi = fm->XHeight();
else
phi = mRuleThickness;
psi = mRuleThickness + phi / 4;
delta = psi % onePixel;
if (delta)
psi += onePixel - delta; // round up
}
if (mRuleThickness < onePixel)
mRuleThickness = onePixel;
// Set horizontal parameters
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
IsToDraw(NOTATION_TOP) ||
IsToDraw(NOTATION_LEFT) ||
IsToDraw(NOTATION_BOTTOM) ||
IsToDraw(NOTATION_CIRCLE))
dx_left = padding;
if (IsToDraw(NOTATION_ROUNDEDBOX) ||
IsToDraw(NOTATION_TOP) ||
IsToDraw(NOTATION_RIGHT) ||
IsToDraw(NOTATION_BOTTOM) ||
IsToDraw(NOTATION_CIRCLE))
dx_right = padding;
// Set vertical parameters
if (IsToDraw(NOTATION_RIGHT) ||
IsToDraw(NOTATION_LEFT) ||
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
IsToDraw(NOTATION_VERTICALSTRIKE) ||
IsToDraw(NOTATION_CIRCLE) ||
IsToDraw(NOTATION_ROUNDEDBOX) ||
IsToDraw(NOTATION_RADICAL) ||
IsToDraw(NOTATION_LONGDIV)) {
// set a minimal value for the base height
bmBase.ascent = NS_MAX(bmOne.ascent, bmBase.ascent);
bmBase.descent = NS_MAX(0, bmBase.descent);
}
mBoundingMetrics.ascent = bmBase.ascent;
mBoundingMetrics.descent = bmBase.descent;
//.........这里部分代码省略.........
开发者ID:Anachid,项目名称:mozilla-central,代码行数:101,代码来源:nsMathMLmencloseFrame.cpp
示例11: rect
DrawResult
nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsPoint aPt, const nsRect& aDirtyRect) {
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
gfxContext* gfx = aRenderingContext.ThebesContext();
Sides skipSides;
const nsStyleBorder* borderStyleData = StyleBorder();
const nsMargin& border = borderStyleData->GetComputedBorder();
nscoord yoff = 0;
nsPresContext* presContext = PresContext();
nsRect groupRect;
nsIFrame* groupBox = GetCaptionBox(presContext, groupRect);
if (groupBox) {
// if the border is smaller than the legend. Move the border down
// to be centered on the legend.
nsMargin groupMargin;
groupBox->StyleMargin()->GetMargin(groupMargin);
groupRect.Inflate(groupMargin);
if (border.top < groupRect.height)
yoff = (groupRect.height - border.top)/2 + groupRect.y;
}
nsRect rect(aPt.x, aPt.y + yoff, mRect.width, mRect.height - yoff);
groupRect += aPt;
DrawResult result =
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
aDirtyRect, rect,
nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES);
if (groupBox) {
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
// we should probably use PaintBorderEdges to do this but for now just use clipping
// to achieve the same effect.
// draw left side
nsRect clipRect(rect);
clipRect.width = groupRect.x - rect.x;
clipRect.height = border.top;
gfx->Save();
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext,
PaintBorderFlags::SYNC_DECODE_IMAGES, skipSides);
gfx->Restore();
// draw right side
clipRect = rect;
clipRect.x = groupRect.XMost();
clipRect.width = rect.XMost() - groupRect.XMost();
clipRect.height = border.top;
gfx->Save();
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext,
PaintBorderFlags::SYNC_DECODE_IMAGES, skipSides);
gfx->Restore();
// draw bottom
clipRect = rect;
clipRect.y += border.top;
clipRect.height = mRect.height - (yoff + border.top);
gfx->Save();
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext,
PaintBorderFlags::SYNC_DECODE_IMAGES, skipSides);
gfx->Restore();
} else {
result &=
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, nsRect(aPt, GetSize()),
mStyleContext,
PaintBorderFlags::SYNC_DECODE_IMAGES, skipSides);
}
return result;
}
开发者ID:kleopatra999,项目名称:system-addons,代码行数:93,代码来源:nsGroupBoxFrame.cpp
示例12: GetCharSpacing
// helper functions to perform the common task of formatting our chars
/*static*/ nsresult
nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
nsMathMLChar* aMathMLChar,
nsOperatorFlags aForm,
PRInt32 aScriptLevel,
nscoord axisHeight,
nscoord leading,
nscoord em,
nsBoundingMetrics& aContainerSize,
nscoord& aAscent,
nscoord& aDescent)
{
if (aMathMLChar && 0 < aMathMLChar->Length()) {
nscoord leftSpace;
nscoord rightSpace;
GetCharSpacing(aMathMLChar, aForm, aScriptLevel, em, leftSpace, rightSpace);
// stretch the char to the appropriate height if it is not big enough.
nsBoundingMetrics charSize;
nsresult res = aMathMLChar->Stretch(aPresContext, aRenderingContext,
NS_STRETCH_DIRECTION_VERTICAL,
aContainerSize, charSize);
if (NS_STRETCH_DIRECTION_UNSUPPORTED != aMathMLChar->GetStretchDirection()) {
// has changed... so center the char around the axis
nscoord height = charSize.ascent + charSize.descent;
charSize.ascent = height/2 + axisHeight;
charSize.descent = height - charSize.ascent;
}
else {
// either it hasn't changed or stretching the char failed (i.e.,
// GetBoundingMetrics failed)
leading = 0;
if (NS_FAILED(res)) {
nsAutoString data;
aMathMLChar->GetData(data);
nsBoundingMetrics metrics =
aRenderingContext.GetBoundingMetrics(data.get(), data.Length());
charSize.ascent = metrics.ascent;
charSize.descent = metrics.descent;
charSize.width = metrics.width;
// Set this as the bounding metrics of the MathMLChar to leave
// the necessary room to paint the char.
aMathMLChar->SetBoundingMetrics(charSize);
}
}
if (aAscent < charSize.ascent + leading)
aAscent = charSize.ascent + leading;
if (aDescent < charSize.descent + leading)
aDescent = charSize.descent + leading;
// account the spacing
charSize.width += leftSpace + rightSpace;
// x-origin is used to store lspace ...
// y-origin is used to stored the ascent ...
aMathMLChar->SetRect(nsRect(leftSpace,
charSize.ascent, charSize.width,
charSize.ascent + charSize.descent));
}
return NS_OK;
}
开发者ID:mozilla,项目名称:mozilla-history,代码行数:65,代码来源:nsMathMLmfencedFrame.cpp
示例13: if
// NOTE: aDesiredStretchSize is an IN/OUT parameter
// On input - it contains our current size
// On output - the same size or the new size that we want
NS_IMETHODIMP
nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
nsStretchDirection aStretchDirection,
nsBoundingMetrics& aContainerSize,
nsHTMLReflowMetrics& aDesiredStretchSize)
{
if (NS_MATHML_STRETCH_WAS_DONE(mPresentationData.flags)) {
NS_WARNING("it is wrong to fire stretch more than once on a frame");
return NS_OK;
}
mPresentationData.flags |= NS_MATHML_STRETCH_DONE;
nsIFrame* firstChild = mFrames.FirstChild();
// get the axis height;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
nscoord axisHeight, height;
GetAxisHeight(aRenderingContext, fm, axisHeight);
// get the leading to be left at the top and the bottom of the stretched char
// this seems more reliable than using fm->GetLeading() on suspicious fonts
nscoord em;
GetEmHeight(fm, em);
nscoord leading = NSToCoordRound(0.2f * em);
// Operators that are stretchy, or those that are to be centered
// to cater for fonts that are not math-aware, are handled by the MathMLChar
// ('form' is reset if stretch fails -- i.e., we don't bother to stretch next time)
bool useMathMLChar = UseMathMLChar();
nsBoundingMetrics charSize;
nsBoundingMetrics container = aDesiredStretchSize.mBoundingMetrics;
bool isVertical = false;
if (((aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL) ||
(aStretchDirection == NS_STRETCH_DIRECTION_DEFAULT)) &&
(mEmbellishData.direction == NS_STRETCH_DIRECTION_VERTICAL)) {
isVertical = true;
}
uint32_t stretchHint =
GetStretchHint(mFlags, mPresentationData, isVertical);
if (useMathMLChar) {
nsBoundingMetrics initialSize = aDesiredStretchSize.mBoundingMetrics;
if (stretchHint != NS_STRETCH_NONE) {
container = aContainerSize;
// some adjustments if the operator is symmetric and vertical
if (isVertical && NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
// we need to center about the axis
nscoord delta = std::max(container.ascent - axisHeight,
container.descent + axisHeight);
container.ascent = delta + axisHeight;
container.descent = delta - axisHeight;
// get ready in case we encounter user-desired min-max size
delta = std::max(initialSize.ascent - axisHeight,
initialSize.descent + axisHeight);
initialSize.ascent = delta + axisHeight;
initialSize.descent = delta - axisHeight;
}
// check for user-desired min-max size
if (mMaxSize != NS_MATHML_OPERATOR_SIZE_INFINITY && mMaxSize > 0.0f) {
// if we are here, there is a user defined maxsize ...
//XXX Set stretchHint = NS_STRETCH_NORMAL? to honor the maxsize as close as possible?
if (NS_MATHML_OPERATOR_MAXSIZE_IS_ABSOLUTE(mFlags)) {
// there is an explicit value like maxsize="20pt"
// try to maintain the aspect ratio of the char
float aspect = mMaxSize / float(initialSize.ascent + initialSize.descent);
container.ascent =
std::min(container.ascent, nscoord(initialSize.ascent * aspect));
container.descent =
std::min(container.descent, nscoord(initialSize.descent * aspect));
// below we use a type cast instead of a conversion to avoid a VC++ bug
// see http://support.microsoft.com/support/kb/articles/Q115/7/05.ASP
container.width =
std::min(container.width, (nscoord)mMaxSize);
}
else { // multiplicative value
container.ascent =
std::min(container.ascent, nscoord(initialSize.ascent * mMaxSize));
container.descent =
std::min(container.descent, nscoord(initialSize.descent * mMaxSize));
container.width =
std::min(container.width, nscoord(initialSize.width * mMaxSize));
}
if (isVertical && !NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
// re-adjust to align the char with the bottom of the initial container
//.........这里部分代码省略.........
开发者ID:RickEyre,项目名称:mozilla-central,代码行数:101,代码来源:nsMathMLmoFrame.cpp
示例14: if
/* virtual */ nsresult
nsMathMLmmultiscriptsFrame::Place(nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
////////////////////////////////////
// Get the children's desired sizes
nscoord minShiftFromXHeight, subDrop, supDrop;
////////////////////////////////////////
// Initialize super/sub shifts that
// depend only on the current font
////////////////////////////////////////
ProcessAttributes();
// get x-height (an ex)
const nsStyleFont* font = GetStyleFont();
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
nscoord xHeight = fm->XHeight();
nscoord ruleSize;
GetRuleThickness (aRenderingContext, fm, ruleSize);
// scriptspace from TeX for extra spacing after sup/subscript (0.5pt in plain TeX)
// forced to be at least 1 pixel here
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord scriptSpace = NS_MAX(nsPresContext::CSSPointsToAppUnits(0.5f), onePixel);
/////////////////////////////////////
// first the shift for the subscript
// subScriptShift{1,2}
// = minimum amount to shift the subscript down
// = sub{1,2} in TeXbook
// subScriptShift1 = subscriptshift attribute * x-height
nscoord subScriptShift1, subScriptShift2;
// Get subScriptShift{1,2} default from font
GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
if (0 < mSubScriptShift) {
// the user has set the subscriptshift attribute
float scaler = ((float) subScriptShift2) / subScriptShift1;
subScriptShift1 = NS_MAX(subScriptShift1, mSubScriptShift);
subScriptShift2 = NSToCoordRound(scaler * subScriptShift1);
}
// the font dependent shift
nscoord subScriptShift = NS_MAX(subScriptShift1,subScriptShift2);
/////////////////////////////////////
// next the shift for the superscript
// supScriptShift{1,2,3}
// = minimum amount to shift the supscript up
// = sup{1,2,3} in TeX
// supScriptShift1 = superscriptshift attribute * x-height
// Note that there are THREE values for supscript shifts depending
// on the current style
nscoord supScriptShift1, supScriptShift2, supScriptShift3;
// Set supScriptShift{1,2,3} default from font
GetSupScriptShifts (fm, supScriptShift1, supScriptShift2, supScriptShift3);
if (0 < mSupScriptShift) {
// the user has set the superscriptshift attribute
float scaler2 = ((float) supScriptShift2) / supScriptShift1;
float scaler3 = ((float) supScriptShift3) / supScriptShift1;
supScriptShift1 = NS_MAX(supScriptShift1, mSupScriptShift);
supScriptShift2 = NSToCoordRound(scaler2 * supScriptShift1);
supScriptShift3 = NSToCoordRound(scaler3 * supScriptShift1);
}
// get sup script shift depending on current script level and display style
// Rule 18c, App. G, TeXbook
nscoord supScriptShift;
if ( font->mScriptLevel == 0 &&
NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags) &&
!NS_MATHML_IS_COMPRESSED(mPresentationData.flags)) {
// Style D in TeXbook
supScriptShift = supScriptShift1;
}
else if (NS_MATHML_IS_COMPRESSED(mPresentationData.flags)) {
// Style C' in TeXbook = D',T',S',SS'
supScriptShift = supScriptShift3;
}
else {
// everything else = T,S,SS
supScriptShift = supScriptShift2;
}
////////////////////////////////////
// Get the children's sizes
////////////////////////////////////
nscoord width = 0, prescriptsWidth = 0, rightBearing = 0;
nsIFrame* mprescriptsFrame = nsnull; // frame of <mprescripts/>, if there.
bool isSubScript = false;
nscoord minSubScriptShift = 0, minSupScriptShift = 0;
//.........这里部分代码省略.........
开发者ID:Anachid,项目名称:mozilla-central,代码行数:101,代码来源:nsMathMLmmultiscriptsFrame.cpp
示例15: clipRect
void
nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
nsPoint aPt, const nsRect& aDirtyRect, uint32_t aBGFlags)
{
// if the border is smaller than the legend. Move the border down
// to be centered on the legend.
// FIXME: This means border-radius clamping is incorrect; we should
// override nsIFrame::GetBorderRadii.
nsRect rect = VisualBorderRectRelativeToSelf();
nscoord yoff = rect.y;
rect += aPt;
nsPresContext* presContext = PresContext();
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
aDirtyRect, rect, aBGFlags);
nsCSSRendering::PaintBoxShadowInner(presContext, aRenderingContext,
this, rect, aDirtyRect);
if (nsIFrame* legend = GetLegend()) {
nscoord topBorder = StyleBorder()->GetComputedBorderWidth(NS_SIDE_TOP);
// Use the rect of the legend frame, not mLegendRect, so we draw our
// border under the legend's left and right margins.
nsRect legendRect = legend->GetRect() + aPt;
// we should probably use PaintBorderEdges to do this but for now just use clipping
// to achieve the same effect.
// draw left side
nsRect clipRect(rect);
clipRect.width = legendRect.x - rect.x;
clipRect.height = topBorder;
aRenderingContext.PushState();
aRenderingContext.IntersectClip(clipRect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
aRenderingContext.PopState();
// draw right side
clipRect = rect;
clipRect.x = legendRect.XMost();
clipRect.width = rect.XMost() - legendRect.XMost();
clipRect.height = topBorder;
aRenderingContext.PushState();
aRenderingContext.IntersectClip(clipRect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
aRenderingContext.PopState();
// draw bottom
clipRect = rect;
clipRect.y += topBorder;
clipRect.height = mRect.height - (yoff + topBorder);
aRenderingContext.PushState();
aRenderingContext.IntersectClip(clipRect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
aRenderingContext.PopState();
} else {
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect,
nsRect(aPt, mRect.Size()),
mStyleContext);
}
}
开发者ID:,项目名称:,代码行数:75,代码来源:
示例16: ReflowError
nsresult
nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
bool
|
请发表评论