--- /dev/null
+<!DOCTYPE html>
+<pre id="console">
+</pre>
+<script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ function log(message)
+ {
+ document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
+ }
+
+ function testQuery(query, expected)
+ {
+ var actual = window.styleMedia.matchMedium(query);
+ var message = (actual === expected) ? 'PASS' : 'FAIL';
+ message += ": \"" + query + "\" evaluates to " + (actual ? "true" : "false") + ".";
+ log(message);
+ }
+
+ testQuery('(min-device-width: 0)', true);
+ testQuery('(min-device-width: 1px)', true);
+ testQuery('(min-device-width: 1deg)', false);
+ testQuery('(min-device-width: 1)', false);
+ testQuery('(min-device-width: solid)', false);
+ testQuery('(min-device-width: "red")', false);
+</script>
+2011-10-02 Dan Bernstein <mitz@apple.com>
+
+ 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.
+
+ 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.
+
2011-10-02 Dirk Schulze <krit@webkit.org>
SVG Mask should take 'color-interpolation' into account to determine the color space of the mask image
return false;
}
+static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, RenderStyle* rootStyle, int& result)
+{
+ if (!value->isPrimitiveValue())
+ return false;
+
+ CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+
+ if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
+ result = primitiveValue->getIntValue();
+ return !strict || !result;
+ }
+
+ if (primitiveValue->isLength()) {
+ result = primitiveValue->computeLength<int>(style, rootStyle);
+ return true;
+ }
+
+ return false;
+}
+
static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
- return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.height()), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
+ int length;
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(sg.height()), length, op);
}
// ({,min-,max-}device-height)
// assume if we have a device, assume non-zero
if (value) {
FloatRect sg = screenRect(frame->page()->mainFrame()->view());
RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
- return value->isPrimitiveValue() && compareValue(static_cast<int>(sg.width()), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
+ int length;
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(sg.width()), length, op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
FrameView* view = frame->view();
- RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
- if (value)
- return value->isPrimitiveValue() && compareValue(view->layoutHeight(), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
+ if (value) {
+ RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
+ int length;
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutHeight(), length, op);
+ }
return view->layoutHeight() != 0;
}
static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
{
FrameView* view = frame->view();
- RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
- if (value)
- return value->isPrimitiveValue() && compareValue(view->layoutWidth(), static_cast<CSSPrimitiveValue*>(value)->computeLength<int>(style, rootStyle), op);
+ if (value) {
+ RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
+ int length;
+ return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(view->layoutWidth(), length, op);
+ }
return view->layoutWidth() != 0;
}