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

Side by Side Diff: Source/core/css/CSSCalculationValue.cpp

Issue 129063002: Update CSS classes to use OVERRIDE / FINAL when needed (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | Source/core/css/CSSCanvasValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 double CSSCalcValue::computeLengthPx(const CSSToLengthConversionData& conversion Data) const 185 double CSSCalcValue::computeLengthPx(const CSSToLengthConversionData& conversion Data) const
186 { 186 {
187 return clampToPermittedRange(m_expression->computeLengthPx(conversionData)); 187 return clampToPermittedRange(m_expression->computeLengthPx(conversionData));
188 } 188 }
189 189
190 CSSCalcExpressionNode::~CSSCalcExpressionNode() 190 CSSCalcExpressionNode::~CSSCalcExpressionNode()
191 { 191 {
192 } 192 }
193 193
194 class CSSCalcPrimitiveValue : public CSSCalcExpressionNode { 194 class CSSCalcPrimitiveValue FINAL : public CSSCalcExpressionNode {
195 WTF_MAKE_FAST_ALLOCATED; 195 WTF_MAKE_FAST_ALLOCATED;
196 public: 196 public:
197 197
198 static PassRefPtr<CSSCalcPrimitiveValue> create(PassRefPtr<CSSPrimitiveValue > value, bool isInteger) 198 static PassRefPtr<CSSCalcPrimitiveValue> create(PassRefPtr<CSSPrimitiveValue > value, bool isInteger)
199 { 199 {
200 return adoptRef(new CSSCalcPrimitiveValue(value, isInteger)); 200 return adoptRef(new CSSCalcPrimitiveValue(value, isInteger));
201 } 201 }
202 202
203 static PassRefPtr<CSSCalcPrimitiveValue> create(double value, CSSPrimitiveVa lue::UnitTypes type, bool isInteger) 203 static PassRefPtr<CSSCalcPrimitiveValue> create(double value, CSSPrimitiveVa lue::UnitTypes type, bool isInteger)
204 { 204 {
205 if (std::isnan(value) || std::isinf(value)) 205 if (std::isnan(value) || std::isinf(value))
206 return 0; 206 return 0;
207 return adoptRef(new CSSCalcPrimitiveValue(CSSPrimitiveValue::create(valu e, type).get(), isInteger)); 207 return adoptRef(new CSSCalcPrimitiveValue(CSSPrimitiveValue::create(valu e, type).get(), isInteger));
208 } 208 }
209 209
210 virtual bool isZero() const 210 virtual bool isZero() const OVERRIDE
211 { 211 {
212 return !m_value->getDoubleValue(); 212 return !m_value->getDoubleValue();
213 } 213 }
214 214
215 virtual String customCSSText() const 215 virtual String customCSSText() const OVERRIDE
216 { 216 {
217 return m_value->cssText(); 217 return m_value->cssText();
218 } 218 }
219 219
220 virtual String serializeResolvingVariables(const HashMap<AtomicString, Strin g>& variables) const 220 virtual String serializeResolvingVariables(const HashMap<AtomicString, Strin g>& variables) const OVERRIDE
221 { 221 {
222 return m_value->customSerializeResolvingVariables(variables); 222 return m_value->customSerializeResolvingVariables(variables);
223 } 223 }
224 224
225 virtual bool hasVariableReference() const 225 virtual bool hasVariableReference() const OVERRIDE
226 { 226 {
227 return m_value->isVariableName(); 227 return m_value->isVariableName();
228 } 228 }
229 229
230 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi onData& conversionData) const 230 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi onData& conversionData) const OVERRIDE
231 { 231 {
232 switch (m_category) { 232 switch (m_category) {
233 case CalcNumber: 233 case CalcNumber:
234 return adoptPtr(new CalcExpressionNumber(m_value->getFloatValue())); 234 return adoptPtr(new CalcExpressionNumber(m_value->getFloatValue()));
235 case CalcLength: 235 case CalcLength:
236 return adoptPtr(new CalcExpressionLength(Length(m_value->computeLeng th<float>(conversionData), WebCore::Fixed))); 236 return adoptPtr(new CalcExpressionLength(Length(m_value->computeLeng th<float>(conversionData), WebCore::Fixed)));
237 case CalcPercent: 237 case CalcPercent:
238 case CalcPercentLength: 238 case CalcPercentLength:
239 return adoptPtr(new CalcExpressionLength(m_value->convertToLength<Fi xedConversion | PercentConversion>(conversionData))); 239 return adoptPtr(new CalcExpressionLength(m_value->convertToLength<Fi xedConversion | PercentConversion>(conversionData)));
240 // Only types that could be part of a Length expression can be converted 240 // Only types that could be part of a Length expression can be converted
241 // to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length . 241 // to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length .
242 case CalcPercentNumber: 242 case CalcPercentNumber:
243 case CalcVariable: 243 case CalcVariable:
244 case CalcOther: 244 case CalcOther:
245 ASSERT_NOT_REACHED(); 245 ASSERT_NOT_REACHED();
246 } 246 }
247 return nullptr; 247 return nullptr;
248 } 248 }
249 249
250 virtual double doubleValue() const 250 virtual double doubleValue() const OVERRIDE
251 { 251 {
252 if (hasDoubleValue(primitiveType())) 252 if (hasDoubleValue(primitiveType()))
253 return m_value->getDoubleValue(); 253 return m_value->getDoubleValue();
254 ASSERT_NOT_REACHED(); 254 ASSERT_NOT_REACHED();
255 return 0; 255 return 0;
256 } 256 }
257 257
258 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa ta) const 258 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa ta) const OVERRIDE
259 { 259 {
260 switch (m_category) { 260 switch (m_category) {
261 case CalcLength: 261 case CalcLength:
262 return m_value->computeLength<double>(conversionData); 262 return m_value->computeLength<double>(conversionData);
263 case CalcPercent: 263 case CalcPercent:
264 case CalcNumber: 264 case CalcNumber:
265 return m_value->getDoubleValue(); 265 return m_value->getDoubleValue();
266 case CalcPercentLength: 266 case CalcPercentLength:
267 case CalcPercentNumber: 267 case CalcPercentNumber:
268 case CalcVariable: 268 case CalcVariable:
269 case CalcOther: 269 case CalcOther:
270 ASSERT_NOT_REACHED(); 270 ASSERT_NOT_REACHED();
271 break; 271 break;
272 } 272 }
273 ASSERT_NOT_REACHED(); 273 ASSERT_NOT_REACHED();
274 return 0; 274 return 0;
275 } 275 }
276 276
277 virtual bool equals(const CSSCalcExpressionNode& other) const 277 virtual bool equals(const CSSCalcExpressionNode& other) const OVERRIDE
278 { 278 {
279 if (type() != other.type()) 279 if (type() != other.type())
280 return false; 280 return false;
281 281
282 return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveVal ue&>(other).m_value); 282 return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveVal ue&>(other).m_value);
283 } 283 }
284 284
285 virtual Type type() const { return CssCalcPrimitiveValue; } 285 virtual Type type() const OVERRIDE { return CssCalcPrimitiveValue; }
286 virtual CSSPrimitiveValue::UnitTypes primitiveType() const 286 virtual CSSPrimitiveValue::UnitTypes primitiveType() const OVERRIDE
287 { 287 {
288 return CSSPrimitiveValue::UnitTypes(m_value->primitiveType()); 288 return CSSPrimitiveValue::UnitTypes(m_value->primitiveType());
289 } 289 }
290 290
291 private: 291 private:
292 explicit CSSCalcPrimitiveValue(PassRefPtr<CSSPrimitiveValue> value, bool isI nteger) 292 explicit CSSCalcPrimitiveValue(PassRefPtr<CSSPrimitiveValue> value, bool isI nteger)
293 : CSSCalcExpressionNode(unitCategory((CSSPrimitiveValue::UnitTypes)value ->primitiveType()), isInteger) 293 : CSSCalcExpressionNode(unitCategory((CSSPrimitiveValue::UnitTypes)value ->primitiveType()), isInteger)
294 , m_value(value) 294 , m_value(value)
295 { 295 {
296 } 296 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 337 }
338 338
339 static bool isIntegerResult(const CSSCalcExpressionNode* leftSide, const CSSCalc ExpressionNode* rightSide, CalcOperator op) 339 static bool isIntegerResult(const CSSCalcExpressionNode* leftSide, const CSSCalc ExpressionNode* rightSide, CalcOperator op)
340 { 340 {
341 // Not testing for actual integer values. 341 // Not testing for actual integer values.
342 // Performs W3C spec's type checking for calc integers. 342 // Performs W3C spec's type checking for calc integers.
343 // http://www.w3.org/TR/css3-values/#calc-type-checking 343 // http://www.w3.org/TR/css3-values/#calc-type-checking
344 return op != CalcDivide && leftSide->isInteger() && rightSide->isInteger(); 344 return op != CalcDivide && leftSide->isInteger() && rightSide->isInteger();
345 } 345 }
346 346
347 class CSSCalcBinaryOperation : public CSSCalcExpressionNode { 347 class CSSCalcBinaryOperation FINAL : public CSSCalcExpressionNode {
348 348
349 public: 349 public:
350 static PassRefPtr<CSSCalcExpressionNode> create(PassRefPtr<CSSCalcExpression Node> leftSide, PassRefPtr<CSSCalcExpressionNode> rightSide, CalcOperator op) 350 static PassRefPtr<CSSCalcExpressionNode> create(PassRefPtr<CSSCalcExpression Node> leftSide, PassRefPtr<CSSCalcExpressionNode> rightSide, CalcOperator op)
351 { 351 {
352 ASSERT(leftSide->category() != CalcOther && rightSide->category() != Cal cOther); 352 ASSERT(leftSide->category() != CalcOther && rightSide->category() != Cal cOther);
353 353
354 CalculationCategory newCategory = determineCategory(*leftSide, *rightSid e, op); 354 CalculationCategory newCategory = determineCategory(*leftSide, *rightSid e, op);
355 if (newCategory == CalcOther) 355 if (newCategory == CalcOther)
356 return 0; 356 return 0;
357 357
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 return 0; 408 return 0;
409 409
410 CSSPrimitiveValue::UnitTypes otherType = otherSide->primitiveType(); 410 CSSPrimitiveValue::UnitTypes otherType = otherSide->primitiveType();
411 if (hasDoubleValue(otherType)) 411 if (hasDoubleValue(otherType))
412 return CSSCalcPrimitiveValue::create(evaluateOperator(otherSide- >doubleValue(), number, op), otherType, isInteger); 412 return CSSCalcPrimitiveValue::create(evaluateOperator(otherSide- >doubleValue(), number, op), otherType, isInteger);
413 } 413 }
414 414
415 return create(leftSide, rightSide, op); 415 return create(leftSide, rightSide, op);
416 } 416 }
417 417
418 virtual bool isZero() const 418 virtual bool isZero() const OVERRIDE
419 { 419 {
420 return !doubleValue(); 420 return !doubleValue();
421 } 421 }
422 422
423 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi onData& conversionData) const 423 virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const CSSToLengthConversi onData& conversionData) const OVERRIDE
424 { 424 {
425 OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(conversionData)) ; 425 OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(conversionData)) ;
426 if (!left) 426 if (!left)
427 return nullptr; 427 return nullptr;
428 OwnPtr<CalcExpressionNode> right(m_rightSide->toCalcValue(conversionData )); 428 OwnPtr<CalcExpressionNode> right(m_rightSide->toCalcValue(conversionData ));
429 if (!right) 429 if (!right)
430 return nullptr; 430 return nullptr;
431 return adoptPtr(new CalcExpressionBinaryOperation(left.release(), right. release(), m_operator)); 431 return adoptPtr(new CalcExpressionBinaryOperation(left.release(), right. release(), m_operator));
432 } 432 }
433 433
434 virtual double doubleValue() const 434 virtual double doubleValue() const OVERRIDE
435 { 435 {
436 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue()); 436 return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue());
437 } 437 }
438 438
439 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa ta) const 439 virtual double computeLengthPx(const CSSToLengthConversionData& conversionDa ta) const OVERRIDE
440 { 440 {
441 const double leftValue = m_leftSide->computeLengthPx(conversionData); 441 const double leftValue = m_leftSide->computeLengthPx(conversionData);
442 const double rightValue = m_rightSide->computeLengthPx(conversionData); 442 const double rightValue = m_rightSide->computeLengthPx(conversionData);
443 return evaluate(leftValue, rightValue); 443 return evaluate(leftValue, rightValue);
444 } 444 }
445 445
446 static String buildCSSText(const String& leftExpression, const String& right Expression, CalcOperator op) 446 static String buildCSSText(const String& leftExpression, const String& right Expression, CalcOperator op)
447 { 447 {
448 StringBuilder result; 448 StringBuilder result;
449 result.append('('); 449 result.append('(');
450 result.append(leftExpression); 450 result.append(leftExpression);
451 result.append(' '); 451 result.append(' ');
452 result.append(static_cast<char>(op)); 452 result.append(static_cast<char>(op));
453 result.append(' '); 453 result.append(' ');
454 result.append(rightExpression); 454 result.append(rightExpression);
455 result.append(')'); 455 result.append(')');
456 456
457 return result.toString(); 457 return result.toString();
458 } 458 }
459 459
460 virtual String customCSSText() const 460 virtual String customCSSText() const OVERRIDE
461 { 461 {
462 return buildCSSText(m_leftSide->customCSSText(), m_rightSide->customCSST ext(), m_operator); 462 return buildCSSText(m_leftSide->customCSSText(), m_rightSide->customCSST ext(), m_operator);
463 } 463 }
464 464
465 virtual String serializeResolvingVariables(const HashMap<AtomicString, Strin g>& variables) const 465 virtual String serializeResolvingVariables(const HashMap<AtomicString, Strin g>& variables) const OVERRIDE
466 { 466 {
467 return buildCSSText(m_leftSide->serializeResolvingVariables(variables), m_rightSide->serializeResolvingVariables(variables), m_operator); 467 return buildCSSText(m_leftSide->serializeResolvingVariables(variables), m_rightSide->serializeResolvingVariables(variables), m_operator);
468 } 468 }
469 469
470 virtual bool hasVariableReference() const 470 virtual bool hasVariableReference() const OVERRIDE
471 { 471 {
472 return m_leftSide->hasVariableReference() || m_rightSide->hasVariableRef erence(); 472 return m_leftSide->hasVariableReference() || m_rightSide->hasVariableRef erence();
473 } 473 }
474 474
475 virtual bool equals(const CSSCalcExpressionNode& exp) const 475 virtual bool equals(const CSSCalcExpressionNode& exp) const OVERRIDE
476 { 476 {
477 if (type() != exp.type()) 477 if (type() != exp.type())
478 return false; 478 return false;
479 479
480 const CSSCalcBinaryOperation& other = static_cast<const CSSCalcBinaryOpe ration&>(exp); 480 const CSSCalcBinaryOperation& other = static_cast<const CSSCalcBinaryOpe ration&>(exp);
481 return compareCSSValuePtr(m_leftSide, other.m_leftSide) 481 return compareCSSValuePtr(m_leftSide, other.m_leftSide)
482 && compareCSSValuePtr(m_rightSide, other.m_rightSide) 482 && compareCSSValuePtr(m_rightSide, other.m_rightSide)
483 && m_operator == other.m_operator; 483 && m_operator == other.m_operator;
484 } 484 }
485 485
486 virtual Type type() const { return CssCalcBinaryOperation; } 486 virtual Type type() const OVERRIDE { return CssCalcBinaryOperation; }
487 487
488 virtual CSSPrimitiveValue::UnitTypes primitiveType() const 488 virtual CSSPrimitiveValue::UnitTypes primitiveType() const OVERRIDE
489 { 489 {
490 switch (m_category) { 490 switch (m_category) {
491 case CalcNumber: 491 case CalcNumber:
492 ASSERT(m_leftSide->category() == CalcNumber && m_rightSide->category () == CalcNumber); 492 ASSERT(m_leftSide->category() == CalcNumber && m_rightSide->category () == CalcNumber);
493 if (m_isInteger) 493 if (m_isInteger)
494 return CSSPrimitiveValue::CSS_PARSER_INTEGER; 494 return CSSPrimitiveValue::CSS_PARSER_INTEGER;
495 return CSSPrimitiveValue::CSS_NUMBER; 495 return CSSPrimitiveValue::CSS_NUMBER;
496 case CalcLength: 496 case CalcLength:
497 case CalcPercent: { 497 case CalcPercent: {
498 if (m_leftSide->category() == CalcNumber) 498 if (m_leftSide->category() == CalcNumber)
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 779
780 return expression ? adoptRef(new CSSCalcValue(expression, range)) : 0; 780 return expression ? adoptRef(new CSSCalcValue(expression, range)) : 0;
781 } 781 }
782 782
783 PassRefPtr<CSSCalcValue> CSSCalcValue::create(PassRefPtr<CSSCalcExpressionNode> expression, ValueRange range) 783 PassRefPtr<CSSCalcValue> CSSCalcValue::create(PassRefPtr<CSSCalcExpressionNode> expression, ValueRange range)
784 { 784 {
785 return adoptRef(new CSSCalcValue(expression, range)); 785 return adoptRef(new CSSCalcValue(expression, range));
786 } 786 }
787 787
788 } // namespace WebCore 788 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/CSSCanvasValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698