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

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

Issue 2047923002: [WIP] Add support for CSSValue-> CSSLengthValue and CSSTranslation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@supported-types
Patch Set: Created 4 years, 6 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 * 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveVal ue&>(other).m_value); 253 return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveVal ue&>(other).m_value);
254 } 254 }
255 255
256 Type getType() const override { return CssCalcPrimitiveValue; } 256 Type getType() const override { return CssCalcPrimitiveValue; }
257 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override 257 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override
258 { 258 {
259 return m_value->typeWithCalcResolved(); 259 return m_value->typeWithCalcResolved();
260 } 260 }
261 261
262 const CSSCalcExpressionNode* getLHS() const
263 {
264 return nullptr;
265 }
266
267 const CSSCalcExpressionNode* getRHS() const
268 {
269 return nullptr;
270 }
271
272 CalcOperator op() const
273 {
274 return CalcAdd;
275 }
262 276
263 DEFINE_INLINE_VIRTUAL_TRACE() 277 DEFINE_INLINE_VIRTUAL_TRACE()
264 { 278 {
265 visitor->trace(m_value); 279 visitor->trace(m_value);
266 CSSCalcExpressionNode::trace(visitor); 280 CSSCalcExpressionNode::trace(visitor);
267 } 281 }
268 282
269 private: 283 private:
270 CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger) 284 CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger)
271 : CSSCalcExpressionNode(unitCategory(value->typeWithCalcResolved()), isI nteger) 285 : CSSCalcExpressionNode(unitCategory(value->typeWithCalcResolved()), isI nteger)
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 return false; 501 return false;
488 502
489 const CSSCalcBinaryOperation& other = static_cast<const CSSCalcBinaryOpe ration&>(exp); 503 const CSSCalcBinaryOperation& other = static_cast<const CSSCalcBinaryOpe ration&>(exp);
490 return compareCSSValuePtr(m_leftSide, other.m_leftSide) 504 return compareCSSValuePtr(m_leftSide, other.m_leftSide)
491 && compareCSSValuePtr(m_rightSide, other.m_rightSide) 505 && compareCSSValuePtr(m_rightSide, other.m_rightSide)
492 && m_operator == other.m_operator; 506 && m_operator == other.m_operator;
493 } 507 }
494 508
495 Type getType() const override { return CssCalcBinaryOperation; } 509 Type getType() const override { return CssCalcBinaryOperation; }
496 510
511 const CSSCalcExpressionNode* getLHS() const
512 {
513 return m_leftSide;
514 }
515
516 const CSSCalcExpressionNode* getRHS() const
517 {
518 return m_rightSide;
519 }
520
521 CalcOperator op() const
522 {
523 return m_operator;
524 }
525
497 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override 526 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override
498 { 527 {
499 switch (m_category) { 528 switch (m_category) {
500 case CalcNumber: 529 case CalcNumber:
501 ASSERT(m_leftSide->category() == CalcNumber && m_rightSide->category () == CalcNumber); 530 ASSERT(m_leftSide->category() == CalcNumber && m_rightSide->category () == CalcNumber);
502 return CSSPrimitiveValue::UnitType::Number; 531 return CSSPrimitiveValue::UnitType::Number;
503 case CalcLength: 532 case CalcLength:
504 case CalcPercent: { 533 case CalcPercent: {
505 if (m_leftSide->category() == CalcNumber) 534 if (m_leftSide->category() == CalcNumber)
506 return m_rightSide->typeWithCalcResolved(); 535 return m_rightSide->typeWithCalcResolved();
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 763
735 return expression ? new CSSCalcValue(expression, range) : nullptr; 764 return expression ? new CSSCalcValue(expression, range) : nullptr;
736 } 765 }
737 766
738 CSSCalcValue* CSSCalcValue::create(CSSCalcExpressionNode* expression, ValueRange range) 767 CSSCalcValue* CSSCalcValue::create(CSSCalcExpressionNode* expression, ValueRange range)
739 { 768 {
740 return new CSSCalcValue(expression, range); 769 return new CSSCalcValue(expression, range);
741 } 770 }
742 771
743 } // namespace blink 772 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSCalculationValue.h ('k') | third_party/WebKit/Source/core/css/cssom/CSSCalcLength.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698