|
1 /* |
|
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. |
|
6 * |
|
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. |
|
11 * |
|
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. |
|
16 * |
|
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. |
|
21 * |
|
22 */ |
|
23 |
|
24 #include "config.h" |
|
25 #include "StyleGeneratedImage.h" |
|
26 |
|
27 #include "CSSImageGeneratorValue.h" |
|
28 #include "RenderObject.h" |
|
29 |
|
30 namespace WebCore { |
|
31 |
|
32 PassRefPtr<CSSValue> StyleGeneratedImage::cssValue() |
|
33 { |
|
34 return m_generator; |
|
35 } |
|
36 |
|
37 IntSize StyleGeneratedImage::imageSize(const RenderObject* renderer, float multiplier) const |
|
38 { |
|
39 if (m_fixedSize) { |
|
40 IntSize fixedSize = m_generator->fixedSize(renderer); |
|
41 if (multiplier == 1.0f) |
|
42 return fixedSize; |
|
43 |
|
44 int width = fixedSize.width() * multiplier; |
|
45 int height = fixedSize.height() * multiplier; |
|
46 |
|
47 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. |
|
48 if (fixedSize.width() > 0) |
|
49 width = max(1, width); |
|
50 |
|
51 if (fixedSize.height() > 0) |
|
52 height = max(1, height); |
|
53 |
|
54 return IntSize(width, height); |
|
55 } |
|
56 |
|
57 return m_containerSize; |
|
58 } |
|
59 |
|
60 void StyleGeneratedImage::setImageContainerSize(const IntSize& size) |
|
61 { |
|
62 m_containerSize = size; |
|
63 } |
|
64 |
|
65 void StyleGeneratedImage::addClient(RenderObject* renderer) |
|
66 { |
|
67 m_generator->addClient(renderer, IntSize()); |
|
68 } |
|
69 |
|
70 void StyleGeneratedImage::removeClient(RenderObject* renderer) |
|
71 { |
|
72 m_generator->removeClient(renderer); |
|
73 } |
|
74 |
|
75 Image* StyleGeneratedImage::image(RenderObject* renderer, const IntSize& size) const |
|
76 { |
|
77 return m_generator->image(renderer, size); |
|
78 } |
|
79 |
|
80 } |