本文整理汇总了C++中LengthSize类的典型用法代码示例。如果您正苦于以下问题:C++ LengthSize类的具体用法?C++ LengthSize怎么用?C++ LengthSize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LengthSize类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToLengthSize
static inline bool convertToLengthSize(const CSSPrimitiveValue& primitiveValue, CSSToLengthConversionData conversionData, LengthSize& size)
{
if (auto* pair = primitiveValue.getPairValue()) {
size.setWidth(pair->first()->convertToLength<AnyConversion>(conversionData));
size.setHeight(pair->second()->convertToLength<AnyConversion>(conversionData));
} else
size.setWidth(primitiveValue.convertToLength<AnyConversion>(conversionData));
return !size.width().isUndefined() && !size.height().isUndefined();
}
示例2: if
void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
if (!value->isPrimitiveValue()) {
layer->setSizeType(SizeNone);
return;
}
CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
if (primitiveValue->getValueID() == CSSValueContain)
layer->setSizeType(Contain);
else if (primitiveValue->getValueID() == CSSValueCover)
layer->setSizeType(Cover);
else
layer->setSizeType(SizeLength);
LengthSize b = FillLayer::initialFillSizeLength(layer->type());
if (value->isInitialValue() || primitiveValue->getValueID() == CSSValueContain || primitiveValue->getValueID() == CSSValueCover) {
layer->setSizeLength(b);
return;
}
float zoomFactor = style()->effectiveZoom();
Length firstLength;
Length secondLength;
if (Pair* pair = primitiveValue->getPairValue()) {
CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first());
CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second());
firstLength = first->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
secondLength = second->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
} else {
firstLength = primitiveValue->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
secondLength = Length();
}
if (firstLength.isUndefined() || secondLength.isUndefined())
return;
b.setWidth(firstLength);
b.setHeight(secondLength);
layer->setSizeLength(b);
}
示例3: if
void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer* layer, CSSValue* value)
{
if (!is<CSSPrimitiveValue>(*value)) {
layer->setSizeType(SizeNone);
return;
}
CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
if (primitiveValue.getValueID() == CSSValueContain)
layer->setSizeType(Contain);
else if (primitiveValue.getValueID() == CSSValueCover)
layer->setSizeType(Cover);
else
layer->setSizeType(SizeLength);
LengthSize b = FillLayer::initialFillSizeLength(layer->type());
if (value->isInitialValue() || primitiveValue.getValueID() == CSSValueContain || primitiveValue.getValueID() == CSSValueCover) {
layer->setSizeLength(b);
return;
}
Length firstLength;
Length secondLength;
if (Pair* pair = primitiveValue.getPairValue()) {
CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first());
CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second());
firstLength = first->convertToLength<AnyConversion>(m_resolver->state().cssToLengthConversionData());
secondLength = second->convertToLength<AnyConversion>(m_resolver->state().cssToLengthConversionData());
} else {
firstLength = primitiveValue.convertToLength<AnyConversion>(m_resolver->state().cssToLengthConversionData());
secondLength = Length();
}
if (firstLength.isUndefined() || secondLength.isUndefined())
return;
b.setWidth(firstLength);
b.setHeight(secondLength);
layer->setSizeLength(b);
}
示例4: if
void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, const CSSValue& value)
{
if (value.isInitialValue()) {
layer->setSizeType(FillLayer::initialFillSizeType(layer->type()));
layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type()));
return;
}
if (!value.isPrimitiveValue() && !value.isValuePair())
return;
if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == CSSValueContain)
layer->setSizeType(Contain);
else if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == CSSValueCover)
layer->setSizeType(Cover);
else
layer->setSizeType(SizeLength);
LengthSize b = FillLayer::initialFillSizeLength(layer->type());
if (value.isPrimitiveValue() && (toCSSPrimitiveValue(value).getValueID() == CSSValueContain || toCSSPrimitiveValue(value).getValueID() == CSSValueCover)) {
layer->setSizeLength(b);
return;
}
Length firstLength;
Length secondLength;
if (value.isValuePair()) {
const CSSValuePair& pair = toCSSValuePair(value);
firstLength = StyleBuilderConverter::convertLengthOrAuto(state, pair.first());
secondLength = StyleBuilderConverter::convertLengthOrAuto(state, pair.second());
} else {
ASSERT(value.isPrimitiveValue());
firstLength = StyleBuilderConverter::convertLengthOrAuto(state, value);
secondLength = Length();
}
b.setWidth(firstLength);
b.setHeight(secondLength);
layer->setSizeLength(b);
}
示例5: toCSSPrimitiveValue
void CSSToStyleMap::mapFillSize(StyleResolverState& state, FillLayer* layer, CSSValue* value)
{
if (value->isInitialValue()) {
layer->setSizeType(FillLayer::initialFillSizeType(layer->type()));
layer->setSizeLength(FillLayer::initialFillSizeLength(layer->type()));
return;
}
if (!value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == CSSValueContain)
layer->setSizeType(Contain);
else if (primitiveValue->getValueID() == CSSValueCover)
layer->setSizeType(Cover);
else
layer->setSizeType(SizeLength);
LengthSize b = FillLayer::initialFillSizeLength(layer->type());
if (primitiveValue->getValueID() == CSSValueContain || primitiveValue->getValueID() == CSSValueCover) {
layer->setSizeLength(b);
return;
}
Length firstLength;
Length secondLength;
if (Pair* pair = primitiveValue->getPairValue()) {
firstLength = pair->first()->convertToLength<AnyConversion>(state.cssToLengthConversionData());
secondLength = pair->second()->convertToLength<AnyConversion>(state.cssToLengthConversionData());
} else {
firstLength = primitiveValue->convertToLength<AnyConversion>(state.cssToLengthConversionData());
secondLength = Length();
}
b.setWidth(firstLength);
b.setHeight(secondLength);
layer->setSizeLength(b);
}
示例6: if
void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style, Element* element, bool UAHasAppearance, const BorderData& border, const FillLayer& background, const Color& backgroundColor)
{
// Force inline and table display styles to be inline-block (except for table- which is block)
ControlPart part = style.appearance();
if (style.display() == INLINE || style.display() == INLINE_TABLE || style.display() == TABLE_ROW_GROUP
|| style.display() == TABLE_HEADER_GROUP || style.display() == TABLE_FOOTER_GROUP
|| style.display() == TABLE_ROW || style.display() == TABLE_COLUMN_GROUP || style.display() == TABLE_COLUMN
|| style.display() == TABLE_CELL || style.display() == TABLE_CAPTION)
style.setDisplay(INLINE_BLOCK);
else if (style.display() == COMPACT || style.display() == LIST_ITEM || style.display() == TABLE)
style.setDisplay(BLOCK);
if (UAHasAppearance && isControlStyled(style, border, background, backgroundColor)) {
if (part == MenulistPart) {
style.setAppearance(MenulistButtonPart);
part = MenulistButtonPart;
} else
style.setAppearance(NoControlPart);
}
if (!style.hasAppearance())
return;
// Never support box-shadow on native controls.
style.setBoxShadow(nullptr);
#if USE(NEW_THEME)
switch (part) {
case CheckboxPart:
case InnerSpinButtonPart:
case RadioPart:
case PushButtonPart:
case SquareButtonPart:
case DefaultButtonPart:
case ButtonPart: {
// Border
LengthBox borderBox(style.borderTopWidth(), style.borderRightWidth(), style.borderBottomWidth(), style.borderLeftWidth());
borderBox = m_theme->controlBorder(part, style.fontCascade(), borderBox, style.effectiveZoom());
if (borderBox.top().value() != static_cast<int>(style.borderTopWidth())) {
if (borderBox.top().value())
style.setBorderTopWidth(borderBox.top().value());
else
style.resetBorderTop();
}
if (borderBox.right().value() != static_cast<int>(style.borderRightWidth())) {
if (borderBox.right().value())
style.setBorderRightWidth(borderBox.right().value());
else
style.resetBorderRight();
}
if (borderBox.bottom().value() != static_cast<int>(style.borderBottomWidth())) {
style.setBorderBottomWidth(borderBox.bottom().value());
if (borderBox.bottom().value())
style.setBorderBottomWidth(borderBox.bottom().value());
else
style.resetBorderBottom();
}
if (borderBox.left().value() != static_cast<int>(style.borderLeftWidth())) {
style.setBorderLeftWidth(borderBox.left().value());
if (borderBox.left().value())
style.setBorderLeftWidth(borderBox.left().value());
else
style.resetBorderLeft();
}
// Padding
LengthBox paddingBox = m_theme->controlPadding(part, style.fontCascade(), style.paddingBox(), style.effectiveZoom());
if (paddingBox != style.paddingBox())
style.setPaddingBox(paddingBox);
// Whitespace
if (m_theme->controlRequiresPreWhiteSpace(part))
style.setWhiteSpace(PRE);
// Width / Height
// The width and height here are affected by the zoom.
// FIXME: Check is flawed, since it doesn't take min-width/max-width into account.
LengthSize controlSize = m_theme->controlSize(part, style.fontCascade(), LengthSize(style.width(), style.height()), style.effectiveZoom());
if (controlSize.width() != style.width())
style.setWidth(controlSize.width());
if (controlSize.height() != style.height())
style.setHeight(controlSize.height());
// Min-Width / Min-Height
LengthSize minControlSize = m_theme->minimumControlSize(part, style.fontCascade(), style.effectiveZoom());
if (minControlSize.width() != style.minWidth())
style.setMinWidth(minControlSize.width());
if (minControlSize.height() != style.minHeight())
style.setMinHeight(minControlSize.height());
// Font
if (auto themeFont = m_theme->controlFont(part, style.fontCascade(), style.effectiveZoom())) {
// If overriding the specified font with the theme font, also override the line height with the standard line height.
style.setLineHeight(RenderStyle::initialLineHeight());
if (style.setFontDescription(themeFont.value()))
style.fontCascade().update(nullptr);
}
// Special style that tells enabled default buttons in active windows to use the ActiveButtonText color.
// The active window part of the test has to be done at paint time since it's not triggered by a style change.
//.........这里部分代码省略.........
示例7: floatSizeForLengthSize
static FloatSize floatSizeForLengthSize(const LengthSize& lengthSize, const FloatRect& boundingBox)
{
return FloatSize(floatValueForLength(lengthSize.width(), boundingBox.width()),
floatValueForLength(lengthSize.height(), boundingBox.height()));
}
示例8: init
void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle& style)
{
init(UnitType::Pair);
m_hasCachedCSSText = false;
m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom()), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues).leakRef();
}
示例9: blendLengthSize
static inline LengthSize blendLengthSize(const LengthSize& to, const LengthSize& from, double progress)
{
return LengthSize(to.width().blend(from.width(), progress, ValueRangeAll),
to.height().blend(from.height(), progress, ValueRangeAll));
}
示例10: if
void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyle* uaStyle)
{
// Force inline and table display styles to be inline-block (except for table- which is block)
ControlPart part = style->appearance();
if (style->display() == INLINE || style->display() == INLINE_TABLE || style->display() == TABLE_ROW_GROUP
|| style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_FOOTER_GROUP
|| style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GROUP || style->display() == TABLE_COLUMN
|| style->display() == TABLE_CELL || style->display() == TABLE_CAPTION)
style->setDisplay(INLINE_BLOCK);
else if (style->display() == LIST_ITEM || style->display() == TABLE)
style->setDisplay(BLOCK);
if (uaStyle && uaStyle->hasAppearance && isControlStyled(style, uaStyle)) {
if (part == MenulistPart) {
style->setAppearance(MenulistButtonPart);
part = MenulistButtonPart;
} else
style->setAppearance(NoControlPart);
}
if (!style->hasAppearance())
return;
if (shouldUseFallbackTheme(style)) {
adjustStyleUsingFallbackTheme(style, e);
return;
}
#if USE(NEW_THEME)
switch (part) {
case CheckboxPart:
case InnerSpinButtonPart:
case RadioPart:
case PushButtonPart:
case SquareButtonPart:
case ButtonPart: {
// Border
LengthBox borderBox(style->borderTopWidth(), style->borderRightWidth(), style->borderBottomWidth(), style->borderLeftWidth());
borderBox = m_platformTheme->controlBorder(part, style->font().fontDescription(), borderBox, style->effectiveZoom());
if (borderBox.top().value() != static_cast<int>(style->borderTopWidth())) {
if (borderBox.top().value())
style->setBorderTopWidth(borderBox.top().value());
else
style->resetBorderTop();
}
if (borderBox.right().value() != static_cast<int>(style->borderRightWidth())) {
if (borderBox.right().value())
style->setBorderRightWidth(borderBox.right().value());
else
style->resetBorderRight();
}
if (borderBox.bottom().value() != static_cast<int>(style->borderBottomWidth())) {
style->setBorderBottomWidth(borderBox.bottom().value());
if (borderBox.bottom().value())
style->setBorderBottomWidth(borderBox.bottom().value());
else
style->resetBorderBottom();
}
if (borderBox.left().value() != static_cast<int>(style->borderLeftWidth())) {
style->setBorderLeftWidth(borderBox.left().value());
if (borderBox.left().value())
style->setBorderLeftWidth(borderBox.left().value());
else
style->resetBorderLeft();
}
// Padding
LengthBox paddingBox = m_platformTheme->controlPadding(part, style->font().fontDescription(), style->paddingBox(), style->effectiveZoom());
if (paddingBox != style->paddingBox())
style->setPaddingBox(paddingBox);
// Whitespace
if (m_platformTheme->controlRequiresPreWhiteSpace(part))
style->setWhiteSpace(PRE);
// Width / Height
// The width and height here are affected by the zoom.
// FIXME: Check is flawed, since it doesn't take min-width/max-width into account.
LengthSize controlSize = m_platformTheme->controlSize(part, style->font().fontDescription(), LengthSize(style->width(), style->height()), style->effectiveZoom());
if (controlSize.width() != style->width())
style->setWidth(controlSize.width());
if (controlSize.height() != style->height())
style->setHeight(controlSize.height());
// Min-Width / Min-Height
LengthSize minControlSize = m_platformTheme->minimumControlSize(part, style->font().fontDescription(), style->effectiveZoom());
if (minControlSize.width() != style->minWidth())
style->setMinWidth(minControlSize.width());
if (minControlSize.height() != style->minHeight())
style->setMinHeight(minControlSize.height());
// Font
FontDescription controlFont = m_platformTheme->controlFont(part, style->font().fontDescription(), style->effectiveZoom());
if (controlFont != style->font().fontDescription()) {
// Reset our line-height
style->setLineHeight(RenderStyle::initialLineHeight());
// Now update our font.
if (style->setFontDescription(controlFont))
style->font().update(nullptr);
//.........这里部分代码省略.........
示例11: destinationOffsetForViewSize
static LayoutUnit destinationOffsetForViewSize(ScrollEventAxis axis, const LengthSize& destination, LayoutUnit viewSize)
{
const Length& dimension = (axis == ScrollEventAxis::Horizontal) ? destination.width() : destination.height();
return valueForLength(dimension, viewSize);
}