[webkit-changes] [WebKit/WebKit] 2fff06: image-set() should serialize in authored order

Ryan Reno noreply at github.com
Wed Mar 1 10:29:18 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2fff06ab22a9a766d9314fdc4eaefeadbf67d63d
      https://github.com/WebKit/WebKit/commit/2fff06ab22a9a766d9314fdc4eaefeadbf67d63d
  Author: Ryan Reno <rreno at apple.com>
  Date:   2023-03-01 (Wed, 01 Mar 2023)

  Changed paths:
    A LayoutTests/fast/css/image-set-type-crash-expected.txt
    A LayoutTests/fast/css/image-set-type-crash.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-computed.sub-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-computed.sub.html
    M LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-computed.sub-expected.txt
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSImageSetOptionValue.cpp
    M Source/WebCore/css/CSSImageSetOptionValue.h
    M Source/WebCore/css/CSSImageSetValue.cpp
    M Source/WebCore/css/CSSImageValue.cpp
    M Source/WebCore/css/CSSImageValue.h
    M Source/WebCore/rendering/style/StyleImage.h
    M Source/WebCore/rendering/style/StyleImageSet.cpp
    M Source/WebCore/rendering/style/StyleImageSet.h
    A Source/WebCore/rendering/style/StyleInvalidImage.cpp
    A Source/WebCore/rendering/style/StyleInvalidImage.h
    M Source/WebCore/rendering/style/StyleMultiImage.cpp
    M Source/WebCore/rendering/style/StyleMultiImage.h

  Log Message:
  -----------
  image-set() should serialize in authored order
https://bugs.webkit.org/show_bug.cgi?id=251196
rdar://104683422

Reviewed by Antti Koivisto.

To make choosing an image in the image-set more efficient we sort the set
by resolution. This was causing us to serialize in a different order than the value
was authored if the author did not also sort by resolution. This change preserves the order
of the image-set-options as authored while providing a vector of sorted indices to enable
linear lookups by device resolution.

In the case where the image-set is empty because there are no supported image types
we introduce the concept of an invalid image[0]. This is a Style object that represents
a zero-sized image. This way we can have a well-defined image object to use in the style,
rendering, and paint systems but no loads will be triggered and the invalid image will
have zero intrinsic size so as not to affect layout calculations.

[0] http://w3c.github.io/csswg-drafts/css-images-4/#invalid-image

* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-computed.sub-expected.txt:
* LayoutTests/fast/css/image-set-type-crash-expected.txt: Added.
* LayoutTests/fast/css/image-set-type-crash.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-computed.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-images/image-set/image-set-computed.sub.html:
    Added test cases for checking the computed style of an image-set with no supported image types.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSImageSetOptionValue.cpp:
(WebCore::CSSImageSetOptionValue::CSSImageSetOptionValue):
(WebCore::CSSImageSetOptionValue::create):
(WebCore::CSSImageSetOptionValue::equals const):
(WebCore::CSSImageSetOptionValue::customCSSText const):
(WebCore::CSSImageSetOptionValue::setResolution):
(WebCore::CSSImageSetOptionValue::setType):
(WebCore::CSSImageSetOptionValue::Type::Type): Deleted.
(WebCore::CSSImageSetOptionValue::Type::cssText const): Deleted.
(WebCore::CSSImageSetOptionValue::image const): Deleted.
(WebCore::CSSImageSetOptionValue::resolution const): Deleted.
(WebCore::CSSImageSetOptionValue::type const): Deleted.
* Source/WebCore/css/CSSImageSetOptionValue.h:
    Remove the CSSImageSetOptionValue::Type class. Since we no longer filter the image set
    by given type prior to making the StyleImageSet object, there's no need to check if the type is
    supported at this stage. Now we just hold the string as given to us by the CSS parser (if any).
    Since type is an optional parameter for the image set option, we represent the lack of
    a specified type with a null string.

* Source/WebCore/css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::createStyleImage const):

* Source/WebCore/rendering/style/StyleImage.h:
(WebCore::StyleImage::isGeneratedImage const):
(WebCore::StyleImage::isInvalidImage const):

* Source/WebCore/rendering/style/StyleImageSet.cpp:
(WebCore::StyleImageSet::create):
(WebCore::StyleImageSet::StyleImageSet):
(WebCore::StyleImageSet::bestImageForScaleFactor):
* Source/WebCore/rendering/style/StyleImageSet.h:

* Source/WebCore/rendering/style/StyleInvalidImage.cpp: Copied from Source/WebCore/css/CSSImageSetOptionValue.h.
(WebCore::StyleInvalidImage::create):
(WebCore::StyleInvalidImage::StyleInvalidImage):
(WebCore::StyleInvalidImage::load):
(WebCore::StyleInvalidImage::image const):
(WebCore::StyleInvalidImage::computedStyleValue const):
* Source/WebCore/rendering/style/StyleInvalidImage.h: Copied from Source/WebCore/css/CSSImageSetOptionValue.h.

* Source/WebCore/rendering/style/StyleMultiImage.cpp:
(WebCore::StyleMultiImage::load):
* Source/WebCore/rendering/style/StyleMultiImage.h:

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




More information about the webkit-changes mailing list