Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Unified Diff: Source/core/css/MediaQueryExp.h

Issue 240453010: Avoid use of CSSValue in MediaQueryExp and MediaQueryEvaluator (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix previous patch Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/MediaQueryEvaluator.cpp ('k') | Source/core/css/MediaQueryExp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/MediaQueryExp.h
diff --git a/Source/core/css/MediaQueryExp.h b/Source/core/css/MediaQueryExp.h
index 5bbe24f3cc68e88c7ad4d7e5999cabfb74d5bf2b..036a030d995820a412f88bd8d701d32862990adc 100644
--- a/Source/core/css/MediaQueryExp.h
+++ b/Source/core/css/MediaQueryExp.h
@@ -29,7 +29,9 @@
#ifndef MediaQueryExp_h
#define MediaQueryExp_h
+#include "CSSValueKeywords.h"
#include "MediaFeatureNames.h"
+#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValue.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefPtr.h"
@@ -37,7 +39,46 @@
namespace WebCore {
class CSSParserValueList;
-class MediaQueryExp : public NoBaseWillBeGarbageCollectedFinalized<MediaQueryExp> {
+struct MediaQueryExpValue {
+ CSSValueID id;
+ double value;
+ CSSPrimitiveValue::UnitTypes unit;
+ unsigned numerator;
+ unsigned denominator;
+
+ bool isID;
+ bool isValue;
+ bool isRatio;
+ bool isInteger;
+
+ MediaQueryExpValue()
+ : id(CSSValueInvalid)
+ , value(0)
+ , unit(CSSPrimitiveValue::CSS_UNKNOWN)
+ , numerator(0)
+ , denominator(1)
+ , isID(false)
+ , isValue(false)
+ , isRatio(false)
+ , isInteger(false)
+ {
+ }
+
+ bool isValid() const { return (isID || isValue || isRatio); }
+ String cssText() const;
+ bool equals(const MediaQueryExpValue& expValue) const
+ {
+ 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*);
@@ -45,14 +86,9 @@ public:
const String& mediaFeature() const { return m_mediaFeature; }
- CSSValue* value() const { return m_value.get(); }
+ MediaQueryExpValue expValue() const { return m_expValue; }
- bool operator==(const MediaQueryExp& other) const
- {
- return (other.m_mediaFeature == m_mediaFeature)
- && ((!other.m_value && !m_value)
- || (other.m_value && m_value && other.m_value->equals(*m_value)));
- }
+ bool operator==(const MediaQueryExp& other) const;
bool isViewportDependent() const;
@@ -60,15 +96,15 @@ public:
PassOwnPtrWillBeRawPtr<MediaQueryExp> copy() const { return adoptPtrWillBeNoop(new MediaQueryExp(*this)); }
- void trace(Visitor* visitor) { visitor->trace(m_value); }
-
MediaQueryExp(const MediaQueryExp& other);
+ void trace(Visitor* visitor) { }
+
private:
- MediaQueryExp(const String&, PassRefPtrWillBeRawPtr<CSSValue>);
+ MediaQueryExp(const String&, const MediaQueryExpValue&);
String m_mediaFeature;
- RefPtrWillBeMember<CSSValue> m_value;
+ MediaQueryExpValue m_expValue;
};
} // namespace
« no previous file with comments | « Source/core/css/MediaQueryEvaluator.cpp ('k') | Source/core/css/MediaQueryExp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698