Ignore:
Timestamp:
Oct 29, 2017, 4:07:45 PM (8 years ago)
Author:
[email protected]
Message:

[Conic Gradients] Add support for parsing conic gradients
https://bugs.webkit.org/show_bug.cgi?id=178987

Reviewed by Dean Jackson.

Source/WebCore:

Adds initial support, disabled by default, for parsing conic gradients as per
CSS 4 Images - https://www.w3.org/TR/css-images-4/#conic-gradients.

Test: fast/gradients/conic-gradient-parsing.html

  • css/CSSGradientValue.cpp:

(WebCore::clone):
(WebCore::CSSGradientValue::isCacheable const):
(WebCore::CSSConicGradientValue::customCSSText const):
(WebCore::CSSConicGradientValue::createGradient):
(WebCore::CSSConicGradientValue::equals const):

  • css/CSSGradientValue.h:


Add CSSConicGradientValue as a subclass of CSSGradientValue and implement
customCSSText() and equals(). Stub out createGradient() as painting is not
yet implemented.


  • css/CSSImageGeneratorValue.cpp:

(WebCore::CSSImageGeneratorValue::image):
(WebCore::CSSImageGeneratorValue::isFixedSize const):
(WebCore::CSSImageGeneratorValue::fixedSize):
(WebCore::CSSImageGeneratorValue::isPending const):
(WebCore::CSSImageGeneratorValue::knownToBeOpaque const):
(WebCore::CSSImageGeneratorValue::loadSubimages):

  • css/CSSValue.cpp:

(WebCore::CSSValue::equals const):
(WebCore::CSSValue::cssText const):
(WebCore::CSSValue::destroy):

Dispatch to CSSConicGradientValue as needed.


  • css/CSSValue.h:

(WebCore::CSSValue::isImageGeneratorValue const):
(WebCore::CSSValue::isGradientValue const):
(WebCore::CSSValue::isConicGradientValue const):

Add conic gradient predicate support and update isImageGeneratorValue and
isGradientValue to include conic gradient.


  • css/CSSValueKeywords.in:


Add conic-gradient and repeating-conic-gradient.


  • css/parser/CSSParser.cpp:

(WebCore::CSSParserContext::CSSParserContext):
(WebCore::operator==):

  • css/parser/CSSParserMode.h:

(WebCore::CSSParserContextHash::hash):

Add runtime flags to enable conic gradients.


  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::consumeAngleOrPercent):

Helper, similar to consumeLengthOrPercent, for consumeGradientColorStops.
Corresponds to https://drafts.csswg.org/css-values-4/#typedef-angle-percentage


(WebCore::CSSPropertyParserHelpers::consumeGradientColorStops):

Convert to take CSSGradientValue by reference.


(WebCore::CSSPropertyParserHelpers::consumeAngularGradientColorStops):

Helper, similar to consumeGradientColorStops, but for angular color stops
used in conic gradients. Corresponds to https://www.w3.org/TR/css-images-4/#typedef-angular-color-stop-list
but does not yet support double position syntax.


(WebCore::CSSPropertyParserHelpers::consumeDeprecatedRadialGradient):
(WebCore::CSSPropertyParserHelpers::consumeRadialGradient):
(WebCore::CSSPropertyParserHelpers::consumeLinearGradient):

Pass CSSGradientValue by reference.


(WebCore::CSSPropertyParserHelpers::consumeConicGradient):

Parse conic gradient.


(WebCore::CSSPropertyParserHelpers::consumeGeneratedImage):

Dispatch to consumeConicGradient for repeating and non-repeating
conic gradients.


(WebCore::CSSPropertyParserHelpers::isGeneratedImage):

Put each value on its own line to make it more readable and add CSSValueConicGradient
and CSSValueRepeatingConicGradient.


  • page/Settings.yaml:


Add a setting to enable conic gradients. Disabled by default.

  • features.json:


Move conic gradients to "In Development".

LayoutTests:

  • http/wpt/css: Added.
  • http/wpt/css/css-images-4: Added.
  • http/wpt/css/css-images-4/conic-gradient-parsing-expected.txt: Added.
  • http/wpt/css/css-images-4/conic-gradient-parsing.html: Added.

Add tests for basic parsing of conic gradients.

File:
1 edited

Legend:

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

    r219744 r224165  
    157157        case RadialGradientClass:
    158158            return compareCSSValues<CSSRadialGradientValue>(*this, other);
     159        case ConicGradientClass:
     160            return compareCSSValues<CSSConicGradientValue>(*this, other);
    159161        case CrossfadeClass:
    160162            return compareCSSValues<CSSCrossfadeValue>(*this, other);
     
    255257    case RadialGradientClass:
    256258        return downcast<CSSRadialGradientValue>(*this).customCSSText();
     259    case ConicGradientClass:
     260        return downcast<CSSConicGradientValue>(*this).customCSSText();
    257261    case CrossfadeClass:
    258262        return downcast<CSSCrossfadeValue>(*this).customCSSText();
     
    360364        delete downcast<CSSRadialGradientValue>(this);
    361365        return;
     366    case ConicGradientClass:
     367        delete downcast<CSSConicGradientValue>(this);
     368        return;
    362369    case CrossfadeClass:
    363370        delete downcast<CSSCrossfadeValue>(this);
Note: See TracChangeset for help on using the changeset viewer.