本文整理汇总了C++中nsCSSValue::SetFloatValue方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCSSValue::SetFloatValue方法的具体用法?C++ nsCSSValue::SetFloatValue怎么用?C++ nsCSSValue::SetFloatValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCSSValue
的用法示例。
在下文中一共展示了nsCSSValue::SetFloatValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
GetDevicePixelRatio(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
if (!ShouldResistFingerprinting(aPresContext)) {
float ratio = aPresContext->CSSPixelsToDevPixels(1.0f);
aResult.SetFloatValue(ratio, eCSSUnit_Number);
} else {
aResult.SetFloatValue(1.0, eCSSUnit_Number);
}
}
示例2: GetDeviceSize
static void
GetDeviceHeight(nsIDocument* aDocument, const nsMediaFeature*,
nsCSSValue& aResult)
{
nsSize size = GetDeviceSize(aDocument);
aResult.SetFloatValue(CSSPixel::FromAppUnits(size.height), eCSSUnit_Pixel);
}
示例3: GetSize
static void
GetWidth(nsIDocument* aDocument, const nsMediaFeature*,
nsCSSValue& aResult)
{
nsSize size = GetSize(aDocument);
aResult.SetFloatValue(CSSPixel::FromAppUnits(size.width), eCSSUnit_Pixel);
}
示例4: GetSize
static void
GetWidth(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
nsSize size = GetSize(aPresContext);
float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width);
aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel);
}
示例5: GetDeviceSize
static void
GetDeviceHeight(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
nsSize size = GetDeviceSize(aPresContext);
float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
}
示例6:
static nsresult
GetDevicePixelRatio(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
float ratio = aPresContext->CSSPixelsToDevPixels(1.0f);
aResult.SetFloatValue(ratio, eCSSUnit_Number);
return NS_OK;
}
示例7: GetDeviceSize
static nsresult
GetDeviceWidth(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
nsSize size = GetDeviceSize(aPresContext);
float pixelWidth = aPresContext->AppUnitsToFloatCSSPixels(size.width);
aResult.SetFloatValue(pixelWidth, eCSSUnit_Pixel);
return NS_OK;
}
示例8: GetSize
static nsresult
GetHeight(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
nsSize size = GetSize(aPresContext);
float pixelHeight = aPresContext->AppUnitsToFloatCSSPixels(size.height);
aResult.SetFloatValue(pixelHeight, eCSSUnit_Pixel);
return NS_OK;
}
示例9: GetDeviceContextFor
static nsresult
GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
// Resolution values are in device pixels, not CSS pixels.
nsDeviceContext *dx = GetDeviceContextFor(aPresContext);
float dpi = float(dx->AppUnitsPerPhysicalInch()) / float(dx->AppUnitsPerDevPixel());
aResult.SetFloatValue(dpi, eCSSUnit_Inch);
return NS_OK;
}
示例10: float
static nsresult
GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
// Resolution measures device pixels per CSS (inch/cm/pixel). We
// return it in device pixels per CSS inches.
float dpi = float(nsPresContext::AppUnitsPerCSSInch()) /
float(aPresContext->AppUnitsPerDevPixel());
aResult.SetFloatValue(dpi, eCSSUnit_Inch);
return NS_OK;
}
示例11: float
static void
GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
float dpi = 96; // Use 96 when resisting fingerprinting.
if (!ShouldResistFingerprinting(aPresContext)) {
// Resolution measures device pixels per CSS (inch/cm/pixel). We
// return it in device pixels per CSS inches.
dpi = float(nsPresContext::AppUnitsPerCSSInch()) /
float(aPresContext->AppUnitsPerDevPixel());
}
aResult.SetFloatValue(dpi, eCSSUnit_Inch);
}
示例12:
static void
GetDevicePixelRatio(nsIDocument* aDocument, const nsMediaFeature*,
nsCSSValue& aResult)
{
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
aResult.SetFloatValue(1.0, eCSSUnit_Number);
return;
}
nsIPresShell* presShell = aDocument->GetShell();
if (!presShell) {
aResult.SetFloatValue(1.0, eCSSUnit_Number);
return;
}
nsPresContext* pc = presShell->GetPresContext();
if (!pc) {
aResult.SetFloatValue(1.0, eCSSUnit_Number);
return;
}
float ratio = pc->CSSPixelsToDevPixels(1.0f);
aResult.SetFloatValue(ratio, eCSSUnit_Number);
}
示例13: if
/* static */ bool
nsMathMLElement::ParseNamedSpaceValue(const nsString& aString,
nsCSSValue& aCSSValue,
uint32_t aFlags)
{
int32_t i = 0;
// See if it is one of the 'namedspace' (ranging -7/18em, -6/18, ... 7/18em)
if (aString.EqualsLiteral("veryverythinmathspace")) {
i = 1;
} else if (aString.EqualsLiteral("verythinmathspace")) {
i = 2;
} else if (aString.EqualsLiteral("thinmathspace")) {
i = 3;
} else if (aString.EqualsLiteral("mediummathspace")) {
i = 4;
} else if (aString.EqualsLiteral("thickmathspace")) {
i = 5;
} else if (aString.EqualsLiteral("verythickmathspace")) {
i = 6;
} else if (aString.EqualsLiteral("veryverythickmathspace")) {
i = 7;
} else if (aFlags & PARSE_ALLOW_NEGATIVE) {
if (aString.EqualsLiteral("negativeveryverythinmathspace")) {
i = -1;
} else if (aString.EqualsLiteral("negativeverythinmathspace")) {
i = -2;
} else if (aString.EqualsLiteral("negativethinmathspace")) {
i = -3;
} else if (aString.EqualsLiteral("negativemediummathspace")) {
i = -4;
} else if (aString.EqualsLiteral("negativethickmathspace")) {
i = -5;
} else if (aString.EqualsLiteral("negativeverythickmathspace")) {
i = -6;
} else if (aString.EqualsLiteral("negativeveryverythickmathspace")) {
i = -7;
}
}
if (0 != i) {
aCSSValue.SetFloatValue(float(i)/float(18), eCSSUnit_EM);
return true;
}
return false;
}
示例14: GetDeviceContextFor
static nsresult
GetResolution(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult)
{
// Resolution measures device pixels per CSS (inch/cm/pixel). We
// return it in device pixels per CSS inches.
//
// However, on platforms where the CSS viewport is not fixed to the
// screen viewport, use the device resolution instead (bug 779527).
nsIPresShell *shell = aPresContext->PresShell();
float appUnitsPerInch = shell->GetIsViewportOverridden() ?
GetDeviceContextFor(aPresContext)->AppUnitsPerPhysicalInch() :
nsPresContext::AppUnitsPerCSSInch();
float dpi = appUnitsPerInch /
float(aPresContext->AppUnitsPerDevPixel());
aResult.SetFloatValue(dpi, eCSSUnit_Inch);
return NS_OK;
}
示例15: float
static void
GetResolution(nsIDocument* aDocument, const nsMediaFeature*,
nsCSSValue& aResult)
{
// We're returning resolution in terms of device pixels per css pixel, since
// that is the preferred unit for media queries of resolution. This avoids
// introducing precision error from conversion to and from less-used
// physical units like inches.
float dppx = 1.;
if (nsDeviceContext* dx = GetDeviceContextFor(aDocument)) {
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
dppx = dx->GetFullZoom();
} else {
// Get the actual device pixel ratio, which also takes zoom into account.
dppx =
float(nsPresContext::AppUnitsPerCSSPixel()) / dx->AppUnitsPerDevPixel();
}
}
aResult.SetFloatValue(dppx, eCSSUnit_Pixel);
}