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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSPrimitiveValue.h

Issue 1481383002: [Experimental] CSSSerializer Proof-of-concept Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: snapshot: top_25 sites ser/dser now works Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom) 195 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom)
196 { 196 {
197 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); 197 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom));
198 } 198 }
199 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create (T value) 199 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create (T value)
200 { 200 {
201 static_assert(!std::is_same<T, CSSValueID>::value, "Do not call create() with a CSSValueID; call createIdentifier() instead"); 201 static_assert(!std::is_same<T, CSSValueID>::value, "Do not call create() with a CSSValueID; call createIdentifier() instead");
202 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); 202 return adoptRefWillBeNoop(new CSSPrimitiveValue(value));
203 } 203 }
204 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> deserialize(CSSDeserializeS tream*);
205 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> deserializeAfterDispatch(CS SDeserializeStream*);
204 206
205 ~CSSPrimitiveValue(); 207 ~CSSPrimitiveValue();
206 208
207 UnitType typeWithCalcResolved() const; 209 UnitType typeWithCalcResolved() const;
208 210
209 double computeDegrees() const; 211 double computeDegrees() const;
210 double computeSeconds() const; 212 double computeSeconds() const;
211 213
212 // Computes a length in pixels, resolving relative lengths 214 // Computes a length in pixels, resolving relative lengths
213 template<typename T> T computeLength(const CSSToLengthConversionData&) const ; 215 template<typename T> T computeLength(const CSSToLengthConversionData&) const ;
(...skipping 19 matching lines...) Expand all
233 235
234 DECLARE_TRACE_AFTER_DISPATCH(); 236 DECLARE_TRACE_AFTER_DISPATCH();
235 237
236 static UnitType canonicalUnitTypeForCategory(UnitCategory); 238 static UnitType canonicalUnitTypeForCategory(UnitCategory);
237 static double conversionToCanonicalUnitsScaleFactor(UnitType); 239 static double conversionToCanonicalUnitsScaleFactor(UnitType);
238 240
239 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false. 241 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false.
240 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); 242 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&);
241 static UnitType lengthUnitTypeToUnitType(LengthUnitType); 243 static UnitType lengthUnitTypeToUnitType(LengthUnitType);
242 244
245 void serializeAfterDispatch(CSSSerializeStream*) const;
246
243 private: 247 private:
244 CSSPrimitiveValue(CSSValueID); 248 CSSPrimitiveValue(CSSValueID);
245 CSSPrimitiveValue(const Length&, float zoom); 249 CSSPrimitiveValue(const Length&, float zoom);
246 CSSPrimitiveValue(double, UnitType); 250 CSSPrimitiveValue(double, UnitType);
247 251
248 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa ppings.h 252 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMa ppings.h
249 template<typename T> CSSPrimitiveValue(T* val) 253 template<typename T> CSSPrimitiveValue(T* val)
250 : CSSValue(PrimitiveClass) 254 : CSSValue(PrimitiveClass)
251 { 255 {
252 init(PassRefPtrWillBeRawPtr<T>(val)); 256 init(PassRefPtrWillBeRawPtr<T>(val));
(...skipping 18 matching lines...) Expand all
271 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT ype); } 275 inline UnitType type() const { return static_cast<UnitType>(m_primitiveUnitT ype); }
272 276
273 union { 277 union {
274 CSSValueID valueID; 278 CSSValueID valueID;
275 double num; 279 double num;
276 // FIXME: oilpan: Should be a member, but no support for members in unio ns. Just trace the raw ptr for now. 280 // FIXME: oilpan: Should be a member, but no support for members in unio ns. Just trace the raw ptr for now.
277 CSSCalcValue* calc; 281 CSSCalcValue* calc;
278 } m_value; 282 } m_value;
279 }; 283 };
280 284
285 template<>
286 class CSSSerializeTrait<CSSPrimitiveValue> : public CSSSerializeTrait<CSSValue> {};
287 template<>
288 class CSSDeserializeTrait<CSSPrimitiveValue> : public CSSDeserializeTrait<CSSVal ue> {};
289
281 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray; 290 using CSSLengthArray = CSSPrimitiveValue::CSSLengthArray;
282 using CSSLengthTypeArray = CSSPrimitiveValue::CSSLengthTypeArray; 291 using CSSLengthTypeArray = CSSPrimitiveValue::CSSLengthTypeArray;
283 292
284 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); 293 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue());
285 294
286 } // namespace blink 295 } // namespace blink
287 296
288 #endif // CSSPrimitiveValue_h 297 #endif // CSSPrimitiveValue_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSKeyframesRule.cpp ('k') | third_party/WebKit/Source/core/css/CSSPrimitiveValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698