Changeset 204560 in webkit


Ignore:
Timestamp:
Aug 17, 2016 9:37:45 AM (8 years ago)
Author:
Antti Koivisto
Message:

Remove StyleCachedImageSet
https://bugs.webkit.org/show_bug.cgi?id=160941

Reviewed by Simon Fraser.

It is almost the same as StyleCachedImage. Just use that.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSCursorImageValue.cpp:

(WebCore::CSSCursorImageValue::cachedImage):

  • css/CSSImageSetValue.cpp:

(WebCore::CSSImageSetValue::detachPendingImage):
(WebCore::CSSImageSetValue::~CSSImageSetValue):
(WebCore::CSSImageSetValue::fillImageSet):
(WebCore::CSSImageSetValue::bestImageForScaleFactor):
(WebCore::CSSImageSetValue::bestFitImage):
(WebCore::CSSImageSetValue::cachedOrPendingImageSet):
(WebCore::CSSImageSetValue::customCSSText):
(WebCore::CSSImageSetValue::traverseSubresources):
(WebCore::CSSImageSetValue::cachedImageSet): Deleted.

  • css/CSSImageSetValue.h:

(WebCore::CSSImageSetValue::create):
(WebCore::CSSImageSetValue::compareByScaleFactor):

  • css/StyleResolver.cpp:
  • page/EventHandler.cpp:
  • rendering/style/ShapeValue.cpp:

(WebCore::ShapeValue::isImageValid):

  • rendering/style/StyleAllInOne.cpp:
  • rendering/style/StyleCachedImage.cpp:

(WebCore::StyleCachedImage::StyleCachedImage):

Add scale factor and CSSImageSetValue backpointer, the only additional features of StyleCachedImageSet.

(WebCore::StyleCachedImage::cssValue):
(WebCore::StyleCachedImage::imageSize):
(WebCore::StyleCachedImage::imageHasRelativeWidth):

  • rendering/style/StyleCachedImage.h:
  • rendering/style/StyleCachedImageSet.cpp: Removed.
  • rendering/style/StyleCachedImageSet.h: Removed.
  • rendering/style/StyleImage.h:

(WebCore::StyleImage::isCachedImage):
(WebCore::StyleImage::isPendingImage):
(WebCore::StyleImage::isGeneratedImage):
(WebCore::StyleImage::StyleImage):
(WebCore::StyleImage::isCachedImageSet): Deleted.

  • style/StylePendingResources.cpp:

(WebCore::Style::loadPendingImage):

