Changeset 80379 in webkit


Ignore:
Timestamp:
Mar 4, 2011 3:05:51 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-03-04 Rik Cabanier <cabanier@gmail.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-03-04 Rik Cabanier <cabanier@gmail.com>

Reviewed by David Hyatt.

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

  • 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

    r80378 r80379  
     12011-03-04  Rik Cabanier  <cabanier@gmail.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-03-03  Gavin Barraclough  <barraclough@apple.com>
    215
  • trunk/LayoutTests/transitions/matched-transform-functions.html

    r79876 r80379  
    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';
    3329      document.getElementById('result').innerHTML = result;
    3430
  • trunk/LayoutTests/transitions/retargetted-transition.html

    r79876 r80379  
    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

    r80377 r80379  
     12011-03-04  Rik Cabanier  <cabanier@gmail.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        * WebCore.xcodeproj/project.pbxproj:
     9        * css/CSSStyleSelector.cpp:
     10        (WebCore::convertToLength):
     11        (WebCore::convertToIntLength):
     12        (WebCore::convertToFloatLength):
     13        (WebCore::CSSStyleSelector::applyProperty):
     14        (WebCore::CSSStyleSelector::createTransformOperations):
     15        * platform/Length.h:
     16        (WebCore::Length::Length):
     17        (WebCore::Length::operator==):
     18        (WebCore::Length::operator!=):
     19        (WebCore::Length::rawValue):
     20        (WebCore::Length::type):
     21        (WebCore::Length::quirk):
     22        (WebCore::Length::setValue):
     23        (WebCore::Length::calcFloatValue):
     24        (WebCore::Length::isZero):
     25        (WebCore::Length::blend):
     26        (WebCore::Length::getIntValue):
     27        (WebCore::Length::getFloatValue):
     28        * rendering/AutoTableLayout.cpp:
     29        (WebCore::AutoTableLayout::recalcColumn):
     30        (WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
     31        * rendering/FixedTableLayout.cpp:
     32        (WebCore::FixedTableLayout::calcWidthArray):
     33
    1342011-03-04  Steve Falkenburg  <sfalken@apple.com>
    235
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r80288 r80379  
    33643364// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
    33653365
    3366 static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)
     3366static Length convertToLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, bool toFloat, double multiplier = 1, bool *ok = 0)
    33673367{
    33683368    // This function is tolerant of a null style value. The only place style is used is in
     
    33793379            if (ok)
    33803380                *ok = false;
    3381         } else if (CSSPrimitiveValue::isUnitTypeLength(type))
    3382             l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed);
     3381        } else if (CSSPrimitiveValue::isUnitTypeLength(type)) {
     3382            if (toFloat)
     3383                l = Length(primitiveValue->computeLengthDouble(style, rootStyle, multiplier), Fixed);
     3384            else
     3385                l = Length(primitiveValue->computeLengthIntForLength(style, rootStyle, multiplier), Fixed);
     3386        }
    33833387        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    33843388            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    33893393    }
    33903394    return l;
     3395}
     3396   
     3397static Length convertToIntLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)
     3398{
     3399    return convertToLength(primitiveValue, style, rootStyle, false, multiplier, ok);
     3400}
     3401
     3402static Length convertToFloatLength(CSSPrimitiveValue* primitiveValue, RenderStyle* style, RenderStyle* rootStyle, double multiplier = 1, bool *ok = 0)
     3403{
     3404    return convertToLength(primitiveValue, style, rootStyle, true, multiplier, ok);
    33913405}
    33923406
     
    47104724            if (!rect)
    47114725                return;
    4712             top = convertToLength(rect->top(), style(), m_rootElementStyle, zoomFactor);
    4713             right = convertToLength(rect->right(), style(), m_rootElementStyle, zoomFactor);
    4714             bottom = convertToLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor);
    4715             left = convertToLength(rect->left(), style(), m_rootElementStyle, zoomFactor);
     4726            top = convertToIntLength(rect->top(), style(), m_rootElementStyle, zoomFactor);
     4727            right = convertToIntLength(rect->right(), style(), m_rootElementStyle, zoomFactor);
     4728            bottom = convertToIntLength(rect->bottom(), style(), m_rootElementStyle, zoomFactor);
     4729            left = convertToIntLength(rect->left(), style(), m_rootElementStyle, zoomFactor);
    47164730        } else if (primitiveValue->getIdent() != CSSValueAuto) {
    47174731            return;
     
    56565670        else {
    56575671            bool ok = true;
    5658             Length l = convertToLength(primitiveValue, style(), m_rootElementStyle, 1, &ok);
     5672            Length marqueeLength = convertToIntLength(primitiveValue, style(), m_rootElementStyle, 1, &ok);
    56595673            if (ok)
    5660                 m_style->setMarqueeIncrement(l);
     5674                m_style->setMarqueeIncrement(marqueeLength);
    56615675        }
    56625676        return;
     
    58045818        DashboardRegion *first = region;
    58055819        while (region) {
    5806             Length top = convertToLength(region->top(), style(), m_rootElementStyle);
    5807             Length right = convertToLength(region->right(), style(), m_rootElementStyle);
    5808             Length bottom = convertToLength(region->bottom(), style(), m_rootElementStyle);
    5809             Length left = convertToLength(region->left(), style(), m_rootElementStyle);
     5820            Length top = convertToIntLength(region->top(), style(), m_rootElementStyle);
     5821            Length right = convertToIntLength(region->right(), style(), m_rootElementStyle);
     5822            Length bottom = convertToIntLength(region->bottom(), style(), m_rootElementStyle);
     5823            Length left = convertToIntLength(region->left(), style(), m_rootElementStyle);
    58105824            if (region->m_isCircle)
    58115825                m_style->setDashboardRegion(StyleDashboardRegion::Circle, region->m_label, top, right, bottom, left, region == first ? false : true);
     
    72657279                Length ty = Length(0, Fixed);
    72667280                if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    7267                     ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7281                    ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72687282                else {
    7269                     tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7283                    tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72707284                    if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    72717285                        if (transformValue->length() > 1) {
    72727286                            CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
    7273                             ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok);
     7287                            ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok);
    72747288                        }
    72757289                    }
     
    72897303                Length tz = Length(0, Fixed);
    72907304                if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
    7291                     tz = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7305                    tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72927306                else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    7293                     ty = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7307                    ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72947308                else {
    7295                     tx = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7309                    tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    72967310                    if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    72977311                        if (transformValue->length() > 2) {
    72987312                            CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
    7299                             tz = convertToLength(thirdValue, style, rootStyle, zoomFactor, &ok);
     7313                            tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor, &ok);
    73007314                        }
    73017315                        if (transformValue->length() > 1) {
    73027316                            CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
    7303                             ty = convertToLength(secondValue, style, rootStyle, zoomFactor, &ok);
     7317                            ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor, &ok);
    73047318                        }
    73057319                    }
     
    74327446                Length p = Length(0, Fixed);
    74337447                if (CSSPrimitiveValue::isUnitTypeLength(firstValue->primitiveType()))
    7434                     p = convertToLength(firstValue, style, rootStyle, zoomFactor, &ok);
     7448                    p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor, &ok);
    74357449                else {
    74367450                    // This is a quirk that should go away when 3d transforms are finalized.
  • trunk/Source/WebCore/platform/Length.h

    r79876 r80379  
    4141public:
    4242    Length()
    43         : m_value(0)
     43        :  m_intValue(0), m_quirk(false), m_type(Auto), m_isFloat(false)
    4444    {
    4545    }
    4646
    4747    Length(LengthType t)
    48         : m_value(t)
     48        : m_intValue(0), m_quirk(false), m_type(t), m_isFloat(false)
    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(false)
    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; }
     59        : m_quirk(q), m_type(t), m_isFloat(false)
     60    {
     61        if (m_type == Percent)
     62            m_intValue = static_cast<int>(v*percentScaleFactor);
     63        else {
     64            m_isFloat = true;           
     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); }
    6671
    6772    int value() const {
     
    7075    }
    7176
    72     int rawValue() const { return (m_value & ~0xF) / 16; }
     77    int rawValue() const { return getIntValue(); }
    7378
    7479    double percent() const
     
    7883    }
    7984
    80     LengthType type() const { return static_cast<LengthType>(m_value & 7); }
    81     bool quirk() const { return (m_value >> 3) & 1; }
     85    LengthType type() const { return static_cast<LengthType>(m_type); }
     86    bool quirk() const { return m_quirk; }
    8287
    8388    void setValue(LengthType t, int value)
    8489    {
    85         ASSERT(t != Percent);
    86         setRawValue(t, value);
    87     }
    88 
    89     void setRawValue(LengthType t, int value) { m_value = value * 16 | (m_value & 0x8) | t; }
     90        m_type = t;
     91        m_intValue = value;
     92        m_isFloat = false;
     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        setValue(Fixed, value);
     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        m_type = t;
     104        m_floatValue = value;
     105        m_isFloat = true;   
    103106    }
    104107
    105108    void setValue(double value)
    106109    {
    107         ASSERT(type() == Percent);
    108         m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0xF);
     110        *this = Length(value, Fixed);
    109111    }
    110112
     
    145147        switch (type()) {
    146148            case Fixed:
    147                 return static_cast<float>(value());
     149                return getFloatValue();
    148150            case Percent:
    149151                return static_cast<float>(maxValue * percent() / 100.0);
     
    156158
    157159    bool isUndefined() const { return rawValue() == undefinedLength; }
    158     bool isZero() const { return !(m_value & ~0xF); }
     160    bool isZero() const { return !getIntValue(); }
    159161    bool isPositive() const { return rawValue() > 0; }
    160162    bool isNegative() const { return rawValue() < 0; }
     
    185187        }
    186188           
    187         int fromValue = from.isZero() ? 0 : from.value();
    188         int toValue = isZero() ? 0 : value();
    189         return Length(int(fromValue + (toValue - fromValue) * progress), resultType);
     189        double fromValue = from.isZero() ? 0 : from.value();
     190        double toValue = isZero() ? 0 : value();
     191        return Length(fromValue + (toValue - fromValue) * progress, resultType);
    190192    }
    191193
    192194private:
    193     int m_value;
     195    int getIntValue() const
     196    {
     197        if (m_isFloat)
     198            return static_cast<int>(m_floatValue);
     199        return m_intValue;
     200    }
     201
     202    float getFloatValue() const
     203    {
     204        if (m_isFloat)
     205                return m_floatValue;
     206        return m_intValue;
     207    }
     208
     209    union {
     210        int m_intValue;
     211        float m_floatValue;
     212    };
     213    bool m_quirk;
     214    unsigned char m_type;
     215    bool m_isFloat;
    194216};
    195217
  • trunk/Source/WebCore/rendering/AutoTableLayout.cpp

    r79876 r80379  
    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

    r79876 r80379  
    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.