OLD | NEW |
| (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 "config.h" | |
27 #include "core/layout/style/StyleFetchedImageSet.h" | |
28 | |
29 #include "core/css/CSSImageSetValue.h" | |
30 #include "core/fetch/ImageResource.h" | |
31 #include "core/layout/LayoutObject.h" | |
32 | |
33 namespace blink { | |
34 | |
35 StyleFetchedImageSet::StyleFetchedImageSet(ImageResource* image, float imageScal
eFactor, CSSImageSetValue* value) | |
36 : m_bestFitImage(image) | |
37 , m_imageScaleFactor(imageScaleFactor) | |
38 , m_imageSetValue(value) | |
39 { | |
40 m_isImageResourceSet = true; | |
41 m_bestFitImage->addClient(this); | |
42 } | |
43 | |
44 | |
45 StyleFetchedImageSet::~StyleFetchedImageSet() | |
46 { | |
47 m_bestFitImage->removeClient(this); | |
48 } | |
49 | |
50 PassRefPtrWillBeRawPtr<CSSValue> StyleFetchedImageSet::cssValue() const | |
51 { | |
52 return m_imageSetValue; | |
53 } | |
54 | |
55 bool StyleFetchedImageSet::canRender(const LayoutObject& layoutObject, float mul
tiplier) const | |
56 { | |
57 return m_bestFitImage->canRender(layoutObject, multiplier); | |
58 } | |
59 | |
60 bool StyleFetchedImageSet::isLoaded() const | |
61 { | |
62 return m_bestFitImage->isLoaded(); | |
63 } | |
64 | |
65 bool StyleFetchedImageSet::errorOccurred() const | |
66 { | |
67 return m_bestFitImage->errorOccurred(); | |
68 } | |
69 | |
70 LayoutSize StyleFetchedImageSet::imageSize(const LayoutObject* layoutObject, flo
at multiplier) const | |
71 { | |
72 LayoutSize scaledImageSize = m_bestFitImage->imageSizeForLayoutObject(layout
Object, multiplier); | |
73 scaledImageSize.scale(1 / m_imageScaleFactor); | |
74 return scaledImageSize; | |
75 } | |
76 | |
77 bool StyleFetchedImageSet::imageHasRelativeWidth() const | |
78 { | |
79 return m_bestFitImage->imageHasRelativeWidth(); | |
80 } | |
81 | |
82 bool StyleFetchedImageSet::imageHasRelativeHeight() const | |
83 { | |
84 return m_bestFitImage->imageHasRelativeHeight(); | |
85 } | |
86 | |
87 void StyleFetchedImageSet::computeIntrinsicDimensions(const LayoutObject*, Lengt
h& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) | |
88 { | |
89 m_bestFitImage->computeIntrinsicDimensions(intrinsicWidth, intrinsicHeight,
intrinsicRatio); | |
90 } | |
91 | |
92 bool StyleFetchedImageSet::usesImageContainerSize() const | |
93 { | |
94 return m_bestFitImage->usesImageContainerSize(); | |
95 } | |
96 | |
97 void StyleFetchedImageSet::setContainerSizeForLayoutObject(const LayoutObject* l
ayoutObject, const IntSize& imageContainerSize, float imageContainerZoomFactor) | |
98 { | |
99 m_bestFitImage->setContainerSizeForLayoutObject(layoutObject, imageContainer
Size, imageContainerZoomFactor); | |
100 } | |
101 | |
102 void StyleFetchedImageSet::addClient(LayoutObject* layoutObject) | |
103 { | |
104 m_bestFitImage->addClient(layoutObject); | |
105 } | |
106 | |
107 void StyleFetchedImageSet::removeClient(LayoutObject* layoutObject) | |
108 { | |
109 m_bestFitImage->removeClient(layoutObject); | |
110 } | |
111 | |
112 PassRefPtr<Image> StyleFetchedImageSet::image(LayoutObject* layoutObject, const
IntSize&) const | |
113 { | |
114 return m_bestFitImage->imageForLayoutObject(layoutObject); | |
115 } | |
116 | |
117 bool StyleFetchedImageSet::knownToBeOpaque(const LayoutObject* layoutObject) con
st | |
118 { | |
119 return m_bestFitImage->currentFrameKnownToBeOpaque(layoutObject); | |
120 } | |
121 | |
122 } // namespace blink | |
OLD | NEW |