Changeset 148619 in webkit


Ignore:
Timestamp:
Apr 17, 2013 11:27:43 AM (11 years ago)
Author:
krit@webkit.org
Message:

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):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148618 r148619  
     12013-04-17  Dirk Schulze  <krit@webkit.org>
     2
     3        Make lengthConversion methods and arguments const
     4        https://bugs.webkit.org/show_bug.cgi?id=114749
     5
     6        Reviewed by Andreas Kling.
     7
     8        Refactoring, no new tests.
     9
     10        * css/CSSCalculationValue.cpp:
     11        (WebCore::CSSCalcValue::computeLengthPx):
     12        (WebCore::CSSCalcPrimitiveValue::toCalcValue):
     13        (WebCore::CSSCalcPrimitiveValue::computeLengthPx):
     14        (WebCore::CSSCalcBinaryOperation::toCalcValue):
     15        (WebCore::CSSCalcBinaryOperation::computeLengthPx):
     16        * css/CSSCalculationValue.h:
     17        (WebCore::CSSCalcValue::toCalcValue):
     18        (CSSCalcValue):
     19        * css/CSSPrimitiveValue.cpp:
     20        (WebCore::CSSPrimitiveValue::computeLength):
     21        (WebCore::CSSPrimitiveValue::computeLengthDouble):
     22        (WebCore::CSSPrimitiveValue::viewportPercentageLength):
     23        * css/CSSPrimitiveValue.h:
     24        (CSSPrimitiveValue):
     25        * css/CSSPrimitiveValueMappings.h:
     26        (WebCore::CSSPrimitiveValue::convertToLength):
     27        * css/StyleResolver.cpp:
     28        (WebCore::StyleResolver::convertToIntLength):
     29        (WebCore::StyleResolver::convertToFloatLength):
     30        * css/StyleResolver.h:
     31        (StyleResolver):
     32
    1332013-04-17  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
    234
  • trunk/Source/WebCore/css/CSSCalculationValue.cpp

    r142904 r148619  
    129129}
    130130
    131 double CSSCalcValue::computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
     131double CSSCalcValue::computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
    132132{
    133133    return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize));
     
    169169#endif
    170170
    171     virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
     171    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
    172172    {
    173173        switch (m_category) {
     
    210210    }
    211211   
    212     virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
     212    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
    213213    {
    214214        switch (m_category) {
     
    315315    }
    316316
    317     virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
     317    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
    318318    {
    319319        OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(style, rootStyle, zoom));
     
    331331    }
    332332   
    333     virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
     333    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
    334334    {
    335335        const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
  • trunk/Source/WebCore/css/CSSCalculationValue.h

    r142444 r148619  
    6868    virtual ~CSSCalcExpressionNode() = 0;
    6969    virtual bool isZero() const = 0;
    70     virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle*, RenderStyle* rootStyle, double zoom = 1.0) const = 0;   
     70    virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0;   
    7171    virtual double doubleValue() const = 0;
    72     virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
     72    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
    7373    virtual String customCssText() const = 0;
    7474#if ENABLE(CSS_VARIABLES)
     
    9999    static PassRefPtr<CSSCalcValue> create(CalculationValue*);
    100100
    101     PassRefPtr<CalculationValue> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom = 1.0) const
     101    PassRefPtr<CalculationValue> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom = 1.0) const
    102102    {
    103103        return CalculationValue::create(m_expression->toCalcValue(style, rootStyle, zoom), m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
     
    107107    double doubleValue() const;
    108108    bool isNegative() const { return m_expression->doubleValue() < 0; }
    109     double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
     109    double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
    110110       
    111111    String customCssText() const;
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r145168 r148619  
    482482}
    483483
    484 template<> int CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     484template<> int CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    485485{
    486486    return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    487487}
    488488
    489 template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     489template<> unsigned CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    490490{
    491491    return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    492492}
    493493
    494 template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     494template<> Length CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    495495{
    496496#if ENABLE(SUBPIXEL_LAYOUT)
     
    501501}
    502502
    503 template<> short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     503template<> short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    504504{
    505505    return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    506506}
    507507
    508 template<> unsigned short CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     508template<> unsigned short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    509509{
    510510    return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    511511}
    512512
    513 template<> float CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     513template<> float CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    514514{
    515515    return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    516516}
    517517
    518 template<> double CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     518template<> double CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    519519{
    520520    return computeLengthDouble(style, rootStyle, multiplier, computingFontSize);
    521521}
    522522
    523 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, RenderStyle* rootStyle, float multiplier, bool computingFontSize)
     523double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    524524{
    525525    if (m_primitiveUnitType == CSS_CALC)
     
    11701170}
    11711171
    1172 Length CSSPrimitiveValue::viewportPercentageLength()
     1172Length CSSPrimitiveValue::viewportPercentageLength() const
    11731173{
    11741174    ASSERT(isViewportPercentageLength());
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r148186 r148619  
    255255     * and some tool to calibrate.
    256256     */
    257     template<typename T> T computeLength(RenderStyle* currStyle, RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false);
     257    template<typename T> T computeLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false) const;
    258258
    259259    // Converts to a Length, mapping various unit types appropriately.
    260     template<int> Length convertToLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
     260    template<int> Length convertToLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
    261261
    262262    // use with care!!!
     
    321321    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
    322322
    323     Length viewportPercentageLength();
     323    Length viewportPercentageLength() const;
    324324   
    325325    PassRefPtr<CSSPrimitiveValue> cloneForCSSOM() const;
     
    366366    bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
    367367
    368     double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, float multiplier, bool computingFontSize);
     368    double computeLengthDouble(const RenderStyle* currentStyle, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const;
    369369
    370370    union {
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r148208 r148619  
    42764276};
    42774277
    4278 template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
     4278template<int supported> Length CSSPrimitiveValue::convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
    42794279{
    42804280#if ENABLE(CSS_VARIABLES)
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r148395 r148619  
    16861686// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
    16871687
    1688 Length StyleResolver::convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
     1688Length StyleResolver::convertToIntLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
    16891689{
    16901690    return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
    16911691}
    16921692
    1693 Length StyleResolver::convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier)
     1693Length StyleResolver::convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
    16941694{
    16951695    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
  • trunk/Source/WebCore/css/StyleResolver.h

    r148363 r148619  
    560560    bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); }
    561561
    562     static Length convertToIntLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
    563     static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
     562    static Length convertToIntLength(const CSSPrimitiveValue*, const RenderStyle*, const RenderStyle* rootStyle, double multiplier = 1);
     563    static Length convertToFloatLength(const CSSPrimitiveValue*, const RenderStyle*, const RenderStyle* rootStyle, double multiplier = 1);
    564564
    565565    CSSToStyleMap* styleMap() { return &m_styleMap; }
Note: See TracChangeset for help on using the changeset viewer.