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

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

Issue 2017303002: Revert of Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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) 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.append("-webkit-gradient(linear, "); 599 result.appendLiteral("-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.append(", "); 603 result.appendLiteral(", ");
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.append("-webkit-repeating-linear-gradient("); 610 result.appendLiteral("-webkit-repeating-linear-gradient(");
611 else 611 else
612 result.append("-webkit-linear-gradient("); 612 result.appendLiteral("-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.append(", "); 632 result.appendLiteral(", ");
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.append("repeating-linear-gradient("); 641 result.appendLiteral("repeating-linear-gradient(");
642 else 642 else
643 result.append("linear-gradient("); 643 result.appendLiteral("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.append("to "); 651 result.appendLiteral("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.append(", "); 664 result.appendLiteral(", ");
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.append(", "); 669 result.appendLiteral(", ");
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.append(", "); 861 result.appendLiteral(", ");
862 if (stop.m_position->getDoubleValue() == 0) { 862 if (stop.m_position->getDoubleValue() == 0) {
863 result.append("from("); 863 result.appendLiteral("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.append("to("); 867 result.appendLiteral("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.append("color-stop("); 871 result.appendLiteral("color-stop(");
872 result.appendNumber(stop.m_position->getDoubleValue()); 872 result.appendNumber(stop.m_position->getDoubleValue());
873 result.append(", "); 873 result.appendLiteral(", ");
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.append("-webkit-gradient(radial, "); 885 result.appendLiteral("-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.append(", "); 889 result.appendLiteral(", ");
890 result.append(m_firstRadius->cssText()); 890 result.append(m_firstRadius->cssText());
891 result.append(", "); 891 result.appendLiteral(", ");
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.append(", "); 895 result.appendLiteral(", ");
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.append("-webkit-repeating-radial-gradient("); 900 result.appendLiteral("-webkit-repeating-radial-gradient(");
901 else 901 else
902 result.append("-webkit-radial-gradient("); 902 result.appendLiteral("-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.append("center"); 913 result.appendLiteral("center");
914 914
915 if (m_shape || m_sizingBehavior) { 915 if (m_shape || m_sizingBehavior) {
916 result.append(", "); 916 result.appendLiteral(", ");
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.append("ellipse "); 921 result.appendLiteral("ellipse ");
922 }
923 922
924 if (m_sizingBehavior) 923 if (m_sizingBehavior)
925 result.append(m_sizingBehavior->cssText()); 924 result.append(m_sizingBehavior->cssText());
926 else 925 else
927 result.append("cover"); 926 result.appendLiteral("cover");
928 927
929 } else if (m_endHorizontalSize && m_endVerticalSize) { 928 } else if (m_endHorizontalSize && m_endVerticalSize) {
930 result.append(", "); 929 result.appendLiteral(", ");
931 result.append(m_endHorizontalSize->cssText()); 930 result.append(m_endHorizontalSize->cssText());
932 result.append(' '); 931 result.append(' ');
933 result.append(m_endVerticalSize->cssText()); 932 result.append(m_endVerticalSize->cssText());
934 } 933 }
935 934
936 for (unsigned i = 0; i < m_stops.size(); i++) { 935 for (unsigned i = 0; i < m_stops.size(); i++) {
937 const CSSGradientColorStop& stop = m_stops[i]; 936 const CSSGradientColorStop& stop = m_stops[i];
938 result.append(", "); 937 result.appendLiteral(", ");
939 result.append(stop.m_color->cssText()); 938 result.append(stop.m_color->cssText());
940 if (stop.m_position) { 939 if (stop.m_position) {
941 result.append(' '); 940 result.append(' ');
942 result.append(stop.m_position->cssText()); 941 result.append(stop.m_position->cssText());
943 } 942 }
944 } 943 }
945 } else { 944 } else {
946 if (m_repeating) 945 if (m_repeating)
947 result.append("repeating-radial-gradient("); 946 result.appendLiteral("repeating-radial-gradient(");
948 else 947 else
949 result.append("radial-gradient("); 948 result.appendLiteral("radial-gradient(");
950 949
951 bool wroteSomething = false; 950 bool wroteSomething = false;
952 951
953 // The only ambiguous case that needs an explicit shape to be provided 952 // The only ambiguous case that needs an explicit shape to be provided
954 // is when a sizing keyword is used (or all sizing is omitted). 953 // is when a sizing keyword is used (or all sizing is omitted).
955 if (m_shape && m_shape->getValueID() != CSSValueEllipse && (m_sizingBeha vior || (!m_sizingBehavior && !m_endHorizontalSize))) { 954 if (m_shape && m_shape->getValueID() != CSSValueEllipse && (m_sizingBeha vior || (!m_sizingBehavior && !m_endHorizontalSize))) {
956 result.append("circle"); 955 result.appendLiteral("circle");
957 wroteSomething = true; 956 wroteSomething = true;
958 } 957 }
959 958
960 if (m_sizingBehavior && m_sizingBehavior->getValueID() != CSSValueFarthe stCorner) { 959 if (m_sizingBehavior && m_sizingBehavior->getValueID() != CSSValueFarthe stCorner) {
961 if (wroteSomething) 960 if (wroteSomething)
962 result.append(' '); 961 result.append(' ');
963 result.append(m_sizingBehavior->cssText()); 962 result.append(m_sizingBehavior->cssText());
964 wroteSomething = true; 963 wroteSomething = true;
965 } else if (m_endHorizontalSize) { 964 } else if (m_endHorizontalSize) {
966 if (wroteSomething) 965 if (wroteSomething)
967 result.append(' '); 966 result.append(' ');
968 result.append(m_endHorizontalSize->cssText()); 967 result.append(m_endHorizontalSize->cssText());
969 if (m_endVerticalSize) { 968 if (m_endVerticalSize) {
970 result.append(' '); 969 result.append(' ');
971 result.append(m_endVerticalSize->cssText()); 970 result.append(m_endVerticalSize->cssText());
972 } 971 }
973 wroteSomething = true; 972 wroteSomething = true;
974 } 973 }
975 974
976 if (m_firstX || m_firstY) { 975 if (m_firstX || m_firstY) {
977 if (wroteSomething) 976 if (wroteSomething)
978 result.append(' '); 977 result.append(' ');
979 result.append("at "); 978 result.appendLiteral("at ");
980 if (m_firstX && m_firstY) { 979 if (m_firstX && m_firstY) {
981 result.append(m_firstX->cssText()); 980 result.append(m_firstX->cssText());
982 result.append(' '); 981 result.append(' ');
983 result.append(m_firstY->cssText()); 982 result.append(m_firstY->cssText());
984 } else if (m_firstX) 983 } else if (m_firstX)
985 result.append(m_firstX->cssText()); 984 result.append(m_firstX->cssText());
986 else 985 else
987 result.append(m_firstY->cssText()); 986 result.append(m_firstY->cssText());
988 wroteSomething = true; 987 wroteSomething = true;
989 } 988 }
990 989
991 if (wroteSomething) 990 if (wroteSomething)
992 result.append(", "); 991 result.appendLiteral(", ");
993 992
994 for (unsigned i = 0; i < m_stops.size(); i++) { 993 for (unsigned i = 0; i < m_stops.size(); i++) {
995 const CSSGradientColorStop& stop = m_stops[i]; 994 const CSSGradientColorStop& stop = m_stops[i];
996 if (i) 995 if (i)
997 result.append(", "); 996 result.appendLiteral(", ");
998 if (stop.m_color) 997 if (stop.m_color)
999 result.append(stop.m_color->cssText()); 998 result.append(stop.m_color->cssText());
1000 if (stop.m_color && stop.m_position) 999 if (stop.m_color && stop.m_position)
1001 result.append(' '); 1000 result.append(' ');
1002 if (stop.m_position) 1001 if (stop.m_position)
1003 result.append(stop.m_position->cssText()); 1002 result.append(stop.m_position->cssText());
1004 } 1003 }
1005 1004
1006 } 1005 }
1007 1006
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 visitor->trace(m_firstRadius); 1216 visitor->trace(m_firstRadius);
1218 visitor->trace(m_secondRadius); 1217 visitor->trace(m_secondRadius);
1219 visitor->trace(m_shape); 1218 visitor->trace(m_shape);
1220 visitor->trace(m_sizingBehavior); 1219 visitor->trace(m_sizingBehavior);
1221 visitor->trace(m_endHorizontalSize); 1220 visitor->trace(m_endHorizontalSize);
1222 visitor->trace(m_endVerticalSize); 1221 visitor->trace(m_endVerticalSize);
1223 CSSGradientValue::traceAfterDispatch(visitor); 1222 CSSGradientValue::traceAfterDispatch(visitor);
1224 } 1223 }
1225 1224
1226 } // namespace blink 1225 } // 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