#ifndef MediaQueryExp_h
#define MediaQueryExp_h
+#include "core/CSSValueKeywords.h"
+#include "core/MediaFeatureNames.h"
+#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValue.h"
-#include "core/css/MediaFeatureNames.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefPtr.h"
-#include "wtf/text/AtomicString.h"
-namespace WebCore {
+namespace blink {
class CSSParserValueList;
-class MediaQueryExp {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- static PassOwnPtr<MediaQueryExp> create(const AtomicString& mediaFeature, CSSParserValueList*);
- ~MediaQueryExp();
+struct MediaQueryExpValue {
+ CSSValueID id;
+ double value;
+ CSSPrimitiveValue::UnitType unit;
+ unsigned numerator;
+ unsigned denominator;
- AtomicString mediaFeature() const { return m_mediaFeature; }
+ bool isID;
+ bool isValue;
+ bool isRatio;
- CSSValue* value() const { return m_value.get(); }
+ MediaQueryExpValue()
+ : id(CSSValueInvalid)
+ , value(0)
+ , unit(CSSPrimitiveValue::CSS_UNKNOWN)
+ , numerator(0)
+ , denominator(1)
+ , isID(false)
+ , isValue(false)
+ , isRatio(false)
+ {
+ }
- bool operator==(const MediaQueryExp& other) const
+ bool isValid() const { return (isID || isValue || isRatio); }
+ String cssText() const;
+ bool equals(const MediaQueryExpValue& expValue) const
{
- return (other.m_mediaFeature == m_mediaFeature)
- && ((!other.m_value && !m_value)
- || (other.m_value && m_value && other.m_value->equals(*m_value)));
+ if (isID)
+ return (id == expValue.id);
+ if (isValue)
+ return (value == expValue.value);
+ if (isRatio)
+ return (numerator == expValue.numerator && denominator == expValue.denominator);
+ return !expValue.isValid();
}
+};
+
+class MediaQueryExp : public NoBaseWillBeGarbageCollectedFinalized<MediaQueryExp> {
+ WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
+public:
+ static PassOwnPtrWillBeRawPtr<MediaQueryExp> createIfValid(const String& mediaFeature, CSSParserValueList*);
+ ~MediaQueryExp();
+
+ const String& mediaFeature() const { return m_mediaFeature; }
+
+ MediaQueryExpValue expValue() const { return m_expValue; }
+
+ bool operator==(const MediaQueryExp& other) const;
bool isViewportDependent() const;
String serialize() const;
- PassOwnPtr<MediaQueryExp> copy() const { return adoptPtr(new MediaQueryExp(*this)); }
+ PassOwnPtrWillBeRawPtr<MediaQueryExp> copy() const { return adoptPtrWillBeNoop(new MediaQueryExp(*this)); }
+
+ MediaQueryExp(const MediaQueryExp& other);
+
+ void trace(Visitor* visitor) { }
private:
- MediaQueryExp(const AtomicString& mediaFeature, PassRefPtr<CSSValue>);
+ MediaQueryExp(const String&, const MediaQueryExpValue&);
- AtomicString m_mediaFeature;
- RefPtr<CSSValue> m_value;
+ String m_mediaFeature;
+ MediaQueryExpValue m_expValue;
};
} // namespace