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

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

Issue 2097383002: Added support of calc() for SVGLength (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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 * (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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 case CalcNumber: 172 case CalcNumber:
173 return UnitType::Number; 173 return UnitType::Number;
174 case CalcPercent: 174 case CalcPercent:
175 return UnitType::Percentage; 175 return UnitType::Percentage;
176 case CalcLength: 176 case CalcLength:
177 return UnitType::Pixels; 177 return UnitType::Pixels;
178 case CalcPercentNumber: 178 case CalcPercentNumber:
179 return UnitType::CalcPercentageWithNumber; 179 return UnitType::CalcPercentageWithNumber;
180 case CalcPercentLength: 180 case CalcPercentLength:
181 return UnitType::CalcPercentageWithLength; 181 return UnitType::CalcPercentageWithLength;
182 case CalcLengthNumber:
183 return UnitType::CalcLengthWithNumber;
184 case CalcPercentLengthNumber:
185 return UnitType::CalcPercentageWithLengthAndNumber;
182 case CalcTime: 186 case CalcTime:
183 return UnitType::Milliseconds; 187 return UnitType::Milliseconds;
184 case CalcOther: 188 case CalcOther:
185 return UnitType::Unknown; 189 return UnitType::Unknown;
186 } 190 }
187 return UnitType::Unknown; 191 return UnitType::Unknown;
188 } 192 }
189 193
190 static const AtomicString& valueName(CSSValueID valueID) 194 static const AtomicString& valueName(CSSValueID valueID)
191 { 195 {
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 return "vh"; 642 return "vh";
639 case UnitType::ViewportMin: 643 case UnitType::ViewportMin:
640 return "vmin"; 644 return "vmin";
641 case UnitType::ViewportMax: 645 case UnitType::ViewportMax:
642 return "vmax"; 646 return "vmax";
643 case UnitType::Unknown: 647 case UnitType::Unknown:
644 case UnitType::ValueID: 648 case UnitType::ValueID:
645 case UnitType::Calc: 649 case UnitType::Calc:
646 case UnitType::CalcPercentageWithNumber: 650 case UnitType::CalcPercentageWithNumber:
647 case UnitType::CalcPercentageWithLength: 651 case UnitType::CalcPercentageWithLength:
652 case UnitType::CalcLengthWithNumber:
653 case UnitType::CalcPercentageWithLengthAndNumber:
648 break; 654 break;
649 }; 655 };
650 ASSERT_NOT_REACHED(); 656 ASSERT_NOT_REACHED();
651 return ""; 657 return "";
652 } 658 }
653 659
654 String CSSPrimitiveValue::customCSSText() const 660 String CSSPrimitiveValue::customCSSText() const
655 { 661 {
656 if (m_hasCachedCSSText) { 662 if (m_hasCachedCSSText) {
657 ASSERT(cssTextCache().contains(this)); 663 ASSERT(cssTextCache().contains(this));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 text = formatNumber(m_value.num, unitTypeToString(type())); 705 text = formatNumber(m_value.num, unitTypeToString(type()));
700 break; 706 break;
701 case UnitType::ValueID: 707 case UnitType::ValueID:
702 text = valueName(m_value.valueID); 708 text = valueName(m_value.valueID);
703 break; 709 break;
704 case UnitType::Calc: 710 case UnitType::Calc:
705 text = m_value.calc->customCSSText(); 711 text = m_value.calc->customCSSText();
706 break; 712 break;
707 case UnitType::CalcPercentageWithNumber: 713 case UnitType::CalcPercentageWithNumber:
708 case UnitType::CalcPercentageWithLength: 714 case UnitType::CalcPercentageWithLength:
715 case UnitType::CalcLengthWithNumber:
716 case UnitType::CalcPercentageWithLengthAndNumber:
709 ASSERT_NOT_REACHED(); 717 ASSERT_NOT_REACHED();
710 break; 718 break;
711 } 719 }
712 720
713 ASSERT(!cssTextCache().contains(this)); 721 ASSERT(!cssTextCache().contains(this));
714 cssTextCache().set(this, text); 722 cssTextCache().set(this, text);
715 m_hasCachedCSSText = true; 723 m_hasCachedCSSText = true;
716 return text; 724 return text;
717 } 725 }
718 726
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 case UnitType::ViewportMax: 762 case UnitType::ViewportMax:
755 case UnitType::Fraction: 763 case UnitType::Fraction:
756 return m_value.num == other.m_value.num; 764 return m_value.num == other.m_value.num;
757 case UnitType::ValueID: 765 case UnitType::ValueID:
758 return m_value.valueID == other.m_value.valueID; 766 return m_value.valueID == other.m_value.valueID;
759 case UnitType::Calc: 767 case UnitType::Calc:
760 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc); 768 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc);
761 case UnitType::Chs: 769 case UnitType::Chs:
762 case UnitType::CalcPercentageWithNumber: 770 case UnitType::CalcPercentageWithNumber:
763 case UnitType::CalcPercentageWithLength: 771 case UnitType::CalcPercentageWithLength:
772 case UnitType::CalcLengthWithNumber:
773 case UnitType::CalcPercentageWithLengthAndNumber:
764 case UnitType::QuirkyEms: 774 case UnitType::QuirkyEms:
765 return false; 775 return false;
766 } 776 }
767 return false; 777 return false;
768 } 778 }
769 779
770 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) 780 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue)
771 { 781 {
772 switch (type()) { 782 switch (type()) {
773 case UnitType::Calc: 783 case UnitType::Calc:
774 visitor->trace(m_value.calc); 784 visitor->trace(m_value.calc);
775 break; 785 break;
776 default: 786 default:
777 break; 787 break;
778 } 788 }
779 CSSValue::traceAfterDispatch(visitor); 789 CSSValue::traceAfterDispatch(visitor);
780 } 790 }
781 791
782 } // namespace blink 792 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698