zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 401a379 | 2013-03-03 10:12:59 +0000 | [diff] [blame] | 31 | #include "CachedImage.h" |
antti@apple.com | 1e9a318 | 2013-09-27 02:02:27 +0000 | [diff] [blame] | 32 | #include "RenderElement.h" |
zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 33 | #include "StyleCachedImage.h" |
| 34 | |
| 35 | namespace WebCore { |
| 36 | |
akling@apple.com | 1a0336b | 2013-10-26 18:59:27 +0000 | [diff] [blame] | 37 | RenderImageResourceStyleImage::RenderImageResourceStyleImage(StyleImage& styleImage) |
zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 38 | : m_styleImage(styleImage) |
| 39 | { |
zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | RenderImageResourceStyleImage::~RenderImageResourceStyleImage() |
| 43 | { |
| 44 | } |
| 45 | |
darin@apple.com | 8cdf712 | 2013-09-30 02:40:50 +0000 | [diff] [blame] | 46 | void RenderImageResourceStyleImage::initialize(RenderElement* renderer) |
zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 47 | { |
| 48 | RenderImageResource::initialize(renderer); |
| 49 | |
| 50 | if (m_styleImage->isCachedImage()) |
akling@apple.com | 1a0336b | 2013-10-26 18:59:27 +0000 | [diff] [blame] | 51 | m_cachedImage = m_styleImage.get().cachedImage(); |
zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 52 | |
| 53 | m_styleImage->addClient(m_renderer); |
| 54 | } |
| 55 | |
| 56 | void RenderImageResourceStyleImage::shutdown() |
| 57 | { |
| 58 | ASSERT(m_renderer); |
| 59 | m_styleImage->removeClient(m_renderer); |
simon.fraser@apple.com | 3227f9b | 2015-10-14 18:10:32 +0000 | [diff] [blame] | 60 | m_cachedImage = nullptr; |
zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 61 | } |
| 62 | |
simon.fraser@apple.com | 4eba1e5 | 2015-10-15 04:55:08 +0000 | [diff] [blame] | 63 | RefPtr<Image> RenderImageResourceStyleImage::image(int width, int height) const |
zimmermann@webkit.org | 4729baa | 2011-10-31 14:07:49 +0000 | [diff] [blame] | 64 | { |
| 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.com | 3227f9b | 2015-10-14 18:10:32 +0000 | [diff] [blame] | 67 | return nullptr; |
zimmermann@webkit.org | 4729baa | 2011-10-31 14:07:49 +0000 | [diff] [blame] | 68 | return m_styleImage->image(m_renderer, IntSize(width, height)); |
| 69 | } |
| 70 | |
| 71 | void RenderImageResourceStyleImage::setContainerSizeForRenderer(const IntSize& size) |
| 72 | { |
| 73 | ASSERT(m_renderer); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 74 | m_styleImage->setContainerSizeForRenderer(m_renderer, size, m_renderer->style().effectiveZoom()); |
zimmermann@webkit.org | 4729baa | 2011-10-31 14:07:49 +0000 | [diff] [blame] | 75 | } |
| 76 | |
zimmermann@webkit.org | 50d2555 | 2010-08-27 14:46:22 +0000 | [diff] [blame] | 77 | } // namespace WebCore |