本文整理汇总了C++中PassRefPtrWillBeRawPtr::category方法的典型用法代码示例。如果您正苦于以下问题:C++ PassRefPtrWillBeRawPtr::category方法的具体用法?C++ PassRefPtrWillBeRawPtr::category怎么用?C++ PassRefPtrWillBeRawPtr::category使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PassRefPtrWillBeRawPtr
的用法示例。
在下文中一共展示了PassRefPtrWillBeRawPtr::category方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adoptRefWillBeNoop
static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> create(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> rightSide, CalcOperator op)
{
ASSERT(leftSide->category() != CalcOther && rightSide->category() != CalcOther);
CalculationCategory newCategory = determineCategory(*leftSide, *rightSide, op);
if (newCategory == CalcOther)
return nullptr;
return adoptRefWillBeNoop(new CSSCalcBinaryOperation(leftSide, rightSide, op, newCategory));
}
示例2: create
static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createSimplified(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> rightSide, CalcOperator op)
{
CalculationCategory leftCategory = leftSide->category();
CalculationCategory rightCategory = rightSide->category();
ASSERT(leftCategory != CalcOther && rightCategory != CalcOther);
bool isInteger = isIntegerResult(leftSide.get(), rightSide.get(), op);
// Simplify numbers.
if (leftCategory == CalcNumber && rightCategory == CalcNumber) {
return CSSCalcPrimitiveValue::create(evaluateOperator(leftSide->doubleValue(), rightSide->doubleValue(), op), CSSPrimitiveValue::UnitType::Number, isInteger);
}
// Simplify addition and subtraction between same types.
if (op == CalcAdd || op == CalcSubtract) {
if (leftCategory == rightSide->category()) {
CSSPrimitiveValue::UnitType leftType = leftSide->typeWithCalcResolved();
if (hasDoubleValue(leftType)) {
CSSPrimitiveValue::UnitType rightType = rightSide->typeWithCalcResolved();
if (leftType == rightType)
return CSSCalcPrimitiveValue::create(evaluateOperator(leftSide->doubleValue(), rightSide->doubleValue(), op), leftType, isInteger);
CSSPrimitiveValue::UnitCategory leftUnitCategory = CSSPrimitiveValue::unitCategory(leftType);
if (leftUnitCategory != CSSPrimitiveValue::UOther && leftUnitCategory == CSSPrimitiveValue::unitCategory(rightType)) {
CSSPrimitiveValue::UnitType canonicalType = CSSPrimitiveValue::canonicalUnitTypeForCategory(leftUnitCategory);
if (canonicalType != CSSPrimitiveValue::UnitType::Unknown) {
double leftValue = leftSide->doubleValue() * CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(leftType);
double rightValue = rightSide->doubleValue() * CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(rightType);
return CSSCalcPrimitiveValue::create(evaluateOperator(leftValue, rightValue, op), canonicalType, isInteger);
}
}
}
}
} else {
// Simplify multiplying or dividing by a number for simplifiable types.
ASSERT(op == CalcMultiply || op == CalcDivide);
CSSCalcExpressionNode* numberSide = getNumberSide(leftSide.get(), rightSide.get());
if (!numberSide)
return create(leftSide, rightSide, op);
if (numberSide == leftSide && op == CalcDivide)
return nullptr;
CSSCalcExpressionNode* otherSide = leftSide == numberSide ? rightSide.get() : leftSide.get();
double number = numberSide->doubleValue();
if (std::isnan(number) || std::isinf(number))
return nullptr;
if (op == CalcDivide && !number)
return nullptr;
CSSPrimitiveValue::UnitType otherType = otherSide->typeWithCalcResolved();
if (hasDoubleValue(otherType))
return CSSCalcPrimitiveValue::create(evaluateOperator(otherSide->doubleValue(), number, op), otherType, isInteger);
}
return create(leftSide, rightSide, op);
}