Changeset 79784 in webkit


Ignore:
Timestamp:
Feb 26, 2011 6:40:20 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-02-26 Rik Cabanier <cabanier@adobe.com>

Reviewed by David Hyatt.

Fix that allows fixed length values to be floating point
https://bugs.webkit.org/show_bug.cgi?id=52699

Transitions now return matrices in floating point. 2 of the transition tests were failing
because they expected integer values.

  • transitions/matched-transform-functions.html:
  • transitions/retargetted-transition.html:

2011-02-26 Rik Cabanier <cabanier@adobe.com>

Reviewed by David Hyatt.

Fix that allows fixed length values to be floating point
https://bugs.webkit.org/show_bug.cgi?id=52699

Transitions now return matrices in floating point. 2 of the transition tests were failing
because they expected integer values.

  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSStyleSelector.cpp: (WebCore::convertToLength): (WebCore::convertToIntLength): (WebCore::convertToFloatLength): (WebCore::CSSStyleSelector::applyProperty): (WebCore::CSSStyleSelector::createTransformOperations):
  • platform/Length.h: (WebCore::Length::Length): (WebCore::Length::operator==): (WebCore::Length::operator!=): (WebCore::Length::rawValue): (WebCore::Length::type): (WebCore::Length::quirk): (WebCore::Length::setValue): (WebCore::Length::calcFloatValue): (WebCore::Length::isZero): (WebCore::Length::blend): (WebCore::Length::getIntValue): (WebCore::Length::getFloatValue):
  • rendering/AutoTableLayout.cpp: (WebCore::AutoTableLayout::recalcColumn): (WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
  • rendering/FixedTableLayout.cpp: (WebCore::FixedTableLayout::calcWidthArray):
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r79783 r79784  
     12011-02-26  Rik Cabanier  <cabanier@adobe.com>
     2
     3        Reviewed by David Hyatt.
     4
     5        Fix that allows fixed length values to be floating point
     6        https://bugs.webkit.org/show_bug.cgi?id=52699
     7
     8        Transitions now return matrices in floating point. 2 of the transition tests were failing
     9        because they expected integer values.
     10
     11        * transitions/matched-transform-functions.html:
     12        * transitions/retargetted-transition.html:
     13
    1142011-02-26  Kenneth Rohde Christiansen  <kenneth@webkit.org>
    215
  • trunk/LayoutTests/transitions/matched-transform-functions.html

    r37496 r79784  
    2525    function test()
    2626    {
    27       var t = window.getComputedStyle(document.getElementById('box')).webkitTransform;
    28       // grab the last value from the matrix()
    29       var lastValueRE = /(\d+)\)$/;
    30       var yTranslate = parseInt(lastValueRE.exec(t));
    31      
    32       var result = (yTranslate < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200';
     27          var c = new WebKitCSSMatrix(window.getComputedStyle(document.getElementById('box')).webkitTransform);     
     28      var result = (c.f < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200';
     29
    3330      document.getElementById('result').innerHTML = result;
    3431
  • trunk/LayoutTests/transitions/retargetted-transition.html

    r37495 r79784  
    2424    function test()
    2525    {
    26       var t = window.getComputedStyle(document.getElementById('box')).webkitTransform;
    27       // grab the last value from the matrix()
    28       var lastValueRE = /(\d+)\)$/;
    29       var yTranslate = parseInt(lastValueRE.exec(t));
    30 
    31       var result = (yTranslate < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200';
     26      var c = new WebKitCSSMatrix(window.getComputedStyle(document.getElementById('box')).webkitTransform);
     27      var result = (c.f < 200) ? 'PASS' : 'FAIL: transition should still be running, so y < 200';
    3228      document.getElementById('result').innerHTML = result;
    3329
  • trunk/Source/WebCore/ChangeLog

    r79781 r79784  
     12011-02-26  Rik Cabanier  <cabanier@adobe.com>
     2
     3        Reviewed by David Hyatt.
     4
     5        Fix that allows fixed length values to be floating point
     6        https://bugs.webkit.org/show_bug.cgi?id=52699
     7
     8        Transitions now return matrices in floating point. 2 of the transition tests were failing
     9        because they expected integer values.
     10
     11        * WebCore.xcodeproj/project.pbxproj:
     12        * css/CSSStyleSelector.cpp:
     13        (WebCore::convertToLength):
     14        (WebCore::convertToIntLength):
     15        (WebCore::convertToFloatLength):
     16        (WebCore::CSSStyleSelector::applyProperty):
     17        (WebCore::CSSStyleSelector::createTransformOperations):
     18        * platform/Length.h:
     19        (WebCore::Length::Length):
     20        (WebCore::Length::operator==):
     21        (WebCore::Length::operator!=):
     22        (WebCore::Length::rawValue):
     23        (WebCore::Length::type):
     24        (WebCore::Length::quirk):
     25        (WebCore::Length::setValue):
     26        (WebCore::Length::calcFloatValue):
     27        (WebCore::Length::isZero):
     28        (WebCore::Length::blend):
     29        (WebCore::Length::getIntValue):
     30        (WebCore::Length::getFloatValue):
     31        * rendering/AutoTableLayout.cpp:
     32        (WebCore::AutoTableLayout::recalcColumn):
     33        (WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
     34        * rendering/FixedTableLayout.cpp:
     35        (WebCore::FixedTableLayout::calcWidthArray):
     36
    1372011-02-26  Eric Seidel  <eric@webkit.org>
    238
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r79298 r79784  
    33353335// -------------------------------------------------------------------------------------
    33363336// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
    3337 
    3338 static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)
     3337static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, bool toFloat, double multiplier = 1, bool *ok = 0)
    33393338{
    33403339    // This function is tolerant of a null style value. The only place style is used is in
     
    33473346    } else {
    33483347        int type = primitiveValue->primitiveType();
    3349        
     3348
    33503349        if (!style && (type == CSSPrimitiveValue::CSS_EMS || type == CSSPrimitiveValue::CSS_EXS || type == CSSPrimitiveValue::CSS_REMS)) {
    33513350            if (ok)
    33523351                *ok = false;
    3353         } else if (CSSPrimitiveValue::isUnitTypeLength(type))
    3354             l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed);
     3352        } else if (CSSPrimitiveValue::isUnitTypeLength(type)) {
     3353            if (toFloat)
     3354                l = Length(primitiveValue->computeLengthDouble(style, rootStyle, multiplier), Fixed);
     3355            else
     3356                l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed);
     3357        }
    33553358        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    33563359            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    33613364    }
    33623365    return l;
     3366}
     3367
     3368static Length convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)
     3369{
     3370    return convertToLength(primitiveValue, style, rootStyle, false, multiplier, ok);
     3371}
     3372
     3373static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)
     3374{
     3375    return convertToLength(primitiveValue, style, rootStyle, true, multiplier, ok);
    33633376}
    33643377
     
    46824695            if (!rect)
    46834696                return;
    4684             top = convertToLength(rect->top(), style(), m_rootElementStyle, zoomFactor);
    4685             right = convertToLength(rect->right(), style(), m_rootElementStyle, zoomFactor);
    4686             bottom = convertToLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor);
    4687             left = convertToLength(rect->left(), style(), m_rootElementStyle, zoomFactor);
     4697            top = convertToIntLength(rect->top(), style(), m_rootElementStyle, zoomFactor);
     4698            right = convertToIntLength(rect->right(), style(), m_rootElementStyle, zoomFactor);
     4699            bottom = convertToIntLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor);
     4700            left = convertToIntLength(rect->left(), style(), m_rootElementStyle, zoomFactor);
    46884701        } else if (primitiveValue->getIdent() != CSSValueAuto) {
    46894702            return;
     
    55745587        else {
    55755588            bool ok = true;
    5576             Length l = convertToLength(primitiveValue, style(), m_rootElementStyle, 1, &ok);
     5589            Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle, 1, &ok);
    55775590            if (ok)
    5578                 m_style->setMarqueeIncrement(l);
     5591                m_style->setMarqueeIncrement(marqueeLength);
    55795592        }
    55805593        return;
     
    57225735        DashboardRegion *first = region;
    57235736        while (region) {
    5724             Length top = convertToLength(region->top(), style(), m_rootElementStyle);
    5725             Length right = convertToLength(region->right(), style(), m_rootElementStyle);
    5726             Length bottom = convertToLength(region->bottom(), style(), m_rootElementStyle);
    5727             Length left = convertToLength(region->left(), style(), m_rootElementStyle);
     5737            Length top = convertToIntLength(region->top(), style(), m_rootElementStyle);
     5738            Length right = convertToIntLength(region->right(), style(), m_rootElementStyle);
     5739            Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle);
     5740            Length left = convertToIntLength(region->left(), style(), m_rootElementStyle);
    57285741            if (region->m_isCircle)
    57295742                m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
     
    71847197                Length ty = Length(0, Fixed);
    71857198                if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    7186                     ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7199                    ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    71877200                else {
    7188                     tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7201                    tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    71897202                    if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    71907203                        if (transformValue->length() > 1) {
    71917204                            CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
    7192                             ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok);
     7205                            ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok);
    71937206                        }
    71947207                    }
     
    72087221                Length tz = Length(0, Fixed);
    72097222                if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
    7210                     tz = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7223                    tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72117224                else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    7212                     ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7225                    ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72137226                else {
    7214                     tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7227                    tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72157228                    if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    72167229                        if (transformValue->length() > 2) {
    72177230                            CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
    7218                             tz = convertToLength(thirdValue, style, rootStyle, zoomFactor, &ok);
     7231                            tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor, &ok);
    72197232                        }
    72207233                        if (transformValue->length() > 1) {
    72217234                            CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
    7222                             ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok);
     7235                            ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok);
    72237236                        }
    72247237                    }
     
    73517364                Length p = Length(0, Fixed);
    73527365                if (CSSPrimitiveValue::isUnitTypeLength(firstValue->primitiveType()))
    7353                     p = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7366                    p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    73547367                else {
    73557368                    // This is a quirk that should go away when 3d transforms are finalized.
  • trunk/Source/WebCore/platform/Length.h

    r79733 r79784  
    4141public:
    4242    Length()
    43         : m_value(0)
     43        : m_intValue(0), m_quirk(0), m_type(Auto), m_isFloat(0)
    4444    {
    4545    }
    4646
    4747    Length(LengthType t)
    48         : m_value(t)
     48        : m_intValue(0), m_quirk(0), m_type(t), m_isFloat(0)
    4949    {
    5050    }
    5151
    5252    Length(int v, LengthType t, bool q = false)
    53         : m_value((v * 16) | (q << 3) | t) // FIXME: Doesn't work if the passed-in value is very large!
     53        : m_intValue(v), m_quirk(q), m_type(t), m_isFloat(0)
    5454    {
    5555        ASSERT(t != Percent);
     
    5757
    5858    Length(double v, LengthType t, bool q = false)
    59         : m_value(static_cast<int>(v * percentScaleFactor) * 16 | (q << 3) | t)
    60     {
    61         ASSERT(t == Percent);
    62     }
    63 
    64     bool operator==(const Length& o) const { return m_value == o.m_value; }
    65     bool operator!=(const Length& o) const { return m_value != o.m_value; }
    66 
     59        : m_quirk(q), m_type(t), m_isFloat(0)
     60    {
     61        if (m_type == Percent)
     62            m_intValue = static_cast<int>(v*percentScaleFactor);
     63        else {
     64            m_isFloat = 1;           
     65            m_floatValue = static_cast<float>(v);
     66        }
     67    }
     68   
     69    bool operator==(const Length& o) const { return (getFloatValue() == o.getFloatValue()) && (m_type == o.m_type) && (m_quirk == o.m_quirk); }
     70    bool operator!=(const Length& o) const { return (getFloatValue() != o.getFloatValue()) || (m_type != o.m_type) || (m_quirk != o.m_quirk); }
     71
     72   
    6773    int value() const {
    6874        ASSERT(type() != Percent);
     
    7076    }
    7177
    72     int rawValue() const { return (m_value & ~0xF) / 16; }
     78    int rawValue() const { return getIntValue(); }
    7379
    7480    double percent() const
     
    7884    }
    7985
    80     LengthType type() const { return static_cast<LengthType>(m_value & 7); }
    81     bool quirk() const { return (m_value >> 3) & 1; }
     86    LengthType type() const { return static_cast<LengthType>(m_type); }
     87    bool quirk() const { return m_quirk; }
    8288
    8389    void setValue(LengthType t, int value)
    8490    {
    8591        ASSERT(t != Percent);
    86         setRawValue(t, value);
    87     }
    88 
    89     void setRawValue(LengthType t, int value) { m_value = value * 16 | (m_value & 0x8) | t; }
     92        *this = Length(value, t);
     93    }
    9094
    9195    void setValue(int value)
    9296    {
    9397        ASSERT(!value || type() != Percent);
    94         setRawValue(value);
    95     }
    96 
    97     void setRawValue(int value) { m_value = value * 16 | (m_value & 0xF); }
     98        *this = Length(value, Fixed);
     99    }
    98100
    99101    void setValue(LengthType t, double value)
    100102    {
    101         ASSERT(t == Percent);
    102         m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0x8) | t;
     103        *this = Length(value, t);
    103104    }
    104105
    105106    void setValue(double value)
    106107    {
    107         ASSERT(type() == Percent);
    108         m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0xF);
     108        *this = Length(value, Fixed);
    109109    }
    110110
     
    145145        switch (type()) {
    146146            case Fixed:
    147                 return static_cast<float>(value());
     147                return getFloatValue();
    148148            case Percent:
    149149                return static_cast<float>(maxValue * percent() / 100.0);
     
    156156
    157157    bool isUndefined() const { return rawValue() == undefinedLength; }
    158     bool isZero() const { return !(m_value & ~0xF); }
     158    bool isZero() const { return !getIntValue(); }
    159159    bool isPositive() const { return rawValue() > 0; }
    160160    bool isNegative() const { return rawValue() < 0; }
     
    185185        }
    186186           
    187         int fromValue = from.isZero() ? 0 : from.value();
    188         int toValue = isZero() ? 0 : value();
    189         return Length(int(fromValue + (toValue - fromValue) * progress), resultType);
     187        double fromValue = from.isZero() ? 0 : from.getFloatValue();
     188        double toValue = isZero() ? 0 : getFloatValue();
     189        return Length(fromValue + (toValue - fromValue) * progress, resultType);
    190190    }
    191191
    192192private:
    193     int m_value;
     193    int getIntValue() const
     194    {
     195        if (m_isFloat)
     196            return static_cast<int>(m_floatValue);
     197        return m_intValue;
     198    }
     199   
     200    float getFloatValue() const
     201    {
     202        if (m_isFloat)
     203            return m_floatValue;
     204        return m_intValue;
     205    }
     206   
     207    union {
     208        int m_intValue;
     209        float m_floatValue;
     210    };
     211    bool m_quirk;
     212    unsigned char m_type;
     213    bool m_isFloat;
    194214};
    195215
  • trunk/Source/WebCore/rendering/AutoTableLayout.cpp

    r79733 r79784  
    8383                    // FIXME: What is this arbitrary value?
    8484                    if (cellLogicalWidth.rawValue() > 32760)
    85                         cellLogicalWidth.setRawValue(32760);
     85                        cellLogicalWidth.setValue(32760);
    8686                    if (cellLogicalWidth.isNegative())
    8787                        cellLogicalWidth.setValue(0);
     
    375375                        percentMissing -= percent;
    376376                        if (percent > 0)
    377                             m_layoutStruct[pos].effectiveLogicalWidth.setRawValue(Percent, percent);
     377                            m_layoutStruct[pos].effectiveLogicalWidth.setValue(Percent, percent);
    378378                        else
    379379                            m_layoutStruct[pos].effectiveLogicalWidth = Length();
  • trunk/Source/WebCore/rendering/FixedTableLayout.cpp

    r71262 r79784  
    119119                }
    120120                if ((w.isFixed() || w.isPercent()) && w.isPositive()) {
    121                     m_width[currentEffectiveColumn].setRawValue(w.type(), w.rawValue() * spanInCurrentEffectiveColumn);
     121                    m_width[currentEffectiveColumn].setValue(w.type(), w.rawValue() * spanInCurrentEffectiveColumn);
    122122                    usedWidth += effWidth * spanInCurrentEffectiveColumn;
    123123                }
     
    168168                    // Only set if no col element has already set it.
    169169                    if (m_width[cCol + i].isAuto() && w.type() != Auto) {
    170                         m_width[cCol + i].setRawValue(w.type(), w.rawValue() * eSpan / span);
     170                        m_width[cCol + i].setValue(w.type(), w.rawValue() * eSpan / span);
    171171                        usedWidth += effWidth * eSpan / span;
    172172                    }
Note: See TracChangeset for help on using the changeset viewer.