本文整理汇总了C++中SVGLength::value方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGLength::value方法的具体用法?C++ SVGLength::value怎么用?C++ SVGLength::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGLength
的用法示例。
在下文中一共展示了SVGLength::value方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: size
IntSize SVGImage::size() const
{
IntSize defaultSize(300, 150);
// FIXME: Eventually we'll be passed in the dest size and can scale against that
IntSize destSize = defaultSize;
if (!m_frame || !m_frame->document())
return IntSize();
SVGSVGElement* rootElement = static_cast<SVGDocument*>(m_frame->document())->rootElement();
if (!rootElement)
return defaultSize;
SVGLength width = rootElement->width();
SVGLength height = rootElement->height();
IntSize svgSize;
if (width.unitType() == LengthTypePercentage)
svgSize.setWidth(static_cast<int>(width.valueInSpecifiedUnits() * destSize.width()));
else
svgSize.setWidth(static_cast<int>(width.value()));
if (height.unitType() == LengthTypePercentage)
svgSize.setHeight(static_cast<int>(height.valueInSpecifiedUnits() * destSize.height()));
else
svgSize.setHeight(static_cast<int>(height.value()));
return svgSize;
}
示例2: size
IntSize SVGImage::size() const
{
if (!m_page)
return IntSize();
Frame* frame = m_page->mainFrame();
SVGSVGElement* rootElement = static_cast<SVGDocument*>(frame->document())->rootElement();
if (!rootElement)
return IntSize();
SVGLength width = rootElement->width();
SVGLength height = rootElement->height();
IntSize svgSize;
if (width.unitType() == LengthTypePercentage)
svgSize.setWidth(rootElement->relativeWidthValue());
else
svgSize.setWidth(static_cast<int>(width.value(rootElement)));
if (height.unitType() == LengthTypePercentage)
svgSize.setHeight(rootElement->relativeHeightValue());
else
svgSize.setHeight(static_cast<int>(height.value(rootElement)));
return svgSize;
}
示例3: resolvePoint
FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitTypes::SVGUnitType type, const SVGLength& x, const SVGLength& y)
{
ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN);
if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
SVGLengthContext lengthContext(context);
return FloatPoint(x.value(lengthContext), y.value(lengthContext));
}
// FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to be resolved in user space and then be considered in objectBoundingBox space.
return FloatPoint(x.valueAsPercentage(), y.valueAsPercentage());
}
示例4: resolveRectangle
FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitTypes::SVGUnitType type, const FloatRect& viewport, const SVGLength& x, const SVGLength& y, const SVGLength& width, const SVGLength& height)
{
ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN);
if (type != SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
const FloatSize& viewportSize = viewport.size();
return FloatRect(
convertValueFromPercentageToUserUnits(x, viewportSize) + viewport.x(),
convertValueFromPercentageToUserUnits(y, viewportSize) + viewport.y(),
convertValueFromPercentageToUserUnits(width, viewportSize),
convertValueFromPercentageToUserUnits(height, viewportSize));
}
SVGLengthContext lengthContext(context);
return FloatRect(x.value(lengthContext), y.value(lengthContext), width.value(lengthContext), height.value(lengthContext));
}
示例5: resolvePoint
FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context,
SVGUnitTypes::SVGUnitType type,
const SVGLength& x,
const SVGLength& y) {
DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type);
if (type == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) {
SVGLengthContext lengthContext(context);
return FloatPoint(x.value(lengthContext), y.value(lengthContext));
}
// FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to
// be resolved in user space and then be considered in objectBoundingBox
// space.
return FloatPoint(x.valueAsPercentage(), y.valueAsPercentage());
}
示例6: calculateCSSKerningAndSpacing
float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderStyle* style, SVGElement* contextElement, const UChar* currentCharacter)
{
float kerning = 0;
SVGLength kerningLength = style->kerning();
if (kerningLength.unitType() == LengthTypePercentage)
kerning = kerningLength.valueAsPercentage() * m_font.pixelSize();
else {
SVGLengthContext lengthContext(contextElement);
kerning = kerningLength.value(lengthContext);
}
const UChar* lastCharacter = m_lastCharacter;
m_lastCharacter = currentCharacter;
if (!kerning && !m_font.letterSpacing() && !m_font.wordSpacing())
return 0;
float spacing = m_font.letterSpacing() + kerning;
if (currentCharacter && lastCharacter && m_font.wordSpacing()) {
if (Font::treatAsSpace(*currentCharacter) && !Font::treatAsSpace(*lastCharacter))
spacing += m_font.wordSpacing();
}
return spacing;
}
示例7: resolveRectangle
FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context,
SVGUnitTypes::SVGUnitType type,
const FloatRect& viewport,
const SVGLength& x,
const SVGLength& y,
const SVGLength& width,
const SVGLength& height) {
DCHECK_NE(SVGUnitTypes::kSvgUnitTypeUnknown, type);
if (type != SVGUnitTypes::kSvgUnitTypeUserspaceonuse) {
const FloatSize& viewportSize = viewport.size();
return FloatRect(
convertValueFromPercentageToUserUnits(x, viewportSize) + viewport.x(),
convertValueFromPercentageToUserUnits(y, viewportSize) + viewport.y(),
convertValueFromPercentageToUserUnits(width, viewportSize),
convertValueFromPercentageToUserUnits(height, viewportSize));
}
SVGLengthContext lengthContext(context);
return FloatRect(x.value(lengthContext), y.value(lengthContext),
width.value(lengthContext), height.value(lengthContext));
}
示例8: resolveRectangle
FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitTypes::SVGUnitType type, const FloatRect& viewport, const SVGLength& x, const SVGLength& y, const SVGLength& width, const SVGLength& height)
{
ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN);
if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
SVGLengthContext lengthContext(context);
return FloatRect(x.value(lengthContext), y.value(lengthContext), width.value(lengthContext), height.value(lengthContext));
}
SVGLengthContext lengthContext(context, viewport);
return FloatRect(x.value(lengthContext) + viewport.x(),
y.value(lengthContext) + viewport.y(),
width.value(lengthContext),
height.value(lengthContext));
}
示例9: extractFloatValuesFromSVGLengthList
static inline void extractFloatValuesFromSVGLengthList(SVGElement* lengthContext, SVGLengthList* list, Vector<float>& floatValues, unsigned textContentLength)
{
ASSERT(lengthContext);
ASSERT(list);
unsigned length = list->numberOfItems();
if (length > textContentLength)
length = textContentLength;
floatValues.reserveCapacity(length);
ExceptionCode ec = 0;
for (unsigned i = 0; i < length; ++i) {
SVGLength length = list->getItem(i, ec);
ASSERT(!ec);
floatValues.append(length.value(lengthContext));
}
}
示例10: calculateBaselineShift
float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle* style, SVGElement* lengthContext) const
{
if (style->baselineShift() == BS_LENGTH) {
SVGLength baselineShiftValueLength = style->baselineShiftValue();
if (baselineShiftValueLength.unitType() == LengthTypePercentage)
return baselineShiftValueLength.valueAsPercentage() * m_font.pixelSize();
return baselineShiftValueLength.value(lengthContext);
}
switch (style->baselineShift()) {
case BS_BASELINE:
return 0;
case BS_SUB:
return -m_font.height() / 2;
case BS_SUPER:
return m_font.height() / 2;
default:
ASSERT_NOT_REACHED();
return 0;
}
}
示例11: calculateBaselineShift
// Helper function
static float calculateBaselineShift(RenderObject* item)
{
ASSERT(item);
ASSERT(item->style());
ASSERT(item->node());
ASSERT(item->node()->isSVGElement());
const Font& font = item->style()->font();
const SVGRenderStyle* svgStyle = item->style()->svgStyle();
float baselineShift = 0.0f;
if (svgStyle->baselineShift() == BS_LENGTH) {
SVGLength baselineShiftValueLength = svgStyle->baselineShiftValue();
if (baselineShiftValueLength.unitType() == LengthTypePercentage)
baselineShift = baselineShiftValueLength.valueAsPercentage() * font.pixelSize();
else
baselineShift = baselineShiftValueLength.value(static_cast<SVGElement*>(item->node()));
} else {
float baselineAscent = font.ascent() + font.descent();
switch (svgStyle->baselineShift()) {
case BS_BASELINE:
break;
case BS_SUB:
baselineShift = -baselineAscent / 2.0f;
break;
case BS_SUPER:
baselineShift = baselineAscent / 2.0f;
break;
default:
ASSERT_NOT_REACHED();
}
}
return baselineShift;
}
示例12: calcViewport
void RenderSVGRoot::calcViewport()
{
SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
if (!selfNeedsLayout() && !svg->hasRelativeValues())
return;
if (!svg->hasSetContainerSize()) {
// In the normal case of <svg> being stand-alone or in a CSSBoxModel object we use
// RenderBox::width()/height() (which pulls data from RenderStyle)
m_viewportSize = FloatSize(width(), height());
} else {
// In the SVGImage case grab the SVGLength values off of SVGSVGElement and use
// the special relativeWidthValue accessors which respect the specified containerSize
SVGLength width = svg->width();
SVGLength height = svg->height();
float viewportWidth = (width.unitType() == LengthTypePercentage) ? svg->relativeWidthValue() : width.value(svg);
float viewportHeight = (height.unitType() == LengthTypePercentage) ? svg->relativeHeightValue() : height.value(svg);
m_viewportSize = FloatSize(viewportWidth, viewportHeight);
}
}
示例13: calcViewport
void RenderSVGRoot::calcViewport()
{
SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
if (!svg->hasSetContainerSize()) {
// In the normal case of <svg> being stand-alone or in a CSSBoxModel object we use
// RenderBox::width()/height() (which pulls data from RenderStyle)
m_viewportSize = FloatSize(width(), height());
return;
}
// In the SVGImage case grab the SVGLength values off of SVGSVGElement and use
// the special relativeWidthValue accessors which respect the specified containerSize
// FIXME: Check how SVGImage + zooming is supposed to be handled?
SVGLength width = svg->width();
SVGLength height = svg->height();
m_viewportSize = FloatSize(width.unitType() == LengthTypePercentage ? svg->relativeWidthValue() : width.value(svg),
height.unitType() == LengthTypePercentage ? svg->relativeHeightValue() : height.value(svg));
}