[webkit-changes] [WebKit/WebKit] 32d57a: Move logic for generated images from CSSValue type...

Sam Weinig noreply at github.com
Sun Oct 23 14:01:31 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 32d57af5e2f83d93188e8ef0afcfa065bb35a41f
      https://github.com/WebKit/WebKit/commit/32d57af5e2f83d93188e8ef0afcfa065bb35a41f
  Author: Sam Weinig <weinig at apple.com>
  Date:   2022-10-23 (Sun, 23 Oct 2022)

  Changed paths:
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/animation/CSSPropertyAnimation.cpp
    M Source/WebCore/css/CSSCanvasValue.cpp
    M Source/WebCore/css/CSSCanvasValue.h
    M Source/WebCore/css/CSSCrossfadeValue.cpp
    M Source/WebCore/css/CSSCrossfadeValue.h
    M Source/WebCore/css/CSSCursorImageValue.cpp
    M Source/WebCore/css/CSSCursorImageValue.h
    M Source/WebCore/css/CSSCustomPropertyValue.cpp
    M Source/WebCore/css/CSSCustomPropertyValue.h
    M Source/WebCore/css/CSSFilterImageValue.cpp
    M Source/WebCore/css/CSSFilterImageValue.h
    M Source/WebCore/css/CSSGradientValue.cpp
    M Source/WebCore/css/CSSGradientValue.h
    R Source/WebCore/css/CSSImageGeneratorValue.cpp
    R Source/WebCore/css/CSSImageGeneratorValue.h
    M Source/WebCore/css/CSSImageSetValue.cpp
    M Source/WebCore/css/CSSImageSetValue.h
    M Source/WebCore/css/CSSImageValue.cpp
    M Source/WebCore/css/CSSImageValue.h
    M Source/WebCore/css/CSSNamedImageValue.cpp
    M Source/WebCore/css/CSSNamedImageValue.h
    M Source/WebCore/css/CSSPaintImageValue.cpp
    M Source/WebCore/css/CSSPaintImageValue.h
    M Source/WebCore/css/CSSToStyleMap.cpp
    M Source/WebCore/css/CSSToStyleMap.h
    M Source/WebCore/css/CSSValue.h
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/css/ComputedStyleExtractor.h
    M Source/WebCore/css/FontFace.cpp
    M Source/WebCore/css/StyleColor.cpp
    M Source/WebCore/css/StyleColor.h
    M Source/WebCore/css/parser/CSSParserContext.cpp
    M Source/WebCore/css/parser/CSSParserContext.h
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/html/CanvasBase.cpp
    M Source/WebCore/html/CanvasBase.h
    M Source/WebCore/html/CustomPaintImage.cpp
    M Source/WebCore/html/CustomPaintImage.h
    M Source/WebCore/html/HTMLBodyElement.cpp
    M Source/WebCore/html/HTMLCanvasElement.cpp
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/rendering/style/StyleCachedImage.cpp
    M Source/WebCore/rendering/style/StyleCachedImage.h
    M Source/WebCore/rendering/style/StyleCanvasImage.cpp
    M Source/WebCore/rendering/style/StyleCanvasImage.h
    M Source/WebCore/rendering/style/StyleCrossfadeImage.cpp
    M Source/WebCore/rendering/style/StyleCrossfadeImage.h
    M Source/WebCore/rendering/style/StyleCursorImage.cpp
    M Source/WebCore/rendering/style/StyleCursorImage.h
    M Source/WebCore/rendering/style/StyleFilterImage.cpp
    M Source/WebCore/rendering/style/StyleFilterImage.h
    M Source/WebCore/rendering/style/StyleGeneratedImage.cpp
    M Source/WebCore/rendering/style/StyleGeneratedImage.h
    M Source/WebCore/rendering/style/StyleGradientImage.cpp
    M Source/WebCore/rendering/style/StyleGradientImage.h
    M Source/WebCore/rendering/style/StyleImage.h
    M Source/WebCore/rendering/style/StyleImageSet.cpp
    M Source/WebCore/rendering/style/StyleImageSet.h
    M Source/WebCore/rendering/style/StyleMultiImage.cpp
    M Source/WebCore/rendering/style/StyleMultiImage.h
    M Source/WebCore/rendering/style/StyleNamedImage.cpp
    M Source/WebCore/rendering/style/StyleNamedImage.h
    M Source/WebCore/rendering/style/StylePaintImage.cpp
    M Source/WebCore/rendering/style/StylePaintImage.h
    M Source/WebCore/style/StyleBuilderConverter.h
    M Source/WebCore/style/StyleBuilderCustom.h
    M Source/WebCore/style/StyleBuilderState.cpp
    M Source/WebCore/style/StyleBuilderState.h
    M Source/WebCore/svg/SVGCursorElement.cpp
    M Source/WebCore/svg/SVGCursorElement.h

  Log Message:
  -----------
  Move logic for generated images from CSSValue types to the StyleImage types
