2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
25 #include "core/style/StyleFetchedImage.h"
27 #include "core/css/CSSImageValue.h"
28 #include "core/fetch/ImageResource.h"
29 #include "core/layout/LayoutObject.h"
30 #include "core/svg/graphics/SVGImage.h"
34 StyleFetchedImage::StyleFetchedImage(ImageResource
* image
, Document
* document
)
36 , m_document(document
)
38 m_isImageResource
= true;
39 m_image
->addClient(this);
42 StyleFetchedImage::~StyleFetchedImage()
44 m_image
->removeClient(this);
47 PassRefPtrWillBeRawPtr
<CSSValue
> StyleFetchedImage::cssValue() const
49 return CSSImageValue::create(m_image
->url(), const_cast<StyleFetchedImage
*>(this));
52 PassRefPtrWillBeRawPtr
<CSSValue
> StyleFetchedImage::computedCSSValue() const
57 bool StyleFetchedImage::canRender(const LayoutObject
& layoutObject
, float multiplier
) const
59 return m_image
->canRender(layoutObject
, multiplier
);
62 bool StyleFetchedImage::isLoaded() const
64 return m_image
->isLoaded();
67 bool StyleFetchedImage::errorOccurred() const
69 return m_image
->errorOccurred();
72 LayoutSize
StyleFetchedImage::imageSize(const LayoutObject
* layoutObject
, float multiplier
) const
74 return m_image
->imageSizeForLayoutObject(layoutObject
, multiplier
);
77 bool StyleFetchedImage::imageHasRelativeWidth() const
79 return m_image
->imageHasRelativeWidth();
82 bool StyleFetchedImage::imageHasRelativeHeight() const
84 return m_image
->imageHasRelativeHeight();
87 void StyleFetchedImage::computeIntrinsicDimensions(const LayoutObject
*, Length
& intrinsicWidth
, Length
& intrinsicHeight
, FloatSize
& intrinsicRatio
)
89 m_image
->computeIntrinsicDimensions(intrinsicWidth
, intrinsicHeight
, intrinsicRatio
);
92 bool StyleFetchedImage::usesImageContainerSize() const
94 return m_image
->usesImageContainerSize();
97 void StyleFetchedImage::setContainerSizeForLayoutObject(const LayoutObject
* layoutObject
, const IntSize
& imageContainerSize
, float imageContainerZoomFactor
)
99 m_image
->setContainerSizeForLayoutObject(layoutObject
, imageContainerSize
, imageContainerZoomFactor
);
102 void StyleFetchedImage::addClient(LayoutObject
* layoutObject
)
104 m_image
->addClient(layoutObject
);
107 void StyleFetchedImage::removeClient(LayoutObject
* layoutObject
)
109 m_image
->removeClient(layoutObject
);
112 void StyleFetchedImage::notifyFinished(Resource
* resource
)
114 if (m_document
&& m_image
&& m_image
->image() && m_image
->image()->isSVGImage())
115 toSVGImage(m_image
->image())->updateUseCounters(*m_document
);
116 // Oilpan: do not prolong the Document's lifetime.
120 PassRefPtr
<Image
> StyleFetchedImage::image(LayoutObject
* layoutObject
, const IntSize
&) const
122 return m_image
->imageForLayoutObject(layoutObject
);
125 bool StyleFetchedImage::knownToBeOpaque(const LayoutObject
* layoutObject
) const
127 return m_image
->currentFrameKnownToBeOpaque(layoutObject
);
130 DEFINE_TRACE(StyleFetchedImage
)
132 visitor
->trace(m_document
);
133 StyleImage::trace(visitor
);