haikuwebkit/Source/WebCore/rendering/style/StyleMultiImage.h

74 lines
2.7 KiB
C
Raw Permalink Normal View History

-webkit-image-set should support all the image functions WebKit supports, not just url() https://bugs.webkit.org/show_bug.cgi?id=81941 Patch by Noam Rosenthal <noam@webkit.org> on 2020-01-21 Reviewed by Darin Adler. Source/WebCore: Separate StyleCachedImage to 4 classes: - StyleCachedImage: for single images only - StyleMultiImage: for values that can contain multiple images: like cursor/image-set - StyleImageSet - StyleCursorImage The new classes only deal with their own value type. Before, ImageSet and cursor were resolved as a StyleCachedImage, which is no longer a valid assumption if image-set can contain generated images. Though cursors still can only contain cached images, it was cleaner to refactor it out as well. Refactored best-fit image selection from loading. Now StyleCachedImage is in charge of loading the actual image, and StyleImageSet/StyleCursorImage perform the source selection. Also, added the necessary logic in the CSS parser to consume generated images inside image-sets, excluding when the image-set is a cursor value. Tests: fast/css/image-set-parsing-generated.html fast/hidpi/image-set-cross-fade.html fast/hidpi/image-set-gradient-multi.html fast/hidpi/image-set-gradient-single.html fast/hidpi/image-set-gradient.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Added new files * css/CSSCursorImageValue.cpp: (WebCore::CSSCursorImageValue::selectBestFitImage): (WebCore::CSSCursorImageValue::loadImage): Deleted. * css/CSSCursorImageValue.h: Instead of cursor loading the image, it selects an image CSS value * css/CSSImageSetValue.cpp: (WebCore::CSSImageSetValue::CSSImageSetValue): (WebCore::CSSImageSetValue::fillImageSet): (WebCore::CSSImageSetValue::cachedImage const): (WebCore::CSSImageSetValue::selectBestFitImage): (WebCore::CSSImageSetValue::updateDeviceScaleFactor): (WebCore::CSSImageSetValue::imageSetWithStylesResolved): (WebCore::CSSImageSetValue::traverseSubresources const): (WebCore::CSSImageSetValue::loadBestFitImage): Deleted. * css/CSSImageSetValue.h: Refactor CSSImageSetValue to include non-cachedImage images * css/parser/CSSPropertyParser.cpp: (WebCore::consumeCursor): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeImageSet): (WebCore::CSSPropertyParserHelpers::consumeImage): (WebCore::CSSPropertyParserHelpers::consumeUrlOrStringAsStringView): Deleted. * css/parser/CSSPropertyParserHelpers.h: * page/animation/CSSPropertyAnimation.cpp: (WebCore::blendFunc): When blending two images, get the selected images in case it is an image-set * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintFillLayerExtended): * rendering/RenderImageResourceStyleImage.cpp: (WebCore::RenderImageResourceStyleImage::initialize): * rendering/RenderLayerBacking.cpp: (WebCore::canDirectlyCompositeBackgroundBackgroundImage): * rendering/style/ShapeValue.cpp: (WebCore::ShapeValue::isImageValid const): Use hasCachedImage() instead of isCachedImage() as a StyleImageSet is no longer an isCachedImage() * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::StyleCachedImage): (WebCore::StyleCachedImage::imageURL): (WebCore::StyleCachedImage::load): * rendering/style/StyleCachedImage.h: * rendering/style/StyleCursorImage.h: * rendering/style/StyleCursorImage.cpp: * rendering/style/StyleMultiImage.h: * rendering/style/StyleMultiImage.cpp: * rendering/style/StyleImageSet.h: * rendering/style/StyleImageSet.cpp: * rendering/style/StyleImage.h: (WebCore::StyleImage::selectedImage): (WebCore::StyleImage::selectedImage const): (WebCore::StyleImage::isCursorImage const): (WebCore::StyleImage::isImageSet const): (WebCore::StyleImage::hasCachedImage const): (WebCore::StyleImage::StyleImage): Separate cursor/image-set related stuff away from StyleCachedImage. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueContent): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::resolveImageStyles): (WebCore::Style::BuilderState::createStyleImage): * style/StyleBuilderState.h: Match the CSS values with the correct Style class. Also, ensure image-sets resolve their images' styles as they may contain gradients and other context-aware values. LayoutTests: * fast/css/cursor-parsing-expected.txt: * fast/css/cursor-parsing.html: Added parsing test to ensure arrow image-sets disable generated images * fast/css/image-set-parsing-generated-expected.txt: Added. * fast/css/image-set-parsing-generated.html: Added. * fast/css/image-set-parsing-invalid-expected.txt: * fast/css/image-set-parsing-invalid.html: Added parsing tests for new generated-inside-image-set use cases Test that image-set inside image-set is not supported * fast/hidpi/image-set-cross-fade-expected.html: Added. * fast/hidpi/image-set-cross-fade.html: Added. * fast/hidpi/image-set-gradient-expected.html: Added. * fast/hidpi/image-set-gradient-multi-expected.html: Added. * fast/hidpi/image-set-gradient-multi.html: Added. * fast/hidpi/image-set-gradient-single-expected.html: Added. * fast/hidpi/image-set-gradient-single.html: Added. * fast/hidpi/image-set-gradient.html: Added. Added ref-tests for several generated-inside-image-set use-cases Canonical link: https://commits.webkit.org/219598@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 18:28:17 +00:00
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
Null check renderers consistently in StyleImage code https://bugs.webkit.org/show_bug.cgi?id=221287 rdar://73356955 Reviewed by Simon Fraser. Many of these functions were asserting renderers are non-null, without a strong guarantee that is true. Adding a few null checks makes the code easier to reason about. An exception was add/removeClient, which never need to be called with a null pointer, so for that we change the argument type from a pointer to a reference. * rendering/RenderElement.cpp: (WebCore::RenderElement::updateFillImages): Pass a reference. (WebCore::RenderElement::updateImage): Ditto. (WebCore::RenderElement::willBeDestroyed): Ditto. * rendering/RenderImageResource.cpp: (WebCore::RenderImageResource::setCachedImage): Check renderer for null. (WebCore::RenderImageResource::resetAnimation): Ditto. (WebCore::RenderImageResource::setContainerContext): Ditto. * rendering/RenderImageResourceStyleImage.cpp: (WebCore::RenderImageResourceStyleImage::initialize): Pass a reference. (WebCore::RenderImageResourceStyleImage::shutdown): Check the renderer for null before passing a reference. (WebCore::RenderImageResourceStyleImage::setContainerContext): Ditto. * rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::willBeDestroyed): Pass a reference. (WebCore::RenderListMarker::styleDidChange): Ditto. * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::addClient): Take a reference. (WebCore::StyleCachedImage::removeClient): Ditto. * rendering/style/StyleGeneratedImage.cpp: (WebCore::StyleGeneratedImage::imageSize const): Check renderer for null. (WebCore::StyleGeneratedImage::addClient): Take a reference. (WebCore::StyleGeneratedImage::removeClient): Ditto. (WebCore::StyleGeneratedImage::image const): Check renderer for null. (WebCore::StyleGeneratedImage::knownToBeOpaque const): Ditto. * rendering/style/StyleMultiImage.cpp: (WebCore::StyleMultiImage::addClient): Take a reference. (WebCore::StyleMultiImage::removeClient): Ditto. * rendering/style/StyleCachedImage.h: Update add/removeClient to take a reference. * rendering/style/StyleGeneratedImage.h: Ditto. * rendering/style/StyleImage.h: Ditto. * rendering/style/StyleMultiImage.h: Ditto. Canonical link: https://commits.webkit.org/233611@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-02 22:00:32 +00:00
* Copyright (C) 2003-2021 Apple Inc. All rights reserved.
-webkit-image-set should support all the image functions WebKit supports, not just url() https://bugs.webkit.org/show_bug.cgi?id=81941 Patch by Noam Rosenthal <noam@webkit.org> on 2020-01-21 Reviewed by Darin Adler. Source/WebCore: Separate StyleCachedImage to 4 classes: - StyleCachedImage: for single images only - StyleMultiImage: for values that can contain multiple images: like cursor/image-set - StyleImageSet - StyleCursorImage The new classes only deal with their own value type. Before, ImageSet and cursor were resolved as a StyleCachedImage, which is no longer a valid assumption if image-set can contain generated images. Though cursors still can only contain cached images, it was cleaner to refactor it out as well. Refactored best-fit image selection from loading. Now StyleCachedImage is in charge of loading the actual image, and StyleImageSet/StyleCursorImage perform the source selection. Also, added the necessary logic in the CSS parser to consume generated images inside image-sets, excluding when the image-set is a cursor value. Tests: fast/css/image-set-parsing-generated.html fast/hidpi/image-set-cross-fade.html fast/hidpi/image-set-gradient-multi.html fast/hidpi/image-set-gradient-single.html fast/hidpi/image-set-gradient.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Added new files * css/CSSCursorImageValue.cpp: (WebCore::CSSCursorImageValue::selectBestFitImage): (WebCore::CSSCursorImageValue::loadImage): Deleted. * css/CSSCursorImageValue.h: Instead of cursor loading the image, it selects an image CSS value * css/CSSImageSetValue.cpp: (WebCore::CSSImageSetValue::CSSImageSetValue): (WebCore::CSSImageSetValue::fillImageSet): (WebCore::CSSImageSetValue::cachedImage const): (WebCore::CSSImageSetValue::selectBestFitImage): (WebCore::CSSImageSetValue::updateDeviceScaleFactor): (WebCore::CSSImageSetValue::imageSetWithStylesResolved): (WebCore::CSSImageSetValue::traverseSubresources const): (WebCore::CSSImageSetValue::loadBestFitImage): Deleted. * css/CSSImageSetValue.h: Refactor CSSImageSetValue to include non-cachedImage images * css/parser/CSSPropertyParser.cpp: (WebCore::consumeCursor): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeImageSet): (WebCore::CSSPropertyParserHelpers::consumeImage): (WebCore::CSSPropertyParserHelpers::consumeUrlOrStringAsStringView): Deleted. * css/parser/CSSPropertyParserHelpers.h: * page/animation/CSSPropertyAnimation.cpp: (WebCore::blendFunc): When blending two images, get the selected images in case it is an image-set * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintFillLayerExtended): * rendering/RenderImageResourceStyleImage.cpp: (WebCore::RenderImageResourceStyleImage::initialize): * rendering/RenderLayerBacking.cpp: (WebCore::canDirectlyCompositeBackgroundBackgroundImage): * rendering/style/ShapeValue.cpp: (WebCore::ShapeValue::isImageValid const): Use hasCachedImage() instead of isCachedImage() as a StyleImageSet is no longer an isCachedImage() * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::StyleCachedImage): (WebCore::StyleCachedImage::imageURL): (WebCore::StyleCachedImage::load): * rendering/style/StyleCachedImage.h: * rendering/style/StyleCursorImage.h: * rendering/style/StyleCursorImage.cpp: * rendering/style/StyleMultiImage.h: * rendering/style/StyleMultiImage.cpp: * rendering/style/StyleImageSet.h: * rendering/style/StyleImageSet.cpp: * rendering/style/StyleImage.h: (WebCore::StyleImage::selectedImage): (WebCore::StyleImage::selectedImage const): (WebCore::StyleImage::isCursorImage const): (WebCore::StyleImage::isImageSet const): (WebCore::StyleImage::hasCachedImage const): (WebCore::StyleImage::StyleImage): Separate cursor/image-set related stuff away from StyleCachedImage. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueContent): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::resolveImageStyles): (WebCore::Style::BuilderState::createStyleImage): * style/StyleBuilderState.h: Match the CSS values with the correct Style class. Also, ensure image-sets resolve their images' styles as they may contain gradients and other context-aware values. LayoutTests: * fast/css/cursor-parsing-expected.txt: * fast/css/cursor-parsing.html: Added parsing test to ensure arrow image-sets disable generated images * fast/css/image-set-parsing-generated-expected.txt: Added. * fast/css/image-set-parsing-generated.html: Added. * fast/css/image-set-parsing-invalid-expected.txt: * fast/css/image-set-parsing-invalid.html: Added parsing tests for new generated-inside-image-set use cases Test that image-set inside image-set is not supported * fast/hidpi/image-set-cross-fade-expected.html: Added. * fast/hidpi/image-set-cross-fade.html: Added. * fast/hidpi/image-set-gradient-expected.html: Added. * fast/hidpi/image-set-gradient-multi-expected.html: Added. * fast/hidpi/image-set-gradient-multi.html: Added. * fast/hidpi/image-set-gradient-single-expected.html: Added. * fast/hidpi/image-set-gradient-single.html: Added. * fast/hidpi/image-set-gradient.html: Added. Added ref-tests for several generated-inside-image-set use-cases Canonical link: https://commits.webkit.org/219598@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 18:28:17 +00:00
* Copyright (C) 2020 Noam Rosenthal (noam@webkit.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#pragma once
#include "StyleImage.h"
namespace WebCore {
class Document;
struct ImageWithScale;
class StyleMultiImage : public StyleImage {
WTF_MAKE_FAST_ALLOCATED;
public:
virtual ~StyleMultiImage();
protected:
StyleMultiImage();
bool equals(const StyleMultiImage& other) const;
virtual ImageWithScale selectBestFitImage(const Document&) const = 0;
CachedImage* cachedImage() const final;
private:
WrappedImagePtr data() const final;
bool canRender(const RenderElement*, float multiplier) const final;
bool isPending() const final;
void load(CachedResourceLoader&, const ResourceLoaderOptions&) final;
bool isLoaded() const final;
bool errorOccurred() const final;
FloatSize imageSize(const RenderElement*, float multiplier) const final;
bool imageHasRelativeWidth() const final;
bool imageHasRelativeHeight() const final;
void computeIntrinsicDimensions(const RenderElement*, Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) final;
bool usesImageContainerSize() const final;
void setContainerContextForRenderer(const RenderElement&, const FloatSize&, float);
Null check renderers consistently in StyleImage code https://bugs.webkit.org/show_bug.cgi?id=221287 rdar://73356955 Reviewed by Simon Fraser. Many of these functions were asserting renderers are non-null, without a strong guarantee that is true. Adding a few null checks makes the code easier to reason about. An exception was add/removeClient, which never need to be called with a null pointer, so for that we change the argument type from a pointer to a reference. * rendering/RenderElement.cpp: (WebCore::RenderElement::updateFillImages): Pass a reference. (WebCore::RenderElement::updateImage): Ditto. (WebCore::RenderElement::willBeDestroyed): Ditto. * rendering/RenderImageResource.cpp: (WebCore::RenderImageResource::setCachedImage): Check renderer for null. (WebCore::RenderImageResource::resetAnimation): Ditto. (WebCore::RenderImageResource::setContainerContext): Ditto. * rendering/RenderImageResourceStyleImage.cpp: (WebCore::RenderImageResourceStyleImage::initialize): Pass a reference. (WebCore::RenderImageResourceStyleImage::shutdown): Check the renderer for null before passing a reference. (WebCore::RenderImageResourceStyleImage::setContainerContext): Ditto. * rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::willBeDestroyed): Pass a reference. (WebCore::RenderListMarker::styleDidChange): Ditto. * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::addClient): Take a reference. (WebCore::StyleCachedImage::removeClient): Ditto. * rendering/style/StyleGeneratedImage.cpp: (WebCore::StyleGeneratedImage::imageSize const): Check renderer for null. (WebCore::StyleGeneratedImage::addClient): Take a reference. (WebCore::StyleGeneratedImage::removeClient): Ditto. (WebCore::StyleGeneratedImage::image const): Check renderer for null. (WebCore::StyleGeneratedImage::knownToBeOpaque const): Ditto. * rendering/style/StyleMultiImage.cpp: (WebCore::StyleMultiImage::addClient): Take a reference. (WebCore::StyleMultiImage::removeClient): Ditto. * rendering/style/StyleCachedImage.h: Update add/removeClient to take a reference. * rendering/style/StyleGeneratedImage.h: Ditto. * rendering/style/StyleImage.h: Ditto. * rendering/style/StyleMultiImage.h: Ditto. Canonical link: https://commits.webkit.org/233611@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-02 22:00:32 +00:00
void addClient(RenderElement&) final;
void removeClient(RenderElement&) final;
CSS custom properties on pseudo elements background gradients causes infinite layout and high CPU load https://bugs.webkit.org/show_bug.cgi?id=194332 <rdar://problem/47873895> Reviewed by Simon Fraser. Source/WebCore: When a background-image uses a CSS custom property the resulting StyleGeneratedImage may not be the same object as during prior style updates. This caused transitions to be triggered for all style updates for such background-image values. To fix this, we modify the == operator for StyleGeneratedImage to use arePointingToEqualData() with the CSSImageGeneratorValue member and added an == operator for the CSSImageGeneratorValue class to call into the existing equals() methods. These equals() methods are now overrides of the virtual CSSImageGeneratorValue method. This change in behavior required a change in RenderElement::updateFillImages() to not only check whether the images were identical, but to also check whether the renderer was registered as a client on the new images. To do this, we add a new virtual hasClient() method on StyleImage. Test: webanimations/css-transition-element-with-gradient-background-image-and-css-custom-property.html * css/CSSImageGeneratorValue.cpp: (WebCore::CSSImageGeneratorValue::operator== const): * css/CSSImageGeneratorValue.h: * rendering/RenderElement.cpp: (WebCore::RenderElement::updateFillImages): * rendering/style/FillLayer.cpp: (WebCore::FillLayer::imagesIdentical): Deleted. * rendering/style/FillLayer.h: * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::hasClient const): * rendering/style/StyleCachedImage.h: * rendering/style/StyleGeneratedImage.cpp: (WebCore::StyleGeneratedImage::operator== const): (WebCore::StyleGeneratedImage::hasClient const): * rendering/style/StyleGeneratedImage.h: * rendering/style/StyleImage.h: * rendering/style/StyleMultiImage.cpp: (WebCore::StyleMultiImage::hasClient const): * rendering/style/StyleMultiImage.h: LayoutTests: Add a test where an element with a background-image set to a CSS gradient using a custom property as a color stop changes another property targeted by a transition to check that there is no background-image transition generated. * webanimations/css-transition-element-with-gradient-background-image-and-css-custom-property-expected.txt: Added. * webanimations/css-transition-element-with-gradient-background-image-and-css-custom-property.html: Added. Canonical link: https://commits.webkit.org/237410@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277112 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-06 20:11:19 +00:00
bool hasClient(RenderElement&) const final;
-webkit-image-set should support all the image functions WebKit supports, not just url() https://bugs.webkit.org/show_bug.cgi?id=81941 Patch by Noam Rosenthal <noam@webkit.org> on 2020-01-21 Reviewed by Darin Adler. Source/WebCore: Separate StyleCachedImage to 4 classes: - StyleCachedImage: for single images only - StyleMultiImage: for values that can contain multiple images: like cursor/image-set - StyleImageSet - StyleCursorImage The new classes only deal with their own value type. Before, ImageSet and cursor were resolved as a StyleCachedImage, which is no longer a valid assumption if image-set can contain generated images. Though cursors still can only contain cached images, it was cleaner to refactor it out as well. Refactored best-fit image selection from loading. Now StyleCachedImage is in charge of loading the actual image, and StyleImageSet/StyleCursorImage perform the source selection. Also, added the necessary logic in the CSS parser to consume generated images inside image-sets, excluding when the image-set is a cursor value. Tests: fast/css/image-set-parsing-generated.html fast/hidpi/image-set-cross-fade.html fast/hidpi/image-set-gradient-multi.html fast/hidpi/image-set-gradient-single.html fast/hidpi/image-set-gradient.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Added new files * css/CSSCursorImageValue.cpp: (WebCore::CSSCursorImageValue::selectBestFitImage): (WebCore::CSSCursorImageValue::loadImage): Deleted. * css/CSSCursorImageValue.h: Instead of cursor loading the image, it selects an image CSS value * css/CSSImageSetValue.cpp: (WebCore::CSSImageSetValue::CSSImageSetValue): (WebCore::CSSImageSetValue::fillImageSet): (WebCore::CSSImageSetValue::cachedImage const): (WebCore::CSSImageSetValue::selectBestFitImage): (WebCore::CSSImageSetValue::updateDeviceScaleFactor): (WebCore::CSSImageSetValue::imageSetWithStylesResolved): (WebCore::CSSImageSetValue::traverseSubresources const): (WebCore::CSSImageSetValue::loadBestFitImage): Deleted. * css/CSSImageSetValue.h: Refactor CSSImageSetValue to include non-cachedImage images * css/parser/CSSPropertyParser.cpp: (WebCore::consumeCursor): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeImageSet): (WebCore::CSSPropertyParserHelpers::consumeImage): (WebCore::CSSPropertyParserHelpers::consumeUrlOrStringAsStringView): Deleted. * css/parser/CSSPropertyParserHelpers.h: * page/animation/CSSPropertyAnimation.cpp: (WebCore::blendFunc): When blending two images, get the selected images in case it is an image-set * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintFillLayerExtended): * rendering/RenderImageResourceStyleImage.cpp: (WebCore::RenderImageResourceStyleImage::initialize): * rendering/RenderLayerBacking.cpp: (WebCore::canDirectlyCompositeBackgroundBackgroundImage): * rendering/style/ShapeValue.cpp: (WebCore::ShapeValue::isImageValid const): Use hasCachedImage() instead of isCachedImage() as a StyleImageSet is no longer an isCachedImage() * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::StyleCachedImage): (WebCore::StyleCachedImage::imageURL): (WebCore::StyleCachedImage::load): * rendering/style/StyleCachedImage.h: * rendering/style/StyleCursorImage.h: * rendering/style/StyleCursorImage.cpp: * rendering/style/StyleMultiImage.h: * rendering/style/StyleMultiImage.cpp: * rendering/style/StyleImageSet.h: * rendering/style/StyleImageSet.cpp: * rendering/style/StyleImage.h: (WebCore::StyleImage::selectedImage): (WebCore::StyleImage::selectedImage const): (WebCore::StyleImage::isCursorImage const): (WebCore::StyleImage::isImageSet const): (WebCore::StyleImage::hasCachedImage const): (WebCore::StyleImage::StyleImage): Separate cursor/image-set related stuff away from StyleCachedImage. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueContent): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::resolveImageStyles): (WebCore::Style::BuilderState::createStyleImage): * style/StyleBuilderState.h: Match the CSS values with the correct Style class. Also, ensure image-sets resolve their images' styles as they may contain gradients and other context-aware values. LayoutTests: * fast/css/cursor-parsing-expected.txt: * fast/css/cursor-parsing.html: Added parsing test to ensure arrow image-sets disable generated images * fast/css/image-set-parsing-generated-expected.txt: Added. * fast/css/image-set-parsing-generated.html: Added. * fast/css/image-set-parsing-invalid-expected.txt: * fast/css/image-set-parsing-invalid.html: Added parsing tests for new generated-inside-image-set use cases Test that image-set inside image-set is not supported * fast/hidpi/image-set-cross-fade-expected.html: Added. * fast/hidpi/image-set-cross-fade.html: Added. * fast/hidpi/image-set-gradient-expected.html: Added. * fast/hidpi/image-set-gradient-multi-expected.html: Added. * fast/hidpi/image-set-gradient-multi.html: Added. * fast/hidpi/image-set-gradient-single-expected.html: Added. * fast/hidpi/image-set-gradient-single.html: Added. * fast/hidpi/image-set-gradient.html: Added. Added ref-tests for several generated-inside-image-set use-cases Canonical link: https://commits.webkit.org/219598@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 18:28:17 +00:00
RefPtr<Image> image(RenderElement*, const FloatSize&) const final;
float imageScaleFactor() const final;
bool knownToBeOpaque(const RenderElement&) const final;
-webkit-image-set should support all the image functions WebKit supports, not just url() https://bugs.webkit.org/show_bug.cgi?id=81941 Patch by Noam Rosenthal <noam@webkit.org> on 2020-01-21 Reviewed by Darin Adler. Source/WebCore: Separate StyleCachedImage to 4 classes: - StyleCachedImage: for single images only - StyleMultiImage: for values that can contain multiple images: like cursor/image-set - StyleImageSet - StyleCursorImage The new classes only deal with their own value type. Before, ImageSet and cursor were resolved as a StyleCachedImage, which is no longer a valid assumption if image-set can contain generated images. Though cursors still can only contain cached images, it was cleaner to refactor it out as well. Refactored best-fit image selection from loading. Now StyleCachedImage is in charge of loading the actual image, and StyleImageSet/StyleCursorImage perform the source selection. Also, added the necessary logic in the CSS parser to consume generated images inside image-sets, excluding when the image-set is a cursor value. Tests: fast/css/image-set-parsing-generated.html fast/hidpi/image-set-cross-fade.html fast/hidpi/image-set-gradient-multi.html fast/hidpi/image-set-gradient-single.html fast/hidpi/image-set-gradient.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Added new files * css/CSSCursorImageValue.cpp: (WebCore::CSSCursorImageValue::selectBestFitImage): (WebCore::CSSCursorImageValue::loadImage): Deleted. * css/CSSCursorImageValue.h: Instead of cursor loading the image, it selects an image CSS value * css/CSSImageSetValue.cpp: (WebCore::CSSImageSetValue::CSSImageSetValue): (WebCore::CSSImageSetValue::fillImageSet): (WebCore::CSSImageSetValue::cachedImage const): (WebCore::CSSImageSetValue::selectBestFitImage): (WebCore::CSSImageSetValue::updateDeviceScaleFactor): (WebCore::CSSImageSetValue::imageSetWithStylesResolved): (WebCore::CSSImageSetValue::traverseSubresources const): (WebCore::CSSImageSetValue::loadBestFitImage): Deleted. * css/CSSImageSetValue.h: Refactor CSSImageSetValue to include non-cachedImage images * css/parser/CSSPropertyParser.cpp: (WebCore::consumeCursor): * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeImageSet): (WebCore::CSSPropertyParserHelpers::consumeImage): (WebCore::CSSPropertyParserHelpers::consumeUrlOrStringAsStringView): Deleted. * css/parser/CSSPropertyParserHelpers.h: * page/animation/CSSPropertyAnimation.cpp: (WebCore::blendFunc): When blending two images, get the selected images in case it is an image-set * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintFillLayerExtended): * rendering/RenderImageResourceStyleImage.cpp: (WebCore::RenderImageResourceStyleImage::initialize): * rendering/RenderLayerBacking.cpp: (WebCore::canDirectlyCompositeBackgroundBackgroundImage): * rendering/style/ShapeValue.cpp: (WebCore::ShapeValue::isImageValid const): Use hasCachedImage() instead of isCachedImage() as a StyleImageSet is no longer an isCachedImage() * rendering/style/StyleCachedImage.cpp: (WebCore::StyleCachedImage::StyleCachedImage): (WebCore::StyleCachedImage::imageURL): (WebCore::StyleCachedImage::load): * rendering/style/StyleCachedImage.h: * rendering/style/StyleCursorImage.h: * rendering/style/StyleCursorImage.cpp: * rendering/style/StyleMultiImage.h: * rendering/style/StyleMultiImage.cpp: * rendering/style/StyleImageSet.h: * rendering/style/StyleImageSet.cpp: * rendering/style/StyleImage.h: (WebCore::StyleImage::selectedImage): (WebCore::StyleImage::selectedImage const): (WebCore::StyleImage::isCursorImage const): (WebCore::StyleImage::isImageSet const): (WebCore::StyleImage::hasCachedImage const): (WebCore::StyleImage::StyleImage): Separate cursor/image-set related stuff away from StyleCachedImage. * style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueContent): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::resolveImageStyles): (WebCore::Style::BuilderState::createStyleImage): * style/StyleBuilderState.h: Match the CSS values with the correct Style class. Also, ensure image-sets resolve their images' styles as they may contain gradients and other context-aware values. LayoutTests: * fast/css/cursor-parsing-expected.txt: * fast/css/cursor-parsing.html: Added parsing test to ensure arrow image-sets disable generated images * fast/css/image-set-parsing-generated-expected.txt: Added. * fast/css/image-set-parsing-generated.html: Added. * fast/css/image-set-parsing-invalid-expected.txt: * fast/css/image-set-parsing-invalid.html: Added parsing tests for new generated-inside-image-set use cases Test that image-set inside image-set is not supported * fast/hidpi/image-set-cross-fade-expected.html: Added. * fast/hidpi/image-set-cross-fade.html: Added. * fast/hidpi/image-set-gradient-expected.html: Added. * fast/hidpi/image-set-gradient-multi-expected.html: Added. * fast/hidpi/image-set-gradient-multi.html: Added. * fast/hidpi/image-set-gradient-single-expected.html: Added. * fast/hidpi/image-set-gradient-single.html: Added. * fast/hidpi/image-set-gradient.html: Added. Added ref-tests for several generated-inside-image-set use-cases Canonical link: https://commits.webkit.org/219598@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 18:28:17 +00:00
const StyleImage* selectedImage() const final { return m_selectedImage.get(); }
StyleImage* selectedImage() final { return m_selectedImage.get(); }
RefPtr<StyleImage> m_selectedImage;
bool m_isPending { true };
};
} // namespace WebCore