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

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

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 #include "sky/engine/core/rendering/style/StyleFetchedImageSet.h"
27
28 #include "sky/engine/core/css/CSSImageSetValue.h"
29 #include "sky/engine/core/fetch/ImageResource.h"
30 #include "sky/engine/core/rendering/RenderObject.h"
31
32 namespace blink {
33
34 StyleFetchedImageSet::StyleFetchedImageSet(ImageResource* image, float imageScal eFactor, CSSImageSetValue* value)
35 : m_bestFitImage(image)
36 , m_imageScaleFactor(imageScaleFactor)
37 , m_imageSetValue(value)
38 {
39 m_isImageResourceSet = true;
40 m_bestFitImage->addClient(this);
41 }
42
43
44 StyleFetchedImageSet::~StyleFetchedImageSet()
45 {
46 m_bestFitImage->removeClient(this);
47 }
48
49 PassRefPtr<CSSValue> StyleFetchedImageSet::cssValue() const
50 {
51 return m_imageSetValue;
52 }
53
54 bool StyleFetchedImageSet::canRender(const RenderObject& renderer) const
55 {
56 return m_bestFitImage->canRender(renderer);
57 }
58
59 bool StyleFetchedImageSet::isLoaded() const
60 {
61 return m_bestFitImage->isLoaded();
62 }
63
64 bool StyleFetchedImageSet::errorOccurred() const
65 {
66 return m_bestFitImage->errorOccurred();
67 }
68
69 LayoutSize StyleFetchedImageSet::imageSize(const RenderObject* renderer) const
70 {
71 LayoutSize scaledImageSize = m_bestFitImage->imageSizeForRenderer(renderer);
72 scaledImageSize.scale(1 / m_imageScaleFactor);
73 return scaledImageSize;
74 }
75
76 bool StyleFetchedImageSet::imageHasRelativeWidth() const
77 {
78 return m_bestFitImage->imageHasRelativeWidth();
79 }
80
81 bool StyleFetchedImageSet::imageHasRelativeHeight() const
82 {
83 return m_bestFitImage->imageHasRelativeHeight();
84 }
85
86 void StyleFetchedImageSet::computeIntrinsicDimensions(const RenderObject*, Lengt h& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
87 {
88 m_bestFitImage->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight, intrinsicRatio);
89 }
90
91 bool StyleFetchedImageSet::usesImageContainerSize() const
92 {
93 return m_bestFitImage->usesImageContainerSize();
94 }
95
96 void StyleFetchedImageSet::setContainerSizeForRenderer(const RenderObject* rende rer, const IntSize& imageContainerSize)
97 {
98 m_bestFitImage->setContainerSizeForRenderer(renderer, imageContainerSize);
99 }
100
101 void StyleFetchedImageSet::addClient(RenderObject* renderer)
102 {
103 m_bestFitImage->addClient(renderer);
104 }
105
106 void StyleFetchedImageSet::removeClient(RenderObject* renderer)
107 {
108 m_bestFitImage->removeClient(renderer);
109 }
110
111 PassRefPtr<Image> StyleFetchedImageSet::image(RenderObject* renderer, const IntS ize&) const
112 {
113 return m_bestFitImage->imageForRenderer(renderer);
114 }
115
116 bool StyleFetchedImageSet::knownToBeOpaque(const RenderObject* renderer) const
117 {
118 return m_bestFitImage->currentFrameKnownToBeOpaque(renderer);
119 }
120
121 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/style/StyleFetchedImageSet.h ('k') | sky/engine/core/rendering/style/StylePendingImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698