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

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

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: fix compile on mac Created 7 years 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 }; 137 };
138 138
139 // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies. 139 // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies.
140 enum UnitCategory { 140 enum UnitCategory {
141 UNumber, 141 UNumber,
142 UPercent, 142 UPercent,
143 ULength, 143 ULength,
144 UAngle, 144 UAngle,
145 UTime, 145 UTime,
146 UFrequency, 146 UFrequency,
147 UViewportPercentageLength,
148 UResolution, 147 UResolution,
149 UOther 148 UOther
150 }; 149 };
151 static UnitCategory unitCategory(CSSPrimitiveValue::UnitTypes); 150 static UnitCategory unitCategory(CSSPrimitiveValue::UnitTypes);
152 151
153 bool isAngle() const 152 bool isAngle() const
154 { 153 {
155 return m_primitiveUnitType == CSS_DEG 154 return m_primitiveUnitType == CSS_DEG
156 || m_primitiveUnitType == CSS_RAD 155 || m_primitiveUnitType == CSS_RAD
157 || m_primitiveUnitType == CSS_GRAD 156 || m_primitiveUnitType == CSS_GRAD
158 || m_primitiveUnitType == CSS_TURN; 157 || m_primitiveUnitType == CSS_TURN;
159 } 158 }
160 bool isAttr() const { return m_primitiveUnitType == CSS_ATTR; } 159 bool isAttr() const { return m_primitiveUnitType == CSS_ATTR; }
161 bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; } 160 bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; }
162 bool isFontIndependentLength() const { return m_primitiveUnitType >= CSS_PX && m_primitiveUnitType <= CSS_PC; } 161 bool isFontIndependentLength() const { return m_primitiveUnitType >= CSS_PX && m_primitiveUnitType <= CSS_PC; }
163 bool isFontRelativeLength() const 162 bool isFontRelativeLength() const
164 { 163 {
165 return m_primitiveUnitType == CSS_EMS 164 return m_primitiveUnitType == CSS_EMS
166 || m_primitiveUnitType == CSS_EXS 165 || m_primitiveUnitType == CSS_EXS
167 || m_primitiveUnitType == CSS_REMS 166 || m_primitiveUnitType == CSS_REMS
168 || m_primitiveUnitType == CSS_CHS; 167 || m_primitiveUnitType == CSS_CHS;
169 } 168 }
170 bool isLength() const 169 bool isLength() const
171 { 170 {
172 unsigned short type = primitiveType(); 171 unsigned short type = primitiveType();
173 return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type = = CSS_CHS; 172 return (type >= CSS_EMS && type <= CSS_PC) || type == CSS_REMS || type = = CSS_CHS || isViewportPercentageLength();
174 } 173 }
175 bool isNumber() const { return primitiveType() == CSS_NUMBER; } 174 bool isNumber() const { return primitiveType() == CSS_NUMBER; }
176 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; } 175 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; }
177 bool isPx() const { return primitiveType() == CSS_PX; } 176 bool isPx() const { return primitiveType() == CSS_PX; }
178 bool isRect() const { return m_primitiveUnitType == CSS_RECT; } 177 bool isRect() const { return m_primitiveUnitType == CSS_RECT; }
179 bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; } 178 bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; }
180 bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; } 179 bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; }
181 bool isString() const { return m_primitiveUnitType == CSS_STRING; } 180 bool isString() const { return m_primitiveUnitType == CSS_STRING; }
182 bool isTime() const { return m_primitiveUnitType == CSS_S || m_primitiveUnit Type == CSS_MS; } 181 bool isTime() const { return m_primitiveUnitType == CSS_S || m_primitiveUnit Type == CSS_MS; }
183 bool isURI() const { return m_primitiveUnitType == CSS_URI; } 182 bool isURI() const { return m_primitiveUnitType == CSS_URI; }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h 307 template<typename T> inline operator T() const; // Defined in CSSPrimitiveVa lueMappings.h
309 308
310 String customCSSText(CSSTextFormattingFlags = QuoteCSSStringIfNeeded) const; 309 String customCSSText(CSSTextFormattingFlags = QuoteCSSStringIfNeeded) const;
311 String customSerializeResolvingVariables(const HashMap<AtomicString, String> &) const; 310 String customSerializeResolvingVariables(const HashMap<AtomicString, String> &) const;
312 bool hasVariableReference() const; 311 bool hasVariableReference() const;
313 312
314 bool isQuirkValue() { return m_isQuirkValue; } 313 bool isQuirkValue() { return m_isQuirkValue; }
315 314
316 void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const; 315 void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
317 316
318 Length viewportPercentageLength();
319
320 PassRefPtr<CSSPrimitiveValue> cloneForCSSOM() const; 317 PassRefPtr<CSSPrimitiveValue> cloneForCSSOM() const;
321 void setCSSOMSafe() { m_isCSSOMSafe = true; } 318 void setCSSOMSafe() { m_isCSSOMSafe = true; }
322 319
323 bool equals(const CSSPrimitiveValue&) const; 320 bool equals(const CSSPrimitiveValue&) const;
324 321
325 static UnitTypes canonicalUnitTypeForCategory(UnitCategory); 322 static UnitTypes canonicalUnitTypeForCategory(UnitCategory);
326 static double conversionToCanonicalUnitsScaleFactor(unsigned short unitType) ; 323 static double conversionToCanonicalUnitsScaleFactor(unsigned short unitType) ;
327 324
328 private: 325 private:
329 CSSPrimitiveValue(CSSValueID); 326 CSSPrimitiveValue(CSSValueID);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 CSSBasicShape* shape; 379 CSSBasicShape* shape;
383 CSSCalcValue* calc; 380 CSSCalcValue* calc;
384 } m_value; 381 } m_value;
385 }; 382 };
386 383
387 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue()); 384 DEFINE_CSS_VALUE_TYPE_CASTS(CSSPrimitiveValue, isPrimitiveValue());
388 385
389 } // namespace WebCore 386 } // namespace WebCore
390 387
391 #endif // CSSPrimitiveValue_h 388 #endif // CSSPrimitiveValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698