| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 #include "platform/graphics/Gradient.h" | 38 #include "platform/graphics/Gradient.h" |
| 39 #include "platform/graphics/GradientGeneratedImage.h" | 39 #include "platform/graphics/GradientGeneratedImage.h" |
| 40 #include "platform/graphics/Image.h" | 40 #include "platform/graphics/Image.h" |
| 41 #include "platform/graphics/skia/SkiaUtils.h" | 41 #include "platform/graphics/skia/SkiaUtils.h" |
| 42 #include "wtf/text/StringBuilder.h" | 42 #include "wtf/text/StringBuilder.h" |
| 43 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 44 #include <utility> | 44 #include <utility> |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 DEFINE_TRACE(CSSGradientColorStop) | |
| 49 { | |
| 50 visitor->trace(m_position); | |
| 51 visitor->trace(m_color); | |
| 52 } | |
| 53 | |
| 54 PassRefPtr<Image> CSSGradientValue::image(LayoutObject* layoutObject, const IntS
ize& size) | 48 PassRefPtr<Image> CSSGradientValue::image(LayoutObject* layoutObject, const IntS
ize& size) |
| 55 { | 49 { |
| 56 if (size.isEmpty()) | 50 if (size.isEmpty()) |
| 57 return nullptr; | 51 return nullptr; |
| 58 | 52 |
| 59 bool cacheable = isCacheable(); | 53 bool cacheable = isCacheable(); |
| 60 if (cacheable) { | 54 if (cacheable) { |
| 61 if (!clients().contains(layoutObject)) | 55 if (!clients().contains(layoutObject)) |
| 62 return nullptr; | 56 return nullptr; |
| 63 | 57 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 Color color; | 91 Color color; |
| 98 float offset; | 92 float offset; |
| 99 bool specified; | 93 bool specified; |
| 100 | 94 |
| 101 GradientStop() | 95 GradientStop() |
| 102 : offset(0) | 96 : offset(0) |
| 103 , specified(false) | 97 , specified(false) |
| 104 { } | 98 { } |
| 105 }; | 99 }; |
| 106 | 100 |
| 107 static void replaceColorHintsWithColorStops(Vector<GradientStop>& stops, const W
illBeHeapVector<CSSGradientColorStop, 2>& cssGradientStops) | 101 static void replaceColorHintsWithColorStops(Vector<GradientStop>& stops, const V
ector<CSSGradientColorStop, 2>& cssGradientStops) |
| 108 { | 102 { |
| 109 // This algorithm will replace each color interpolation hint with 9 regular | 103 // This algorithm will replace each color interpolation hint with 9 regular |
| 110 // color stops. The color values for the new color stops will be calculated | 104 // color stops. The color values for the new color stops will be calculated |
| 111 // using the color weighting formula defined in the spec. The new color | 105 // using the color weighting formula defined in the spec. The new color |
| 112 // stops will be positioned in such a way that all the pixels between the tw
o | 106 // stops will be positioned in such a way that all the pixels between the tw
o |
| 113 // user defined color stops have color values close to the interpolation cur
ve. | 107 // user defined color stops have color values close to the interpolation cur
ve. |
| 114 // If the hint is closer to the left color stop, add 2 stops to the left and | 108 // If the hint is closer to the left color stop, add 2 stops to the left and |
| 115 // 6 to the right, else add 6 stops to the left and 2 to the right. | 109 // 6 to the right, else add 6 stops to the left and 2 to the right. |
| 116 // The color stops on the side with more space start midway because | 110 // The color stops on the side with more space start midway because |
| 117 // the curve approximates a line in that region. | 111 // the curve approximates a line in that region. |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const | 556 bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const |
| 563 { | 557 { |
| 564 ASSERT(object); | 558 ASSERT(object); |
| 565 for (auto& stop : m_stops) { | 559 for (auto& stop : m_stops) { |
| 566 if (!stop.isHint() && resolveStopColor(stop.m_color.get(), *object).hasA
lpha()) | 560 if (!stop.isHint() && resolveStopColor(stop.m_color.get(), *object).hasA
lpha()) |
| 567 return false; | 561 return false; |
| 568 } | 562 } |
| 569 return true; | 563 return true; |
| 570 } | 564 } |
| 571 | 565 |
| 572 DEFINE_TRACE_AFTER_DISPATCH(CSSGradientValue) | |
| 573 { | |
| 574 #if ENABLE(OILPAN) | |
| 575 visitor->trace(m_firstX); | |
| 576 visitor->trace(m_firstY); | |
| 577 visitor->trace(m_secondX); | |
| 578 visitor->trace(m_secondY); | |
| 579 visitor->trace(m_stops); | |
| 580 #endif | |
| 581 CSSImageGeneratorValue::traceAfterDispatch(visitor); | |
| 582 } | |
| 583 | |
| 584 String CSSLinearGradientValue::customCSSText() const | 566 String CSSLinearGradientValue::customCSSText() const |
| 585 { | 567 { |
| 586 StringBuilder result; | 568 StringBuilder result; |
| 587 if (m_gradientType == CSSDeprecatedLinearGradient) { | 569 if (m_gradientType == CSSDeprecatedLinearGradient) { |
| 588 result.appendLiteral("-webkit-gradient(linear, "); | 570 result.appendLiteral("-webkit-gradient(linear, "); |
| 589 result.append(m_firstX->cssText()); | 571 result.append(m_firstX->cssText()); |
| 590 result.append(' '); | 572 result.append(' '); |
| 591 result.append(m_firstY->cssText()); | 573 result.append(m_firstY->cssText()); |
| 592 result.appendLiteral(", "); | 574 result.appendLiteral(", "); |
| 593 result.append(m_secondX->cssText()); | 575 result.append(m_secondX->cssText()); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 else if (m_firstX) | 812 else if (m_firstX) |
| 831 equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_fi
rstY; | 813 equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_fi
rstY; |
| 832 else if (m_firstY) | 814 else if (m_firstY) |
| 833 equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_fi
rstX; | 815 equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_fi
rstX; |
| 834 else | 816 else |
| 835 equalXandY = !other.m_firstX && !other.m_firstY; | 817 equalXandY = !other.m_firstX && !other.m_firstY; |
| 836 | 818 |
| 837 return equalXandY && m_stops == other.m_stops; | 819 return equalXandY && m_stops == other.m_stops; |
| 838 } | 820 } |
| 839 | 821 |
| 840 DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) | |
| 841 { | |
| 842 visitor->trace(m_angle); | |
| 843 CSSGradientValue::traceAfterDispatch(visitor); | |
| 844 } | |
| 845 | |
| 846 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder
& result) const | 822 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder
& result) const |
| 847 { | 823 { |
| 848 for (unsigned i = 0; i < m_stops.size(); i++) { | 824 for (unsigned i = 0; i < m_stops.size(); i++) { |
| 849 const CSSGradientColorStop& stop = m_stops[i]; | 825 const CSSGradientColorStop& stop = m_stops[i]; |
| 850 result.appendLiteral(", "); | 826 result.appendLiteral(", "); |
| 851 if (stop.m_position->getDoubleValue() == 0) { | 827 if (stop.m_position->getDoubleValue() == 0) { |
| 852 result.appendLiteral("from("); | 828 result.appendLiteral("from("); |
| 853 result.append(stop.m_color->cssText()); | 829 result.append(stop.m_color->cssText()); |
| 854 result.append(')'); | 830 result.append(')'); |
| 855 } else if (stop.m_position->getDoubleValue() == 1) { | 831 } else if (stop.m_position->getDoubleValue() == 1) { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 else if (m_endHorizontalSize && m_endVerticalSize) | 1168 else if (m_endHorizontalSize && m_endVerticalSize) |
| 1193 equalHorizontalAndVerticalSize = compareCSSValuePtr(m_endHorizontalSize,
other.m_endHorizontalSize) && compareCSSValuePtr(m_endVerticalSize, other.m_end
VerticalSize); | 1169 equalHorizontalAndVerticalSize = compareCSSValuePtr(m_endHorizontalSize,
other.m_endHorizontalSize) && compareCSSValuePtr(m_endVerticalSize, other.m_end
VerticalSize); |
| 1194 else { | 1170 else { |
| 1195 equalShape = !other.m_shape; | 1171 equalShape = !other.m_shape; |
| 1196 equalSizingBehavior = !other.m_sizingBehavior; | 1172 equalSizingBehavior = !other.m_sizingBehavior; |
| 1197 equalHorizontalAndVerticalSize = !other.m_endHorizontalSize && !other.m_
endVerticalSize; | 1173 equalHorizontalAndVerticalSize = !other.m_endHorizontalSize && !other.m_
endVerticalSize; |
| 1198 } | 1174 } |
| 1199 return equalShape && equalSizingBehavior && equalHorizontalAndVerticalSize &
& m_stops == other.m_stops; | 1175 return equalShape && equalSizingBehavior && equalHorizontalAndVerticalSize &
& m_stops == other.m_stops; |
| 1200 } | 1176 } |
| 1201 | 1177 |
| 1202 DEFINE_TRACE_AFTER_DISPATCH(CSSRadialGradientValue) | |
| 1203 { | |
| 1204 visitor->trace(m_firstRadius); | |
| 1205 visitor->trace(m_secondRadius); | |
| 1206 visitor->trace(m_shape); | |
| 1207 visitor->trace(m_sizingBehavior); | |
| 1208 visitor->trace(m_endHorizontalSize); | |
| 1209 visitor->trace(m_endVerticalSize); | |
| 1210 CSSGradientValue::traceAfterDispatch(visitor); | |
| 1211 } | |
| 1212 | |
| 1213 } // namespace blink | 1178 } // namespace blink |
| OLD | NEW |