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

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

Issue 1316153003: Removed m_isQuirkValue and used CSSPrimitiveValue::QuirkyEms instead (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Small fix in unitTypeToString() Created 5 years, 3 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 Integer, 101 Integer,
102 Rems, 102 Rems,
103 Chs, 103 Chs,
104 Shape, 104 Shape,
105 Calc, 105 Calc,
106 CalcPercentageWithNumber, 106 CalcPercentageWithNumber,
107 CalcPercentageWithLength, 107 CalcPercentageWithLength,
108 String, 108 String,
109 PropertyID, 109 PropertyID,
110 ValueID, 110 ValueID,
111
Timothy Loh 2015/09/02 01:59:03 Should probably mention that this is non-standard
sashab 2015/09/02 03:54:49 Done.
112 // This value is used to handle quirky margins in reflow roots (body, td , and th) like WinIE.
113 // The basic idea is that a stylesheet can use the value __qem (for quir ky em) instead of em.
114 // When the quirky value is used, if you're in quirks mode, the margin w ill collapse away
115 // inside a table cell.
111 QuirkyEms, 116 QuirkyEms,
112 }; 117 };
113 118
114 enum LengthUnitType { 119 enum LengthUnitType {
115 UnitTypePixels = 0, 120 UnitTypePixels = 0,
116 UnitTypePercentage, 121 UnitTypePercentage,
117 UnitTypeFontSize, 122 UnitTypeFontSize,
118 UnitTypeFontXSize, 123 UnitTypeFontXSize,
119 UnitTypeRootFontSize, 124 UnitTypeRootFontSize,
120 UnitTypeZeroCharacterWidth, 125 UnitTypeZeroCharacterWidth,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 bool isAngle() const 158 bool isAngle() const
154 { 159 {
155 return type() == UnitType::Degrees 160 return type() == UnitType::Degrees
156 || type() == UnitType::Radians 161 || type() == UnitType::Radians
157 || type() == UnitType::Gradians 162 || type() == UnitType::Gradians
158 || type() == UnitType::Turns; 163 || type() == UnitType::Turns;
159 } 164 }
160 bool isCustomIdent() const { return type() == UnitType::CustomIdentifier; } 165 bool isCustomIdent() const { return type() == UnitType::CustomIdentifier; }
161 bool isFontRelativeLength() const 166 bool isFontRelativeLength() const
162 { 167 {
163 return type() == UnitType::Ems 168 return type() == UnitType::QuirkyEms
169 || type() == UnitType::Ems
164 || type() == UnitType::Exs 170 || type() == UnitType::Exs
165 || type() == UnitType::Rems 171 || type() == UnitType::Rems
166 || type() == UnitType::Chs; 172 || type() == UnitType::Chs;
167 } 173 }
174 bool isQuirkValue() const { return type() == UnitType::QuirkyEms; }
Timothy Loh 2015/09/02 01:59:03 isQuirkyEms?
sashab 2015/09/02 03:54:49 Done.
168 bool isViewportPercentageLength() const { return isViewportPercentageLength( type()); } 175 bool isViewportPercentageLength() const { return isViewportPercentageLength( type()); }
169 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT ype::ViewportWidth && type <= UnitType::ViewportMax; } 176 static bool isViewportPercentageLength(UnitType type) { return type >= UnitT ype::ViewportWidth && type <= UnitType::ViewportMax; }
170 static bool isLength(UnitType type) 177 static bool isLength(UnitType type)
171 { 178 {
172 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni tType::Rems || type == UnitType::Chs || isViewportPercentageLength(type); 179 return (type >= UnitType::Ems && type <= UnitType::Picas) || type == Uni tType::QuirkyEms || type == UnitType::Rems || type == UnitType::Chs || isViewpor tPercentageLength(type);
173 } 180 }
174 bool isLength() const { return isLength(typeWithCalcResolved()); } 181 bool isLength() const { return isLength(typeWithCalcResolved()); }
175 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number || typeWithCalcResolved() == UnitType::Integer; } 182 bool isNumber() const { return typeWithCalcResolved() == UnitType::Number || typeWithCalcResolved() == UnitType::Integer; }
176 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce ntage; } 183 bool isPercentage() const { return typeWithCalcResolved() == UnitType::Perce ntage; }
177 bool isPropertyID() const { return type() == UnitType::PropertyID; } 184 bool isPropertyID() const { return type() == UnitType::PropertyID; }
178 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; } 185 bool isPx() const { return typeWithCalcResolved() == UnitType::Pixels; }
179 bool isRGBColor() const { return type() == UnitType::RGBColor; } 186 bool isRGBColor() const { return type() == UnitType::RGBColor; }
180 bool isShape() const { return type() == UnitType::Shape; } 187 bool isShape() const { return type() == UnitType::Shape; }
181 bool isString() const { return type() == UnitType::String; } 188 bool isString() const { return type() == UnitType::String; }
182 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy pe::Milliseconds; } 189 bool isTime() const { return type() == UnitType::Seconds || type() == UnitTy pe::Milliseconds; }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 221 }
215 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom) 222 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create(const Length& value, float zoom)
216 { 223 {
217 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom)); 224 return adoptRefWillBeNoop(new CSSPrimitiveValue(value, zoom));
218 } 225 }
219 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create (T value) 226 template<typename T> static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> create (T value)
220 { 227 {
221 return adoptRefWillBeNoop(new CSSPrimitiveValue(value)); 228 return adoptRefWillBeNoop(new CSSPrimitiveValue(value));
222 } 229 }
223 230
224 // This value is used to handle quirky margins in reflow roots (body, td, an d th) like WinIE.
225 // The basic idea is that a stylesheet can use the value __qem (for quirky e m) instead of em.
226 // When the quirky value is used, if you're in quirks mode, the margin will collapse away
227 // inside a table cell.
228 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createAllowingMarginQuirk(d ouble value, UnitType type)
229 {
230 CSSPrimitiveValue* quirkValue = new CSSPrimitiveValue(value, type);
231 quirkValue->m_isQuirkValue = true;
232 return adoptRefWillBeNoop(quirkValue);
233 }
234
235 ~CSSPrimitiveValue(); 231 ~CSSPrimitiveValue();
236 232
237 void cleanup(); 233 void cleanup();
238 234
239 UnitType typeWithCalcResolved() const; 235 UnitType typeWithCalcResolved() const;
240 236
241 double computeDegrees() const; 237 double computeDegrees() const;
242 double computeSeconds() const; 238 double computeSeconds() const;
243 239
244 // Computes a length in pixels, resolving relative lengths 240 // Computes a length in pixels, resolving relative lengths
(...skipping 14 matching lines...) Expand all
259 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value. calc; } 255 CSSCalcValue* cssCalcValue() const { ASSERT(isCalculated()); return m_value. calc; }
260 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value .propertyID; } 256 CSSPropertyID getPropertyID() const { ASSERT(isPropertyID()); return m_value .propertyID; }
261 257
262 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value .valueID : CSSValueInvalid; } 258 CSSValueID getValueID() const { return type() == UnitType::ValueID ? m_value .valueID : CSSValueInvalid; }
263 259
264 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h 260 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h
265 261
266 static const char* unitTypeToString(UnitType); 262 static const char* unitTypeToString(UnitType);
267 String customCSSText() const; 263 String customCSSText() const;
268 264
269 bool isQuirkValue() const { return m_isQuirkValue; }
270
271 bool equals(const CSSPrimitiveValue&) const; 265 bool equals(const CSSPrimitiveValue&) const;
272 266
273 DECLARE_TRACE_AFTER_DISPATCH(); 267 DECLARE_TRACE_AFTER_DISPATCH();
274 268
275 static UnitType canonicalUnitTypeForCategory(UnitCategory); 269 static UnitType canonicalUnitTypeForCategory(UnitCategory);
276 static double conversionToCanonicalUnitsScaleFactor(UnitType); 270 static double conversionToCanonicalUnitsScaleFactor(UnitType);
277 271
278 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false. 272 // Returns true and populates lengthUnitType, if unitType is a length unit. Otherwise, returns false.
279 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&); 273 static bool unitTypeToLengthUnitType(UnitType, LengthUnitType&);
280 static UnitType lengthUnitTypeToUnitType(LengthUnitType); 274 static UnitType lengthUnitTypeToUnitType(LengthUnitType);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 }; 320 };
327 321
328 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray; 322 typedef CSSPrimitiveValue::CSSLengthArray CSSLengthArray;
329 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray; 323 typedef CSSPrimitiveValue::CSSLengthTypeArray CSSLengthTypeArray;
330 324
331 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); 325 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue());
332 326
333 } // namespace blink 327 } // namespace blink
334 328
335 #endif // CSSPrimitiveValue_h 329 #endif // CSSPrimitiveValue_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/CSSPrimitiveValue.cpp » ('j') | Source/core/css/CSSPrimitiveValue.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698