本文整理汇总了C++中FloatSize::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatSize::isEmpty方法的具体用法?C++ FloatSize::isEmpty怎么用?C++ FloatSize::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatSize
的用法示例。
在下文中一共展示了FloatSize::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 = static_cast<SVGSVGElement*>(node());
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());
}
}
示例2: computeAspectRatioInformationForRenderBox
void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* contentRenderer, FloatSize& constrainedSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
{
FloatSize intrinsicSize;
if (contentRenderer) {
contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
if (intrinsicRatio)
ASSERT(!isPercentageIntrinsicSize);
// Handle zoom & vertical writing modes here, as the embedded document doesn't know about them.
if (!isPercentageIntrinsicSize)
intrinsicSize.scale(style()->effectiveZoom());
if (rendererHasAspectRatio(this) && isPercentageIntrinsicSize)
intrinsicRatio = 1;
// Update our intrinsic size to match what the content renderer has computed, so that when we
// constrain the size below, the correct intrinsic size will be obtained for comparison against
// min and max widths.
if (intrinsicRatio && !isPercentageIntrinsicSize && !intrinsicSize.isEmpty())
m_intrinsicSize = LayoutSize(intrinsicSize);
if (!isHorizontalWritingMode()) {
if (intrinsicRatio)
intrinsicRatio = 1 / intrinsicRatio;
intrinsicSize = intrinsicSize.transposedSize();
}
} else {
computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
if (intrinsicRatio) {
ASSERT(!isPercentageIntrinsicSize);
if (!intrinsicSize.isEmpty())
m_intrinsicSize = LayoutSize(isHorizontalWritingMode() ? intrinsicSize : intrinsicSize.transposedSize());
}
}
// Now constrain the intrinsic size along each axis according to minimum and maximum width/heights along the
// opposite axis. So for example a maximum width that shrinks our width will result in the height we compute here
// having to shrink in order to preserve the aspect ratio. Because we compute these values independently along
// each axis, the final returned size may in fact not preserve the aspect ratio.
// FIXME: In the long term, it might be better to just return this code more to the way it used to be before this
// function was added, since all it has done is make the code more unclear.
constrainedSize = intrinsicSize;
if (intrinsicRatio && !isPercentageIntrinsicSize && !intrinsicSize.isEmpty() && style()->logicalWidth().isAuto() && style()->logicalHeight().isAuto()) {
// We can't multiply or divide by 'intrinsicRatio' here, it breaks tests, like fast/images/zoomed-img-size.html, which
// can only be fixed once subpixel precision is available for things like intrinsicWidth/Height - which include zoom!
constrainedSize.setWidth(RenderBox::computeReplacedLogicalHeight() * intrinsicSize.width() / intrinsicSize.height());
constrainedSize.setHeight(RenderBox::computeReplacedLogicalWidth() * intrinsicSize.height() / intrinsicSize.width());
}
}
示例3: determineViewport
bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const
{
if (!m_context)
return false;
// If an overriden viewport is given, it has precedence.
if (!m_overridenViewport.isEmpty()) {
viewportSize = m_overridenViewport.size();
return true;
}
// Root <svg> element lengths are resolved against the top level viewport.
if (m_context->isOutermostSVGSVGElement()) {
viewportSize = downcast<SVGSVGElement>(*m_context).currentViewportSize();
return true;
}
// Take size from nearest viewport element.
SVGElement* viewportElement = m_context->viewportElement();
if (!is<SVGSVGElement>(viewportElement))
return false;
const SVGSVGElement& svg = downcast<SVGSVGElement>(*viewportElement);
viewportSize = svg.currentViewBoxRect().size();
if (viewportSize.isEmpty())
viewportSize = svg.currentViewportSize();
return true;
}
示例4: sizeNeedsClamping
bool ImageBuffer::sizeNeedsClamping(const FloatSize& size)
{
if (size.isEmpty())
return false;
return floorf(size.height()) * floorf(size.width()) > MaxClampedArea;
}
示例5: computeIntrinsicRatioInformation
void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicRatio, bool& isPercentageIntrinsicSize) const
{
// Spec: http://dev.w3.org/SVG/profiles/1.1F2/publish/coords.html#IntrinsicSizing
// 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.
isPercentageIntrinsicSize = false;
if (style()->width().isFixed() && style()->height().isFixed()) {
intrinsicRatio = FloatSize(width(), 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.
intrinsicRatio = static_cast<SVGSVGElement*>(node())->currentViewBoxRect().size();
// Compatibility with authors expectations and Firefox/Opera: when percentage units are used, take them into
// account for certain cases of the intrinsic width/height calculation in RenderPart::computeReplacedLogicalWidth/Height.
if (intrinsicRatio.isEmpty() && style()->width().isPercent() && style()->height().isPercent()) {
isPercentageIntrinsicSize = true;
intrinsicRatio = FloatSize(style()->width().percent(), style()->height().percent());
}
}
示例6: nullImage
RefPtr<Image> CSSCrossfadeValue::image(RenderElement* renderer, const FloatSize& size)
{
if (size.isEmpty())
return nullptr;
// FIXME: Skip Content Security Policy check when cross fade is applied to an element in a user agent shadow tree.
// See <https://bugs.webkit.org/show_bug.cgi?id=146663>.
ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
CachedResourceLoader& cachedResourceLoader = renderer->document().cachedResourceLoader();
CachedImage* cachedFromImage = cachedImageForCSSValue(m_fromValue, cachedResourceLoader, options);
CachedImage* cachedToImage = cachedImageForCSSValue(m_toValue, cachedResourceLoader, options);
if (!cachedFromImage || !cachedToImage)
return Image::nullImage();
Image* fromImage = cachedFromImage->imageForRenderer(renderer);
Image* toImage = cachedToImage->imageForRenderer(renderer);
if (!fromImage || !toImage)
return Image::nullImage();
m_generatedImage = CrossfadeGeneratedImage::create(*fromImage, *toImage, m_percentageValue->getFloatValue(), fixedSize(renderer), size);
return m_generatedImage;
}
示例7: determineViewport
bool SVGLengthContext::determineViewport(float& width, float& height) const
{
if (!m_context)
return false;
// If an overriden viewport is given, it has precedence.
if (!m_overridenViewport.isEmpty()) {
width = m_overridenViewport.width();
height = m_overridenViewport.height();
return true;
}
// SVGLengthContext should NEVER be used to resolve width/height values for <svg> elements,
// as they require special treatment, due the relationship with the CSS width/height properties.
ASSERT(m_context->document().documentElement() != m_context);
// Take size from nearest viewport element.
SVGElement* viewportElement = m_context->viewportElement();
if (!viewportElement || !viewportElement->isSVGSVGElement())
return false;
const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
FloatSize viewportSize = svg->currentViewBoxRect().size();
if (viewportSize.isEmpty())
viewportSize = svg->currentViewportSize();
width = viewportSize.width();
height = viewportSize.height();
return true;
}
示例8: containerSize
IntSize SVGImage::containerSize() const
{
SVGSVGElement* rootElement = this->rootElement();
if (!rootElement)
return IntSize();
auto* renderer = downcast<RenderSVGRoot>(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->hasIntrinsicWidth() && rootElement->hasIntrinsicHeight())
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);
}
示例9: 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);
}
示例10: computeIntrinsicRatioInformation
void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
{
intrinsicSize = FloatSize(intrinsicLogicalWidth().toFloat(), intrinsicLogicalHeight().toFloat());
// Figure out if we need to compute an intrinsic ratio.
if (intrinsicSize.isEmpty() || !rendererHasAspectRatio(this))
return;
intrinsicRatio = intrinsicSize.width() / intrinsicSize.height();
}
示例11: containerSize
IntSize SVGImage::containerSize() const
{
SVGSVGElement* rootElement = svgRootElement(m_page.get());
if (!rootElement)
return IntSize();
LayoutSVGRoot* layoutObject = toLayoutSVGRoot(rootElement->layoutObject());
if (!layoutObject)
return IntSize();
// If a container size is available it has precedence.
IntSize containerSize = layoutObject->containerSize();
if (!containerSize.isEmpty())
return containerSize;
// Assure that a container size is always given for a non-identity zoom level.
ASSERT(layoutObject->style()->effectiveZoom() == 1);
FloatSize intrinsicSize;
double intrinsicRatio = 0;
layoutObject->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio);
if (intrinsicSize.isEmpty() && intrinsicRatio) {
if (!intrinsicSize.width() && intrinsicSize.height())
intrinsicSize.setWidth(intrinsicSize.height() * intrinsicRatio);
else if (intrinsicSize.width() && !intrinsicSize.height())
intrinsicSize.setHeight(intrinsicSize.width() / intrinsicRatio);
}
// TODO(davve): In order to maintain aspect ratio the intrinsic
// size is faked from the viewBox as a last resort. This may cause
// unwanted side effects. Preferably we should be able to signal
// the intrinsic ratio in another way.
if (intrinsicSize.isEmpty())
intrinsicSize = rootElement->currentViewBoxRect().size();
if (!intrinsicSize.isEmpty())
return expandedIntSize(intrinsicSize);
// As last resort, use CSS replaced element fallback size.
return IntSize(300, 150);
}
示例12: didChangeViewportSize
void PageViewportController::didChangeViewportSize(const FloatSize& newSize)
{
if (newSize.isEmpty())
return;
m_viewportSize = newSize;
// Let the WebProcess know about the new viewport size, so that
// it can resize the content accordingly.
m_webPageProxy->setViewportSize(roundedIntSize(newSize));
}
示例13: clampedSize
FloatSize ImageBuffer::clampedSize(const FloatSize& size, FloatSize& scale)
{
if (size.isEmpty())
return size;
FloatSize clampedSize = ImageBuffer::clampedSize(size);
scale = FloatSize(clampedSize.width() / size.width(), clampedSize.height() / size.height());
ASSERT(!sizeNeedsClamping(clampedSize));
ASSERT(!sizeNeedsClamping(size, scale));
return clampedSize;
}
示例14: computeAspectRatioInformationForRenderBox
void RenderReplaced::computeAspectRatioInformationForRenderBox(FloatSize& constrainedSize, double& intrinsicRatio) const
{
FloatSize intrinsicSize;
computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio);
if (intrinsicRatio && !intrinsicSize.isEmpty())
m_intrinsicSize = LayoutSize(intrinsicSize);
// Now constrain the intrinsic size along each axis according to minimum and maximum width/heights along the
// opposite axis. So for example a maximum width that shrinks our width will result in the height we compute here
// having to shrink in order to preserve the aspect ratio. Because we compute these values independently along
// each axis, the final returned size may in fact not preserve the aspect ratio.
// FIXME: In the long term, it might be better to just return this code more to the way it used to be before this
// function was added, since all it has done is make the code more unclear.
constrainedSize = intrinsicSize;
if (intrinsicRatio && !intrinsicSize.isEmpty() && style()->logicalWidth().isAuto() && style()->logicalHeight().isAuto()) {
// We can't multiply or divide by 'intrinsicRatio' here, it breaks tests, like fast/images/zoomed-img-size.html, which
// can only be fixed once subpixel precision is available for things like intrinsicWidth/Height.
constrainedSize.setWidth(RenderBox::computeReplacedLogicalHeight() * intrinsicSize.width() / intrinsicSize.height());
constrainedSize.setHeight(RenderBox::computeReplacedLogicalWidth() * intrinsicSize.height() / intrinsicSize.width());
}
}
示例15: computeIntrinsicRatioInformation
void RenderReplaced::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
{
// If there's an embeddedContentBox() of a remote, referenced document available, this code-path should never be used.
ASSERT(!embeddedContentBox());
intrinsicSize = FloatSize(intrinsicLogicalWidth(), intrinsicLogicalHeight());
// Figure out if we need to compute an intrinsic ratio.
if (intrinsicSize.isEmpty() || !hasAspectRatio())
return;
intrinsicRatio = intrinsicSize.width() / intrinsicSize.height();
}