Changeset 176301 in webkit


Ignore:
Timestamp:
Nov 18, 2014 6:05:34 PM (9 years ago)
Author:
Chris Dumez
Message:

Crash when setting 'z-index' / 'flex-shrink' CSS properties to a calculated value
https://bugs.webkit.org/show_bug.cgi?id=138783

Reviewed by Andreas Kling.

Source/WebCore:

Update operators converting CSSPrimitiveValue to integer / floating
point types to properly handle calculated values (e.g. 'calc(2 * 3)').
Previously, this was not working in release builds and we would hit an
ASSERT_NOT_REACHED() in debug builds.

Tests: fast/css/flex-shrink-calculated-value.html

fast/css/z-index-calculated-value.html

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::operator unsigned short):
(WebCore::CSSPrimitiveValue::operator int):
(WebCore::CSSPrimitiveValue::operator unsigned):
(WebCore::CSSPrimitiveValue::operator float):

LayoutTests:

Add layout tests to check that settings 'z-index' / 'flex-shrink' CSS
properties to a calculated value does not crash and behaves as
expected.

  • fast/css/flex-shrink-calculated-value-expected.txt: Added.
  • fast/css/flex-shrink-calculated-value.html: Added.
  • fast/css/z-index-calculated-value-expected.txt: Added.
  • fast/css/z-index-calculated-value.html: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r176298 r176301  
     12014-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash when setting 'z-index' / 'flex-shrink' CSS properties to a calculated value
     4        https://bugs.webkit.org/show_bug.cgi?id=138783
     5
     6        Reviewed by Andreas Kling.
     7
     8        Add layout tests to check that settings 'z-index' / 'flex-shrink' CSS
     9        properties to a calculated value does not crash and behaves as
     10        expected.
     11
     12        * fast/css/flex-shrink-calculated-value-expected.txt: Added.
     13        * fast/css/flex-shrink-calculated-value.html: Added.
     14        * fast/css/z-index-calculated-value-expected.txt: Added.
     15        * fast/css/z-index-calculated-value.html: Added.
     16
    1172014-11-18  Commit Queue  <commit-queue@webkit.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r176298 r176301  
     12014-11-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash when setting 'z-index' / 'flex-shrink' CSS properties to a calculated value
     4        https://bugs.webkit.org/show_bug.cgi?id=138783
     5
     6        Reviewed by Andreas Kling.
     7
     8        Update operators converting CSSPrimitiveValue to integer / floating
     9        point types to properly handle calculated values (e.g. 'calc(2 * 3)').
     10        Previously, this was not working in release builds and we would hit an
     11        ASSERT_NOT_REACHED() in debug builds.
     12
     13        Tests: fast/css/flex-shrink-calculated-value.html
     14               fast/css/z-index-calculated-value.html
     15
     16        * css/CSSPrimitiveValueMappings.h:
     17        (WebCore::CSSPrimitiveValue::operator unsigned short):
     18        (WebCore::CSSPrimitiveValue::operator int):
     19        (WebCore::CSSPrimitiveValue::operator unsigned):
     20        (WebCore::CSSPrimitiveValue::operator float):
     21
    1222014-11-18  Commit Queue  <commit-queue@webkit.org>
    223
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r176258 r176301  
    8383template<> inline CSSPrimitiveValue::operator unsigned short() const
    8484{
    85     if (m_primitiveUnitType == CSS_NUMBER)
    86         return clampTo<unsigned short>(m_value.num);
     85    if (primitiveType() == CSS_NUMBER)
     86        return getValue<unsigned short>();
    8787
    8888    ASSERT_NOT_REACHED();
     
    9292template<> inline CSSPrimitiveValue::operator int() const
    9393{
    94     if (m_primitiveUnitType == CSS_NUMBER)
    95         return clampTo<int>(m_value.num);
     94    if (primitiveType() == CSS_NUMBER)
     95        return getValue<int>();
    9696
    9797    ASSERT_NOT_REACHED();
     
    101101template<> inline CSSPrimitiveValue::operator unsigned() const
    102102{
    103     if (m_primitiveUnitType == CSS_NUMBER)
    104         return clampTo<unsigned>(m_value.num);
     103    if (primitiveType() == CSS_NUMBER)
     104        return getValue<unsigned>();
    105105
    106106    ASSERT_NOT_REACHED();
     
    118118template<> inline CSSPrimitiveValue::operator float() const
    119119{
    120     if (m_primitiveUnitType == CSS_NUMBER)
    121         return clampTo<float>(m_value.num);
     120    if (primitiveType() == CSS_NUMBER)
     121        return getValue<float>();
    122122
    123123    ASSERT_NOT_REACHED();
Note: See TracChangeset for help on using the changeset viewer.