Changeset 169248 in webkit


Ignore:
Timestamp:
May 22, 2014, 10:18:23 PM (11 years ago)
Author:
Simon Fraser
Message:

Make viewport units work in CSS gradients
https://bugs.webkit.org/show_bug.cgi?id=133204
<rdar://problem/17012259>

Source/WebCore:

Reviewed by Tim Horton.

Make viewport percentage lengths work in gradients.

Test: fast/gradients/viewport-units-gradient.html

  • css/CSSGradientValue.cpp:

(WebCore::CSSGradientValue::addStops):
(WebCore::CSSLinearGradientValue::createGradient):
(WebCore::CSSRadialGradientValue::createGradient):

  • css/CSSGradientValue.h:

LayoutTests:

Reviewed by Tim Horton.

Make viewport percentage lengths work in gradients.

  • fast/gradients/viewport-units-gradient-expected.html: Added.
  • fast/gradients/viewport-units-gradient.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r169244 r169248  
     12014-05-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make viewport units work in CSS gradients
     4        https://bugs.webkit.org/show_bug.cgi?id=133204
     5        <rdar://problem/17012259>
     6
     7        Reviewed by Tim Horton.
     8
     9        Make viewport percentage lengths work in gradients.
     10
     11        * fast/gradients/viewport-units-gradient-expected.html: Added.
     12        * fast/gradients/viewport-units-gradient.html: Added.
     13
    1142014-05-22  Ryosuke Niwa  <rniwa@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r169245 r169248  
     12014-05-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make viewport units work in CSS gradients
     4        https://bugs.webkit.org/show_bug.cgi?id=133204
     5        <rdar://problem/17012259>
     6       
     7        Reviewed by Tim Horton.
     8       
     9        Make viewport percentage lengths work in gradients.
     10
     11        Test: fast/gradients/viewport-units-gradient.html
     12
     13        * css/CSSGradientValue.cpp:
     14        (WebCore::CSSGradientValue::addStops):
     15        (WebCore::CSSLinearGradientValue::createGradient):
     16        (WebCore::CSSRadialGradientValue::createGradient):
     17        * css/CSSGradientValue.h:
     18
    1192014-05-22  Benjamin Poulain  <bpoulain@apple.com>
    220
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r167937 r169248  
    130130}
    131131
    132 void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionData& conversionData, float maxLengthForRepeat)
     132void CSSGradientValue::addStops(Gradient* gradient, RenderView* renderView, const CSSToLengthConversionData& conversionData, float maxLengthForRepeat)
    133133{
    134134    if (m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CSSDeprecatedRadialGradient) {
     
    172172
    173173        if (stop.m_position) {
    174             if (stop.m_position->isPercentage())
    175                 stops[i].offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100;
    176             else if (stop.m_position->isLength() || stop.m_position->isCalculatedPercentageWithLength()) {
     174            const CSSPrimitiveValue& positionValue = *stop.m_position;
     175            if (positionValue.isPercentage())
     176                stops[i].offset = positionValue.getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100;
     177            else if (positionValue.isLength() || positionValue.isViewportPercentageLength() || positionValue.isCalculatedPercentageWithLength()) {
    177178                if (!computedGradientLength) {
    178179                    FloatSize gradientSize(gradientStart - gradientEnd);
     
    180181                }
    181182                float length;
    182                 if (stop.m_position->isLength())
    183                     length = stop.m_position->computeLength<float>(conversionData);
     183                if (positionValue.isLength())
     184                    length = positionValue.computeLength<float>(conversionData);
     185                else if (positionValue.isViewportPercentageLength())
     186                    length = valueForLength(positionValue.viewportPercentageLength(), 0, renderView);
    184187                else {
    185                     Ref<CalculationValue> calculationValue { stop.m_position->cssCalcValue()->createCalculationValue(conversionData) };
     188                    Ref<CalculationValue> calculationValue { positionValue.cssCalcValue()->createCalculationValue(conversionData) };
    186189                    length = calculationValue->evaluate(gradientLength);
    187190                }
     
    702705
    703706    // Now add the stops.
    704     addStops(gradient.get(), conversionData, 1);
     707    addStops(gradient.get(), &renderer->view(), conversionData, 1);
    705708
    706709    return gradient.release();
     
    11161119
    11171120    // Now add the stops.
    1118     addStops(gradient.get(), conversionData, maxExtent);
     1121    addStops(gradient.get(), &renderer->view(), conversionData, maxExtent);
    11191122
    11201123    return gradient.release();
  • trunk/Source/WebCore/css/CSSGradientValue.h

    r167937 r169248  
    3636class FloatPoint;
    3737class Gradient;
     38class RenderView;
    3839
    3940enum CSSGradientType {
     
    110111    }
    111112
    112     void addStops(Gradient*, const CSSToLengthConversionData&, float maxLengthForRepeat = 0);
     113    void addStops(Gradient*, RenderView*, const CSSToLengthConversionData&, float maxLengthForRepeat = 0);
    113114
    114115    // Resolve points/radii to front end values.
Note: See TracChangeset for help on using the changeset viewer.