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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 } else { | 474 } else { |
475 // Normalization failed because the stop set is coincident. | 475 // Normalization failed because the stop set is coincident. |
476 } | 476 } |
477 } else { | 477 } else { |
478 // No normalization required, just add the current stops. | 478 // No normalization required, just add the current stops. |
479 for (const auto& stop : stops) | 479 for (const auto& stop : stops) |
480 gradient->addColorStop(stop.offset, stop.color); | 480 gradient->addColorStop(stop.offset, stop.color); |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 static float positionFromValue(CSSValue* value, const CSSToLengthConversionData& conversionData, const IntSize& size, bool isHorizontal) | 484 static float positionFromValue(const CSSValue* value, const CSSToLengthConversio nData& conversionData, const IntSize& size, bool isHorizontal) |
485 { | 485 { |
486 int origin = 0; | 486 int origin = 0; |
487 int sign = 1; | 487 int sign = 1; |
488 int edgeDistance = isHorizontal ? size.width() : size.height(); | 488 int edgeDistance = isHorizontal ? size.width() : size.height(); |
489 | 489 |
490 // In this case the center of the gradient is given relative to an edge in t he form of: | 490 // In this case the center of the gradient is given relative to an edge in t he form of: |
491 // [ top | bottom | right | left ] [ <percentage> | <length> ]. | 491 // [ top | bottom | right | left ] [ <percentage> | <length> ]. |
492 const CSSValue* localValue = value; | |
nainar
2016/07/18 01:47:00
As per IRL conversation we can just modify value a
| |
492 if (value->isValuePair()) { | 493 if (value->isValuePair()) { |
493 CSSValuePair& pair = toCSSValuePair(*value); | 494 const CSSValuePair& pair = toCSSValuePair(*value); |
494 CSSValueID originID = toCSSPrimitiveValue(pair.first()).getValueID(); | 495 CSSValueID originID = toCSSPrimitiveValue(pair.first()).getValueID(); |
495 value = &pair.second(); | 496 localValue = &pair.second(); |
496 | 497 |
497 if (originID == CSSValueRight || originID == CSSValueBottom) { | 498 if (originID == CSSValueRight || originID == CSSValueBottom) { |
498 // For right/bottom, the offset is relative to the far edge. | 499 // For right/bottom, the offset is relative to the far edge. |
499 origin = edgeDistance; | 500 origin = edgeDistance; |
500 sign = -1; | 501 sign = -1; |
501 } | 502 } |
502 } | 503 } |
503 | 504 |
504 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 505 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(localValue); |
505 | 506 |
506 if (primitiveValue->isNumber()) | 507 if (primitiveValue->isNumber()) |
507 return origin + sign * primitiveValue->getFloatValue() * conversionData. zoom(); | 508 return origin + sign * primitiveValue->getFloatValue() * conversionData. zoom(); |
508 | 509 |
509 if (primitiveValue->isPercentage()) | 510 if (primitiveValue->isPercentage()) |
510 return origin + sign * primitiveValue->getFloatValue() / 100.f * edgeDis tance; | 511 return origin + sign * primitiveValue->getFloatValue() / 100.f * edgeDis tance; |
511 | 512 |
512 if (primitiveValue->isCalculatedPercentageWithLength()) | 513 if (primitiveValue->isCalculatedPercentageWithLength()) |
513 return origin + sign * primitiveValue->cssCalcValue()->toCalcValue(conve rsionData)->evaluate(edgeDistance); | 514 return origin + sign * primitiveValue->cssCalcValue()->toCalcValue(conve rsionData)->evaluate(edgeDistance); |
514 | 515 |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 visitor->trace(m_firstRadius); | 1223 visitor->trace(m_firstRadius); |
1223 visitor->trace(m_secondRadius); | 1224 visitor->trace(m_secondRadius); |
1224 visitor->trace(m_shape); | 1225 visitor->trace(m_shape); |
1225 visitor->trace(m_sizingBehavior); | 1226 visitor->trace(m_sizingBehavior); |
1226 visitor->trace(m_endHorizontalSize); | 1227 visitor->trace(m_endHorizontalSize); |
1227 visitor->trace(m_endVerticalSize); | 1228 visitor->trace(m_endVerticalSize); |
1228 CSSGradientValue::traceAfterDispatch(visitor); | 1229 CSSGradientValue::traceAfterDispatch(visitor); |
1229 } | 1230 } |
1230 | 1231 |
1231 } // namespace blink | 1232 } // namespace blink |
OLD | NEW |