Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: sky/engine/core/rendering/style/StyleFetchedImageSet.h

Issue 1214633005: Remove CSS clients of ImageResource (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef SKY_ENGINE_CORE_RENDERING_STYLE_STYLEFETCHEDIMAGESET_H_
27 #define SKY_ENGINE_CORE_RENDERING_STYLE_STYLEFETCHEDIMAGESET_H_
28
29 #include "sky/engine/core/fetch/ImageResourceClient.h"
30 #include "sky/engine/core/fetch/ResourcePtr.h"
31 #include "sky/engine/core/rendering/style/StyleImage.h"
32 #include "sky/engine/platform/geometry/LayoutSize.h"
33
34 namespace blink {
35
36 class ImageResource;
37 class CSSImageSetValue;
38
39 // This class keeps one cached image and has access to a set of alternatives.
40
41 class StyleFetchedImageSet final : public StyleImage, private ImageResourceClien t {
42 WTF_MAKE_FAST_ALLOCATED;
43 public:
44 static PassRefPtr<StyleFetchedImageSet> create(ImageResource* image, float i mageScaleFactor, CSSImageSetValue* value)
45 {
46 return adoptRef(new StyleFetchedImageSet(image, imageScaleFactor, value) );
47 }
48 virtual ~StyleFetchedImageSet();
49
50 virtual PassRefPtr<CSSValue> cssValue() const override;
51
52 // FIXME: This is used by StyleImage for equals comparison, but this impleme ntation
53 // only looks at the image from the set that we have loaded. I'm not sure if that is
54 // meaningful enough or not.
55 virtual WrappedImagePtr data() const override { return m_bestFitImage.get(); }
56
57 void clearImageSetValue() { m_imageSetValue = 0; }
58
59 virtual bool canRender(const RenderObject&) const override;
60 virtual bool isLoaded() const override;
61 virtual bool errorOccurred() const override;
62 virtual LayoutSize imageSize(const RenderObject*) const override;
63 virtual bool imageHasRelativeWidth() const override;
64 virtual bool imageHasRelativeHeight() const override;
65 virtual void computeIntrinsicDimensions(const RenderObject*, Length& intrins icWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) override;
66 virtual bool usesImageContainerSize() const override;
67 virtual void setContainerSizeForRenderer(const RenderObject*, const IntSize& ) override;
68 virtual void addClient(RenderObject*) override;
69 virtual void removeClient(RenderObject*) override;
70 virtual PassRefPtr<Image> image(RenderObject*, const IntSize&) const overrid e;
71 virtual float imageScaleFactor() const override { return m_imageScaleFactor; }
72 virtual bool knownToBeOpaque(const RenderObject*) const override;
73 virtual ImageResource* cachedImage() const override { return m_bestFitImage. get(); }
74
75 private:
76 StyleFetchedImageSet(ImageResource*, float imageScaleFactor, CSSImageSetValu e*);
77
78 ResourcePtr<ImageResource> m_bestFitImage;
79 float m_imageScaleFactor;
80
81 // FIXME: oilpan: Change to RawPtr when moving this class onto oilpan heap.
82 // Also add "if !ENABLE(OILPAN)" around clearImageSetValue above as well as around its
83 // caller since it should not be needed once both of the objects are on the heap and
84 // oilpan is enabled.
85 CSSImageSetValue* m_imageSetValue; // Not retained; it owns us.
86 };
87
88 DEFINE_STYLE_IMAGE_TYPE_CASTS(StyleFetchedImageSet, isImageResourceSet());
89
90 } // namespace blink
91
92 #endif // SKY_ENGINE_CORE_RENDERING_STYLE_STYLEFETCHEDIMAGESET_H_
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/style/StyleFetchedImage.cpp ('k') | sky/engine/core/rendering/style/StyleFetchedImageSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698