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

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

Issue 805823002: Remove code duplication from the customCSSText() methods of gradient classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename the new method Created 6 years 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
« no previous file with comments | « Source/core/css/CSSGradientValue.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 StringBuilder result; 571 StringBuilder result;
572 if (m_gradientType == CSSDeprecatedLinearGradient) { 572 if (m_gradientType == CSSDeprecatedLinearGradient) {
573 result.appendLiteral("-webkit-gradient(linear, "); 573 result.appendLiteral("-webkit-gradient(linear, ");
574 result.append(m_firstX->cssText()); 574 result.append(m_firstX->cssText());
575 result.append(' '); 575 result.append(' ');
576 result.append(m_firstY->cssText()); 576 result.append(m_firstY->cssText());
577 result.appendLiteral(", "); 577 result.appendLiteral(", ");
578 result.append(m_secondX->cssText()); 578 result.append(m_secondX->cssText());
579 result.append(' '); 579 result.append(' ');
580 result.append(m_secondY->cssText()); 580 result.append(m_secondY->cssText());
581 581 appendCSSTextForDeprecatedColorStops(result);
582 for (unsigned i = 0; i < m_stops.size(); i++) {
583 const CSSGradientColorStop& stop = m_stops[i];
584 result.appendLiteral(", ");
585 if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) = = 0) {
586 result.appendLiteral("from(");
587 result.append(stop.m_color->cssText());
588 result.append(')');
589 } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NU MBER) == 1) {
590 result.appendLiteral("to(");
591 result.append(stop.m_color->cssText());
592 result.append(')');
593 } else {
594 result.appendLiteral("color-stop(");
595 result.appendNumber(stop.m_position->getDoubleValue(CSSPrimitive Value::CSS_NUMBER));
596 result.appendLiteral(", ");
597 result.append(stop.m_color->cssText());
598 result.append(')');
599 }
600 }
601 } else if (m_gradientType == CSSPrefixedLinearGradient) { 582 } else if (m_gradientType == CSSPrefixedLinearGradient) {
602 if (m_repeating) 583 if (m_repeating)
603 result.appendLiteral("-webkit-repeating-linear-gradient("); 584 result.appendLiteral("-webkit-repeating-linear-gradient(");
604 else 585 else
605 result.appendLiteral("-webkit-linear-gradient("); 586 result.appendLiteral("-webkit-linear-gradient(");
606 587
607 if (m_angle) 588 if (m_angle)
608 result.append(m_angle->cssText()); 589 result.append(m_angle->cssText());
609 else { 590 else {
610 if (m_firstX && m_firstY) { 591 if (m_firstX && m_firstY) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 820
840 return equalXandY && m_stops == other.m_stops; 821 return equalXandY && m_stops == other.m_stops;
841 } 822 }
842 823
843 void CSSLinearGradientValue::traceAfterDispatch(Visitor* visitor) 824 void CSSLinearGradientValue::traceAfterDispatch(Visitor* visitor)
844 { 825 {
845 visitor->trace(m_angle); 826 visitor->trace(m_angle);
846 CSSGradientValue::traceAfterDispatch(visitor); 827 CSSGradientValue::traceAfterDispatch(visitor);
847 } 828 }
848 829
830 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder & result) const
831 {
832 for (unsigned i = 0; i < m_stops.size(); i++) {
833 const CSSGradientColorStop& stop = m_stops[i];
834 result.appendLiteral(", ");
835 if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) {
836 result.appendLiteral("from(");
837 result.append(stop.m_color->cssText());
838 result.append(')');
839 } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER ) == 1) {
840 result.appendLiteral("to(");
841 result.append(stop.m_color->cssText());
842 result.append(')');
843 } else {
844 result.appendLiteral("color-stop(");
845 result.appendNumber(stop.m_position->getDoubleValue(CSSPrimitiveValu e::CSS_NUMBER));
846 result.appendLiteral(", ");
847 result.append(stop.m_color->cssText());
848 result.append(')');
849 }
850 }
851 }
852
849 String CSSRadialGradientValue::customCSSText() const 853 String CSSRadialGradientValue::customCSSText() const
850 { 854 {
851 StringBuilder result; 855 StringBuilder result;
852 856
853 if (m_gradientType == CSSDeprecatedRadialGradient) { 857 if (m_gradientType == CSSDeprecatedRadialGradient) {
854 result.appendLiteral("-webkit-gradient(radial, "); 858 result.appendLiteral("-webkit-gradient(radial, ");
855 result.append(m_firstX->cssText()); 859 result.append(m_firstX->cssText());
856 result.append(' '); 860 result.append(' ');
857 result.append(m_firstY->cssText()); 861 result.append(m_firstY->cssText());
858 result.appendLiteral(", "); 862 result.appendLiteral(", ");
859 result.append(m_firstRadius->cssText()); 863 result.append(m_firstRadius->cssText());
860 result.appendLiteral(", "); 864 result.appendLiteral(", ");
861 result.append(m_secondX->cssText()); 865 result.append(m_secondX->cssText());
862 result.append(' '); 866 result.append(' ');
863 result.append(m_secondY->cssText()); 867 result.append(m_secondY->cssText());
864 result.appendLiteral(", "); 868 result.appendLiteral(", ");
865 result.append(m_secondRadius->cssText()); 869 result.append(m_secondRadius->cssText());
866 870 appendCSSTextForDeprecatedColorStops(result);
867 // FIXME: share?
868 for (unsigned i = 0; i < m_stops.size(); i++) {
869 const CSSGradientColorStop& stop = m_stops[i];
870 result.appendLiteral(", ");
871 if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) = = 0) {
872 result.appendLiteral("from(");
873 result.append(stop.m_color->cssText());
874 result.append(')');
875 } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NU MBER) == 1) {
876 result.appendLiteral("to(");
877 result.append(stop.m_color->cssText());
878 result.append(')');
879 } else {
880 result.appendLiteral("color-stop(");
881 result.appendNumber(stop.m_position->getDoubleValue(CSSPrimitive Value::CSS_NUMBER));
882 result.appendLiteral(", ");
883 result.append(stop.m_color->cssText());
884 result.append(')');
885 }
886 }
887 } else if (m_gradientType == CSSPrefixedRadialGradient) { 871 } else if (m_gradientType == CSSPrefixedRadialGradient) {
888 if (m_repeating) 872 if (m_repeating)
889 result.appendLiteral("-webkit-repeating-radial-gradient("); 873 result.appendLiteral("-webkit-repeating-radial-gradient(");
890 else 874 else
891 result.appendLiteral("-webkit-radial-gradient("); 875 result.appendLiteral("-webkit-radial-gradient(");
892 876
893 if (m_firstX && m_firstY) { 877 if (m_firstX && m_firstY) {
894 result.append(m_firstX->cssText()); 878 result.append(m_firstX->cssText());
895 result.append(' '); 879 result.append(' ');
896 result.append(m_firstY->cssText()); 880 result.append(m_firstY->cssText());
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 visitor->trace(m_firstRadius); 1264 visitor->trace(m_firstRadius);
1281 visitor->trace(m_secondRadius); 1265 visitor->trace(m_secondRadius);
1282 visitor->trace(m_shape); 1266 visitor->trace(m_shape);
1283 visitor->trace(m_sizingBehavior); 1267 visitor->trace(m_sizingBehavior);
1284 visitor->trace(m_endHorizontalSize); 1268 visitor->trace(m_endHorizontalSize);
1285 visitor->trace(m_endVerticalSize); 1269 visitor->trace(m_endVerticalSize);
1286 CSSGradientValue::traceAfterDispatch(visitor); 1270 CSSGradientValue::traceAfterDispatch(visitor);
1287 } 1271 }
1288 1272
1289 } // namespace blink 1273 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/CSSGradientValue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698