https://bugs.webkit.org/show_bug.cgi?id=246594
rdar://101225901

Reviewed by Darin Adler.

In a step toward creating a comprehensive layering between the CSSValue types
and the Style types they resolve to, this change moves all of the logic that
used to be in the CSSValue derived types for generated images into their new
Style counterparts. This leaves the CSSValue side as immutable representations
of the parsed CSS (or an immutable representation of a computed CSS property)
that is capable of only a few operations:
   - equality
   - serialization
   - resolution to Style counterpart

This initial move does a pretty close approximation of just moving the logic
and state, in some cases having the Style type continue to store CSSValues,
but subsequent changes should change this so that we do conversion to lower
level types at creation time (e.g. use Length rather than CSSPrimitiveValue).
The one major exception is that we now reference other images as StyleImages
rather than CSSValues in the places where the types require input images
such as StyleCrossfadeImage and StyleFilterImage. This puts us in a strong
position to fix a bunch of long standing issues with animating between
various combinations of nested images.

Due to the simplification on the CSSValue side, we no longer need the
CSSImageGeneratorValue intermediate class, so it has been removed.

This change does not update CSSImageValue in the same way as the generated
image classes, as that has additional complications that should be handled
on their own.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSImageGeneratorValue.cpp: Removed.
* Source/WebCore/css/CSSImageGeneratorValue.h: Removed.
Remove CSSImageGeneratorValue.

* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::blendFilter):
(WebCore::crossfadeBlend):
(WebCore::blendFunc):
Update to use StyleImages (and subclasses thereof) rather than the CSSValue
types, making the logic much closer to other blend primitives and allowing
the removal of a lot of unnecessary temporary allocations.

* Source/WebCore/css/CSSCanvasValue.cpp:
* Source/WebCore/css/CSSCanvasValue.h:
* Source/WebCore/css/CSSCrossfadeValue.cpp:
* Source/WebCore/css/CSSCrossfadeValue.h:
* Source/WebCore/css/CSSCursorImageValue.cpp:
* Source/WebCore/css/CSSCursorImageValue.h:
* Source/WebCore/css/CSSFilterImageValue.cpp:
* Source/WebCore/css/CSSFilterImageValue.h:
* Source/WebCore/css/CSSGradientValue.cpp:
* Source/WebCore/css/CSSGradientValue.h:
* Source/WebCore/css/CSSImageSetValue.cpp:
* Source/WebCore/css/CSSImageSetValue.h:
* Source/WebCore/css/CSSNamedImageValue.cpp:
* Source/WebCore/css/CSSNamedImageValue.h:
* Source/WebCore/css/CSSPaintImageValue.cpp:
* Source/WebCore/css/CSSPaintImageValue.h:
Move most of the logic and behaviors out of these classes and into
their Style counterparts. In some cases, member variable names were
expanded to make it more clear what they could hold in the surprising
cases where it was either an image or the `none` identifier.

* Source/WebCore/css/CSSCustomPropertyValue.cpp:
(WebCore::CSSCustomPropertyValue::equals const):
(WebCore::CSSCustomPropertyValue::customCSSText const):
* Source/WebCore/css/CSSCustomPropertyValue.h:
Remove unused creation function and subsequent dead code removing
it creates.

* Source/WebCore/css/CSSImageValue.cpp:
* Source/WebCore/css/CSSImageValue.h:
As this change focused on the generated image types, this class remains
relatively the same, but has its create methods cleaned up and replaces
the valueWithStylesResolved with the new direct createStyleImage. The
ResolvedURL type was also moved to CSSParserContext so it can be included
in more places with out cycles.

* Source/WebCore/css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::mapNinePieceImage):
* Source/WebCore/style/StyleBuilderConverter.h:
(WebCore::Style::isImageShape):
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyValueContent):
Now that there isn't a CSSImageGeneratorValue type, we use the existing
isImageGeneratorValue() function that does the same thing as an is<>.

* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::valueForNinePieceImage):
(WebCore::ComputedStyleExtractor::currentColorOrValidColor):
(WebCore::contentToCSSValue):
(WebCore::shapePropertyValue):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
(WebCore::ComputedStyleExtractor::currentColorOrValidColor const): Deleted.
* Source/WebCore/css/ComputedStyleExtractor.h:
With the StyleImage subclasses taking on more responsibility, a bit more context
is now needed when generating computed values for them. To resolve this, we now
pass the currently computing RenderStyle to them in their renamed computedStyleValue()
methods (previously named cssValue()).

* Source/WebCore/css/StyleColor.cpp:
* Source/WebCore/css/StyleColor.h:
(WebCore::serializationForRenderTreeAsText): Deleted.
Remove unused function.

* Source/WebCore/css/parser/CSSParserContext.cpp:
* Source/WebCore/css/parser/CSSParserContext.h:
Move ResolvedURL here from CSSImageValue to allow use in more places
with including CSSImageValue. It also makes more sense here as this
is where they are created.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeGradientColorStops):
Remove now removed third argument.
(WebCore::CSSPropertyParserHelpers::consumeCrossFade):
(WebCore::CSSPropertyParserHelpers::consumeFilterImage):
Add some notes and FIXMEs about the implementation and rename a few variables
for clarity.