Location:
trunk/Source/WebCore
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r204531 r204560  
    25792579    rendering/style/StyleBoxData.cpp
    25802580    rendering/style/StyleCachedImage.cpp
    2581     rendering/style/StyleCachedImageSet.cpp
    25822581    rendering/style/StyleDeprecatedFlexibleBoxData.cpp
    25832582    rendering/style/StyleFilterData.cpp
  • trunk/Source/WebCore/ChangeLog

    r204558 r204560  
     12016-08-17  Antti Koivisto  <antti@apple.com>
     2
     3        Remove StyleCachedImageSet
     4        https://bugs.webkit.org/show_bug.cgi?id=160941
     5
     6        Reviewed by Simon Fraser.
     7
     8        It is almost the same as StyleCachedImage. Just use that.
     9
     10        * CMakeLists.txt:
     11        * WebCore.xcodeproj/project.pbxproj:
     12        * css/CSSCursorImageValue.cpp:
     13        (WebCore::CSSCursorImageValue::cachedImage):
     14        * css/CSSImageSetValue.cpp:
     15        (WebCore::CSSImageSetValue::detachPendingImage):
     16        (WebCore::CSSImageSetValue::~CSSImageSetValue):
     17        (WebCore::CSSImageSetValue::fillImageSet):
     18        (WebCore::CSSImageSetValue::bestImageForScaleFactor):
     19        (WebCore::CSSImageSetValue::bestFitImage):
     20        (WebCore::CSSImageSetValue::cachedOrPendingImageSet):
     21        (WebCore::CSSImageSetValue::customCSSText):
     22        (WebCore::CSSImageSetValue::traverseSubresources):
     23        (WebCore::CSSImageSetValue::cachedImageSet): Deleted.
     24        * css/CSSImageSetValue.h:
     25        (WebCore::CSSImageSetValue::create):
     26        (WebCore::CSSImageSetValue::compareByScaleFactor):
     27        * css/StyleResolver.cpp:
     28        * page/EventHandler.cpp:
     29        * rendering/style/ShapeValue.cpp:
     30        (WebCore::ShapeValue::isImageValid):
     31        * rendering/style/StyleAllInOne.cpp:
     32        * rendering/style/StyleCachedImage.cpp:
     33        (WebCore::StyleCachedImage::StyleCachedImage):
     34
     35            Add scale factor and CSSImageSetValue backpointer, the only additional features of StyleCachedImageSet.
     36
     37        (WebCore::StyleCachedImage::cssValue):
     38        (WebCore::StyleCachedImage::imageSize):
     39        (WebCore::StyleCachedImage::imageHasRelativeWidth):
     40        * rendering/style/StyleCachedImage.h:
     41        * rendering/style/StyleCachedImageSet.cpp: Removed.
     42        * rendering/style/StyleCachedImageSet.h: Removed.
     43        * rendering/style/StyleImage.h:
     44        (WebCore::StyleImage::isCachedImage):
     45        (WebCore::StyleImage::isPendingImage):
     46        (WebCore::StyleImage::isGeneratedImage):
     47        (WebCore::StyleImage::StyleImage):
     48        (WebCore::StyleImage::isCachedImageSet): Deleted.
     49        * style/StylePendingResources.cpp:
     50        (WebCore::Style::loadPendingImage):
     51
    1522016-08-17  Per Arne Vollan  <pvollan@apple.com>
    253
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r204532 r204560  
    35783578                9393E5FF151A99F200066F06 /* CSSImageSetValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9393E5FD151A99F200066F06 /* CSSImageSetValue.cpp */; };
    35793579                9393E600151A99F200066F06 /* CSSImageSetValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9393E5FE151A99F200066F06 /* CSSImageSetValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3580                 9393E604151A9A1800066F06 /* StyleCachedImageSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9393E602151A9A1800066F06 /* StyleCachedImageSet.cpp */; };
    3581                 9393E605151A9A1800066F06 /* StyleCachedImageSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 9393E603151A9A1800066F06 /* StyleCachedImageSet.h */; };
    35823580                939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939885C108B7E3D100E707C4 /* EventNames.cpp */; };
    35833581                939885C408B7E3D100E707C4 /* EventNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 939885C208B7E3D100E707C4 /* EventNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1109211090                9393E5FD151A99F200066F06 /* CSSImageSetValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSImageSetValue.cpp; sourceTree = "<group>"; };
    1109311091                9393E5FE151A99F200066F06 /* CSSImageSetValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSImageSetValue.h; sourceTree = "<group>"; };
    11094                 9393E602151A9A1800066F06 /* StyleCachedImageSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleCachedImageSet.cpp; sourceTree = "<group>"; };
    11095                 9393E603151A9A1800066F06 /* StyleCachedImageSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleCachedImageSet.h; sourceTree = "<group>"; };
    1109611092                93955A4103D72932008635CE /* RenderTreeAsText.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeAsText.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    1109711093                93955A4203D72932008635CE /* RenderTreeAsText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeAsText.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    2227822274                                BCEF44790E6747D0001C1287 /* StyleCachedImage.cpp */,
    2227922275                                BCEF444C0E674628001C1287 /* StyleCachedImage.h */,
    22280                                 9393E602151A9A1800066F06 /* StyleCachedImageSet.cpp */,
    22281                                 9393E603151A9A1800066F06 /* StyleCachedImageSet.h */,
    2228222276                                9DAC7C561AF2CB6400437C44 /* StyleContentAlignmentData.h */,
    2228322277                                BC779E151BB226A200CAA8BF /* StyleCustomPropertyData.h */,
     
    2765227646                                835D363719FF6193004C93AB /* StyleBuilderCustom.h in Headers */,
    2765327647                                BCEF444D0E674628001C1287 /* StyleCachedImage.h in Headers */,
    27654                                 9393E605151A9A1800066F06 /* StyleCachedImageSet.h in Headers */,
    2765527648                                E401E0A41C3C0B8300F34D10 /* StyleChange.h in Headers */,
    2765627649                                9DAC7C571AF2CB6400437C44 /* StyleContentAlignmentData.h in Headers */,
     
    3127931272                                8386A97019F61E4F00E1EC4A /* StyleBuilder.cpp in Sources */,
    3128031273                                BCEF447A0E6747D0001C1287 /* StyleCachedImage.cpp in Sources */,
    31281                                 9393E604151A9A1800066F06 /* StyleCachedImageSet.cpp in Sources */,
    3128231274                                E401E0A61C3C0CF700F34D10 /* StyleChange.cpp in Sources */,
    3128331275                                A8C4A7FE09D563270003AC8D /* StyledElement.cpp in Sources */,
  • trunk/Source/WebCore/css/CSSCursorImageValue.cpp

    r202656 r204560  
    2323#include "CSSCursorImageValue.h"
    2424
     25#include "CSSImageSetValue.h"
    2526#include "CSSImageValue.h"
    2627#include "CachedImage.h"
     
    4041#if ENABLE(CSS_IMAGE_SET)
    4142#include "CSSImageSetValue.h"
    42 #include "StyleCachedImageSet.h"
    4343#endif
    4444
     
    121121#if ENABLE(CSS_IMAGE_SET)
    122122    if (is<CSSImageSetValue>(m_imageValue.get()))
    123         return downcast<CSSImageSetValue>(m_imageValue.get()).cachedImageSet(loader, options);
     123        return downcast<CSSImageSetValue>(m_imageValue.get()).bestFitImage(loader, options);
    124124#endif
    125125
  • trunk/Source/WebCore/css/CSSImageSetValue.cpp

    r204014 r204560  
    3838#include "Document.h"
    3939#include "Page.h"
    40 #include "StyleCachedImageSet.h"
     40#include "StyleCachedImage.h"
    4141#include "StylePendingImage.h"
    4242#include <wtf/text/StringBuilder.h>
     
    5353inline void CSSImageSetValue::detachPendingImage()
    5454{
    55     if (is<StylePendingImage>(m_imageSet.get()))
    56         downcast<StylePendingImage>(*m_imageSet).detachFromCSSValue();
     55    if (is<StylePendingImage>(m_image.get()))
     56        downcast<StylePendingImage>(*m_image).detachFromCSSValue();
    5757}
    5858
     
    6161    detachPendingImage();
    6262
    63     if (is<StyleCachedImageSet>(m_imageSet.get()))
    64         downcast<StyleCachedImageSet>(*m_imageSet).clearImageSetValue();
     63    if (is<StyleCachedImage>(m_image.get()))
     64        downcast<StyleCachedImage>(*m_image).detachFromCSSValue();
    6565}
    6666
     
    101101}
    102102
    103 StyleCachedImageSet* CSSImageSetValue::cachedImageSet(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
     103StyleCachedImage* CSSImageSetValue::bestFitImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
    104104{
    105105    Document* document = loader.document();
     
    125125        if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) {
    126126            detachPendingImage();
    127             m_imageSet = StyleCachedImageSet::create(cachedImage.get(), image.scaleFactor, this);
     127            m_image = StyleCachedImage::createForImageSet(cachedImage.get(), image.scaleFactor, *this);
    128128            m_accessedBestFitImage = true;
    129129        }
    130130    }
    131131
    132     return is<StyleCachedImageSet>(m_imageSet.get()) ? downcast<StyleCachedImageSet>(m_imageSet.get()) : nullptr;
     132    return is<StyleCachedImage>(m_image.get()) ? downcast<StyleCachedImage>(m_image.get()) : nullptr;
    133133}
    134134
    135135StyleImage* CSSImageSetValue::cachedOrPendingImageSet(const Document& document)
    136136{
    137     if (!m_imageSet)
    138         m_imageSet = StylePendingImage::create(this);
    139     else if (!m_imageSet->isPendingImage()) {
     137    if (!m_image)
     138        m_image = StylePendingImage::create(this);
     139    else if (!m_image->isPendingImage()) {
    140140        float deviceScaleFactor = 1;
    141141        if (Page* page = document.page())
     
    145145        if (deviceScaleFactor != m_scaleFactor) {
    146146            m_accessedBestFitImage = false;
    147             m_imageSet = StylePendingImage::create(this);
     147            m_image = StylePendingImage::create(this);
    148148        }
    149149    }
    150150
    151     return m_imageSet.get();
     151    return m_image.get();
    152152}
    153153
     
    184184bool CSSImageSetValue::traverseSubresources(const std::function<bool (const CachedResource&)>& handler) const
    185185{
    186     if (!is<StyleCachedImageSet>(m_imageSet.get()))
     186    if (!is<StyleCachedImage>(m_image.get()))
    187187        return false;
    188     CachedImage* cachedResource = downcast<StyleCachedImageSet>(*m_imageSet).cachedImage();
     188    CachedImage* cachedResource = downcast<StyleCachedImage>(*m_image).cachedImage();
    189189    ASSERT(cachedResource);
    190190    return handler(*cachedResource);
  • trunk/Source/WebCore/css/CSSImageSetValue.h

    r202656 r204560  
    3535class CachedResourceLoader;
    3636class Document;
    37 class StyleCachedImageSet;
     37class StyleCachedImage;
    3838class StyleImage;
    3939struct ResourceLoaderOptions;
     
    4848    ~CSSImageSetValue();
    4949
    50     StyleCachedImageSet* cachedImageSet(CachedResourceLoader&, const ResourceLoaderOptions&);
     50    StyleCachedImage* bestFitImage(CachedResourceLoader&, const ResourceLoaderOptions&);
    5151
    52     // Returns a StyleCachedImageSet if the best fit image has been cached already, otherwise a StylePendingImage.
     52    // Returns a StyleCachedImage if the best fit image has been cached already, otherwise a StylePendingImage.
    5353    StyleImage* cachedOrPendingImageSet(const Document&);
    5454
     
    7777    static inline bool compareByScaleFactor(ImageWithScale first, ImageWithScale second) { return first.scaleFactor < second.scaleFactor; }
    7878
    79     RefPtr<StyleImage> m_imageSet;
     79    RefPtr<StyleImage> m_image;
    8080    bool m_accessedBestFitImage;
    8181
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r204455 r204560  
    155155#if ENABLE(CSS_IMAGE_SET)
    156156#include "CSSImageSetValue.h"
    157 #include "StyleCachedImageSet.h"
    158157#endif
    159158
  • trunk/Source/WebCore/page/EventHandler.cpp

    r204466 r204560  
    103103#include <wtf/WeakPtr.h>
    104104
    105 #if ENABLE(CSS_IMAGE_SET)
    106 #include "StyleCachedImageSet.h"
    107 #endif
    108 
    109105#if ENABLE(IOS_TOUCH_EVENTS)
    110106#include "PlatformTouchEventIOS.h"
  • trunk/Source/WebCore/rendering/style/ShapeValue.cpp

    r202167 r204560  
    3737    if (!image())
    3838        return false;
    39     if (image()->isCachedImage() || image()->isCachedImageSet())
     39    if (image()->isCachedImage())
    4040        return image()->cachedImage() && image()->cachedImage()->hasImage();
    4141    return image()->isGeneratedImage();
  • trunk/Source/WebCore/rendering/style/StyleAllInOne.cpp

    r198207 r204560  
    4242#include "StyleBoxData.cpp"
    4343#include "StyleCachedImage.cpp"
    44 #include "StyleCachedImageSet.cpp"
    4544#include "StyleDeprecatedFlexibleBoxData.cpp"
    4645#include "StyleFilterData.cpp"
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp

    r191083 r204560  
    2525#include "StyleCachedImage.h"
    2626
     27#include "CSSImageSetValue.h"
    2728#include "CachedImage.h"
    2829#include "RenderElement.h"
     
    3031namespace WebCore {
    3132
    32 StyleCachedImage::StyleCachedImage(CachedImage* image)
     33StyleCachedImage::StyleCachedImage(CachedImage* image, float scaleFactor, CSSImageSetValue* cssValue)
    3334    : m_image(image)
     35    , m_scaleFactor(scaleFactor)
     36    , m_cssImageSetValue(cssValue)
    3437{
    3538    m_isCachedImage = true;
     
    4447PassRefPtr<CSSValue> StyleCachedImage::cssValue() const
    4548{
     49    if (m_cssImageSetValue)
     50        return const_cast<CSSImageSetValue*>(m_cssImageSetValue);
    4651    return CSSPrimitiveValue::create(m_image->url(), CSSPrimitiveValue::CSS_URI);
    4752}
     
    6469FloatSize StyleCachedImage::imageSize(const RenderElement* renderer, float multiplier) const
    6570{
    66     return m_image->imageSizeForRenderer(renderer, multiplier);
     71    FloatSize size = m_image->imageSizeForRenderer(renderer, multiplier);
     72    size.scale(1 / m_scaleFactor);
     73    return size;
    6774}
    6875
     
    107114}
    108115
     116float StyleCachedImage::imageScaleFactor() const
     117{
     118    return m_scaleFactor;
     119}
     120
    109121bool StyleCachedImage::knownToBeOpaque(const RenderElement* renderer) const
    110122{
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.h

    r197563 r204560  
    3131namespace WebCore {
    3232
     33class CSSImageSetValue;
    3334class CachedImage;
    3435
     
    3637    WTF_MAKE_FAST_ALLOCATED;
    3738public:
    38     static Ref<StyleCachedImage> create(CachedImage* image) { return adoptRef(*new StyleCachedImage(image)); }
     39    static Ref<StyleCachedImage> create(CachedImage* image) { return adoptRef(*new StyleCachedImage(image, 1, nullptr)); }
     40    static Ref<StyleCachedImage> createForImageSet(CachedImage* image, float scaleFactor, CSSImageSetValue& cssValue) { return adoptRef(*new StyleCachedImage(image, scaleFactor, &cssValue)); }
    3941    virtual ~StyleCachedImage();
    4042
    4143    CachedImage* cachedImage() const override { return m_image.get(); }
     44
     45    void detachFromCSSValue() { m_cssImageSetValue = nullptr; }
    4246
    4347private:
     
    5862    void removeClient(RenderElement*) override;
    5963    RefPtr<Image> image(RenderElement*, const FloatSize&) const override;
     64    float imageScaleFactor() const override;
    6065    bool knownToBeOpaque(const RenderElement*) const override;
    6166
    62     explicit StyleCachedImage(CachedImage*);
     67    StyleCachedImage(CachedImage*, float scaleFactor, CSSImageSetValue*);
    6368
    6469    CachedResourceHandle<CachedImage> m_image;
     70    float m_scaleFactor;
     71    CSSImageSetValue* m_cssImageSetValue; // Not retained; it owns us.
    6572};
    6673
  • trunk/Source/WebCore/rendering/style/StyleImage.h

    r191083 r204560  
    7373    ALWAYS_INLINE bool isPendingImage() const { return m_isPendingImage; }
    7474    ALWAYS_INLINE bool isGeneratedImage() const { return m_isGeneratedImage; }
    75     ALWAYS_INLINE bool isCachedImageSet() const { return m_isCachedImageSet; }
    76    
     75
    7776protected:
    7877    StyleImage()
     
    8079        , m_isPendingImage(false)
    8180        , m_isGeneratedImage(false)
    82         , m_isCachedImageSet(false)
    8381    {
    8482    }
     
    8684    bool m_isPendingImage : 1;
    8785    bool m_isGeneratedImage : 1;
    88     bool m_isCachedImageSet : 1;
    8986};
    9087
  • trunk/Source/WebCore/style/StylePendingResources.cpp

    r204014 r204560  
    3636#include "SVGURIReference.h"
    3737#include "StyleCachedImage.h"
    38 #include "StyleCachedImageSet.h"
    3938#include "StyleGeneratedImage.h"
    4039#include "StylePendingImage.h"
     
    7069#if ENABLE(CSS_IMAGE_SET)
    7170    if (auto imageSetValue = pendingImage.cssImageSetValue())
    72         return imageSetValue->cachedImageSet(document.cachedResourceLoader(), options);
     71        return imageSetValue->bestFitImage(document.cachedResourceLoader(), options);
    7372#endif
    7473
Note: See TracChangeset for help on using the changeset viewer.