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

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

Issue 64293008: Wrap CSS length conversion arguments in an object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: don't make it noncopyable ; clang doesn't do the RVO stuffs? Created 7 years 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
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/css/CSSCalculationValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28 matching lines...) Expand all
39 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.h"
40 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 class CSSParserValueList; 44 class CSSParserValueList;
45 class CSSValueList; 45 class CSSValueList;
46 class CalculationValue; 46 class CalculationValue;
47 class CalcExpressionNode; 47 class CalcExpressionNode;
48 class Length; 48 class Length;
49 class RenderStyle;
50 49
51 enum CalculationCategory { 50 enum CalculationCategory {
52 CalcNumber = 0, 51 CalcNumber = 0,
53 CalcLength, 52 CalcLength,
54 CalcPercent, 53 CalcPercent,
55 CalcPercentNumber, 54 CalcPercentNumber,
56 CalcPercentLength, 55 CalcPercentLength,
57 CalcVariable, 56 CalcVariable,
58 CalcOther 57 CalcOther
59 }; 58 };
60 59
61 class CSSCalcExpressionNode : public RefCounted<CSSCalcExpressionNode> { 60 class CSSCalcExpressionNode : public RefCounted<CSSCalcExpressionNode> {
62 public: 61 public:
63 enum Type { 62 enum Type {
64 CssCalcPrimitiveValue = 1, 63 CssCalcPrimitiveValue = 1,
65 CssCalcBinaryOperation 64 CssCalcBinaryOperation
66 }; 65 };
67 66
68 virtual ~CSSCalcExpressionNode() = 0; 67 virtual ~CSSCalcExpressionNode() = 0;
69 virtual bool isZero() const = 0; 68 virtual bool isZero() const = 0;
70 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0; 69 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi onData&) const = 0;
71 virtual double doubleValue() const = 0; 70 virtual double doubleValue() const = 0;
72 virtual double computeLengthPx(const RenderStyle* currentStyle, const Render Style* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0; 71 virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0;
73 virtual String customCSSText() const = 0; 72 virtual String customCSSText() const = 0;
74 virtual String serializeResolvingVariables(const HashMap<AtomicString, Strin g>&) const = 0; 73 virtual String serializeResolvingVariables(const HashMap<AtomicString, Strin g>&) const = 0;
75 virtual bool hasVariableReference() const = 0; 74 virtual bool hasVariableReference() const = 0;
76 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat egory == other.m_category && m_isInteger == other.m_isInteger; } 75 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_cat egory == other.m_category && m_isInteger == other.m_isInteger; }
77 virtual Type type() const = 0; 76 virtual Type type() const = 0;
78 77
79 CalculationCategory category() const { return m_category; } 78 CalculationCategory category() const { return m_category; }
80 virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0; 79 virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0;
81 bool isInteger() const { return m_isInteger; } 80 bool isInteger() const { return m_isInteger; }
82 81
(...skipping 12 matching lines...) Expand all
95 public: 94 public:
96 static PassRefPtr<CSSCalcValue> create(CSSParserString name, CSSParserValueL ist*, ValueRange); 95 static PassRefPtr<CSSCalcValue> create(CSSParserString name, CSSParserValueL ist*, ValueRange);
97 static PassRefPtr<CSSCalcValue> create(PassRefPtr<CSSCalcExpressionNode>, Va lueRange = ValueRangeAll); 96 static PassRefPtr<CSSCalcValue> create(PassRefPtr<CSSCalcExpressionNode>, Va lueRange = ValueRangeAll);
98 static PassRefPtr<CSSCalcValue> create(const CalculationValue* value, float zoom) { return adoptRef(new CSSCalcValue(value, zoom)); } 97 static PassRefPtr<CSSCalcValue> create(const CalculationValue* value, float zoom) { return adoptRef(new CSSCalcValue(value, zoom)); }
99 98
100 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSS PrimitiveValue>, bool isInteger = false); 99 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSS PrimitiveValue>, bool isInteger = false);
101 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSS CalcExpressionNode>, PassRefPtr<CSSCalcExpressionNode>, CalcOperator); 100 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(PassRefPtr<CSS CalcExpressionNode>, PassRefPtr<CSSCalcExpressionNode>, CalcOperator);
102 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const CalcExpr essionNode*, float zoom); 101 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const CalcExpr essionNode*, float zoom);
103 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const Length&, float zoom); 102 static PassRefPtr<CSSCalcExpressionNode> createExpressionNode(const Length&, float zoom);
104 103
105 PassRefPtr<CalculationValue> toCalcValue(const RenderStyle* style, const Ren derStyle* rootStyle, double zoom = 1.0) const 104 PassRefPtr<CalculationValue> toCalcValue(const CSSToLengthConversionData& co nversionData) const
106 { 105 {
107 return CalculationValue::create(m_expression->toCalcValue(style, rootSty le, zoom), m_nonNegative ? ValueRangeNonNegative : ValueRangeAll); 106 return CalculationValue::create(m_expression->toCalcValue(conversionData ), m_nonNegative ? ValueRangeNonNegative : ValueRangeAll);
108 } 107 }
109 CalculationCategory category() const { return m_expression->category(); } 108 CalculationCategory category() const { return m_expression->category(); }
110 bool isInt() const { return m_expression->isInteger(); } 109 bool isInt() const { return m_expression->isInteger(); }
111 double doubleValue() const; 110 double doubleValue() const;
112 bool isNegative() const { return m_expression->doubleValue() < 0; } 111 bool isNegative() const { return m_expression->doubleValue() < 0; }
113 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat ive : ValueRangeAll; } 112 ValueRange permittedValueRange() { return m_nonNegative ? ValueRangeNonNegat ive : ValueRangeAll; }
114 double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* r ootStyle, double multiplier = 1.0, bool computingFontSize = false) const; 113 double computeLengthPx(const CSSToLengthConversionData&) const;
115 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } 114 CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); }
116 115
117 String customCSSText() const; 116 String customCSSText() const;
118 bool equals(const CSSCalcValue&) const; 117 bool equals(const CSSCalcValue&) const;
119 String customSerializeResolvingVariables(const HashMap<AtomicString, String> &) const; 118 String customSerializeResolvingVariables(const HashMap<AtomicString, String> &) const;
120 bool hasVariableReference() const; 119 bool hasVariableReference() const;
121 120
122 private: 121 private:
123 CSSCalcValue(PassRefPtr<CSSCalcExpressionNode> expression, ValueRange range) 122 CSSCalcValue(PassRefPtr<CSSCalcExpressionNode> expression, ValueRange range)
124 : CSSValue(CalculationClass) 123 : CSSValue(CalculationClass)
(...skipping 13 matching lines...) Expand all
138 const RefPtr<CSSCalcExpressionNode> m_expression; 137 const RefPtr<CSSCalcExpressionNode> m_expression;
139 const bool m_nonNegative; 138 const bool m_nonNegative;
140 }; 139 };
141 140
142 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue()); 141 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue());
143 142
144 } // namespace WebCore 143 } // namespace WebCore
145 144
146 145
147 #endif // CSSCalculationValue_h 146 #endif // CSSCalculationValue_h
OLDNEW
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/css/CSSCalculationValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698