blob: 41203b870a0b9ff2d51d1f0ce45dd312191876ec [file] [log] [blame]
zimmermann@webkit.org50d25552010-08-27 14:46:22 +00001/*
2 * Copyright (C) 1999 Lars Knoll <knoll@kde.org>
3 * Copyright (C) 1999 Antti Koivisto <koivisto@kde.org>
4 * Copyright (C) 2000 Dirk Mueller <mueller@kde.org>
5 * Copyright (C) 2006 Allan Sandfeld Jensen <kde@carewolf.com>
6 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 *
26 */
27
28#include "config.h"
29#include "RenderImageResourceStyleImage.h"
30
abarth@webkit.org401a3792013-03-03 10:12:59 +000031#include "CachedImage.h"
antti@apple.com1e9a3182013-09-27 02:02:27 +000032#include "RenderElement.h"
zimmermann@webkit.org50d25552010-08-27 14:46:22 +000033#include "StyleCachedImage.h"
34
35namespace WebCore {
36
akling@apple.com1a0336b2013-10-26 18:59:27 +000037RenderImageResourceStyleImage::RenderImageResourceStyleImage(StyleImage& styleImage)
zimmermann@webkit.org50d25552010-08-27 14:46:22 +000038 : m_styleImage(styleImage)
39{
zimmermann@webkit.org50d25552010-08-27 14:46:22 +000040}
41
42RenderImageResourceStyleImage::~RenderImageResourceStyleImage()
43{
44}
45
darin@apple.com8cdf7122013-09-30 02:40:50 +000046void RenderImageResourceStyleImage::initialize(RenderElement* renderer)
zimmermann@webkit.org50d25552010-08-27 14:46:22 +000047{
48 RenderImageResource::initialize(renderer);
49
50 if (m_styleImage->isCachedImage())
akling@apple.com1a0336b2013-10-26 18:59:27 +000051 m_cachedImage = m_styleImage.get().cachedImage();
zimmermann@webkit.org50d25552010-08-27 14:46:22 +000052
53 m_styleImage->addClient(m_renderer);
54}
55
56void RenderImageResourceStyleImage::shutdown()
57{
58 ASSERT(m_renderer);
59 m_styleImage->removeClient(m_renderer);
simon.fraser@apple.com3227f9b2015-10-14 18:10:32 +000060 m_cachedImage = nullptr;
zimmermann@webkit.org50d25552010-08-27 14:46:22 +000061}
62
simon.fraser@apple.com4eba1e52015-10-15 04:55:08 +000063RefPtr<Image> RenderImageResourceStyleImage::image(int width, int height) const
zimmermann@webkit.org4729baa2011-10-31 14:07:49 +000064{
65 // Generated content may trigger calls to image() while we're still pending, don't assert but gracefully exit.
66 if (m_styleImage->isPendingImage())
simon.fraser@apple.com3227f9b2015-10-14 18:10:32 +000067 return nullptr;
zimmermann@webkit.org4729baa2011-10-31 14:07:49 +000068 return m_styleImage->image(m_renderer, IntSize(width, height));
69}
70
71void RenderImageResourceStyleImage::setContainerSizeForRenderer(const IntSize& size)
72{
73 ASSERT(m_renderer);
akling@apple.com827be9c2013-10-29 02:58:43 +000074 m_styleImage->setContainerSizeForRenderer(m_renderer, size, m_renderer->style().effectiveZoom());
zimmermann@webkit.org4729baa2011-10-31 14:07:49 +000075}
76
zimmermann@webkit.org50d25552010-08-27 14:46:22 +000077} // namespace WebCore