本文整理汇总了C++中ComputedStyle类的典型用法代码示例。如果您正苦于以下问题:C++ ComputedStyle类的具体用法?C++ ComputedStyle怎么用?C++ ComputedStyle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComputedStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateAdjustedSize
void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const ComputedStyle& style, FontSelector* fontSelector)
{
const float specifiedSize = fontDescription.specifiedSize();
if (!fontDescription.hasSizeAdjust() || !specifiedSize)
return;
// We need to create a temporal Font to get xHeight of a primary font.
// The aspect value is based on the xHeight of the font for the computed font size,
// so we need to reset the adjustedSize to computedSize. See FontDescription::effectiveFontSize.
fontDescription.setAdjustedSize(fontDescription.computedSize());
Font font(fontDescription);
font.update(fontSelector);
if (!font.fontMetrics().hasXHeight())
return;
const float sizeAdjust = fontDescription.sizeAdjust();
float aspectValue = font.fontMetrics().xHeight() / specifiedSize;
float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize;
adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effectiveZoom(), adjustedSize);
float multiplier = style.textAutosizingMultiplier();
if (multiplier > 1)
adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, multiplier);
fontDescription.setAdjustedSize(adjustedSize);
}
示例2: requiresCompositingForAnimation
bool CompositingReasonFinder::requiresCompositingForAnimation(const ComputedStyle& style) const
{
if (style.subtreeWillChangeContents())
return style.isRunningAnimationOnCompositor();
return style.shouldCompositeForCurrentAnimations();
}
示例3: styleWillChange
void LayoutListMarker::styleWillChange(StyleDifference diff, const ComputedStyle& newStyle)
{
if (style() && (newStyle.listStylePosition() != style()->listStylePosition() || newStyle.listStyleType() != style()->listStyleType()))
setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::StyleChange);
LayoutBox::styleWillChange(diff, newStyle);
}
示例4: adjustMediaSliderThumbSize
void MediaControlsPainter::adjustMediaSliderThumbSize(ComputedStyle& style)
{
static Image* mediaSliderThumb = platformResource("mediaplayerSliderThumb",
"mediaplayerSliderThumbNew");
static Image* mediaVolumeSliderThumb = platformResource(
"mediaplayerVolumeSliderThumb",
"mediaplayerVolumeSliderThumbNew");
int width = 0;
int height = 0;
Image* thumbImage = 0;
if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) {
// Volume and time sliders are the same.
thumbImage = mediaSliderThumb;
width = mediaSliderThumbTouchWidthNew;
height = mediaSliderThumbTouchHeightNew;
} else if (style.appearance() == MediaSliderThumbPart) {
thumbImage = mediaSliderThumb;
width = mediaSliderThumbWidth;
height = mediaSliderThumbHeight;
} else if (style.appearance() == MediaVolumeSliderThumbPart) {
thumbImage = mediaVolumeSliderThumb;
width = mediaVolumeSliderThumbWidth;
height = mediaVolumeSliderThumbHeight;
}
float zoomLevel = style.effectiveZoom();
if (thumbImage) {
style.setWidth(Length(static_cast<int>(width * zoomLevel), Fixed));
style.setHeight(Length(static_cast<int>(height * zoomLevel), Fixed));
}
}
示例5: isControlStyled
bool LayoutTheme::isControlStyled(const ComputedStyle& style, const AuthorStyleInfo& authorStyle) const
{
switch (style.appearance()) {
case PushButtonPart:
case SquareButtonPart:
case ButtonPart:
case ProgressBarPart:
case MeterPart:
case RelevancyLevelIndicatorPart:
case ContinuousCapacityLevelIndicatorPart:
case DiscreteCapacityLevelIndicatorPart:
case RatingLevelIndicatorPart:
return authorStyle.specifiesBackground() || authorStyle.specifiesBorder();
case MenulistPart:
case SearchFieldPart:
case TextAreaPart:
case TextFieldPart:
return authorStyle.specifiesBackground() || authorStyle.specifiesBorder() || style.boxShadow();
case SliderHorizontalPart:
case SliderVerticalPart:
return style.boxShadow();
default:
return false;
}
}
示例6: hasWillChangeThatCreatesStackingContext
static bool hasWillChangeThatCreatesStackingContext(const ComputedStyle& style)
{
for (size_t i = 0; i < style.willChangeProperties().size(); ++i) {
switch (style.willChangeProperties()[i]) {
case CSSPropertyOpacity:
case CSSPropertyTransform:
case CSSPropertyAliasWebkitTransform:
case CSSPropertyTransformStyle:
case CSSPropertyAliasWebkitTransformStyle:
case CSSPropertyPerspective:
case CSSPropertyAliasWebkitPerspective:
case CSSPropertyWebkitMask:
case CSSPropertyWebkitMaskBoxImage:
case CSSPropertyWebkitClipPath:
case CSSPropertyWebkitBoxReflect:
case CSSPropertyWebkitFilter:
case CSSPropertyBackdropFilter:
case CSSPropertyZIndex:
case CSSPropertyPosition:
return true;
case CSSPropertyMixBlendMode:
case CSSPropertyIsolation:
if (RuntimeEnabledFeatures::cssCompositingEnabled())
return true;
break;
default:
break;
}
}
return false;
}
示例7: willIsolateBlendingDescendantsForStyle
bool SVGLayoutSupport::willIsolateBlendingDescendantsForStyle(const ComputedStyle& style)
{
const SVGComputedStyle& svgStyle = style.svgStyle();
return style.hasIsolation() || style.opacity() < 1 || style.hasBlendMode()
|| svgStyle.hasFilter() || svgStyle.hasMasker() || svgStyle.hasClipper();
}
示例8: textLayoutObjectIsNeeded
bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObject& parent)
{
if (!parent.canHaveChildren())
return false;
if (isEditingText())
return true;
if (!length())
return false;
if (style.display() == NONE)
return false;
if (!containsOnlyWhitespace())
return true;
if (!canHaveWhitespaceChildren(parent, this))
return false;
// pre-wrap in SVG never makes layoutObject.
if (style.whiteSpace() == PRE_WRAP && parent.isSVG())
return false;
// pre/pre-wrap/-bb-pre-wrap-text/pre-line always make layoutObjects.
if (style.preserveNewline())
return true;
// childNeedsDistributionRecalc() here is rare, only happens JS calling surroundContents() etc. from DOMNodeInsertedIntoDocument etc.
if (document().childNeedsDistributionRecalc())
return true;
const LayoutObject* prev = LayoutTreeBuilderTraversal::previousSiblingLayoutObject(*this);
if (prev && prev->isBR()) // <span><br/> <br/></span>
return false;
if (parent.isLayoutInline()) {
// <span><div/> <div/></span>
if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned())
return false;
} else {
if (parent.isLayoutBlock() && !parent.childrenInline() && (!prev || !prev->isInline()))
return false;
// Avoiding creation of a layoutObject for the text node is a non-essential memory optimization.
// So to avoid blowing up on very wide DOMs, we limit the number of siblings to visit.
unsigned maxSiblingsToVisit = 50;
LayoutObject* first = parent.slowFirstChild();
while (first && first->isFloatingOrOutOfFlowPositioned() && maxSiblingsToVisit--)
first = first->nextSibling();
if (!first || first == layoutObject() || LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*this) == first) {
// Whitespace at the start of a block just goes away. Don't even
// make a layout object for this text.
return false;
}
}
return true;
}
示例9: updateComputedSize
void FontBuilder::updateComputedSize(FontDescription& fontDescription, const ComputedStyle& style)
{
float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effectiveZoom(), fontDescription.specifiedSize());
float multiplier = style.textAutosizingMultiplier();
if (multiplier > 1)
computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, multiplier);
fontDescription.setComputedSize(computedSize);
}
示例10: adjustInnerEditorStyle
void LayoutTextControl::adjustInnerEditorStyle(ComputedStyle& textBlockStyle) const
{
// The inner block, if present, always has its direction set to LTR,
// so we need to inherit the direction and unicode-bidi style from the element.
textBlockStyle.setDirection(style()->direction());
textBlockStyle.setUnicodeBidi(style()->unicodeBidi());
updateUserModifyProperty(*textFormControlElement(), textBlockStyle);
}
示例11: boxReflectionForPaintLayer
BoxReflection boxReflectionForPaintLayer(const PaintLayer& layer,
const ComputedStyle& style) {
const StyleReflection* reflectStyle = style.boxReflect();
LayoutRect frameLayoutRect = toLayoutBox(layer.layoutObject())->frameRect();
FloatRect frameRect(frameLayoutRect);
BoxReflection::ReflectionDirection direction =
BoxReflection::VerticalReflection;
float offset = 0;
switch (reflectStyle->direction()) {
case ReflectionAbove:
direction = BoxReflection::VerticalReflection;
offset = -floatValueForLength(reflectStyle->offset(), frameRect.height());
break;
case ReflectionBelow:
direction = BoxReflection::VerticalReflection;
offset = 2 * frameRect.height() +
floatValueForLength(reflectStyle->offset(), frameRect.height());
break;
case ReflectionLeft:
direction = BoxReflection::HorizontalReflection;
offset = -floatValueForLength(reflectStyle->offset(), frameRect.width());
break;
case ReflectionRight:
direction = BoxReflection::HorizontalReflection;
offset = 2 * frameRect.width() +
floatValueForLength(reflectStyle->offset(), frameRect.width());
break;
}
sk_sp<SkPicture> mask;
const NinePieceImage& maskNinePiece = reflectStyle->mask();
if (maskNinePiece.hasImage()) {
LayoutRect maskRect(LayoutPoint(), frameLayoutRect.size());
LayoutRect maskBoundingRect(maskRect);
maskBoundingRect.expand(style.imageOutsets(maskNinePiece));
FloatRect maskBoundingFloatRect(maskBoundingRect);
// TODO(jbroman): SkPictureBuilder + DrawingRecorder seems excessive.
// If NinePieceImagePainter operated on SkCanvas, we'd only need an
// SkPictureRecorder here.
SkPictureBuilder recorder(maskBoundingFloatRect);
{
GraphicsContext& context = recorder.context();
DrawingRecorder drawingRecorder(context, *layer.layoutObject(),
DisplayItem::kReflectionMask,
maskBoundingFloatRect);
NinePieceImagePainter(*layer.layoutObject())
.paint(recorder.context(), maskRect, style, maskNinePiece,
SkXfermode::kSrcOver_Mode);
}
mask = recorder.endRecording();
}
return BoxReflection(direction, offset, std::move(mask));
}
示例12: getClipAutos
static ClipAutos getClipAutos(const ComputedStyle& style)
{
if (style.hasAutoClip())
return ClipAutos();
return ClipAutos(
style.clipTop().isAuto(),
style.clipRight().isAuto(),
style.clipBottom().isAuto(),
style.clipLeft().isAuto());
}
示例13: updateAnimationFlags
void ElementAnimations::updateAnimationFlags(ComputedStyle& style)
{
for (const auto& entry : m_animations) {
const Animation& animation = *entry.key;
ASSERT(animation.effect());
// FIXME: Needs to consider AnimationGroup once added.
ASSERT(animation.effect()->isAnimation());
const KeyframeEffect& effect = *toKeyframeEffect(animation.effect());
if (effect.isCurrent()) {
if (effect.affects(PropertyHandle(CSSPropertyOpacity)))
style.setHasCurrentOpacityAnimation(true);
if (effect.affects(PropertyHandle(CSSPropertyTransform))
|| effect.affects(PropertyHandle(CSSPropertyRotate))
|| effect.affects(PropertyHandle(CSSPropertyScale))
|| effect.affects(PropertyHandle(CSSPropertyTranslate)))
style.setHasCurrentTransformAnimation(true);
if (effect.affects(PropertyHandle(CSSPropertyWebkitFilter)))
style.setHasCurrentFilterAnimation(true);
}
}
if (style.hasCurrentOpacityAnimation())
style.setIsRunningOpacityAnimationOnCompositor(m_defaultStack.hasActiveAnimationsOnCompositor(CSSPropertyOpacity));
if (style.hasCurrentTransformAnimation())
style.setIsRunningTransformAnimationOnCompositor(m_defaultStack.hasActiveAnimationsOnCompositor(CSSPropertyTransform));
if (style.hasCurrentFilterAnimation())
style.setIsRunningFilterAnimationOnCompositor(m_defaultStack.hasActiveAnimationsOnCompositor(CSSPropertyWebkitFilter));
}
示例14: adjustStyleForFirstLetter
void StyleAdjuster::adjustStyleForFirstLetter(ComputedStyle& style)
{
if (style.styleType() != FIRST_LETTER)
return;
// Force inline display (except for floating first-letters).
style.setDisplay(style.isFloating() ? BLOCK : INLINE);
// CSS2 says first-letter can't be positioned.
style.setPosition(StaticPosition);
}
示例15: adjustInnerSpinButtonStyle
void LayoutThemeMobile::adjustInnerSpinButtonStyle(ComputedStyle& style) const
{
if (LayoutTestSupport::isRunningLayoutTest()) {
// Match Linux spin button style in layout tests.
// FIXME: Consider removing the conditional if a future Android theme matches this.
IntSize size = Platform::current()->themeEngine()->getSize(WebThemeEngine::PartInnerSpinButton);
style.setWidth(Length(size.width(), Fixed));
style.setMinWidth(Length(size.width(), Fixed));
}
}