* Source/WebCore/html/CanvasBase.cpp:
* Source/WebCore/html/CanvasBase.h:
(WebCore::CanvasObserver::isStyleCanvasImage const):
(WebCore::CanvasObserver::isCanvasObserverProxy const): Deleted.
* Source/WebCore/html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::~HTMLCanvasElement):
Update to reflect that now the StyleCanvasImage and not the CSSCanvasValue::CanvasObserverProxy
is the observer for canvas() images.

* Source/WebCore/html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::collectPresentationalHintsForAttribute):
Pass the initiatorName via the create function rather than an
explicit getter, now that the create function supports that. This
allows the type to move toward immutability.

* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::autoFillStrongPasswordMaskImage):
(WebCore::HTMLInputElement::createInnerTextStyle):
Now that StyleGradientImage is more than just a wrapper around CSSGradientValue, we can
use it directly for the image mask, bypassing the need for a CSS value entirely.

* Source/WebCore/rendering/style/StyleCachedImage.cpp:
(WebCore::StyleCachedImage::create):
(WebCore::StyleCachedImage::copyOverridingScaleFactor):
* Source/WebCore/rendering/style/StyleCachedImage.h:
While mostly unchanged behavior wise, update to conform to some of the
idiomatic norms of the StyleImage types, adding a typed equals() function
(used by the CSSPropertyAnimations), and an explicit copyOverridingScaleFactor
create function used by StyleMultiImage to avoid that class knowing that
getting the internal CSSValue was possible (since it won't be in the future).

* Source/WebCore/rendering/style/StyleCanvasImage.cpp:
* Source/WebCore/rendering/style/StyleCanvasImage.h:
* Source/WebCore/rendering/style/StyleCrossfadeImage.cpp:
* Source/WebCore/rendering/style/StyleCrossfadeImage.h:
* Source/WebCore/rendering/style/StyleCursorImage.cpp:
* Source/WebCore/rendering/style/StyleCursorImage.h:
* Source/WebCore/rendering/style/StyleFilterImage.cpp:
* Source/WebCore/rendering/style/StyleFilterImage.h:
* Source/WebCore/rendering/style/StyleGradientImage.cpp:
* Source/WebCore/rendering/style/StyleGradientImage.h:
* Source/WebCore/rendering/style/StyleImageSet.cpp:
* Source/WebCore/rendering/style/StyleImageSet.h:
* Source/WebCore/rendering/style/StyleNamedImage.cpp:
* Source/WebCore/rendering/style/StyleNamedImage.h:
* Source/WebCore/rendering/style/StylePaintImage.cpp:
* Source/WebCore/rendering/style/StylePaintImage.h:
Move logic and state from the CSSValue counterparts, aiming to change as little
as possible. This means that in some cases we are storing the data in a non
optimal way. For example, we store gradient parameters as the CSSPrimitiveValues
to keep the current (and incorrect) behavior for color serialization. This
allows this change to be behavior neutral, with the fixes coming on their own.

* Source/WebCore/rendering/style/StyleGeneratedImage.cpp:
* Source/WebCore/rendering/style/StyleGeneratedImage.h:
(WebCore::StyleGeneratedImage:: const):
Move the logic from CSSImageGeneratorValue for generated image caching / eviction
and client tracking. Also adds additional virtual functions for the generated images,
didAddClient/didRemoveClient to allow them to react to clients. This is used by
StyleCanvasImage, for example, to notify the inspector.

* Source/WebCore/rendering/style/StyleImage.h:
Rename cssValue() function to computedStyleValue() and pass in the computing RenderStyle.
This is needed now that the StyleImages don't store pointers to their original CSSValues
anymore.

* Source/WebCore/rendering/style/StyleMultiImage.cpp:
* Source/WebCore/rendering/style/StyleMultiImage.h:
Move ImageWithScale here (it was previously defined in CSSImageSetValue)
and replace the CSSValue with a StyleImage. This means we now can track
the image set options as StyleImages, allowing the removal of creates
in StyleMultiImage::load (except the one when you have a StyleCachedImage
with a different scale factor).

* Source/WebCore/style/StyleBuilderState.cpp:
(WebCore::Style::BuilderState::createStyleImage):
(WebCore::Style::BuilderState::resolveImageStyles): Deleted.
* Source/WebCore/style/StyleBuilderState.h:
Remove resolveImageStyles entirely, merging resolution into style
creation, and converting to taking const CSSValue references,
removing the possibility for the confusing interim resolved state
to return.

* Source/WebCore/svg/SVGCursorElement.cpp:
* Source/WebCore/svg/SVGCursorElement.h:
Updated to use StyleCursorImage as the client.

Canonical link: https://commits.webkit.org/255897@main




More information about the webkit-changes mailing list