[Conic Gradients] Add support for parsing conic gradients
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Oct 2017 23:07:45 +0000 (23:07 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Oct 2017 23:07:45 +0000 (23:07 +0000)
commit56bd100904b7a8f53f247e22466e656e79a112c3
treed954567eb0bdfe53bdad284361bb2d10790927db
parent28ee02e2ecaf5b598126b4d276651980ab362858
[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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224165 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/css/css-images-4/conic-gradient-parsing-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/css/css-images-4/conic-gradient-parsing.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSGradientValue.cpp
Source/WebCore/css/CSSGradientValue.h
Source/WebCore/css/CSSImageGeneratorValue.cpp
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParserMode.h
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
Source/WebCore/features.json
Source/WebCore/page/Settings.yaml