| 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 10 matching lines...) Expand all Loading... |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/css/CSSGradientValue.h" | 27 #include "core/css/CSSGradientValue.h" |
| 28 | 28 |
| 29 #include "core/CSSValueKeywords.h" | 29 #include "core/CSSValueKeywords.h" |
| 30 #include "core/css/CSSCalculationValue.h" | 30 #include "core/css/CSSCalculationValue.h" |
| 31 #include "core/css/CSSColorValue.h" |
| 31 #include "core/css/CSSToLengthConversionData.h" | 32 #include "core/css/CSSToLengthConversionData.h" |
| 32 #include "core/css/CSSValuePair.h" | 33 #include "core/css/CSSValuePair.h" |
| 34 #include "core/css/serializer/CSSDeserializeStream.h" |
| 35 #include "core/css/serializer/CSSSerializeStream.h" |
| 33 #include "core/dom/NodeComputedStyle.h" | 36 #include "core/dom/NodeComputedStyle.h" |
| 34 #include "core/dom/TextLinkColors.h" | 37 #include "core/dom/TextLinkColors.h" |
| 35 #include "core/layout/LayoutObject.h" | 38 #include "core/layout/LayoutObject.h" |
| 36 #include "platform/geometry/IntSize.h" | 39 #include "platform/geometry/IntSize.h" |
| 37 #include "platform/graphics/Gradient.h" | 40 #include "platform/graphics/Gradient.h" |
| 38 #include "platform/graphics/GradientGeneratedImage.h" | 41 #include "platform/graphics/GradientGeneratedImage.h" |
| 39 #include "platform/graphics/Image.h" | 42 #include "platform/graphics/Image.h" |
| 40 #include "platform/graphics/skia/SkiaUtils.h" | 43 #include "platform/graphics/skia/SkiaUtils.h" |
| 41 #include "wtf/text/StringBuilder.h" | 44 #include "wtf/text/StringBuilder.h" |
| 42 #include "wtf/text/WTFString.h" | 45 #include "wtf/text/WTFString.h" |
| 43 #include <algorithm> | 46 #include <algorithm> |
| 44 #include <utility> | 47 #include <utility> |
| 45 | 48 |
| 46 namespace blink { | 49 namespace blink { |
| 47 | 50 |
| 51 void CSSGradientColorStop::deserialize(CSSDeserializeStream* stream) |
| 52 { |
| 53 m_position = stream->readNullableRef<CSSPrimitiveValue>(); |
| 54 m_color = stream->readNullableRef<CSSValue>(); |
| 55 m_colorIsDerivedFromElement = stream->readBool(); |
| 56 } |
| 57 |
| 58 void CSSGradientColorStop::serialize(CSSSerializeStream* stream) const |
| 59 { |
| 60 m_position->serialize(stream); |
| 61 m_color->serialize(stream); |
| 62 stream->writeBool(m_colorIsDerivedFromElement); |
| 63 } |
| 64 |
| 48 DEFINE_TRACE(CSSGradientColorStop) | 65 DEFINE_TRACE(CSSGradientColorStop) |
| 49 { | 66 { |
| 50 visitor->trace(m_position); | 67 visitor->trace(m_position); |
| 51 visitor->trace(m_color); | 68 visitor->trace(m_color); |
| 52 } | 69 } |
| 53 | 70 |
| 54 PassRefPtr<Image> CSSGradientValue::image(const LayoutObject* layoutObject, cons
t IntSize& size) | 71 PassRefPtr<Image> CSSGradientValue::image(const LayoutObject* layoutObject, cons
t IntSize& size) |
| 55 { | 72 { |
| 56 if (size.isEmpty()) | 73 if (size.isEmpty()) |
| 57 return nullptr; | 74 return nullptr; |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 void CSSGradientValue::getStopColors(WillBeHeapVector<Color>& stopColors, const
LayoutObject* object) const | 592 void CSSGradientValue::getStopColors(WillBeHeapVector<Color>& stopColors, const
LayoutObject* object) const |
| 576 { | 593 { |
| 577 ASSERT(object); | 594 ASSERT(object); |
| 578 for (auto& stop : m_stops) { | 595 for (auto& stop : m_stops) { |
| 579 if (!stop.isHint()) | 596 if (!stop.isHint()) |
| 580 stopColors.append(resolveStopColor(*stop.m_color, *object)); | 597 stopColors.append(resolveStopColor(*stop.m_color, *object)); |
| 581 } | 598 } |
| 582 | 599 |
| 583 } | 600 } |
| 584 | 601 |
| 602 void CSSGradientValue::serializeAfterDispatch(CSSSerializeStream* stream) const |
| 603 { |
| 604 m_firstX->serialize(stream); |
| 605 m_firstY->serialize(stream); |
| 606 m_secondX->serialize(stream); |
| 607 m_secondY->serialize(stream); |
| 608 |
| 609 stream->writeUnsigned(m_stops.size()); |
| 610 for (const CSSGradientColorStop& stop : m_stops) { |
| 611 stop.serialize(stream); |
| 612 } |
| 613 |
| 614 stream->writeEnumAsInt<CSSGradientType>(m_gradientType); |
| 615 stream->writeBool(m_repeating); |
| 616 } |
| 617 |
| 618 void CSSGradientValue::deserializeAfterDispatch(CSSDeserializeStream* stream) |
| 619 { |
| 620 m_firstX = stream->readNullableRef<CSSValue>(); |
| 621 m_firstY = stream->readNullableRef<CSSValue>(); |
| 622 m_secondX = stream->readNullableRef<CSSValue>(); |
| 623 m_secondY = stream->readNullableRef<CSSValue>(); |
| 624 |
| 625 unsigned stopsSize = stream->readUnsigned(); |
| 626 m_stops.resize(stopsSize); |
| 627 for (unsigned i = 0; i < stopsSize; ++ i) { |
| 628 m_stops[i].deserialize(stream); |
| 629 } |
| 630 |
| 631 m_gradientType = stream->readIntAsEnum<CSSGradientType>(); |
| 632 m_repeating = stream->readBool(); |
| 633 } |
| 634 |
| 585 DEFINE_TRACE_AFTER_DISPATCH(CSSGradientValue) | 635 DEFINE_TRACE_AFTER_DISPATCH(CSSGradientValue) |
| 586 { | 636 { |
| 587 #if ENABLE(OILPAN) | 637 #if ENABLE(OILPAN) |
| 588 visitor->trace(m_firstX); | 638 visitor->trace(m_firstX); |
| 589 visitor->trace(m_firstY); | 639 visitor->trace(m_firstY); |
| 590 visitor->trace(m_secondX); | 640 visitor->trace(m_secondX); |
| 591 visitor->trace(m_secondY); | 641 visitor->trace(m_secondY); |
| 592 visitor->trace(m_stops); | 642 visitor->trace(m_stops); |
| 593 #endif | 643 #endif |
| 594 CSSImageGeneratorValue::traceAfterDispatch(visitor); | 644 CSSImageGeneratorValue::traceAfterDispatch(visitor); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 else if (m_firstX) | 893 else if (m_firstX) |
| 844 equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_fi
rstY; | 894 equalXandY = compareCSSValuePtr(m_firstX, other.m_firstX) && !other.m_fi
rstY; |
| 845 else if (m_firstY) | 895 else if (m_firstY) |
| 846 equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_fi
rstX; | 896 equalXandY = compareCSSValuePtr(m_firstY, other.m_firstY) && !other.m_fi
rstX; |
| 847 else | 897 else |
| 848 equalXandY = !other.m_firstX && !other.m_firstY; | 898 equalXandY = !other.m_firstX && !other.m_firstY; |
| 849 | 899 |
| 850 return equalXandY && m_stops == other.m_stops; | 900 return equalXandY && m_stops == other.m_stops; |
| 851 } | 901 } |
| 852 | 902 |
| 903 void CSSLinearGradientValue::serializeAfterDispatch(CSSSerializeStream* stream)
const |
| 904 { |
| 905 CSSGradientValue::serializeAfterDispatch(stream); |
| 906 stream->serializeNullable(m_angle); |
| 907 } |
| 908 |
| 909 PassRefPtrWillBeRawPtr<CSSLinearGradientValue> CSSLinearGradientValue::deseriali
zeAfterDispatch(CSSDeserializeStream* stream) |
| 910 { |
| 911 RefPtrWillBeRawPtr<CSSLinearGradientValue> value = create(NonRepeating /* du
mmy */); |
| 912 |
| 913 value->CSSGradientValue::deserializeAfterDispatch(stream); |
| 914 value->m_angle = stream->readNullableRef<CSSPrimitiveValue>(); |
| 915 |
| 916 return value.release(); |
| 917 } |
| 918 |
| 853 DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) | 919 DEFINE_TRACE_AFTER_DISPATCH(CSSLinearGradientValue) |
| 854 { | 920 { |
| 855 visitor->trace(m_angle); | 921 visitor->trace(m_angle); |
| 856 CSSGradientValue::traceAfterDispatch(visitor); | 922 CSSGradientValue::traceAfterDispatch(visitor); |
| 857 } | 923 } |
| 858 | 924 |
| 859 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder
& result) const | 925 inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder
& result) const |
| 860 { | 926 { |
| 861 for (unsigned i = 0; i < m_stops.size(); i++) { | 927 for (unsigned i = 0; i < m_stops.size(); i++) { |
| 862 const CSSGradientColorStop& stop = m_stops[i]; | 928 const CSSGradientColorStop& stop = m_stops[i]; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 else if (m_endHorizontalSize && m_endVerticalSize) | 1272 else if (m_endHorizontalSize && m_endVerticalSize) |
| 1207 equalHorizontalAndVerticalSize = compareCSSValuePtr(m_endHorizontalSize,
other.m_endHorizontalSize) && compareCSSValuePtr(m_endVerticalSize, other.m_end
VerticalSize); | 1273 equalHorizontalAndVerticalSize = compareCSSValuePtr(m_endHorizontalSize,
other.m_endHorizontalSize) && compareCSSValuePtr(m_endVerticalSize, other.m_end
VerticalSize); |
| 1208 else { | 1274 else { |
| 1209 equalShape = !other.m_shape; | 1275 equalShape = !other.m_shape; |
| 1210 equalSizingBehavior = !other.m_sizingBehavior; | 1276 equalSizingBehavior = !other.m_sizingBehavior; |
| 1211 equalHorizontalAndVerticalSize = !other.m_endHorizontalSize && !other.m_
endVerticalSize; | 1277 equalHorizontalAndVerticalSize = !other.m_endHorizontalSize && !other.m_
endVerticalSize; |
| 1212 } | 1278 } |
| 1213 return equalShape && equalSizingBehavior && equalHorizontalAndVerticalSize &
& m_stops == other.m_stops; | 1279 return equalShape && equalSizingBehavior && equalHorizontalAndVerticalSize &
& m_stops == other.m_stops; |
| 1214 } | 1280 } |
| 1215 | 1281 |
| 1282 void CSSRadialGradientValue::serializeAfterDispatch(CSSSerializeStream* stream)
const |
| 1283 { |
| 1284 CSSGradientValue::serializeAfterDispatch(stream); |
| 1285 stream->serializeNullable(m_firstRadius); |
| 1286 stream->serializeNullable(m_secondRadius); |
| 1287 stream->serializeNullable(m_shape); |
| 1288 stream->serializeNullable(m_sizingBehavior); |
| 1289 stream->serializeNullable(m_endHorizontalSize); |
| 1290 stream->serializeNullable(m_endVerticalSize); |
| 1291 } |
| 1292 |
| 1293 PassRefPtrWillBeRawPtr<CSSRadialGradientValue> CSSRadialGradientValue::deseriali
zeAfterDispatch(CSSDeserializeStream* stream) |
| 1294 { |
| 1295 RefPtrWillBeRawPtr<CSSRadialGradientValue> value = create(NonRepeating /* du
mmy */); |
| 1296 |
| 1297 value->CSSGradientValue::deserializeAfterDispatch(stream); |
| 1298 value->m_firstRadius = stream->readNullableRef<CSSPrimitiveValue>(); |
| 1299 value->m_secondRadius = stream->readNullableRef<CSSPrimitiveValue>(); |
| 1300 value->m_shape = stream->readNullableRef<CSSPrimitiveValue>(); |
| 1301 value->m_sizingBehavior = stream->readNullableRef<CSSPrimitiveValue>(); |
| 1302 value->m_endHorizontalSize = stream->readNullableRef<CSSPrimitiveValue>(); |
| 1303 value->m_endVerticalSize = stream->readNullableRef<CSSPrimitiveValue>(); |
| 1304 |
| 1305 return value.release(); |
| 1306 } |
| 1307 |
| 1216 DEFINE_TRACE_AFTER_DISPATCH(CSSRadialGradientValue) | 1308 DEFINE_TRACE_AFTER_DISPATCH(CSSRadialGradientValue) |
| 1217 { | 1309 { |
| 1218 visitor->trace(m_firstRadius); | 1310 visitor->trace(m_firstRadius); |
| 1219 visitor->trace(m_secondRadius); | 1311 visitor->trace(m_secondRadius); |
| 1220 visitor->trace(m_shape); | 1312 visitor->trace(m_shape); |
| 1221 visitor->trace(m_sizingBehavior); | 1313 visitor->trace(m_sizingBehavior); |
| 1222 visitor->trace(m_endHorizontalSize); | 1314 visitor->trace(m_endHorizontalSize); |
| 1223 visitor->trace(m_endVerticalSize); | 1315 visitor->trace(m_endVerticalSize); |
| 1224 CSSGradientValue::traceAfterDispatch(visitor); | 1316 CSSGradientValue::traceAfterDispatch(visitor); |
| 1225 } | 1317 } |
| 1226 | 1318 |
| 1227 } // namespace blink | 1319 } // namespace blink |
| OLD | NEW |