OLD | NEW |
---|---|
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 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
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/CSSToLengthConversionData.h" | 31 #include "core/css/CSSToLengthConversionData.h" |
32 #include "core/css/Pair.h" | |
32 #include "core/dom/NodeRenderStyle.h" | 33 #include "core/dom/NodeRenderStyle.h" |
33 #include "core/dom/TextLinkColors.h" | 34 #include "core/dom/TextLinkColors.h" |
34 #include "core/rendering/RenderObject.h" | 35 #include "core/rendering/RenderObject.h" |
35 #include "platform/geometry/IntSize.h" | 36 #include "platform/geometry/IntSize.h" |
36 #include "platform/graphics/Gradient.h" | 37 #include "platform/graphics/Gradient.h" |
37 #include "platform/graphics/GradientGeneratedImage.h" | 38 #include "platform/graphics/GradientGeneratedImage.h" |
38 #include "platform/graphics/Image.h" | 39 #include "platform/graphics/Image.h" |
39 #include "wtf/text/StringBuilder.h" | 40 #include "wtf/text/StringBuilder.h" |
40 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
41 | 42 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 | 381 |
381 gradient->setStartRadius(gradient->startRadius() * scale); | 382 gradient->setStartRadius(gradient->startRadius() * scale); |
382 gradient->setEndRadius(gradient->endRadius() * scale); | 383 gradient->setEndRadius(gradient->endRadius() * scale); |
383 } | 384 } |
384 } | 385 } |
385 | 386 |
386 for (unsigned i = 0; i < numStops; i++) | 387 for (unsigned i = 0; i < numStops; i++) |
387 gradient->addColorStop(stops[i].offset, stops[i].color); | 388 gradient->addColorStop(stops[i].offset, stops[i].color); |
388 } | 389 } |
389 | 390 |
391 static float positionFromPairValue(CSSPrimitiveValue* value, int edgeDistance, c onst CSSToLengthConversionData& conversionData) | |
f(malita)
2014/06/26 20:33:43
I think we can fold this into the original method,
| |
392 { | |
393 if (value->isNumber()) | |
394 return edgeDistance - (value->getFloatValue() * conversionData.zoom()); | |
395 if (value->isPercentage()) | |
396 return (100 - value->getFloatValue()) / 100.f * edgeDistance; | |
397 if (value->isCalculatedPercentageWithLength()) | |
398 return edgeDistance - value->cssCalcValue()->toCalcValue(conversionData) ->evaluate(edgeDistance); | |
399 return edgeDistance - value->computeLength<float>(conversionData); | |
400 } | |
401 | |
390 static float positionFromValue(CSSPrimitiveValue* value, const CSSToLengthConver sionData& conversionData, const IntSize& size, bool isHorizontal) | 402 static float positionFromValue(CSSPrimitiveValue* value, const CSSToLengthConver sionData& conversionData, const IntSize& size, bool isHorizontal) |
f(malita)
2014/06/26 20:33:43
How about something like this instead:
static flo
| |
391 { | 403 { |
404 int edgeDistance = isHorizontal ? size.width() : size.height(); | |
405 if (Pair* pair = value->getPairValue()) { | |
f(malita)
2014/06/26 20:33:42
We should probably add an inline comment describin
| |
406 CSSValueID keyword = pair->first()->getValueID(); | |
407 CSSPrimitiveValue* offsetValue = pair->second(); | |
408 | |
409 if (keyword == CSSValueRight || keyword == CSSValueBottom) | |
410 return positionFromPairValue(offsetValue, edgeDistance, conversionDa ta); | |
411 | |
412 value = offsetValue; | |
413 } | |
414 | |
392 if (value->isNumber()) | 415 if (value->isNumber()) |
393 return value->getFloatValue() * conversionData.zoom(); | 416 return value->getFloatValue() * conversionData.zoom(); |
394 | 417 |
395 int edgeDistance = isHorizontal ? size.width() : size.height(); | |
396 if (value->isPercentage()) | 418 if (value->isPercentage()) |
397 return value->getFloatValue() / 100.f * edgeDistance; | 419 return value->getFloatValue() / 100.f * edgeDistance; |
398 | 420 |
399 if (value->isCalculatedPercentageWithLength()) | 421 if (value->isCalculatedPercentageWithLength()) |
400 return value->cssCalcValue()->toCalcValue(conversionData)->evaluate(edge Distance); | 422 return value->cssCalcValue()->toCalcValue(conversionData)->evaluate(edge Distance); |
401 | 423 |
402 switch (value->getValueID()) { | 424 switch (value->getValueID()) { |
403 case CSSValueTop: | 425 case CSSValueTop: |
404 ASSERT(!isHorizontal); | 426 ASSERT(!isHorizontal); |
405 return 0; | 427 return 0; |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1181 visitor->trace(m_firstRadius); | 1203 visitor->trace(m_firstRadius); |
1182 visitor->trace(m_secondRadius); | 1204 visitor->trace(m_secondRadius); |
1183 visitor->trace(m_shape); | 1205 visitor->trace(m_shape); |
1184 visitor->trace(m_sizingBehavior); | 1206 visitor->trace(m_sizingBehavior); |
1185 visitor->trace(m_endHorizontalSize); | 1207 visitor->trace(m_endHorizontalSize); |
1186 visitor->trace(m_endVerticalSize); | 1208 visitor->trace(m_endVerticalSize); |
1187 CSSGradientValue::traceAfterDispatch(visitor); | 1209 CSSGradientValue::traceAfterDispatch(visitor); |
1188 } | 1210 } |
1189 | 1211 |
1190 } // namespace WebCore | 1212 } // namespace WebCore |
OLD | NEW |