Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * CSS Media Query | 2 * CSS Media Query |
| 3 * | 3 * |
| 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. | 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. |
| 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #ifndef MediaQueryExp_h | 29 #ifndef MediaQueryExp_h |
| 30 #define MediaQueryExp_h | 30 #define MediaQueryExp_h |
| 31 | 31 |
| 32 #include "CSSValueKeywords.h" | |
| 32 #include "MediaFeatureNames.h" | 33 #include "MediaFeatureNames.h" |
| 34 #include "core/css/CSSPrimitiveValue.h" | |
| 33 #include "core/css/CSSValue.h" | 35 #include "core/css/CSSValue.h" |
| 34 #include "wtf/PassOwnPtr.h" | 36 #include "wtf/PassOwnPtr.h" |
| 35 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
| 36 | 38 |
| 37 namespace WebCore { | 39 namespace WebCore { |
| 38 class CSSParserValueList; | 40 class CSSParserValueList; |
| 39 | 41 |
| 40 class MediaQueryExp : public NoBaseWillBeGarbageCollectedFinalized<MediaQueryExp > { | 42 struct MediaQueryExpValue { |
| 43 CSSValueID id; | |
| 44 double value; | |
| 45 CSSPrimitiveValue::UnitTypes unit; | |
| 46 unsigned numerator; | |
| 47 unsigned denominator; | |
| 48 | |
| 49 bool isID; | |
| 50 bool isValue; | |
| 51 bool isRatio; | |
| 52 bool isInteger; | |
| 53 | |
| 54 MediaQueryExpValue() | |
| 55 : id(CSSValueInvalid) | |
| 56 , value(0) | |
| 57 , unit(CSSPrimitiveValue::CSS_UNKNOWN) | |
| 58 , numerator(0) | |
| 59 , denominator(1) | |
| 60 , isID(false) | |
| 61 , isValue(false) | |
| 62 , isRatio(false) | |
| 63 , isInteger(false) | |
| 64 { | |
| 65 } | |
| 66 | |
| 67 bool isInit() const { return (isID || isValue || isRatio); } | |
|
eseidel
2014/04/24 00:23:59
isValid?
| |
| 68 String cssText() const; | |
| 69 bool equals(const MediaQueryExpValue& expValue) const | |
| 70 { | |
| 71 if (isID) | |
| 72 return (id == expValue.id); | |
| 73 if (isValue) | |
| 74 return (value == expValue.value); | |
| 75 if (isRatio) | |
| 76 return (numerator == expValue.numerator && denominator == expValue.d enominator); | |
| 77 return !expValue.isInit(); | |
| 78 } | |
| 79 }; | |
| 80 | |
| 81 class MediaQueryExp : public NoBaseWillBeGarbageCollectedFinalized<MediaQueryEx p> { | |
| 41 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 82 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 42 public: | 83 public: |
| 43 static PassOwnPtrWillBeRawPtr<MediaQueryExp> createIfValid(const String& med iaFeature, CSSParserValueList*); | 84 static PassOwnPtrWillBeRawPtr<MediaQueryExp> createIfValid(const String& med iaFeature, CSSParserValueList*); |
| 44 ~MediaQueryExp(); | 85 ~MediaQueryExp(); |
| 45 | 86 |
| 46 const String& mediaFeature() const { return m_mediaFeature; } | 87 const String& mediaFeature() const { return m_mediaFeature; } |
| 47 | 88 |
| 48 CSSValue* value() const { return m_value.get(); } | 89 MediaQueryExpValue expValue() const { return m_expValue; } |
| 49 | 90 |
| 50 bool operator==(const MediaQueryExp& other) const | 91 bool operator==(const MediaQueryExp& other) const; |
| 51 { | |
| 52 return (other.m_mediaFeature == m_mediaFeature) | |
| 53 && ((!other.m_value && !m_value) | |
| 54 || (other.m_value && m_value && other.m_value->equals(*m_value)) ); | |
| 55 } | |
| 56 | 92 |
| 57 bool isViewportDependent() const; | 93 bool isViewportDependent() const; |
| 58 | 94 |
| 59 String serialize() const; | 95 String serialize() const; |
| 60 | 96 |
| 61 PassOwnPtrWillBeRawPtr<MediaQueryExp> copy() const { return adoptPtrWillBeNo op(new MediaQueryExp(*this)); } | 97 PassOwnPtrWillBeRawPtr<MediaQueryExp> copy() const { return adoptPtrWillBeNo op(new MediaQueryExp(*this)); } |
| 62 | 98 |
| 63 void trace(Visitor* visitor) { visitor->trace(m_value); } | |
| 64 | |
| 65 MediaQueryExp(const MediaQueryExp& other); | 99 MediaQueryExp(const MediaQueryExp& other); |
| 66 | 100 |
| 101 void trace(Visitor* visitor) { } | |
| 102 | |
| 67 private: | 103 private: |
| 68 MediaQueryExp(const String&, PassRefPtrWillBeRawPtr<CSSValue>); | 104 MediaQueryExp(const String&, const MediaQueryExpValue&); |
| 69 | 105 |
| 70 String m_mediaFeature; | 106 String m_mediaFeature; |
| 71 RefPtrWillBeMember<CSSValue> m_value; | 107 MediaQueryExpValue m_expValue; |
| 72 }; | 108 }; |
| 73 | 109 |
| 74 } // namespace | 110 } // namespace |
| 75 | 111 |
| 76 #endif | 112 #endif |
| OLD | NEW |