本文整理汇总了C++中SVGSVGElement::GetCurrentViewElement方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGSVGElement::GetCurrentViewElement方法的具体用法?C++ SVGSVGElement::GetCurrentViewElement怎么用?C++ SVGSVGElement::GetCurrentViewElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGSVGElement
的用法示例。
在下文中一共展示了SVGSVGElement::GetCurrentViewElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ratio
/* virtual */ nsSize
nsSVGOuterSVGFrame::GetIntrinsicRatio()
{
// We only have an intrinsic size/ratio if our width and height attributes
// are both specified and set to non-percentage values, or we have a viewBox
// rect: http://www.w3.org/TR/SVGMobile12/coords.html#IntrinsicSizing
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
nsSVGLength2 &width = content->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
nsSVGLength2 &height = content->mLengthAttributes[SVGSVGElement::ATTR_HEIGHT];
if (!width.IsPercentage() && !height.IsPercentage()) {
nsSize ratio(NSToCoordRoundWithClamp(width.GetAnimValue(content)),
NSToCoordRoundWithClamp(height.GetAnimValue(content)));
if (ratio.width < 0) {
ratio.width = 0;
}
if (ratio.height < 0) {
ratio.height = 0;
}
return ratio;
}
SVGViewElement* viewElement = content->GetCurrentViewElement();
const nsSVGViewBoxRect* viewbox = nullptr;
// The logic here should match HasViewBox().
if (viewElement && viewElement->mViewBox.HasRect()) {
viewbox = &viewElement->mViewBox.GetAnimValue();
} else if (content->mViewBox.HasRect()) {
viewbox = &content->mViewBox.GetAnimValue();
}
if (viewbox) {
float viewBoxWidth = viewbox->width;
float viewBoxHeight = viewbox->height;
if (viewBoxWidth < 0.0f) {
viewBoxWidth = 0.0f;
}
if (viewBoxHeight < 0.0f) {
viewBoxHeight = 0.0f;
}
return nsSize(NSToCoordRoundWithClamp(viewBoxWidth),
NSToCoordRoundWithClamp(viewBoxHeight));
}
return nsSVGOuterSVGFrameBase::GetIntrinsicRatio();
}