MediaQueryExp::MediaQueryExp(const DOMString &mediaFeature, ValueList *valueList) : m_mediaFeature(mediaFeature) , m_value(0) { m_viewportDependent = (m_mediaFeature == "width" || m_mediaFeature == "height" || m_mediaFeature == "min-width" || m_mediaFeature == "min-height" || m_mediaFeature == "max-width" || m_mediaFeature == "max-height" || m_mediaFeature == "orientation" || m_mediaFeature == "aspect-ratio" || m_mediaFeature == "min-aspect-ratio" || m_mediaFeature == "max-aspect-ratio"); if (valueList) { if (valueList->size() == 1) { Value *value = valueList->current(); if (value->id != 0) { m_value = new CSSPrimitiveValueImpl(value->id); } else if (value->unit == CSSPrimitiveValue::CSS_STRING) { m_value = new CSSPrimitiveValueImpl(domString(value->string), (CSSPrimitiveValue::UnitTypes) value->unit); } else if ((value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ) || value->unit == CSSPrimitiveValue::CSS_DPI || value->unit == CSSPrimitiveValue::CSS_DPCM) { m_value = new CSSPrimitiveValueImpl(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit); } if (m_value) { m_value->ref(); } valueList->next(); } else if (valueList->size() > 1) { // create list of values // currently accepts only <integer>/<integer> CSSValueListImpl *list = new CSSValueListImpl(); Value *value = 0; bool isValid = true; while ((value = valueList->current()) && isValid) { if (value->unit == Value::Operator && value->iValue == '/') { list->append(new CSSPrimitiveValueImpl(DOMString("/"), CSSPrimitiveValue::CSS_STRING)); } else if (value->unit == CSSPrimitiveValue::CSS_NUMBER) { list->append(new CSSPrimitiveValueImpl(value->fValue, CSSPrimitiveValue::CSS_NUMBER)); } else { isValid = false; } value = valueList->next(); } if (isValid) { m_value = list; m_value->ref(); } else { delete list; } } } }
static CSSValueImpl* valueForShadow(const ShadowData *shadow) { if (!shadow) return new CSSPrimitiveValueImpl(CSS_VAL_NONE); CSSValueListImpl *list = new CSSValueListImpl; for (const ShadowData *s = shadow; s; s = s->next) { CSSPrimitiveValueImpl *x = new CSSPrimitiveValueImpl(s->x, CSSPrimitiveValue::CSS_PX); CSSPrimitiveValueImpl *y = new CSSPrimitiveValueImpl(s->y, CSSPrimitiveValue::CSS_PX); CSSPrimitiveValueImpl *blur = new CSSPrimitiveValueImpl(s->blur, CSSPrimitiveValue::CSS_PX); CSSPrimitiveValueImpl *color = new CSSPrimitiveValueImpl(s->color.rgb()); list->append(new ShadowValueImpl(x, y, blur, color)); } return list; }