Commit af0fcb80 authored by krit@webkit.org's avatar krit@webkit.org

Make lengthConversion methods and arguments const

https://bugs.webkit.org/show_bug.cgi?id=114749

Reviewed by Andreas Kling.

Refactoring, no new tests.

* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcValue::computeLengthPx):
(WebCore::CSSCalcPrimitiveValue::toCalcValue):
(WebCore::CSSCalcPrimitiveValue::computeLengthPx):
(WebCore::CSSCalcBinaryOperation::toCalcValue):
(WebCore::CSSCalcBinaryOperation::computeLengthPx):
* css/CSSCalculationValue.h:
(WebCore::CSSCalcValue::toCalcValue):
(CSSCalcValue):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeLength):
(WebCore::CSSPrimitiveValue::computeLengthDouble):
(WebCore::CSSPrimitiveValue::viewportPercentageLength):
* css/CSSPrimitiveValue.h:
(CSSPrimitiveValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::convertToLength):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::convertToIntLength):
(WebCore::StyleResolver::convertToFloatLength):
* css/StyleResolver.h:
(StyleResolver):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bd448dc8
2013-04-17 Dirk Schulze <krit@webkit.org>
Make lengthConversion methods and arguments const
https://bugs.webkit.org/show_bug.cgi?id=114749
Reviewed by Andreas Kling.
Refactoring, no new tests.
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcValue::computeLengthPx):
(WebCore::CSSCalcPrimitiveValue::toCalcValue):
(WebCore::CSSCalcPrimitiveValue::computeLengthPx):
(WebCore::CSSCalcBinaryOperation::toCalcValue):
(WebCore::CSSCalcBinaryOperation::computeLengthPx):
* css/CSSCalculationValue.h:
(WebCore::CSSCalcValue::toCalcValue):
(CSSCalcValue):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeLength):
(WebCore::CSSPrimitiveValue::computeLengthDouble):
(WebCore::CSSPrimitiveValue::viewportPercentageLength):
* css/CSSPrimitiveValue.h:
(CSSPrimitiveValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::convertToLength):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::convertToIntLength):
(WebCore::StyleResolver::convertToFloatLength):
* css/StyleResolver.h:
(StyleResolver):
2013-04-17 Bruno de Oliveira Abinader <bruno.abinader@basyskom.com>
[refactor] Moved ScriptedAnimationController common code to inline function
......@@ -128,7 +128,7 @@ double CSSCalcValue::doubleValue() const
return clampToPermittedRange(m_expression->doubleValue());
}
double CSSCalcValue::computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
double CSSCalcValue::computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
{
return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize));
}
......@@ -168,7 +168,7 @@ public:
}
#endif
virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
{
switch (m_category) {
case CalcNumber:
......@@ -209,7 +209,7 @@ public:
return 0;
}
virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
{
switch (m_category) {
case CalcLength:
......@@ -314,7 +314,7 @@ public:
return !doubleValue();
}
virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
{
OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(style, rootStyle, zoom));
if (!left)
......@@ -330,7 +330,7 @@ public:
return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue());
}
virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
{
const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
const double rightValue = m_rightSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
......
......@@ -67,9 +67,9 @@ public:
virtual ~CSSCalcExpressionNode() = 0;
virtual bool isZero() const = 0;
virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle*, RenderStyle* rootStyle, double zoom = 1.0) const = 0;
virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0;
virtual double doubleValue() const = 0;
virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
virtual String customCssText() const = 0;
#if ENABLE(CSS_VARIABLES)
virtual String serializeResolvingVariables(const HashMap<AtomicString, String>&) const = 0;
......@@ -98,7 +98,7 @@ public:
static PassRefPtr<CSSCalcValue> create(CSSParserString name, CSSParserValueList*, CalculationPermittedValueRange);
static PassRefPtr<CSSCalcValue> create(CalculationValue*);
PassRefPtr<CalculationValue> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom = 1.0) const
PassRefPtr<CalculationValue> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom = 1.0) const
{
return CalculationValue::create(m_expression->toCalcValue(style, rootStyle, zoom), m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
}
......@@ -106,7 +106,7 @@ public:
bool isInt() const { return m_expression->isInteger(); }
double doubleValue() const;
bool isNegative() const { return m_expression->doubleValue() < 0; }
double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
String customCssText() const;
bool equals(const CSSCalcValue&) const;
......
......@@ -481,17 +481,17 @@ double CSSPrimitiveValue::computeDegrees()
}
}
template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
template<> int CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
}
template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
template<> unsigned CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
}
template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
template<> Length CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
#if ENABLE(SUBPIXEL_LAYOUT)
return Length(clampTo<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize), minValueForCssLength, maxValueForCssLength), Fixed);
......@@ -500,27 +500,27 @@ template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderSty
#endif
}
template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
template<> short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
}
template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
template<> unsigned short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
}
template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
template<> float CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
}
template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
template<> double CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
return computeLengthDouble(style, rootStyle, multiplier, computingFontSize);
}
double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
{
if (m_primitiveUnitType == CSS_CALC)
// The multiplier and factor is applied to each value in the calc expression individually
......@@ -1169,7 +1169,7 @@ void CSSPrimitiveValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const S
addSubresourceURL(urls, styleSheet->completeURL(m_value.string));
}
Length CSSPrimitiveValue::viewportPercentageLength()
Length CSSPrimitiveValue::viewportPercentageLength() const
{
ASSERT(isViewportPercentageLength());
Length viewportLength;
......
......@@ -254,10 +254,10 @@ public:
* this is screen/printer dependent, so we probably need a config option for this,
* and some tool to calibrate.
*/
template<typename T> T computeLength(RenderStyle* currStyle, RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false);
template<typename T> T computeLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false) const;
// Converts to a Length, mapping various unit types appropriately.
template<int> Length convertToLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
template<int> Length convertToLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
// use with care!!!
void setPrimitiveType(unsigned short type) { m_primitiveUnitType = type; }
......@@ -320,7 +320,7 @@ public:
void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
Length viewportPercentageLength();
Length viewportPercentageLength() const;
PassRefPtr<CSSPrimitiveValue> cloneForCSSOM() const;
void setCSSOMSafe() { m_isCSSOMSafe = true; }
......@@ -365,7 +365,7 @@ private:
void init(PassRefPtr<CSSCalcValue>);
bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, float multiplier, bool computingFontSize);
double computeLengthDouble(const RenderStyle* currentStyle, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const;
union {
int ident;
......
......@@ -4275,7 +4275,7 @@ enum LengthConversion {
ViewportPercentageConversion = 1 << 6
};
template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
template<int supported> Length CSSPrimitiveValue::convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
{
#if ENABLE(CSS_VARIABLES)
ASSERT(!hasVariableReference());
......
......@@ -1685,12 +1685,12 @@ PassRefPtr<CSSRuleList> StyleResolver::pseudoStyleRulesForElement(Element* e, Ps
// -------------------------------------------------------------------------------------
// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
Length StyleResolver::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
Length StyleResolver::convertToIntLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
{
return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
}
Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
Length StyleResolver::convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
{
return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
}
......
......@@ -559,8 +559,8 @@ public:
bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle(); }
bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); }
static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
static Length convertToIntLength(const CSSPrimitiveValue*, const RenderStyle*, const RenderStyle* rootStyle, double multiplier = 1);
static Length convertToFloatLength(const CSSPrimitiveValue*, const RenderStyle*, const RenderStyle* rootStyle, double multiplier = 1);
CSSToStyleMap* styleMap() { return &m_styleMap; }
InspectorCSSOMWrappers& inspectorCSSOMWrappers() { return m_inspectorCSSOMWrappers; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment