Changeset 105403 in webkit


Ignore:
Timestamp:
Jan 19, 2012 4:59:52 AM (12 years ago)
Author:
alexis.menard@openbossa.org
Message:

Strange Result for getComputedStyle on borderWidth set in em
https://bugs.webkit.org/show_bug.cgi?id=18294

Reviewed by Tony Chang.

Source/WebCore:

BorderValue stores its width on a 12 bits unsigned. This patch
increase it to 27. The patch also modify the way to set the
width or to get it, we now use a unsigned rather than a short.

Test: fast/css/border-width-large.html

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::computeLength):

  • css/CSSStyleApplyProperty.cpp:

(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):

  • page/animation/AnimationBase.cpp:

(WebCore::blendFunc):
(WebCore::AnimationBase::ensurePropertyMap):

  • platform/animation/AnimationUtilities.h:

(WebCore::blend):

  • rendering/RenderTheme.cpp:

(WebCore::RenderTheme::adjustStyle):

  • rendering/style/BorderData.h:

(WebCore::BorderData::borderLeftWidth):
(WebCore::BorderData::borderRightWidth):
(WebCore::BorderData::borderTopWidth):
(WebCore::BorderData::borderBottomWidth):

  • rendering/style/BorderValue.h:

(WebCore::BorderValue::width):

  • rendering/style/RenderStyle.cpp:
  • rendering/style/RenderStyle.h:

(WebCore::RenderStyleBitfields::borderLeftWidth):
(WebCore::RenderStyleBitfields::borderRightWidth):
(WebCore::RenderStyleBitfields::borderTopWidth):
(WebCore::RenderStyleBitfields::borderBottomWidth):
(WebCore::RenderStyleBitfields::setBorderLeftWidth):
(WebCore::RenderStyleBitfields::setBorderRightWidth):
(WebCore::RenderStyleBitfields::setBorderTopWidth):
(WebCore::RenderStyleBitfields::setBorderBottomWidth):
(WebCore::RenderStyleBitfields::initialBorderWidth):
(WebCore::RenderStyleBitfields::initialColumnRuleWidth):
(WebCore::RenderStyleBitfields::initialOutlineWidth):

LayoutTests:

This test covers that setting big values to border-width will
return correct values.

  • fast/css/border-width-large-expected.txt: Added.
  • fast/css/border-width-large.html: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r105402 r105403  
     12012-01-19  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Strange Result for getComputedStyle on borderWidth set in em
     4        https://bugs.webkit.org/show_bug.cgi?id=18294
     5
     6        Reviewed by Tony Chang.
     7
     8        This test covers that setting big values to border-width will
     9        return correct values.
     10
     11        * fast/css/border-width-large-expected.txt: Added.
     12        * fast/css/border-width-large.html: Added.
     13
    1142012-01-18  Nikolas Zimmermann  <nzimmermann@rim.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r105402 r105403  
     12012-01-19  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Strange Result for getComputedStyle on borderWidth set in em
     4        https://bugs.webkit.org/show_bug.cgi?id=18294
     5
     6        Reviewed by Tony Chang.
     7
     8        BorderValue stores its width on a 12 bits unsigned. This patch
     9        increase it to 27. The patch also modify the way to set the
     10        width or to get it, we now use a unsigned rather than a short.
     11
     12        Test: fast/css/border-width-large.html
     13
     14        * css/CSSPrimitiveValue.cpp:
     15        (WebCore::CSSPrimitiveValue::computeLength):
     16        * css/CSSStyleApplyProperty.cpp:
     17        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
     18        * page/animation/AnimationBase.cpp:
     19        (WebCore::blendFunc):
     20        (WebCore::AnimationBase::ensurePropertyMap):
     21        * platform/animation/AnimationUtilities.h:
     22        (WebCore::blend):
     23        * rendering/RenderTheme.cpp:
     24        (WebCore::RenderTheme::adjustStyle):
     25        * rendering/style/BorderData.h:
     26        (WebCore::BorderData::borderLeftWidth):
     27        (WebCore::BorderData::borderRightWidth):
     28        (WebCore::BorderData::borderTopWidth):
     29        (WebCore::BorderData::borderBottomWidth):
     30        * rendering/style/BorderValue.h:
     31        (WebCore::BorderValue::width):
     32        * rendering/style/RenderStyle.cpp:
     33        * rendering/style/RenderStyle.h:
     34        (WebCore::RenderStyleBitfields::borderLeftWidth):
     35        (WebCore::RenderStyleBitfields::borderRightWidth):
     36        (WebCore::RenderStyleBitfields::borderTopWidth):
     37        (WebCore::RenderStyleBitfields::borderBottomWidth):
     38        (WebCore::RenderStyleBitfields::setBorderLeftWidth):
     39        (WebCore::RenderStyleBitfields::setBorderRightWidth):
     40        (WebCore::RenderStyleBitfields::setBorderTopWidth):
     41        (WebCore::RenderStyleBitfields::setBorderBottomWidth):
     42        (WebCore::RenderStyleBitfields::initialBorderWidth):
     43        (WebCore::RenderStyleBitfields::initialColumnRuleWidth):
     44        (WebCore::RenderStyleBitfields::initialOutlineWidth):
     45
    1462012-01-18  Nikolas Zimmermann  <nzimmermann@rim.com>
    247
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r105135 r105403  
    361361}
    362362
     363template<> unsigned CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
     364{
     365    return roundForImpreciseConversion<unsigned, UINT_MAX, 0>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
     366}
     367
    363368template<> Length CSSPrimitiveValue::computeLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
    364369{
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r105049 r105403  
    16991699    setPropertyHandler(CSSPropertyBorderLeftStyle, ApplyPropertyDefault<EBorderStyle, &RenderStyle::borderLeftStyle, EBorderStyle, &RenderStyle::setBorderLeftStyle, EBorderStyle, &RenderStyle::initialBorderStyle>::createHandler());
    17001700
    1701     setPropertyHandler(CSSPropertyBorderTopWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
    1702     setPropertyHandler(CSSPropertyBorderRightWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
    1703     setPropertyHandler(CSSPropertyBorderBottomWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
    1704     setPropertyHandler(CSSPropertyBorderLeftWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
    1705     setPropertyHandler(CSSPropertyOutlineWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
    1706     setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     1701    setPropertyHandler(CSSPropertyBorderTopWidth, ApplyPropertyComputeLength<unsigned, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     1702    setPropertyHandler(CSSPropertyBorderRightWidth, ApplyPropertyComputeLength<unsigned, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     1703    setPropertyHandler(CSSPropertyBorderBottomWidth, ApplyPropertyComputeLength<unsigned, &RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     1704    setPropertyHandler(CSSPropertyBorderLeftWidth, ApplyPropertyComputeLength<unsigned, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     1705    setPropertyHandler(CSSPropertyOutlineWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialOutlineWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     1706    setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialColumnRuleWidth, NormalDisabled, ThicknessEnabled>::createHandler());
    17071707
    17081708    setPropertyHandler(CSSPropertyBorderTop, ApplyPropertyExpanding<SuppressValue, CSSPropertyBorderTopColor, CSSPropertyBorderTopStyle, CSSPropertyBorderTopWidth>::createHandler());
  • trunk/Source/WebCore/page/animation/AnimationBase.cpp

    r104047 r105403  
    8585}
    8686
     87static inline unsigned blendFunc(const AnimationBase*, unsigned from, unsigned to, double progress)
     88{
     89    return blend(from, to, progress);
     90}
     91
    8792static inline double blendFunc(const AnimationBase*, double from, double to, double progress)
    8893
     
    951956        gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMaxHeight, &RenderStyle::maxHeight, &RenderStyle::setMaxHeight));
    952957
    953         gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderLeftWidth, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth));
    954         gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderRightWidth, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth));
    955         gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderTopWidth, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth));
    956         gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyBorderBottomWidth, &RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth));
     958        gPropertyWrappers->append(new PropertyWrapper<unsigned>(CSSPropertyBorderLeftWidth, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth));
     959        gPropertyWrappers->append(new PropertyWrapper<unsigned>(CSSPropertyBorderRightWidth, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth));
     960        gPropertyWrappers->append(new PropertyWrapper<unsigned>(CSSPropertyBorderTopWidth, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth));
     961        gPropertyWrappers->append(new PropertyWrapper<unsigned>(CSSPropertyBorderBottomWidth, &RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth));
    957962        gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMarginLeft, &RenderStyle::marginLeft, &RenderStyle::setMarginLeft));
    958963        gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyMarginRight, &RenderStyle::marginRight, &RenderStyle::setMarginRight));
  • trunk/Source/WebCore/platform/animation/AnimationUtilities.h

    r102745 r105403  
    3636}
    3737
     38inline unsigned blend(unsigned from, unsigned to, double progress)
     39{
     40    return static_cast<unsigned>(lround(static_cast<double>(from) + static_cast<double>(to - from) * progress));
     41}
     42
    3843inline double blend(double from, double to, double progress)
    3944
  • trunk/Source/WebCore/rendering/RenderTheme.cpp

    r102655 r105403  
    112112            LengthBox borderBox(style->borderTopWidth(), style->borderRightWidth(), style->borderBottomWidth(), style->borderLeftWidth());
    113113            borderBox = m_theme->controlBorder(part, style->font(), borderBox, style->effectiveZoom());
    114             if (borderBox.top().value() != style->borderTopWidth()) {
     114            if (borderBox.top().value() != static_cast<int>(style->borderTopWidth())) {
    115115                if (borderBox.top().value())
    116116                    style->setBorderTopWidth(borderBox.top().value());
     
    118118                    style->resetBorderTop();
    119119            }
    120             if (borderBox.right().value() != style->borderRightWidth()) {
     120            if (borderBox.right().value() != static_cast<int>(style->borderRightWidth())) {
    121121                if (borderBox.right().value())
    122122                    style->setBorderRightWidth(borderBox.right().value());
     
    124124                    style->resetBorderRight();
    125125            }
    126             if (borderBox.bottom().value() != style->borderBottomWidth()) {
     126            if (borderBox.bottom().value() != static_cast<int>(style->borderBottomWidth())) {
    127127                style->setBorderBottomWidth(borderBox.bottom().value());
    128128                if (borderBox.bottom().value())
     
    131131                    style->resetBorderBottom();
    132132            }
    133             if (borderBox.left().value() != style->borderLeftWidth()) {
     133            if (borderBox.left().value() != static_cast<int>(style->borderLeftWidth())) {
    134134                style->setBorderLeftWidth(borderBox.left().value());
    135135                if (borderBox.left().value())
  • trunk/Source/WebCore/rendering/style/BorderData.h

    r81625 r105403  
    6161    }
    6262   
    63     unsigned short borderLeftWidth() const
     63    unsigned borderLeftWidth() const
    6464    {
    6565        if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() == BHIDDEN))
     
    6868    }
    6969   
    70     unsigned short borderRightWidth() const
     70    unsigned borderRightWidth() const
    7171    {
    7272        if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style() == BHIDDEN))
     
    7575    }
    7676   
    77     unsigned short borderTopWidth() const
     77    unsigned borderTopWidth() const
    7878    {
    7979        if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == BHIDDEN))
     
    8282    }
    8383   
    84     unsigned short borderBottomWidth() const
     84    unsigned borderBottomWidth() const
    8585    {
    8686        if (!m_image.hasImage() && (m_bottom.style() == BNONE || m_bottom.style() == BHIDDEN))
  • trunk/Source/WebCore/rendering/style/BorderValue.h

    r97046 r105403  
    6767   
    6868    const Color& color() const { return m_color; }
    69     unsigned short width() const { return m_width; }
     69    unsigned width() const { return m_width; }
    7070    EBorderStyle style() const { return static_cast<EBorderStyle>(m_style); }
    7171
    7272protected:
    7373    Color m_color;
    74     unsigned m_width : 12;
     74    unsigned m_width : 27;
    7575    unsigned m_style : 4; // EBorderStyle
    7676
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r103656 r105403  
    4444
    4545namespace WebCore {
     46
     47struct SameSizeAsBorderValue {
     48    Color m_color;
     49    unsigned m_width;
     50};
     51
     52COMPILE_ASSERT(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), BorderValue_should_not_grow);
    4653
    4754struct SameSizeAsRenderStyle : public RefCounted<SameSizeAsRenderStyle> {
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r105015 r105403  
    546546    bool hasBorderRadius() const { return surround->border.hasBorderRadius(); }
    547547
    548     unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
     548    unsigned borderLeftWidth() const { return surround->border.borderLeftWidth(); }
    549549    EBorderStyle borderLeftStyle() const { return surround->border.left().style(); }
    550550    bool borderLeftIsTransparent() const { return surround->border.left().isTransparent(); }
    551     unsigned short borderRightWidth() const { return surround->border.borderRightWidth(); }
     551    unsigned borderRightWidth() const { return surround->border.borderRightWidth(); }
    552552    EBorderStyle borderRightStyle() const { return surround->border.right().style(); }
    553553    bool borderRightIsTransparent() const { return surround->border.right().isTransparent(); }
    554     unsigned short borderTopWidth() const { return surround->border.borderTopWidth(); }
     554    unsigned borderTopWidth() const { return surround->border.borderTopWidth(); }
    555555    EBorderStyle borderTopStyle() const { return surround->border.top().style(); }
    556556    bool borderTopIsTransparent() const { return surround->border.top().isTransparent(); }
    557     unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); }
     557    unsigned borderBottomWidth() const { return surround->border.borderBottomWidth(); }
    558558    EBorderStyle borderBottomStyle() const { return surround->border.bottom().style(); }
    559559    bool borderBottomIsTransparent() const { return surround->border.bottom().isTransparent(); }
     
    10441044        LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
    10451045
    1046     void setBorderLeftWidth(unsigned short v) { SET_VAR(surround, border.m_left.m_width, v) }
     1046    void setBorderLeftWidth(unsigned v) { SET_VAR(surround, border.m_left.m_width, v) }
    10471047    void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.m_left.m_style, v) }
    10481048    void setBorderLeftColor(const Color& v) { SET_VAR(surround, border.m_left.m_color, v) }
    1049     void setBorderRightWidth(unsigned short v) { SET_VAR(surround, border.m_right.m_width, v) }
     1049    void setBorderRightWidth(unsigned v) { SET_VAR(surround, border.m_right.m_width, v) }
    10501050    void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround, border.m_right.m_style, v) }
    10511051    void setBorderRightColor(const Color& v) { SET_VAR(surround, border.m_right.m_color, v) }
    1052     void setBorderTopWidth(unsigned short v) { SET_VAR(surround, border.m_top.m_width, v) }
     1052    void setBorderTopWidth(unsigned v) { SET_VAR(surround, border.m_top.m_width, v) }
    10531053    void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround, border.m_top.m_style, v) }
    10541054    void setBorderTopColor(const Color& v) { SET_VAR(surround, border.m_top.m_color, v) }
    1055     void setBorderBottomWidth(unsigned short v) { SET_VAR(surround, border.m_bottom.m_width, v) }
     1055    void setBorderBottomWidth(unsigned v) { SET_VAR(surround, border.m_bottom.m_width, v) }
    10561056    void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround, border.m_bottom.m_style, v) }
    10571057    void setBorderBottomColor(const Color& v) { SET_VAR(surround, border.m_bottom.m_color, v) }
     
    15141514    static Color initialColor() { return Color::black; }
    15151515    static StyleImage* initialListStyleImage() { return 0; }
    1516     static unsigned short initialBorderWidth() { return 3; }
     1516    static unsigned initialBorderWidth() { return 3; }
     1517    static unsigned short initialColumnRuleWidth() { return 3; }
     1518    static unsigned short initialOutlineWidth() { return 3; }
    15171519    static int initialLetterWordSpacing() { return 0; }
    15181520    static Length initialSize() { return Length(); }
Note: See TracChangeset for help on using the changeset viewer.