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

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

Issue 1314783002: Made all const methods on CSSPrimitiveValue have the const keyword (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_out_quad
Patch Set: Rebase branch onto master 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
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.h ('k') | no next file » | 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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 case UnitType::PropertyID: 460 case UnitType::PropertyID:
461 case UnitType::ValueID: 461 case UnitType::ValueID:
462 break; 462 break;
463 } 463 }
464 if (m_hasCachedCSSText) { 464 if (m_hasCachedCSSText) {
465 cssTextCache().remove(this); 465 cssTextCache().remove(this);
466 m_hasCachedCSSText = false; 466 m_hasCachedCSSText = false;
467 } 467 }
468 } 468 }
469 469
470 double CSSPrimitiveValue::computeSeconds() 470 double CSSPrimitiveValue::computeSeconds() const
471 { 471 {
472 ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime )); 472 ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime ));
473 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->ty peWithCalcResolved() : type(); 473 UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->ty peWithCalcResolved() : type();
474 if (currentType == UnitType::Seconds) 474 if (currentType == UnitType::Seconds)
475 return getDoubleValue(); 475 return getDoubleValue();
476 if (currentType == UnitType::Milliseconds) 476 if (currentType == UnitType::Milliseconds)
477 return getDoubleValue() / 1000; 477 return getDoubleValue() / 1000;
478 ASSERT_NOT_REACHED(); 478 ASSERT_NOT_REACHED();
479 return 0; 479 return 0;
480 } 480 }
(...skipping 10 matching lines...) Expand all
491 case UnitType::Gradians: 491 case UnitType::Gradians:
492 return grad2deg(getDoubleValue()); 492 return grad2deg(getDoubleValue());
493 case UnitType::Turns: 493 case UnitType::Turns:
494 return turn2deg(getDoubleValue()); 494 return turn2deg(getDoubleValue());
495 default: 495 default:
496 ASSERT_NOT_REACHED(); 496 ASSERT_NOT_REACHED();
497 return 0; 497 return 0;
498 } 498 }
499 } 499 }
500 500
501 template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) 501 template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
502 { 502 {
503 return roundForImpreciseConversion<int>(computeLengthDouble(conversionData)) ; 503 return roundForImpreciseConversion<int>(computeLengthDouble(conversionData)) ;
504 } 504 }
505 505
506 template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversion Data& conversionData) 506 template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversion Data& conversionData) const
507 { 507 {
508 return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionD ata)); 508 return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionD ata));
509 } 509 }
510 510
511 template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa ta& conversionData) 511 template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa ta& conversionData) const
512 { 512 {
513 return Length(clampToCSSLengthRange(computeLengthDouble(conversionData)), Fi xed); 513 return Length(clampToCSSLengthRange(computeLengthDouble(conversionData)), Fi xed);
514 } 514 }
515 515
516 template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat a& conversionData) 516 template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat a& conversionData) const
517 { 517 {
518 return roundForImpreciseConversion<short>(computeLengthDouble(conversionData )); 518 return roundForImpreciseConversion<short>(computeLengthDouble(conversionData ));
519 } 519 }
520 520
521 template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConv ersionData& conversionData) 521 template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConv ersionData& conversionData) const
522 { 522 {
523 return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conve rsionData)); 523 return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conve rsionData));
524 } 524 }
525 525
526 template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat a& conversionData) 526 template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionDat a& conversionData) const
527 { 527 {
528 return static_cast<float>(computeLengthDouble(conversionData)); 528 return static_cast<float>(computeLengthDouble(conversionData));
529 } 529 }
530 530
531 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa ta& conversionData) 531 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionDa ta& conversionData) const
532 { 532 {
533 return computeLengthDouble(conversionData); 533 return computeLengthDouble(conversionData);
534 } 534 }
535 535
536 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c onversionData) 536 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c onversionData) const
537 { 537 {
538 // The logic in this function is duplicated in MediaValues::computeLength 538 // The logic in this function is duplicated in MediaValues::computeLength
539 // because MediaValues::computeLength needs nearly identical logic, but we h aven't found a way to make 539 // because MediaValues::computeLength needs nearly identical logic, but we h aven't found a way to make
540 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases) without hurting performance. 540 // CSSPrimitiveValue::computeLengthDouble more generic (to solve both cases) without hurting performance.
541 if (type() == UnitType::Calc) 541 if (type() == UnitType::Calc)
542 return m_value.calc->computeLengthPx(conversionData); 542 return m_value.calc->computeLengthPx(conversionData);
543 543
544 double factor; 544 double factor;
545 545
546 switch (type()) { 546 switch (type()) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 case UnitType::Kilohertz: 675 case UnitType::Kilohertz:
676 factor = 1000; 676 factor = 1000;
677 break; 677 break;
678 default: 678 default:
679 break; 679 break;
680 } 680 }
681 681
682 return factor; 682 return factor;
683 } 683 }
684 684
685 Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conve rsionData) 685 Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conve rsionData) const
686 { 686 {
687 if (isLength()) 687 if (isLength())
688 return computeLength<Length>(conversionData); 688 return computeLength<Length>(conversionData);
689 if (isPercentage()) 689 if (isPercentage())
690 return Length(getDoubleValue(), Percent); 690 return Length(getDoubleValue(), Percent);
691 ASSERT(isCalculated()); 691 ASSERT(isCalculated());
692 return Length(cssCalcValue()->toCalcValue(conversionData)); 692 return Length(cssCalcValue()->toCalcValue(conversionData));
693 } 693 }
694 694
695 double CSSPrimitiveValue::getDoubleValue() const 695 double CSSPrimitiveValue::getDoubleValue() const
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 visitor->trace(m_value.shape); 1109 visitor->trace(m_value.shape);
1110 break; 1110 break;
1111 default: 1111 default:
1112 break; 1112 break;
1113 } 1113 }
1114 #endif 1114 #endif
1115 CSSValue::traceAfterDispatch(visitor); 1115 CSSValue::traceAfterDispatch(visitor);
1116 } 1116 }
1117 1117
1118 } // namespace blink 1118 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698