Changeset 156586 in webkit for trunk/Source/WebCore/css/CSSCalculationValue.h
- Timestamp:
- Sep 27, 2013, 4:17:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSCalculationValue.h
r156260 r156586 33 33 34 34 #include "CSSParserValues.h" 35 #include "CSSPrimitiveValue.h" 35 36 #include "CSSValue.h" 36 37 #include "CalculationValue.h" … … 43 44 class CSSParserValueList; 44 45 class CSSValueList; 45 class RenderStyle;46 46 class CalculationValue; 47 47 class CalcExpressionNode; 48 class RenderStyle; 49 struct Length; 48 50 49 51 enum CalculationCategory { … … 58 60 CalcOther 59 61 }; 60 62 61 63 class CSSCalcExpressionNode : public RefCounted<CSSCalcExpressionNode> { 62 64 public: … … 68 70 virtual ~CSSCalcExpressionNode() = 0; 69 71 virtual bool isZero() const = 0; 70 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0; 72 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0; 71 73 virtual double doubleValue() const = 0; 72 74 virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0; … … 79 81 virtual Type type() const = 0; 80 82 81 CalculationCategory category() const { return m_category; } 83 CalculationCategory category() const { return m_category; } 84 virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0; 82 85 bool isInteger() const { return m_isInteger; } 83 86 84 87 protected: 85 88 CSSCalcExpressionNode(CalculationCategory category, bool isInteger) … … 88 91 { 89 92 } 90 93 91 94 CalculationCategory m_category; 92 95 bool m_isInteger; 93 96 }; 94 97 95 98 class CSSCalcValue : public CSSValue { 96 99 public: 97 100 static PassRefPtr<CSSCalcValue> create(CSSParserString name, CSSParserValueList*, CalculationPermittedValueRange); 98 static PassRefPtr<CSSCalcValue> create(CalculationValue*); 101 static PassRefPtr<CSSCalcValue> create(PassRefPtr<CSSCalcExpressionNode>, CalculationPermittedValueRange = CalculationRangeAll); 102 static PassRefPtr<CSSCalcValue> create(const CalculationValue* value, const RenderStyle* style) { return adoptRef(new CSSCalcValue(value, style)); } 103 104 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSSPrimitiveValue>, bool isInteger = false); 105 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSSCalcExpressionNode>, PassRefPtr<CSSCalcExpressionNode>, CalcOperator); 106 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const CalcExpressionNode*, const RenderStyle*); 107 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const Length&, const RenderStyle*); 99 108 100 109 PassRefPtr<CalculationValue> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom = 1.0) const … … 103 112 } 104 113 CalculationCategory category() const { return m_expression->category(); } 105 bool isInt() const { return m_expression->isInteger(); } 114 bool isInt() const { return m_expression->isInteger(); } 106 115 double doubleValue() const; 107 116 bool isNegative() const { return m_expression->doubleValue() < 0; } 117 CalculationPermittedValueRange permittedValueRange() { return m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll; } 108 118 double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const; 109 119 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } 120 110 121 String customCSSText() const; 111 122 bool equals(const CSSCalcValue&) const; … … 114 125 bool hasVariableReference() const; 115 126 #endif 116 117 private: 127 128 private: 118 129 CSSCalcValue(PassRefPtr<CSSCalcExpressionNode> expression, CalculationPermittedValueRange range) 119 130 : CSSValue(CalculationClass) … … 122 133 { 123 134 } 124 135 CSSCalcValue(const CalculationValue* value, const RenderStyle* style) 136 : CSSValue(CalculationClass) 137 , m_expression(createExpressionNode(value->expression(), style)) 138 , m_nonNegative(value->isNonNegative()) 139 { 140 } 141 125 142 double clampToPermittedRange(double) const; 126 143 … … 128 145 const bool m_nonNegative; 129 146 }; 130 147 148 inline CSSCalcValue* toCSSCalcValue(CSSValue* value) 149 { 150 ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isCalculationValue()); 151 return static_cast<CSSCalcValue*>(value); 152 } 153 154 inline const CSSCalcValue* toCSSCalcValue(const CSSValue* value) 155 { 156 ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isCalculationValue()); 157 return static_cast<const CSSCalcValue*>(value); 158 } 159 131 160 } // namespace WebCore 132 161
Note:
See TracChangeset
for help on using the changeset viewer.