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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/css/CSSCanvasValue.cpp » ('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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 public: 185 public:
186 186
187 static PassRefPtrWillBeRawPtr<CSSCalcPrimitiveValue> create(PassRefPtrWillBe RawPtr<CSSPrimitiveValue> value, bool isInteger) 187 static PassRefPtrWillBeRawPtr<CSSCalcPrimitiveValue> create(PassRefPtrWillBe RawPtr<CSSPrimitiveValue> value, bool isInteger)
188 { 188 {
189 return adoptRefWillBeNoop(new CSSCalcPrimitiveValue(value, isInteger)); 189 return adoptRefWillBeNoop(new CSSCalcPrimitiveValue(value, isInteger));
190 } 190 }
191 191
192 static PassRefPtrWillBeRawPtr<CSSCalcPrimitiveValue> create(double value, CS SPrimitiveValue::UnitTypes type, bool isInteger) 192 static PassRefPtrWillBeRawPtr<CSSCalcPrimitiveValue> create(double value, CS SPrimitiveValue::UnitTypes type, bool isInteger)
193 { 193 {
194 if (std::isnan(value) || std::isinf(value)) 194 if (std::isnan(value) || std::isinf(value))
195 return 0; 195 return nullptr;
196 return adoptRefWillBeNoop(new CSSCalcPrimitiveValue(CSSPrimitiveValue::c reate(value, type).get(), isInteger)); 196 return adoptRefWillBeNoop(new CSSCalcPrimitiveValue(CSSPrimitiveValue::c reate(value, type).get(), isInteger));
197 } 197 }
198 198
199 virtual bool isZero() const OVERRIDE 199 virtual bool isZero() const OVERRIDE
200 { 200 {
201 return !m_value->getDoubleValue(); 201 return !m_value->getDoubleValue();
202 } 202 }
203 203
204 virtual String customCSSText() const OVERRIDE 204 virtual String customCSSText() const OVERRIDE
205 { 205 {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 326 }
327 327
328 class CSSCalcBinaryOperation FINAL : public CSSCalcExpressionNode { 328 class CSSCalcBinaryOperation FINAL : public CSSCalcExpressionNode {
329 public: 329 public:
330 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> create(PassRefPtrWillBe RawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalcExpression Node> rightSide, CalcOperator op) 330 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> create(PassRefPtrWillBe RawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalcExpression Node> rightSide, CalcOperator op)
331 { 331 {
332 ASSERT(leftSide->category() != CalcOther && rightSide->category() != Cal cOther); 332 ASSERT(leftSide->category() != CalcOther && rightSide->category() != Cal cOther);
333 333
334 CalculationCategory newCategory = determineCategory(*leftSide, *rightSid e, op); 334 CalculationCategory newCategory = determineCategory(*leftSide, *rightSid e, op);
335 if (newCategory == CalcOther) 335 if (newCategory == CalcOther)
336 return 0; 336 return nullptr;
337 337
338 return adoptRefWillBeNoop(new CSSCalcBinaryOperation(leftSide, rightSide , op, newCategory)); 338 return adoptRefWillBeNoop(new CSSCalcBinaryOperation(leftSide, rightSide , op, newCategory));
339 } 339 }
340 340
341 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createSimplified(PassRe fPtrWillBeRawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalc ExpressionNode> rightSide, CalcOperator op) 341 static PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> createSimplified(PassRe fPtrWillBeRawPtr<CSSCalcExpressionNode> leftSide, PassRefPtrWillBeRawPtr<CSSCalc ExpressionNode> rightSide, CalcOperator op)
342 { 342 {
343 CalculationCategory leftCategory = leftSide->category(); 343 CalculationCategory leftCategory = leftSide->category();
344 CalculationCategory rightCategory = rightSide->category(); 344 CalculationCategory rightCategory = rightSide->category();
345 ASSERT(leftCategory != CalcOther && rightCategory != CalcOther); 345 ASSERT(leftCategory != CalcOther && rightCategory != CalcOther);
346 346
(...skipping 24 matching lines...) Expand all
371 } 371 }
372 } 372 }
373 } 373 }
374 } else { 374 } else {
375 // Simplify multiplying or dividing by a number for simplifiable typ es. 375 // Simplify multiplying or dividing by a number for simplifiable typ es.
376 ASSERT(op == CalcMultiply || op == CalcDivide); 376 ASSERT(op == CalcMultiply || op == CalcDivide);
377 CSSCalcExpressionNode* numberSide = getNumberSide(leftSide.get(), ri ghtSide.get()); 377 CSSCalcExpressionNode* numberSide = getNumberSide(leftSide.get(), ri ghtSide.get());
378 if (!numberSide) 378 if (!numberSide)
379 return create(leftSide, rightSide, op); 379 return create(leftSide, rightSide, op);
380 if (numberSide == leftSide && op == CalcDivide) 380 if (numberSide == leftSide && op == CalcDivide)
381 return 0; 381 return nullptr;
382 CSSCalcExpressionNode* otherSide = leftSide == numberSide ? rightSid e.get() : leftSide.get(); 382 CSSCalcExpressionNode* otherSide = leftSide == numberSide ? rightSid e.get() : leftSide.get();
383 383
384 double number = numberSide->doubleValue(); 384 double number = numberSide->doubleValue();
385 if (std::isnan(number) || std::isinf(number)) 385 if (std::isnan(number) || std::isinf(number))
386 return 0; 386 return nullptr;
387 if (op == CalcDivide && !number) 387 if (op == CalcDivide && !number)
388 return 0; 388 return nullptr;
389 389
390 CSSPrimitiveValue::UnitTypes otherType = otherSide->primitiveType(); 390 CSSPrimitiveValue::UnitTypes otherType = otherSide->primitiveType();
391 if (hasDoubleValue(otherType)) 391 if (hasDoubleValue(otherType))
392 return CSSCalcPrimitiveValue::create(evaluateOperator(otherSide- >doubleValue(), number, op), otherType, isInteger); 392 return CSSCalcPrimitiveValue::create(evaluateOperator(otherSide- >doubleValue(), number, op), otherType, isInteger);
393 } 393 }
394 394
395 return create(leftSide, rightSide, op); 395 return create(leftSide, rightSide, op);
396 } 396 }
397 397
398 virtual bool isZero() const OVERRIDE 398 virtual bool isZero() const OVERRIDE
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 class CSSCalcExpressionNodeParser { 548 class CSSCalcExpressionNodeParser {
549 DISALLOW_ALLOCATION(); // Is only ever stack allocated. 549 DISALLOW_ALLOCATION(); // Is only ever stack allocated.
550 public: 550 public:
551 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> parseCalc(CSSParserValueList* tokens) 551 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> parseCalc(CSSParserValueList* tokens)
552 { 552 {
553 unsigned index = 0; 553 unsigned index = 0;
554 Value result; 554 Value result;
555 bool ok = parseValueExpression(tokens, 0, &index, &result); 555 bool ok = parseValueExpression(tokens, 0, &index, &result);
556 ASSERT_WITH_SECURITY_IMPLICATION(index <= tokens->size()); 556 ASSERT_WITH_SECURITY_IMPLICATION(index <= tokens->size());
557 if (!ok || index != tokens->size()) 557 if (!ok || index != tokens->size())
558 return 0; 558 return nullptr;
559 return result.value; 559 return result.value;
560 } 560 }
561 561
562 private: 562 private:
563 struct Value { 563 struct Value {
564 DISALLOW_ALLOCATION(); // Is only ever stack allocated. 564 DISALLOW_ALLOCATION(); // Is only ever stack allocated.
565 public: 565 public:
566 RefPtrWillBeRawPtr<CSSCalcExpressionNode> value; 566 RefPtrWillBeRawPtr<CSSCalcExpressionNode> value;
567 }; 567 };
568 568
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 createExpressionNode(CSSPrimitiveValue::create(1 - progress, CSS PrimitiveValue::CSS_NUMBER), isInteger), 706 createExpressionNode(CSSPrimitiveValue::create(1 - progress, CSS PrimitiveValue::CSS_NUMBER), isInteger),
707 CalcMultiply), 707 CalcMultiply),
708 createExpressionNode( 708 createExpressionNode(
709 createExpressionNode(blendNode->to(), zoom), 709 createExpressionNode(blendNode->to(), zoom),
710 createExpressionNode(CSSPrimitiveValue::create(progress, CSSPrim itiveValue::CSS_NUMBER), isInteger), 710 createExpressionNode(CSSPrimitiveValue::create(progress, CSSPrim itiveValue::CSS_NUMBER), isInteger),
711 CalcMultiply), 711 CalcMultiply),
712 CalcAdd); 712 CalcAdd);
713 } 713 }
714 case CalcExpressionNodeUndefined: 714 case CalcExpressionNodeUndefined:
715 ASSERT_NOT_REACHED(); 715 ASSERT_NOT_REACHED();
716 return 0; 716 return nullptr;
717 } 717 }
718 ASSERT_NOT_REACHED(); 718 ASSERT_NOT_REACHED();
719 return 0; 719 return nullptr;
720 } 720 }
721 721
722 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> CSSCalcValue::createExpressionNode (const Length& length, float zoom) 722 PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> CSSCalcValue::createExpressionNode (const Length& length, float zoom)
723 { 723 {
724 switch (length.type()) { 724 switch (length.type()) {
725 case Percent: 725 case Percent:
726 case Fixed: 726 case Fixed:
727 return createExpressionNode(CSSPrimitiveValue::create(length, zoom), len gth.value() == trunc(length.value())); 727 return createExpressionNode(CSSPrimitiveValue::create(length, zoom), len gth.value() == trunc(length.value()));
728 case Calculated: 728 case Calculated:
729 return createExpressionNode(length.calculationValue()->expression(), zoo m); 729 return createExpressionNode(length.calculationValue()->expression(), zoo m);
730 case Auto: 730 case Auto:
731 case Intrinsic: 731 case Intrinsic:
732 case MinIntrinsic: 732 case MinIntrinsic:
733 case MinContent: 733 case MinContent:
734 case MaxContent: 734 case MaxContent:
735 case FillAvailable: 735 case FillAvailable:
736 case FitContent: 736 case FitContent:
737 case ExtendToZoom: 737 case ExtendToZoom:
738 case DeviceWidth: 738 case DeviceWidth:
739 case DeviceHeight: 739 case DeviceHeight:
740 case Undefined: 740 case Undefined:
741 ASSERT_NOT_REACHED(); 741 ASSERT_NOT_REACHED();
742 return 0; 742 return nullptr;
743 } 743 }
744 ASSERT_NOT_REACHED(); 744 ASSERT_NOT_REACHED();
745 return 0; 745 return nullptr;
746 } 746 }
747 747
748 PassRefPtrWillBeRawPtr<CSSCalcValue> CSSCalcValue::create(CSSParserString name, CSSParserValueList* parserValueList, ValueRange range) 748 PassRefPtrWillBeRawPtr<CSSCalcValue> CSSCalcValue::create(CSSParserString name, CSSParserValueList* parserValueList, ValueRange range)
749 { 749 {
750 CSSCalcExpressionNodeParser parser; 750 CSSCalcExpressionNodeParser parser;
751 RefPtrWillBeRawPtr<CSSCalcExpressionNode> expression; 751 RefPtrWillBeRawPtr<CSSCalcExpressionNode> expression;
752 752
753 if (equalIgnoringCase(name, "calc(") || equalIgnoringCase(name, "-webkit-cal c(")) 753 if (equalIgnoringCase(name, "calc(") || equalIgnoringCase(name, "-webkit-cal c("))
754 expression = parser.parseCalc(parserValueList); 754 expression = parser.parseCalc(parserValueList);
755 // FIXME calc (http://webkit.org/b/16662) Add parsing for min and max here 755 // FIXME calc (http://webkit.org/b/16662) Add parsing for min and max here
756 756
757 return expression ? adoptRefCountedWillBeRefCountedGarbageCollected(new CSSC alcValue(expression, range)) : 0; 757 return expression ? adoptRefCountedWillBeRefCountedGarbageCollected(new CSSC alcValue(expression, range)) : nullptr;
758 } 758 }
759 759
760 PassRefPtrWillBeRawPtr<CSSCalcValue> CSSCalcValue::create(PassRefPtrWillBeRawPtr <CSSCalcExpressionNode> expression, ValueRange range) 760 PassRefPtrWillBeRawPtr<CSSCalcValue> CSSCalcValue::create(PassRefPtrWillBeRawPtr <CSSCalcExpressionNode> expression, ValueRange range)
761 { 761 {
762 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSCalcValue(expr ession, range)); 762 return adoptRefCountedWillBeRefCountedGarbageCollected(new CSSCalcValue(expr ession, range));
763 } 763 }
764 764
765 void CSSCalcValue::traceAfterDispatch(Visitor* visitor) 765 void CSSCalcValue::traceAfterDispatch(Visitor* visitor)
766 { 766 {
767 visitor->trace(m_expression); 767 visitor->trace(m_expression);
768 CSSValue::traceAfterDispatch(visitor); 768 CSSValue::traceAfterDispatch(visitor);
769 } 769 }
770 770
771 } // namespace WebCore 771 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/BasicShapeFunctions.cpp ('k') | Source/core/css/CSSCanvasValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698