Ignore:
Timestamp:
Apr 14, 2021, 11:15:53 PM (4 years ago)
Author:
[email protected]
Message:

Omit default position/angle when serializing radial & conic gradients
https://bugs.webkit.org/show_bug.cgi?id=223892

Patch by Tim Nguyen <[email protected]> on 2021-04-14
Reviewed by Antti Koivisto.

Test: LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-image-computed.sub.html

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-backgrounds/parsing/background-image-computed.sub-expected.txt:

Source/WebCore:

  • css/CSSGradientValue.cpp:

(WebCore::ConicGradientAdapter::normalizeStopsAndEndpointsOutsideRange):
(WebCore::CSSLinearGradientValue::customCSSText const):
(WebCore::CSSRadialGradientValue::customCSSText const):
(WebCore::CSSConicGradientValue::customCSSText const):

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::isCenterPosition const):

  • css/CSSPrimitiveValue.h:

LayoutTests:

  • fast/gradients/unprefixed-gradient-parsing-expected.txt:
  • fast/gradients/unprefixed-gradient-parsing.html:
  • http/wpt/css/css-images-4/conic-gradient-parsing.html:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r275055 r276002  
    290290
    291291                // Clamp the positions to 1 and set the color.
    292                 for (size_t i = index + 1; i <= lastStopIndex; ++i) {
     292                for (size_t i = index + 1; i < numStops; ++i) {
    293293                    stops[i].offset = 1;
    294294                    stops[i].color = blendedColor;
     
    720720            result.append(m_angle->cssText());
    721721            wroteSomething = true;
    722         } else if ((firstX() || firstY()) && !(!firstX() && firstY() && firstY()->valueID() == CSSValueBottom)) {
     722        } else if (firstX() || (firstY() && firstY()->valueID() != CSSValueBottom)) {
    723723            result.appendLiteral("to ");
    724724            appendSpaceSeparatedOptionalCSSPtrText(result, firstX(), firstY());
     
    946946        }
    947947
    948         if (firstX() || firstY()) {
     948        if ((firstX() && !firstX()->isCenterPosition()) || (firstY() && !firstY()->isCenterPosition())) {
    949949            if (wroteSomething)
    950950                result.append(' ');
     
    12261226    bool wroteSomething = false;
    12271227
    1228     if (m_angle) {
     1228    if (m_angle && m_angle->computeDegrees() > 0) {
    12291229        result.append("from ", m_angle->cssText());
    12301230        wroteSomething = true;
    12311231    }
    12321232
    1233     if (firstX() && firstY()) {
     1233    if ((firstX() && !firstX()->isCenterPosition()) || (firstY() && !firstY()->isCenterPosition())) {
    12341234        if (wroteSomething)
    12351235            result.append(' ');
Note: See TracChangeset for help on using the changeset viewer.