Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: Source/core/css/CSSCalculationValue.h

Issue 166443003: Move CSSCalcExpressionNode and subclasses to the oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 enum CalculationCategory { 50 enum CalculationCategory {
51 CalcNumber = 0, 51 CalcNumber = 0,
52 CalcLength, 52 CalcLength,
53 CalcPercent, 53 CalcPercent,
54 CalcPercentNumber, 54 CalcPercentNumber,
55 CalcPercentLength, 55 CalcPercentLength,
56 CalcOther 56 CalcOther
57 }; 57 };
58 58
59 class CSSCalcExpressionNode : public RefCounted<CSSCalcExpressionNode> { 59 class CSSCalcExpressionNode : public RefCountedWillBeGarbageCollected<CSSCalcExp ressionNode> {
60 DECLARE_GC_INFO;
60 public: 61 public:
61 enum Type { 62 enum Type {
62 CssCalcPrimitiveValue = 1, 63 CssCalcPrimitiveValue = 1,
63 CssCalcBinaryOperation 64 CssCalcBinaryOperation
64 }; 65 };
65 66
66 virtual ~CSSCalcExpressionNode() = 0; 67 virtual ~CSSCalcExpressionNode() = 0;
67 virtual bool isZero() const = 0; 68 virtual bool isZero() const = 0;
68 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi onData&) const = 0; 69 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi onData&) const = 0;
69 virtual double doubleValue() const = 0; 70 virtual double doubleValue() const = 0;
70 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0; 71 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0;
71 virtual String customCSSText() const = 0; 72 virtual String customCSSText() const = 0;
72 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat egory == other.m_category && m_isInteger == other.m_isInteger; } 73 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat egory == other.m_category && m_isInteger == other.m_isInteger; }
73 virtual Type type() const = 0; 74 virtual Type type() const = 0;
74 75
75 CalculationCategory category() const { return m_category; } 76 CalculationCategory category() const { return m_category; }
76 virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0; 77 virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0;
77 bool isInteger() const { return m_isInteger; } 78 bool isInteger() const { return m_isInteger; }
78 79
80 virtual void trace(Visitor*) { }
81
79 protected: 82 protected:
80 CSSCalcExpressionNode(CalculationCategory category, bool isInteger) 83 CSSCalcExpressionNode(CalculationCategory category, bool isInteger)
81 : m_category(category) 84 : m_category(category)
82 , m_isInteger(isInteger) 85 , m_isInteger(isInteger)
83 { 86 {
84 } 87 }
85 88
86 CalculationCategory m_category; 89 CalculationCategory m_category;
87 bool m_isInteger; 90 bool m_isInteger;
88 }; 91 };
89 92
90 class CSSCalcValue : public CSSValue { 93 class CSSCalcValue : public CSSValue {
91 public: 94 public:
92 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(CSSParserString name, CSS ParserValueList*, ValueRange); 95 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(CSSParserString name, CSS ParserValueList*, ValueRange);
93 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(PassRefPtr<CSSCalcExpress ionNode>, ValueRange = ValueRangeAll); 96 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(PassRefPtrWillBeRawPtr<CS SCalcExpressionNode>, ValueRange = ValueRangeAll);
94 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(const CalculationValue* v alue, float zoom) { return adoptRefCountedWillBeRefCountedGarbageCollected(new C SSCalcValue(value, zoom)); } 97 static PassRefPtrWillBeRawPtr<CSSCalcValue> create(const CalculationValue* v alue, float zoom) { return adoptRefCountedWillBeRefCountedGarbageCollected(new C SSCalcValue(value, zoom)); }
95 98
96 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSS PrimitiveValue>, bool isInteger = false); 99 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa ssRefPtrWillBeRawPtr<CSSPrimitiveValue>, bool isInteger = false);
97 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSS CalcExpressionNode>, PassRefPtr<CSSCalcExpressionNode>, CalcOperator); 100 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(Pa ssRefPtrWillBeRawPtr<CSSCalcExpressionNode>, PassRefPtrWillBeRawPtr<CSSCalcExpre ssionNode>, CalcOperator);
98 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const CalcExpr essionNode*, float zoom); 101 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(co nst CalcExpressionNode*, float zoom);
99 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const Length&, float zoom); 102 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createExpressionNode(co nst Length&, float zoom);
100 103
101 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co nversionData) const 104 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co nversionData) const
102 { 105 {
103 return CalculationValue::create(m_expression->toCalcValue(conversionData ), m_nonNegative ? ValueRangeNonNegative : ValueRangeAll); 106 return CalculationValue::create(m_expression->toCalcValue(conversionData ), m_nonNegative ? ValueRangeNonNegative : ValueRangeAll);
104 } 107 }
105 CalculationCategory category() const { return m_expression->category(); } 108 CalculationCategory category() const { return m_expression->category(); }
106 bool isInt() const { return m_expression->isInteger(); } 109 bool isInt() const { return m_expression->isInteger(); }
107 double doubleValue() const; 110 double doubleValue() const;
108 bool isNegative() const { return m_expression->doubleValue() < 0; } 111 bool isNegative() const { return m_expression->doubleValue() < 0; }
109 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat ive : ValueRangeAll; } 112 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat ive : ValueRangeAll; }
110 double computeLengthPx(const CSSToLengthConversionData&) const; 113 double computeLengthPx(const CSSToLengthConversionData&) const;
111 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } 114 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); }
112 115
113 String customCSSText() const; 116 String customCSSText() const;
114 bool equals(const CSSCalcValue&) const; 117 bool equals(const CSSCalcValue&) const;
115 118
116 void traceAfterDispatch(Visitor* visitor) { CSSValue::traceAfterDispatch(vis itor); } 119 void traceAfterDispatch(Visitor*);
117 120
118 private: 121 private:
119 CSSCalcValue(PassRefPtr<CSSCalcExpressionNode> expression, ValueRange range) 122 CSSCalcValue(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, Value Range range)
120 : CSSValue(CalculationClass) 123 : CSSValue(CalculationClass)
121 , m_expression(expression) 124 , m_expression(expression)
122 , m_nonNegative(range == ValueRangeNonNegative) 125 , m_nonNegative(range == ValueRangeNonNegative)
123 { 126 {
124 } 127 }
125 CSSCalcValue(const CalculationValue* value, float zoom) 128 CSSCalcValue(const CalculationValue* value, float zoom)
126 : CSSValue(CalculationClass) 129 : CSSValue(CalculationClass)
127 , m_expression(createExpressionNode(value->expression(), zoom)) 130 , m_expression(createExpressionNode(value->expression(), zoom))
128 , m_nonNegative(value->isNonNegative()) 131 , m_nonNegative(value->isNonNegative())
129 { 132 {
130 } 133 }
131 134
132 double clampToPermittedRange(double) const; 135 double clampToPermittedRange(double) const;
133 136
134 const RefPtr<CSSCalcExpressionNode> m_expression; 137 const RefPtrWillBeMember<CSSCalcExpressionNode> m_expression;
135 const bool m_nonNegative; 138 const bool m_nonNegative;
136 }; 139 };
137 140
138 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue()); 141 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue());
139 142
140 } // namespace WebCore 143 } // namespace WebCore
141 144
142 145
143 #endif // CSSCalculationValue_h 146 #endif // CSSCalculationValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698