本文整理汇总了C++中SVGSVGElement::intrinsicHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGSVGElement::intrinsicHeight方法的具体用法?C++ SVGSVGElement::intrinsicHeight怎么用?C++ SVGSVGElement::intrinsicHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGSVGElement
的用法示例。
在下文中一共展示了SVGSVGElement::intrinsicHeight方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: containerSize
IntSize SVGImage::containerSize() const
{
if (!m_page)
return IntSize();
Frame* frame = m_page->mainFrame();
SVGSVGElement* rootElement = toSVGDocument(frame->document())->rootElement();
if (!rootElement)
return IntSize();
RenderSVGRoot* renderer = toRenderSVGRoot(rootElement->renderer());
if (!renderer)
return IntSize();
// If a container size is available it has precedence.
IntSize containerSize = renderer->containerSize();
if (!containerSize.isEmpty())
return containerSize;
// Assure that a container size is always given for a non-identity zoom level.
ASSERT(renderer->style()->effectiveZoom() == 1);
FloatSize currentSize;
if (rootElement->intrinsicWidth().isFixed() && rootElement->intrinsicHeight().isFixed())
currentSize = rootElement->currentViewportSize();
else
currentSize = rootElement->currentViewBoxRect().size();
if (!currentSize.isEmpty())
return IntSize(static_cast<int>(ceilf(currentSize.width())), static_cast<int>(ceilf(currentSize.height())));
// As last resort, use CSS default intrinsic size.
return IntSize(300, 150);
}
示例2: hasRelativeHeight
bool SVGImage::hasRelativeHeight() const
{
SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return false;
return rootElement->intrinsicHeight().isPercentOrCalculated();
}
示例3: hasRelativeDimensions
bool RenderSVGRoot::hasRelativeDimensions() const
{
SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
ASSERT(svg);
return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent() || svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties).isPercent();
}
示例4: computeReplacedLogicalHeight
LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
{
SVGSVGElement* svg = toSVGSVGElement(node());
ASSERT(svg);
// When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
if (!m_containerSize.isEmpty())
return m_containerSize.height();
if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().isSpecified())
return RenderReplaced::computeReplacedLogicalHeight();
if (svg->heightAttributeEstablishesViewport()) {
Length height = svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
if (height.isPercent()) {
RenderBlock* cb = containingBlock();
ASSERT(cb);
while (cb->isAnonymous()) {
cb = cb->containingBlock();
cb->addPercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
}
} else
RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
return resolveLengthAttributeForSVG(height, style()->effectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding), view());
}
// SVG embedded through object/embed/iframe.
if (isEmbeddedThroughFrameContainingSVGDocument())
return document()->frame()->ownerRenderer()->availableLogicalHeight(IncludeMarginBorderPadding);
// SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
return RenderReplaced::computeReplacedLogicalHeight();
}
示例5: computeReplacedLogicalHeight
LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
{
SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
ASSERT(svg);
// When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
if (!m_containerSize.isEmpty())
return m_containerSize.height();
if (hasReplacedLogicalHeight())
return RenderReplaced::computeReplacedLogicalHeight();
if (svg->heightAttributeEstablishesViewport()) {
Length height = svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
if (height.isPercent()) {
RenderBlock* cb = containingBlock();
ASSERT(cb);
while (cb->isAnonymous()) {
cb = cb->containingBlock();
cb->addPercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
}
} else
RenderBlock::removePercentHeightDescendant(const_cast<RenderSVGRoot*>(this));
return resolveLengthAttributeForSVG(height, style()->effectiveZoom(), containingBlock()->availableLogicalHeight());
}
// Only SVGs embedded in <object> reach this point.
ASSERT(isEmbeddedThroughFrameContainingSVGDocument());
return document()->frame()->ownerRenderer()->availableLogicalHeight();
}
示例6: hasRelativeLogicalHeight
bool RenderSVGRoot::hasRelativeLogicalHeight() const
{
SVGSVGElement* svg = toSVGSVGElement(node());
ASSERT(svg);
return svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties).isPercent();
}
示例7: computeIntrinsicRatioInformation
void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
{
// Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
// SVG needs to specify how to calculate some intrinsic sizing properties to enable inclusion within other languages.
// The intrinsic width and height of the viewport of SVG content must be determined from the ‘width’ and ‘height’ attributes.
SVGSVGElement* svg = toSVGSVGElement(node());
ASSERT(svg);
// The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including SVG from an ‘object’
// element in HTML styled with CSS. It is possible (indeed, common) for an SVG graphic to have an intrinsic aspect ratio but
// not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules:
// - The aspect ratio is calculated by dividing a width by a height.
// - If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers (in, mm, cm, pt, pc,
// px, em, ex) or in user units, then the aspect ratio is calculated from the ‘width’ and ‘height’ attributes after
// resolving both values to user units.
intrinsicSize.setWidth(floatValueForLength(svg->intrinsicWidth(), 0));
intrinsicSize.setHeight(floatValueForLength(svg->intrinsicHeight(), 0));
if (!intrinsicSize.isEmpty()) {
intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
} else {
// - If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted), the
// aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG document
// fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio cannot be
// calculated and is considered unspecified.
FloatSize viewBoxSize = svg->viewBox()->currentValue()->value().size();
if (!viewBoxSize.isEmpty()) {
// The viewBox can only yield an intrinsic ratio, not an intrinsic size.
intrinsicRatio = viewBoxSize.width() / static_cast<double>(viewBoxSize.height());
}
}
}
示例8: hasRelativeHeight
bool SVGImage::hasRelativeHeight() const
{
if (!m_page)
return false;
SVGSVGElement* rootElement = toSVGDocument(m_page->mainFrame().document())->rootElement();
if (!rootElement)
return false;
return rootElement->intrinsicHeight().isPercent();
}
示例9: computeIntrinsicRatioInformation
void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
{
// Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
// SVG needs to specify how to calculate some intrinsic sizing properties to enable inclusion within other languages.
// The intrinsic width and height of the viewport of SVG content must be determined from the ‘width’ and ‘height’ attributes.
// If either of these are not specified, a value of '100%' must be assumed. Note: the ‘width’ and ‘height’ attributes are not
// the same as the CSS width and height properties. Specifically, percentage values do not provide an intrinsic width or height,
// and do not indicate a percentage of the containing block. Rather, once the viewport is established, they indicate the portion
// of the viewport that is actually covered by image data.
SVGSVGElement* svg = toSVGSVGElement(node());
ASSERT(svg);
Length intrinsicWidthAttribute = svg->intrinsicWidth(SVGSVGElement::IgnoreCSSProperties);
Length intrinsicHeightAttribute = svg->intrinsicHeight(SVGSVGElement::IgnoreCSSProperties);
// The intrinsic aspect ratio of the viewport of SVG content is necessary for example, when including SVG from an ‘object’
// element in HTML styled with CSS. It is possible (indeed, common) for an SVG graphic to have an intrinsic aspect ratio but
// not to have an intrinsic width or height. The intrinsic aspect ratio must be calculated based upon the following rules:
// - The aspect ratio is calculated by dividing a width by a height.
// - If the ‘width’ and ‘height’ of the rootmost ‘svg’ element are both specified with unit identifiers (in, mm, cm, pt, pc,
// px, em, ex) or in user units, then the aspect ratio is calculated from the ‘width’ and ‘height’ attributes after
// resolving both values to user units.
if (intrinsicWidthAttribute.isFixed() || intrinsicHeightAttribute.isFixed()) {
if (intrinsicWidthAttribute.isFixed())
intrinsicSize.setWidth(floatValueForLength(intrinsicWidthAttribute, 0));
if (intrinsicHeightAttribute.isFixed())
intrinsicSize.setHeight(floatValueForLength(intrinsicHeightAttribute, 0));
if (!intrinsicSize.isEmpty())
intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
return;
}
// - If either/both of the ‘width’ and ‘height’ of the rootmost ‘svg’ element are in percentage units (or omitted), the
// aspect ratio is calculated from the width and height values of the ‘viewBox’ specified for the current SVG document
// fragment. If the ‘viewBox’ is not correctly specified, or set to 'none', the intrinsic aspect ratio cannot be
// calculated and is considered unspecified.
intrinsicSize = svg->viewBox().size();
if (!intrinsicSize.isEmpty()) {
// The viewBox can only yield an intrinsic ratio, not an intrinsic size.
intrinsicRatio = intrinsicSize.width() / static_cast<double>(intrinsicSize.height());
intrinsicSize = FloatSize();
return;
}
// If our intrinsic size is in percentage units, return those to the caller through the intrinsicSize. Notify the caller
// about the special situation, by setting isPercentageIntrinsicSize=true, so it knows how to interpret the return values.
if (intrinsicWidthAttribute.isPercent() && intrinsicHeightAttribute.isPercent()) {
isPercentageIntrinsicSize = true;
intrinsicSize = FloatSize(intrinsicWidthAttribute.percent(), intrinsicHeightAttribute.percent());
}
}
示例10: computeIntrinsicDimensions
void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return;
intrinsicWidth = rootElement->intrinsicWidth();
intrinsicHeight = rootElement->intrinsicHeight();
if (rootElement->preserveAspectRatio().align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
return;
intrinsicRatio = rootElement->viewBox().size();
if (intrinsicRatio.isEmpty() && intrinsicWidth.isFixed() && intrinsicHeight.isFixed())
intrinsicRatio = FloatSize(floatValueForLength(intrinsicWidth, 0), floatValueForLength(intrinsicHeight, 0));
}
示例11: computeIntrinsicDimensions
void SVGImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
{
if (!m_page)
return;
Frame* frame = m_page->mainFrame();
SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
if (!rootElement)
return;
intrinsicWidth = rootElement->intrinsicWidth();
intrinsicHeight = rootElement->intrinsicHeight();
if (rootElement->preserveAspectRatio().align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
return;
intrinsicRatio = rootElement->viewBox().size();
if (intrinsicRatio.isEmpty() && intrinsicWidth.isFixed() && intrinsicHeight.isFixed())
intrinsicRatio = FloatSize(intrinsicWidth.calcFloatValue(0), intrinsicHeight.calcFloatValue(0));
}
示例12: computeReplacedLogicalHeight
LayoutUnit RenderSVGRoot::computeReplacedLogicalHeight() const
{
SVGSVGElement* svg = toSVGSVGElement(node());
ASSERT(svg);
// When we're embedded through SVGImage (border-image/background-image/<html:img>/...) we're forced to resize to a specific size.
if (!m_containerSize.isEmpty())
return m_containerSize.height();
if (isEmbeddedThroughFrameContainingSVGDocument())
return containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding);
if (style()->logicalHeight().isSpecified() || style()->logicalMaxHeight().isSpecified())
return RenderReplaced::computeReplacedLogicalHeight();
if (svg->hasIntrinsicHeight())
return resolveLengthAttributeForSVG(svg->intrinsicHeight(), style()->effectiveZoom(), containingBlock()->availableLogicalHeight(IncludeMarginBorderPadding).toFloat());
// SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
return RenderReplaced::computeReplacedLogicalHeight();
}
示例13: calculateIntrinsicSize
FloatSize LayoutSVGRoot::calculateIntrinsicSize() const
{
SVGSVGElement* svg = toSVGSVGElement(node());
ASSERT(svg);
return FloatSize(floatValueForLength(svg->intrinsicWidth(), 0), floatValueForLength(svg->intrinsicHeight(), 0));
}