本文整理汇总了C++中nsIRenderingContext::GetDeviceContext方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIRenderingContext::GetDeviceContext方法的具体用法?C++ nsIRenderingContext::GetDeviceContext怎么用?C++ nsIRenderingContext::GetDeviceContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIRenderingContext
的用法示例。
在下文中一共展示了nsIRenderingContext::GetDeviceContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTextDecorations
void
nsHTMLContainerFrame::PaintDecorationsAndChildren(
nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRBool aIsBlock,
PRUint32 aFlags)
{
// Do standards mode painting of 'text-decoration's: under+overline
// behind children, line-through in front. For Quirks mode, see
// nsTextFrame::PaintTextDecorations. (See bug 1777.)
nscolor underColor, overColor, strikeColor;
PRUint8 decorations = NS_STYLE_TEXT_DECORATION_NONE;
nsCOMPtr<nsIFontMetrics> fm;
PRBool isVisible;
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode() &&
NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer &&
NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext,
PR_TRUE, &isVisible)) &&
isVisible) {
GetTextDecorations(aPresContext, aIsBlock, decorations, underColor,
overColor, strikeColor);
if (decorations & (NS_STYLE_TEXT_DECORATION_UNDERLINE |
NS_STYLE_TEXT_DECORATION_OVERLINE |
NS_STYLE_TEXT_DECORATION_LINE_THROUGH)) {
const nsStyleFont* font = GetStyleFont();
NS_ASSERTION(font->mFont.decorations == NS_FONT_DECORATION_NONE,
"fonts on style structs shouldn't have decorations");
// XXX This is relatively slow and shouldn't need to be used here.
nsCOMPtr<nsIDeviceContext> deviceContext;
aRenderingContext.GetDeviceContext(*getter_AddRefs(deviceContext));
nsCOMPtr<nsIFontMetrics> normalFont;
const nsStyleVisibility* visibility = GetStyleVisibility();
deviceContext->GetMetricsFor(font->mFont, visibility->mLangGroup, *getter_AddRefs(fm));
}
if (decorations & NS_STYLE_TEXT_DECORATION_UNDERLINE) {
PaintTextDecorations(aRenderingContext, fm,
NS_STYLE_TEXT_DECORATION_UNDERLINE, underColor);
}
if (decorations & NS_STYLE_TEXT_DECORATION_OVERLINE) {
PaintTextDecorations(aRenderingContext, fm,
NS_STYLE_TEXT_DECORATION_OVERLINE, overColor);
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect,
aWhichLayer, aFlags);
if (decorations & NS_STYLE_TEXT_DECORATION_LINE_THROUGH) {
PaintTextDecorations(aRenderingContext, fm,
NS_STYLE_TEXT_DECORATION_LINE_THROUGH, strikeColor);
}
}