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

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

Issue 2371673002: [CSS Typed OM] Implement support for CSSValue -> CSSCalcLength (Closed)
Patch Set: sync to head Created 4 years, 2 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return false; 245 return false;
246 246
247 return compareCSSValuePtr( 247 return compareCSSValuePtr(
248 m_value, static_cast<const CSSCalcPrimitiveValue&>(other).m_value); 248 m_value, static_cast<const CSSCalcPrimitiveValue&>(other).m_value);
249 } 249 }
250 250
251 Type getType() const override { return CssCalcPrimitiveValue; } 251 Type getType() const override { return CssCalcPrimitiveValue; }
252 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override { 252 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override {
253 return m_value->typeWithCalcResolved(); 253 return m_value->typeWithCalcResolved();
254 } 254 }
255 const CSSCalcExpressionNode* leftExpressionNode() const { return nullptr; }
256
257 const CSSCalcExpressionNode* rightExpressionNode() const { return nullptr; }
258
259 CalcOperator operatorType() const { return CalcAdd; }
alancutter (OOO until 2018) 2016/10/13 22:19:05 Can these just be NOTREACHED()?
meade_UTC10 2016/11/16 19:28:21 Done.
255 260
256 DEFINE_INLINE_VIRTUAL_TRACE() { 261 DEFINE_INLINE_VIRTUAL_TRACE() {
257 visitor->trace(m_value); 262 visitor->trace(m_value);
258 CSSCalcExpressionNode::trace(visitor); 263 CSSCalcExpressionNode::trace(visitor);
259 } 264 }
260 265
261 private: 266 private:
262 CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger) 267 CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger)
263 : CSSCalcExpressionNode(unitCategory(value->typeWithCalcResolved()), 268 : CSSCalcExpressionNode(unitCategory(value->typeWithCalcResolved()),
264 isInteger), 269 isInteger),
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 return false; 549 return false;
545 550
546 const CSSCalcBinaryOperation& other = 551 const CSSCalcBinaryOperation& other =
547 static_cast<const CSSCalcBinaryOperation&>(exp); 552 static_cast<const CSSCalcBinaryOperation&>(exp);
548 return compareCSSValuePtr(m_leftSide, other.m_leftSide) && 553 return compareCSSValuePtr(m_leftSide, other.m_leftSide) &&
549 compareCSSValuePtr(m_rightSide, other.m_rightSide) && 554 compareCSSValuePtr(m_rightSide, other.m_rightSide) &&
550 m_operator == other.m_operator; 555 m_operator == other.m_operator;
551 } 556 }
552 557
553 Type getType() const override { return CssCalcBinaryOperation; } 558 Type getType() const override { return CssCalcBinaryOperation; }
559 const CSSCalcExpressionNode* leftExpressionNode() const { return m_leftSide; }
560
561 const CSSCalcExpressionNode* rightExpressionNode() const {
562 return m_rightSide;
563 }
564
565 CalcOperator operatorType() const { return m_operator; }
554 566
555 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override { 567 CSSPrimitiveValue::UnitType typeWithCalcResolved() const override {
556 switch (m_category) { 568 switch (m_category) {
557 case CalcNumber: 569 case CalcNumber:
558 ASSERT(m_leftSide->category() == CalcNumber && 570 ASSERT(m_leftSide->category() == CalcNumber &&
559 m_rightSide->category() == CalcNumber); 571 m_rightSide->category() == CalcNumber);
560 return CSSPrimitiveValue::UnitType::Number; 572 return CSSPrimitiveValue::UnitType::Number;
561 case CalcLength: 573 case CalcLength:
562 case CalcPercent: { 574 case CalcPercent: {
563 if (m_leftSide->category() == CalcNumber) 575 if (m_leftSide->category() == CalcNumber)
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 824
813 return expression ? new CSSCalcValue(expression, range) : nullptr; 825 return expression ? new CSSCalcValue(expression, range) : nullptr;
814 } 826 }
815 827
816 CSSCalcValue* CSSCalcValue::create(CSSCalcExpressionNode* expression, 828 CSSCalcValue* CSSCalcValue::create(CSSCalcExpressionNode* expression,
817 ValueRange range) { 829 ValueRange range) {
818 return new CSSCalcValue(expression, range); 830 return new CSSCalcValue(expression, range);
819 } 831 }
820 832
821 } // namespace blink 833 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698