Changeset 96471 in webkit


Ignore:
Timestamp:
Oct 2, 2011, 1:25:34 AM (14 years ago)
Author:
mitz@apple.com
Message:

REGRESSION (r95502): Assertion failure in CSSPrimitiveValue::computeLengthDouble() when media query specifies unit-less length
https://bugs.webkit.org/show_bug.cgi?id=68760

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/media/invalid-lengths.html

Made length-comparison media queries accept only length values. In compatibility mode, numbers
are allowed as well, and they are interpreted as pixels.

  • css/MediaQueryEvaluator.cpp:

(WebCore::computeLength): Added this helper function.
(WebCore::device_heightMediaFeatureEval): Changed to use computeLength().
(WebCore::device_widthMediaFeatureEval): Ditto.
(WebCore::heightMediaFeatureEval): Ditto.
(WebCore::widthMediaFeatureEval): Ditto.

LayoutTests:

  • fast/media/invalid-lengths-expected.txt: Added.
  • fast/media/invalid-lengths.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96470 r96471  
     12011-10-02  Dan Bernstein  <mitz@apple.com>
     2
     3        REGRESSION (r95502): Assertion failure in CSSPrimitiveValue::computeLengthDouble() when media query specifies unit-less length
     4        https://bugs.webkit.org/show_bug.cgi?id=68760
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/media/invalid-lengths-expected.txt: Added.
     9        * fast/media/invalid-lengths.html: Added.
     10
    1112011-10-02  Dirk Schulze  <krit@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r96470 r96471  
     12011-10-02  Dan Bernstein  <mitz@apple.com>
     2
     3        REGRESSION (r95502): Assertion failure in CSSPrimitiveValue::computeLengthDouble() when media query specifies unit-less length
     4        https://bugs.webkit.org/show_bug.cgi?id=68760
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Test: fast/media/invalid-lengths.html
     9
     10        Made length-comparison media queries accept only length values. In compatibility mode, numbers
     11        are allowed as well, and they are interpreted as pixels.
     12
     13        * css/MediaQueryEvaluator.cpp:
     14        (WebCore::computeLength): Added this helper function.
     15        (WebCore::device_heightMediaFeatureEval): Changed to use computeLength().
     16        (WebCore::device_widthMediaFeatureEval): Ditto.
     17        (WebCore::heightMediaFeatureEval): Ditto.
     18        (WebCore::widthMediaFeatureEval): Ditto.
     19
    1202011-10-02  Dirk Schulze  <krit@webkit.org>
    221
  • trunk/Source/WebCore/css/MediaQueryEvaluator.cpp

    r93303 r96471  
    307307}
    308308
     309static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, RenderStyle* rootStyle, int& result)
     310{
     311    if (!value->isPrimitiveValue())
     312        return false;
     313
     314    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     315
     316    if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
     317        result = primitiveValue->getIntValue();
     318        return !strict || !result;
     319    }
     320
     321    if (primitiveValue->isLength()) {
     322        result = primitiveValue->computeLength<int>(style, rootStyle);
     323        return true;
     324    }
     325
     326    return false;
     327}
     328
    309329static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
    310330{
     
    312332        FloatRect sg = screenRect(frame->page()->mainFrame()->view());
    313333        RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    314         return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
     334        int length;
     335        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(sg.height()), length, op);
    315336    }
    316337    // ({,min-,max-}device-height)
     
    324345        FloatRect sg = screenRect(frame->page()->mainFrame()->view());
    325346        RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    326         return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
     347        int length;
     348        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(sg.width()), length, op);
    327349    }
    328350    // ({,min-,max-}device-width)
     
    334356{
    335357    FrameView* view = frame->view();
    336     RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    337 
    338     if (value)
    339         return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
     358
     359    if (value) {
     360        RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
     361        int length;
     362        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutHeight(), length, op);
     363    }
    340364
    341365    return view->layoutHeight() != 0;
     
    345369{
    346370    FrameView* view = frame->view();
    347     RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    348 
    349     if (value)
    350         return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
     371
     372    if (value) {
     373        RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
     374        int length;
     375        return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutWidth(), length, op);
     376    }
    351377
    352378    return view->layoutWidth() != 0;
Note: See TracChangeset for help on using the changeset viewer.