本文整理汇总了C++中SVGUseElement::width方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGUseElement::width方法的具体用法?C++ SVGUseElement::width怎么用?C++ SVGUseElement::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGUseElement
的用法示例。
在下文中一共展示了SVGUseElement::width方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calcViewport
void RenderSVGViewportContainer::calcViewport()
{
SVGSVGElement& svg = svgSVGElement();
FloatRect oldViewport = m_viewport;
SVGLengthContext lengthContext(&svg);
m_viewport = FloatRect(svg.x().value(lengthContext), svg.y().value(lengthContext), svg.width().value(lengthContext), svg.height().value(lengthContext));
SVGElement* correspondingElement = svg.correspondingElement();
if (correspondingElement && svg.isInShadowTree()) {
const HashSet<SVGElementInstance*>& instances = correspondingElement->instancesForElement();
ASSERT(!instances.isEmpty());
SVGUseElement* useElement = 0;
const HashSet<SVGElementInstance*>::const_iterator end = instances.end();
for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) {
const SVGElementInstance* instance = (*it);
ASSERT(instance->correspondingElement()->hasTagName(SVGNames::svgTag) || instance->correspondingElement()->hasTagName(SVGNames::symbolTag));
if (instance->shadowTreeElement() == &svg) {
ASSERT(correspondingElement == instance->correspondingElement());
useElement = instance->directUseElement();
if (!useElement)
useElement = instance->correspondingUseElement();
break;
}
}
ASSERT(useElement);
bool isSymbolElement = correspondingElement->hasTagName(SVGNames::symbolTag);
// Spec (<use> on <symbol>): This generated 'svg' will always have explicit values for attributes width and height.
// If attributes width and/or height are provided on the 'use' element, then these attributes
// will be transferred to the generated 'svg'. If attributes width and/or height are not specified,
// the generated 'svg' element will use values of 100% for these attributes.
// Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these
// values will override the corresponding attributes on the 'svg' in the generated tree.
SVGLengthContext lengthContext(&svg);
if (useElement->hasAttribute(SVGNames::widthAttr))
m_viewport.setWidth(useElement->width().value(lengthContext));
else if (isSymbolElement && svg.hasAttribute(SVGNames::widthAttr)) {
SVGLength containerWidth(LengthModeWidth, "100%");
m_viewport.setWidth(containerWidth.value(lengthContext));
}
if (useElement->hasAttribute(SVGNames::heightAttr))
m_viewport.setHeight(useElement->height().value(lengthContext));
else if (isSymbolElement && svg.hasAttribute(SVGNames::heightAttr)) {
SVGLength containerHeight(LengthModeHeight, "100%");
m_viewport.setHeight(containerHeight.value(lengthContext));
}
}
if (oldViewport != m_viewport) {
setNeedsBoundariesUpdate();
setNeedsTransformUpdate();
}
}
示例2: transferUseWidthAndHeightIfNeeded
static void transferUseWidthAndHeightIfNeeded(
const SVGUseElement& use,
SVGElement& shadowElement,
const SVGElement& originalElement) {
DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%"));
// Use |originalElement| for checking the element type, because we will
// have replaced a <symbol> with an <svg> in the instance tree.
if (isSVGSymbolElement(originalElement)) {
// Spec (<use> on <symbol>): This generated 'svg' will always have
// explicit values for attributes width and height. If attributes
// width and/or height are provided on the 'use' element, then these
// attributes will be transferred to the generated 'svg'. If attributes
// width and/or height are not specified, the generated 'svg' element
// will use values of 100% for these attributes.
shadowElement.setAttribute(
SVGNames::widthAttr,
use.width()->isSpecified()
? AtomicString(use.width()->currentValue()->valueAsString())
: hundredPercentString);
shadowElement.setAttribute(
SVGNames::heightAttr,
use.height()->isSpecified()
? AtomicString(use.height()->currentValue()->valueAsString())
: hundredPercentString);
} else if (isSVGSVGElement(originalElement)) {
// Spec (<use> on <svg>): If attributes width and/or height are
// provided on the 'use' element, then these values will override the
// corresponding attributes on the 'svg' in the generated tree.
shadowElement.setAttribute(
SVGNames::widthAttr,
use.width()->isSpecified()
? AtomicString(use.width()->currentValue()->valueAsString())
: originalElement.getAttribute(SVGNames::widthAttr));
shadowElement.setAttribute(
SVGNames::heightAttr,
use.height()->isSpecified()
? AtomicString(use.height()->currentValue()->valueAsString())
: originalElement.getAttribute(SVGNames::heightAttr));
}
}
示例3: transferUseWidthAndHeightIfNeeded
void transferUseWidthAndHeightIfNeeded(const SVGUseElement& use, SVGElement* shadowElement, const SVGElement& originalElement)
{
DEFINE_STATIC_LOCAL(const AtomicString, hundredPercentString, ("100%", AtomicString::ConstructFromLiteral));
ASSERT(shadowElement);
if (isSVGSymbolElement(*shadowElement)) {
// Spec (<use> on <symbol>): This generated 'svg' will always have explicit values for attributes width and height.
// If attributes width and/or height are provided on the 'use' element, then these attributes
// will be transferred to the generated 'svg'. If attributes width and/or height are not specified,
// the generated 'svg' element will use values of 100% for these attributes.
shadowElement->setAttribute(SVGNames::widthAttr, use.width()->isSpecified() ? AtomicString(use.width()->currentValue()->valueAsString()) : hundredPercentString);
shadowElement->setAttribute(SVGNames::heightAttr, use.height()->isSpecified() ? AtomicString(use.height()->currentValue()->valueAsString()) : hundredPercentString);
} else if (isSVGSVGElement(*shadowElement)) {
// Spec (<use> on <svg>): If attributes width and/or height are provided on the 'use' element, then these
// values will override the corresponding attributes on the 'svg' in the generated tree.
if (use.width()->isSpecified())
shadowElement->setAttribute(SVGNames::widthAttr, AtomicString(use.width()->currentValue()->valueAsString()));
else
shadowElement->setAttribute(SVGNames::widthAttr, originalElement.getAttribute(SVGNames::widthAttr));
if (use.height()->isSpecified())
shadowElement->setAttribute(SVGNames::heightAttr, AtomicString(use.height()->currentValue()->valueAsString()));
else
shadowElement->setAttribute(SVGNames::heightAttr, originalElement.getAttribute(SVGNames::heightAttr));
}
}