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

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

Issue 2017053003: Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. 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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2015 Google Inc. All rights reserved. 3 * Copyright (C) 2015 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 visitor->trace(m_secondX); 589 visitor->trace(m_secondX);
590 visitor->trace(m_secondY); 590 visitor->trace(m_secondY);
591 visitor->trace(m_stops); 591 visitor->trace(m_stops);
592 CSSImageGeneratorValue::traceAfterDispatch(visitor); 592 CSSImageGeneratorValue::traceAfterDispatch(visitor);
593 } 593 }
594 594
595 String CSSLinearGradientValue::customCSSText() const 595 String CSSLinearGradientValue::customCSSText() const
596 { 596 {
597 StringBuilder result; 597 StringBuilder result;
598 if (m_gradientType == CSSDeprecatedLinearGradient) { 598 if (m_gradientType == CSSDeprecatedLinearGradient) {
599 result.appendLiteral("-webkit-gradient(linear, "); 599 result.append("-webkit-gradient(linear, ");
600 result.append(m_firstX->cssText()); 600 result.append(m_firstX->cssText());
601 result.append(' '); 601 result.append(' ');
602 result.append(m_firstY->cssText()); 602 result.append(m_firstY->cssText());
603 result.appendLiteral(", "); 603 result.append(", ");
604 result.append(m_secondX->cssText()); 604 result.append(m_secondX->cssText());
605 result.append(' '); 605 result.append(' ');
606 result.append(m_secondY->cssText()); 606 result.append(m_secondY->cssText());
607 appendCSSTextForDeprecatedColorStops(result); 607 appendCSSTextForDeprecatedColorStops(result);
608 } else if (m_gradientType == CSSPrefixedLinearGradient) { 608 } else if (m_gradientType == CSSPrefixedLinearGradient) {
609 if (m_repeating) 609 if (m_repeating)
610 result.appendLiteral("-webkit-repeating-linear-gradient("); 610 result.append("-webkit-repeating-linear-gradient(");
611 else 611 else
612 result.appendLiteral("-webkit-linear-gradient("); 612 result.append("-webkit-linear-gradient(");
613 613
614 if (m_angle) 614 if (m_angle)
615 result.append(m_angle->cssText()); 615 result.append(m_angle->cssText());
616 else { 616 else {
617 if (m_firstX && m_firstY) { 617 if (m_firstX && m_firstY) {
618 result.append(m_firstX->cssText()); 618 result.append(m_firstX->cssText());
619 result.append(' '); 619 result.append(' ');
620 result.append(m_firstY->cssText()); 620 result.append(m_firstY->cssText());
621 } else if (m_firstX || m_firstY) { 621 } else if (m_firstX || m_firstY) {
622 if (m_firstX) 622 if (m_firstX)
623 result.append(m_firstX->cssText()); 623 result.append(m_firstX->cssText());
624 624
625 if (m_firstY) 625 if (m_firstY)
626 result.append(m_firstY->cssText()); 626 result.append(m_firstY->cssText());
627 } 627 }
628 } 628 }
629 629
630 for (unsigned i = 0; i < m_stops.size(); i++) { 630 for (unsigned i = 0; i < m_stops.size(); i++) {
631 const CSSGradientColorStop& stop = m_stops[i]; 631 const CSSGradientColorStop& stop = m_stops[i];
632 result.appendLiteral(", "); 632 result.append(", ");
633 result.append(stop.m_color->cssText()); 633 result.append(stop.m_color->cssText());
634 if (stop.m_position) { 634 if (stop.m_position) {
635 result.append(' '); 635 result.append(' ');
636 result.append(stop.m_position->cssText()); 636 result.append(stop.m_position->cssText());
637 } 637 }
638 } 638 }
639 } else { 639 } else {
640 if (m_repeating) 640 if (m_repeating)
641 result.appendLiteral("repeating-linear-gradient("); 641 result.append("repeating-linear-gradient(");
642 else 642 else
643 result.appendLiteral("linear-gradient("); 643 result.append("linear-gradient(");
644 644
645 bool wroteSomething = false; 645 bool wroteSomething = false;
646 646
647 if (m_angle && m_angle->computeDegrees() != 180) { 647 if (m_angle && m_angle->computeDegrees() != 180) {
648 result.append(m_angle->cssText()); 648 result.append(m_angle->cssText());
649 wroteSomething = true; 649 wroteSomething = true;
650 } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && m_firstY ->isPrimitiveValue() && toCSSPrimitiveValue(m_firstY.get())->getValueID() == CSS ValueBottom)) { 650 } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && m_firstY ->isPrimitiveValue() && toCSSPrimitiveValue(m_firstY.get())->getValueID() == CSS ValueBottom)) {
651 result.appendLiteral("to "); 651 result.append("to ");
652 if (m_firstX && m_firstY) { 652 if (m_firstX && m_firstY) {
653 result.append(m_firstX->cssText()); 653 result.append(m_firstX->cssText());
654 result.append(' '); 654 result.append(' ');
655 result.append(m_firstY->cssText()); 655 result.append(m_firstY->cssText());
656 } else if (m_firstX) 656 } else if (m_firstX)
657 result.append(m_firstX->cssText()); 657 result.append(m_firstX->cssText());
658 else 658 else
659 result.append(m_firstY->cssText()); 659 result.append(m_firstY->cssText());
660 wroteSomething = true; 660 wroteSomething = true;
661 } 661 }
662 662
663 if (wroteSomething) 663 if (wroteSomething)
664 result.appendLiteral(", "); 664 result.append(", ");
665 665
666 for (unsigned i = 0; i < m_stops.size(); i++) { 666 for (unsigned i = 0; i < m_stops.size(); i++) {
667 const CSSGradientColorStop& stop = m_stops[i]; 667 const CSSGradientColorStop& stop = m_stops[i];
668 if (i) 668 if (i)
669 result.appendLiteral(", "); 669 result.append(", ");
670 if (stop.m_color) 670 if (stop.m_color)
671 result.append(stop.m_color->cssText()); 671 result.append(stop.m_color->cssText());
672 if (stop.m_color && stop.m_position) 672 if (stop.m_color && stop.m_position)
673 result.append(' '); 673 result.append(' ');
674 if (stop.m_position) 674 if (stop.m_position)
675 result.append(stop.m_position->cssText()); 675 result.append(stop.m_position->cssText());
676 } 676 }
677 677
678 } 678 }
679 679
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) 851 DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue)
852 { 852 {
853 visitor->trace(m_angle); 853 visitor->trace(m_angle);
854 CSSGradientValue::traceAfterDispatch(visitor); 854 CSSGradientValue::traceAfterDispatch(visitor);
855 } 855 }
856 856
857 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder & result) const 857 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder & result) const
858 { 858 {
859 for (unsigned i = 0; i < m_stops.size(); i++) { 859 for (unsigned i = 0; i < m_stops.size(); i++) {
860 const CSSGradientColorStop& stop = m_stops[i]; 860 const CSSGradientColorStop& stop = m_stops[i];
861 result.appendLiteral(", "); 861 result.append(", ");
862 if (stop.m_position->getDoubleValue() == 0) { 862 if (stop.m_position->getDoubleValue() == 0) {
863 result.appendLiteral("from("); 863 result.append("from(");
864 result.append(stop.m_color->cssText()); 864 result.append(stop.m_color->cssText());
865 result.append(')'); 865 result.append(')');
866 } else if (stop.m_position->getDoubleValue() == 1) { 866 } else if (stop.m_position->getDoubleValue() == 1) {
867 result.appendLiteral("to("); 867 result.append("to(");
868 result.append(stop.m_color->cssText()); 868 result.append(stop.m_color->cssText());
869 result.append(')'); 869 result.append(')');
870 } else { 870 } else {
871 result.appendLiteral("color-stop("); 871 result.append("color-stop(");
872 result.appendNumber(stop.m_position->getDoubleValue()); 872 result.appendNumber(stop.m_position->getDoubleValue());
873 result.appendLiteral(", "); 873 result.append(", ");
874 result.append(stop.m_color->cssText()); 874 result.append(stop.m_color->cssText());
875 result.append(')'); 875 result.append(')');
876 } 876 }
877 } 877 }
878 } 878 }
879 879
880 String CSSRadialGradientValue::customCSSText() const 880 String CSSRadialGradientValue::customCSSText() const
881 { 881 {
882 StringBuilder result; 882 StringBuilder result;
883 883
884 if (m_gradientType == CSSDeprecatedRadialGradient) { 884 if (m_gradientType == CSSDeprecatedRadialGradient) {
885 result.appendLiteral("-webkit-gradient(radial, "); 885 result.append("-webkit-gradient(radial, ");
886 result.append(m_firstX->cssText()); 886 result.append(m_firstX->cssText());
887 result.append(' '); 887 result.append(' ');
888 result.append(m_firstY->cssText()); 888 result.append(m_firstY->cssText());
889 result.appendLiteral(", "); 889 result.append(", ");
890 result.append(m_firstRadius->cssText()); 890 result.append(m_firstRadius->cssText());
891 result.appendLiteral(", "); 891 result.append(", ");
892 result.append(m_secondX->cssText()); 892 result.append(m_secondX->cssText());
893 result.append(' '); 893 result.append(' ');
894 result.append(m_secondY->cssText()); 894 result.append(m_secondY->cssText());
895 result.appendLiteral(", "); 895 result.append(", ");
896 result.append(m_secondRadius->cssText()); 896 result.append(m_secondRadius->cssText());
897 appendCSSTextForDeprecatedColorStops(result); 897 appendCSSTextForDeprecatedColorStops(result);
898 } else if (m_gradientType == CSSPrefixedRadialGradient) { 898 } else if (m_gradientType == CSSPrefixedRadialGradient) {
899 if (m_repeating) 899 if (m_repeating)
900 result.appendLiteral("-webkit-repeating-radial-gradient("); 900 result.append("-webkit-repeating-radial-gradient(");
901 else 901 else
902 result.appendLiteral("-webkit-radial-gradient("); 902 result.append("-webkit-radial-gradient(");
903 903
904 if (m_firstX && m_firstY) { 904 if (m_firstX && m_firstY) {
905 result.append(m_firstX->cssText()); 905 result.append(m_firstX->cssText());
906 result.append(' '); 906 result.append(' ');
907 result.append(m_firstY->cssText()); 907 result.append(m_firstY->cssText());
908 } else if (m_firstX) 908 } else if (m_firstX)
909 result.append(m_firstX->cssText()); 909 result.append(m_firstX->cssText());
910 else if (m_firstY) 910 else if (m_firstY)
911 result.append(m_firstY->cssText()); 911 result.append(m_firstY->cssText());
912 else 912 else
913 result.appendLiteral("center"); 913 result.append("center");
914 914
915 if (m_shape || m_sizingBehavior) { 915 if (m_shape || m_sizingBehavior) {
916 result.appendLiteral(", "); 916 result.append(", ");
917 if (m_shape) { 917 if (m_shape) {
918 result.append(m_shape->cssText()); 918 result.append(m_shape->cssText());
919 result.append(' '); 919 result.append(' ');
920 } else 920 } else {
921 result.appendLiteral("ellipse "); 921 result.append("ellipse ");
922 }
922 923
923 if (m_sizingBehavior) 924 if (m_sizingBehavior)
924 result.append(m_sizingBehavior->cssText()); 925 result.append(m_sizingBehavior->cssText());
925 else 926 else
926 result.appendLiteral("cover"); 927 result.append("cover");
927 928
928 } else if (m_endHorizontalSize && m_endVerticalSize) { 929 } else if (m_endHorizontalSize && m_endVerticalSize) {
929 result.appendLiteral(", "); 930 result.append(", ");
930 result.append(m_endHorizontalSize->cssText()); 931 result.append(m_endHorizontalSize->cssText());
931 result.append(' '); 932 result.append(' ');
932 result.append(m_endVerticalSize->cssText()); 933 result.append(m_endVerticalSize->cssText());
933 } 934 }
934 935
935 for (unsigned i = 0; i < m_stops.size(); i++) { 936 for (unsigned i = 0; i < m_stops.size(); i++) {
936 const CSSGradientColorStop& stop = m_stops[i]; 937 const CSSGradientColorStop& stop = m_stops[i];
937 result.appendLiteral(", "); 938 result.append(", ");
938 result.append(stop.m_color->cssText()); 939 result.append(stop.m_color->cssText());
939 if (stop.m_position) { 940 if (stop.m_position) {
940 result.append(' '); 941 result.append(' ');
941 result.append(stop.m_position->cssText()); 942 result.append(stop.m_position->cssText());
942 } 943 }
943 } 944 }
944 } else { 945 } else {
945 if (m_repeating) 946 if (m_repeating)
946 result.appendLiteral("repeating-radial-gradient("); 947 result.append("repeating-radial-gradient(");
947 else 948 else
948 result.appendLiteral("radial-gradient("); 949 result.append("radial-gradient(");
949 950
950 bool wroteSomething = false; 951 bool wroteSomething = false;
951 952
952 // The only ambiguous case that needs an explicit shape to be provided 953 // The only ambiguous case that needs an explicit shape to be provided
953 // is when a sizing keyword is used (or all sizing is omitted). 954 // is when a sizing keyword is used (or all sizing is omitted).
954 if (m_shape && m_shape->getValueID() != CSSValueEllipse && (m_sizingBeha vior || (!m_sizingBehavior && !m_endHorizontalSize))) { 955 if (m_shape && m_shape->getValueID() != CSSValueEllipse && (m_sizingBeha vior || (!m_sizingBehavior && !m_endHorizontalSize))) {
955 result.appendLiteral("circle"); 956 result.append("circle");
956 wroteSomething = true; 957 wroteSomething = true;
957 } 958 }
958 959
959 if (m_sizingBehavior && m_sizingBehavior->getValueID() != CSSValueFarthe stCorner) { 960 if (m_sizingBehavior && m_sizingBehavior->getValueID() != CSSValueFarthe stCorner) {
960 if (wroteSomething) 961 if (wroteSomething)
961 result.append(' '); 962 result.append(' ');
962 result.append(m_sizingBehavior->cssText()); 963 result.append(m_sizingBehavior->cssText());
963 wroteSomething = true; 964 wroteSomething = true;
964 } else if (m_endHorizontalSize) { 965 } else if (m_endHorizontalSize) {
965 if (wroteSomething) 966 if (wroteSomething)
966 result.append(' '); 967 result.append(' ');
967 result.append(m_endHorizontalSize->cssText()); 968 result.append(m_endHorizontalSize->cssText());
968 if (m_endVerticalSize) { 969 if (m_endVerticalSize) {
969 result.append(' '); 970 result.append(' ');
970 result.append(m_endVerticalSize->cssText()); 971 result.append(m_endVerticalSize->cssText());
971 } 972 }
972 wroteSomething = true; 973 wroteSomething = true;
973 } 974 }
974 975
975 if (m_firstX || m_firstY) { 976 if (m_firstX || m_firstY) {
976 if (wroteSomething) 977 if (wroteSomething)
977 result.append(' '); 978 result.append(' ');
978 result.appendLiteral("at "); 979 result.append("at ");
979 if (m_firstX && m_firstY) { 980 if (m_firstX && m_firstY) {
980 result.append(m_firstX->cssText()); 981 result.append(m_firstX->cssText());
981 result.append(' '); 982 result.append(' ');
982 result.append(m_firstY->cssText()); 983 result.append(m_firstY->cssText());
983 } else if (m_firstX) 984 } else if (m_firstX)
984 result.append(m_firstX->cssText()); 985 result.append(m_firstX->cssText());
985 else 986 else
986 result.append(m_firstY->cssText()); 987 result.append(m_firstY->cssText());
987 wroteSomething = true; 988 wroteSomething = true;
988 } 989 }
989 990
990 if (wroteSomething) 991 if (wroteSomething)
991 result.appendLiteral(", "); 992 result.append(", ");
992 993
993 for (unsigned i = 0; i < m_stops.size(); i++) { 994 for (unsigned i = 0; i < m_stops.size(); i++) {
994 const CSSGradientColorStop& stop = m_stops[i]; 995 const CSSGradientColorStop& stop = m_stops[i];
995 if (i) 996 if (i)
996 result.appendLiteral(", "); 997 result.append(", ");
997 if (stop.m_color) 998 if (stop.m_color)
998 result.append(stop.m_color->cssText()); 999 result.append(stop.m_color->cssText());
999 if (stop.m_color && stop.m_position) 1000 if (stop.m_color && stop.m_position)
1000 result.append(' '); 1001 result.append(' ');
1001 if (stop.m_position) 1002 if (stop.m_position)
1002 result.append(stop.m_position->cssText()); 1003 result.append(stop.m_position->cssText());
1003 } 1004 }
1004 1005
1005 } 1006 }
1006 1007
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 visitor->trace(m_firstRadius); 1217 visitor->trace(m_firstRadius);
1217 visitor->trace(m_secondRadius); 1218 visitor->trace(m_secondRadius);
1218 visitor->trace(m_shape); 1219 visitor->trace(m_shape);
1219 visitor->trace(m_sizingBehavior); 1220 visitor->trace(m_sizingBehavior);
1220 visitor->trace(m_endHorizontalSize); 1221 visitor->trace(m_endHorizontalSize);
1221 visitor->trace(m_endVerticalSize); 1222 visitor->trace(m_endVerticalSize);
1222 CSSGradientValue::traceAfterDispatch(visitor); 1223 CSSGradientValue::traceAfterDispatch(visitor);
1223 } 1224 }
1224 1225
1225 } // namespace blink 1226 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSFontFeatureValue.cpp ('k') | third_party/WebKit/Source/core/css/CSSGroupingRule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698