本文整理汇总了C++中StyleSheet::SetComplete方法的典型用法代码示例。如果您正苦于以下问题:C++ StyleSheet::SetComplete方法的具体用法?C++ StyleSheet::SetComplete怎么用?C++ StyleSheet::SetComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StyleSheet
的用法示例。
在下文中一共展示了StyleSheet::SetComplete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: url
void
nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr<StyleSheet>* aSheet,
nsPresContext* aPresContext)
{
if (mBackendType == StyleBackendType::Gecko) {
*aSheet = new CSSStyleSheet(eAgentSheetFeatures, CORS_NONE,
mozilla::net::RP_Default);
} else {
*aSheet = new ServoStyleSheet(eAgentSheetFeatures, CORS_NONE,
mozilla::net::RP_Default, dom::SRIMetadata());
}
StyleSheet* sheet = *aSheet;
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), "about:PreferenceStyleSheet", nullptr);
MOZ_ASSERT(uri, "URI creation shouldn't fail");
sheet->SetURIs(uri, uri, uri);
sheet->SetComplete();
static const uint32_t kPreallocSize = 1024;
nsString sheetText;
sheetText.SetCapacity(kPreallocSize);
#define NS_GET_R_G_B(color_) \
NS_GET_R(color_), NS_GET_G(color_), NS_GET_B(color_)
sheetText.AppendLiteral(
"@namespace url(http://www.w3.org/1999/xhtml);\n"
"@namespace svg url(http://www.w3.org/2000/svg);\n");
// Rules for link styling.
nscolor linkColor = aPresContext->DefaultLinkColor();
nscolor activeColor = aPresContext->DefaultActiveLinkColor();
nscolor visitedColor = aPresContext->DefaultVisitedLinkColor();
sheetText.AppendPrintf(
"*|*:link { color: #%02x%02x%02x; }\n"
"*|*:any-link:active { color: #%02x%02x%02x; }\n"
"*|*:visited { color: #%02x%02x%02x; }\n",
NS_GET_R_G_B(linkColor),
NS_GET_R_G_B(activeColor),
NS_GET_R_G_B(visitedColor));
bool underlineLinks =
aPresContext->GetCachedBoolPref(kPresContext_UnderlineLinks);
sheetText.AppendPrintf(
"*|*:any-link%s { text-decoration: %s; }\n",
underlineLinks ? ":not(svg|a)" : "",
underlineLinks ? "underline" : "none");
// Rules for focus styling.
bool focusRingOnAnything = aPresContext->GetFocusRingOnAnything();
uint8_t focusRingWidth = aPresContext->FocusRingWidth();
uint8_t focusRingStyle = aPresContext->GetFocusRingStyle();
if ((focusRingWidth != 1 && focusRingWidth <= 4) || focusRingOnAnything) {
if (focusRingWidth != 1) {
// If the focus ring width is different from the default, fix buttons
// with rings.
sheetText.AppendPrintf(
"button::-moz-focus-inner, input[type=\"reset\"]::-moz-focus-inner, "
"input[type=\"button\"]::-moz-focus-inner, "
"input[type=\"submit\"]::-moz-focus-inner { "
"padding: 1px 2px 1px 2px; "
"border: %dpx %s transparent !important; }\n",
focusRingWidth,
focusRingStyle == 0 ? "solid" : "dotted");
sheetText.AppendLiteral(
"button:focus::-moz-focus-inner, "
"input[type=\"reset\"]:focus::-moz-focus-inner, "
"input[type=\"button\"]:focus::-moz-focus-inner, "
"input[type=\"submit\"]:focus::-moz-focus-inner { "
"border-color: ButtonText !important; }\n");
}
sheetText.AppendPrintf(
"%s { outline: %dpx %s !important; %s}\n",
focusRingOnAnything ?
":focus" :
"*|*:link:focus, *|*:visited:focus",
focusRingWidth,
focusRingStyle == 0 ? // solid
"solid -moz-mac-focusring" : "dotted WindowText",
focusRingStyle == 0 ? // solid
"-moz-outline-radius: 3px; outline-offset: 1px; " : "");
}
if (aPresContext->GetUseFocusColors()) {
nscolor focusText = aPresContext->FocusTextColor();
nscolor focusBG = aPresContext->FocusBackgroundColor();
sheetText.AppendPrintf(
"*:focus, *:focus > font { color: #%02x%02x%02x !important; "
"background-color: #%02x%02x%02x !important; }\n",
NS_GET_R_G_B(focusText),
NS_GET_R_G_B(focusBG));
//.........这里部分代码省略.........