blob: dd5247400f7595094d305f46aa719c3cc45c9e07 [file] [log] [blame]
darin@apple.com640fa302008-02-15 05:03:55 +00001/*
darinb9481ed2006-03-20 02:57:59 +00002 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
darin@apple.com640fa302008-02-15 05:03:55 +00007 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
darinb9481ed2006-03-20 02:57:59 +00008 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
ddkilzerc8eccec2007-09-26 02:29:57 +000021 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
darinb9481ed2006-03-20 02:57:59 +000023 *
24 */
25
26#include "config.h"
27#include "RenderImage.h"
28
eseidela8445792006-12-28 00:48:37 +000029#include "BitmapImage.h"
darinb9481ed2006-03-20 02:57:59 +000030#include "Document.h"
31#include "GraphicsContext.h"
eseidel84943622006-05-15 23:23:42 +000032#include "HTMLImageElement.h"
darinb9481ed2006-03-20 02:57:59 +000033#include "HTMLInputElement.h"
eseidel84943622006-05-15 23:23:42 +000034#include "HTMLMapElement.h"
darin98fa8b82006-03-20 08:03:57 +000035#include "HTMLNames.h"
bdakinc1a5a832006-10-28 18:28:00 +000036#include "HitTestResult.h"
hyattb21f8372007-09-04 22:58:27 +000037#include "Page.h"
hyattd8048342006-05-31 01:48:18 +000038#include "RenderView.h"
darinb9481ed2006-03-20 02:57:59 +000039
darin7bd70952006-04-13 07:07:34 +000040using namespace std;
41
darinb9481ed2006-03-20 02:57:59 +000042namespace WebCore {
43
44using namespace HTMLNames;
45
weinigc24ab182006-10-30 22:41:29 +000046RenderImage::RenderImage(Node* node)
darin751cf302007-05-01 22:10:41 +000047 : RenderReplaced(node, IntSize(0, 0))
eseidel84943622006-05-15 23:23:42 +000048 , m_cachedImage(0)
darinb9481ed2006-03-20 02:57:59 +000049{
darinb9481ed2006-03-20 02:57:59 +000050 updateAltText();
51}
52
53RenderImage::~RenderImage()
54{
55 if (m_cachedImage)
hyatt@apple.com2c814c42008-04-12 04:09:22 +000056 m_cachedImage->removeClient(this);
darinb9481ed2006-03-20 02:57:59 +000057}
58
darinb9481ed2006-03-20 02:57:59 +000059void RenderImage::setCachedImage(CachedImage* newImage)
60{
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +000061 if (m_cachedImage == newImage)
bdakineb2c2042006-07-10 11:39:35 +000062 return;
darinec375482007-01-06 01:36:24 +000063 if (m_cachedImage)
hyatt@apple.com2c814c42008-04-12 04:09:22 +000064 m_cachedImage->removeClient(this);
darinec375482007-01-06 01:36:24 +000065 m_cachedImage = newImage;
66 if (m_cachedImage) {
hyatt@apple.com2c814c42008-04-12 04:09:22 +000067 m_cachedImage->addClient(this);
kmcculloadfd67d2007-03-03 02:18:43 +000068 if (m_cachedImage->errorOccurred())
darinb9481ed2006-03-20 02:57:59 +000069 imageChanged(m_cachedImage);
70 }
71}
72
bdash58feef62007-01-11 02:24:30 +000073// If we'll be displaying either alt text or an image, add some padding.
74static const unsigned short paddingWidth = 4;
75static const unsigned short paddingHeight = 4;
76
77// Alt text is restricted to this maximum size, in pixels. These are
78// signed integers because they are compared with other signed values.
79static const int maxAltTextWidth = 1024;
80static const int maxAltTextHeight = 256;
81
82// Sets the image height and width to fit the alt text. Returns true if the
83// image size changed.
84bool RenderImage::setImageSizeForAltText(CachedImage* newImage /* = 0 */)
85{
86 int imageWidth = 0;
87 int imageHeight = 0;
88
89 // If we'll be displaying either text or an image, add a little padding.
90 if (!m_altText.isEmpty() || newImage) {
91 imageWidth = paddingWidth;
92 imageHeight = paddingHeight;
93 }
94
95 if (newImage) {
hyatt@apple.coma8031482008-03-19 17:58:22 +000096 // imageSize() returns 0 for the error image. We need the true size of the
97 // error image, so we have to get it by grabbing image() directly.
98 imageWidth += newImage->image()->width() * style()->effectiveZoom();
99 imageHeight += newImage->image()->height() * style()->effectiveZoom();
bdash58feef62007-01-11 02:24:30 +0000100 }
101
102 // we have an alt and the user meant it (its not a text we invented)
103 if (!m_altText.isEmpty()) {
104 const Font& font = style()->font();
105 imageWidth = max(imageWidth, min(font.width(TextRun(m_altText.characters(), m_altText.length())), maxAltTextWidth));
106 imageHeight = max(imageHeight, min(font.height(), maxAltTextHeight));
107 }
108
darin751cf302007-05-01 22:10:41 +0000109 IntSize imageSize = IntSize(imageWidth, imageHeight);
110 if (imageSize == intrinsicSize())
111 return false;
112
113 setIntrinsicSize(imageSize);
114 return true;
bdash58feef62007-01-11 02:24:30 +0000115}
116
weinigc24ab182006-10-30 22:41:29 +0000117void RenderImage::imageChanged(CachedImage* newImage)
darinb9481ed2006-03-20 02:57:59 +0000118{
ap692e06e2006-10-01 09:11:35 +0000119 if (documentBeingDestroyed())
120 return;
121
hyatt0fd84c82007-03-17 23:39:50 +0000122 if (hasBoxDecorations())
123 RenderReplaced::imageChanged(newImage);
124
hyatt@apple.coma8031482008-03-19 17:58:22 +0000125 if (newImage != m_cachedImage || !newImage)
darinb9481ed2006-03-20 02:57:59 +0000126 return;
darinb9481ed2006-03-20 02:57:59 +0000127
weinigc24ab182006-10-30 22:41:29 +0000128 bool imageSizeChanged = false;
darinb9481ed2006-03-20 02:57:59 +0000129
bdash58feef62007-01-11 02:24:30 +0000130 // Set image dimensions, taking into account the size of the alt text.
kmcculloadfd67d2007-03-03 02:18:43 +0000131 if (newImage->errorOccurred())
bdash58feef62007-01-11 02:24:30 +0000132 imageSizeChanged = setImageSizeForAltText(newImage);
133
bdasha1595472007-05-02 09:17:52 +0000134 bool shouldRepaint = true;
darinb9481ed2006-03-20 02:57:59 +0000135
136 // Image dimensions have been changed, see what needs to be done
hyatt@apple.coma8031482008-03-19 17:58:22 +0000137 if (newImage->imageSize(style()->effectiveZoom()) != intrinsicSize() || imageSizeChanged) {
darin751cf302007-05-01 22:10:41 +0000138 if (!newImage->errorOccurred())
hyatt@apple.coma8031482008-03-19 17:58:22 +0000139 setIntrinsicSize(newImage->imageSize(style()->effectiveZoom()));
darinb9481ed2006-03-20 02:57:59 +0000140
141 // In the case of generated image content using :before/:after, we might not be in the
142 // render tree yet. In that case, we don't need to worry about check for layout, since we'll get a
143 // layout when we get added in to the render tree hierarchy later.
144 if (containingBlock()) {
145 // lets see if we need to relayout at all..
146 int oldwidth = m_width;
147 int oldheight = m_height;
bdasha1595472007-05-02 09:17:52 +0000148 if (!prefWidthsDirty())
149 setPrefWidthsDirty(true);
darinb9481ed2006-03-20 02:57:59 +0000150 calcWidth();
151 calcHeight();
bdasha1595472007-05-02 09:17:52 +0000152
153 if (imageSizeChanged || m_width != oldwidth || m_height != oldheight) {
154 shouldRepaint = false;
155 if (!selfNeedsLayout())
156 setNeedsLayout(true);
157 }
weinigc24ab182006-10-30 22:41:29 +0000158
darinb9481ed2006-03-20 02:57:59 +0000159 m_width = oldwidth;
160 m_height = oldheight;
161 }
162 }
163
bdasha1595472007-05-02 09:17:52 +0000164 if (shouldRepaint)
darinb9481ed2006-03-20 02:57:59 +0000165 // FIXME: We always just do a complete repaint, since we always pass in the full image
166 // rect at the moment anyway.
bdasha1595472007-05-02 09:17:52 +0000167 repaintRectangle(contentBox());
darinb9481ed2006-03-20 02:57:59 +0000168}
169
170void RenderImage::resetAnimation()
171{
172 if (m_cachedImage) {
173 image()->resetAnimation();
174 if (!needsLayout())
175 repaint();
176 }
177}
178
antti@apple.com7f6c5da2007-12-04 19:21:09 +0000179void RenderImage::paintReplaced(PaintInfo& paintInfo, int tx, int ty)
darinb9481ed2006-03-20 02:57:59 +0000180{
darinb9481ed2006-03-20 02:57:59 +0000181 int cWidth = contentWidth();
182 int cHeight = contentHeight();
183 int leftBorder = borderLeft();
184 int topBorder = borderTop();
185 int leftPad = paddingLeft();
186 int topPad = paddingTop();
187
antti@apple.com7f6c5da2007-12-04 19:21:09 +0000188 if (document()->printing() && !view()->printImages())
darinb9481ed2006-03-20 02:57:59 +0000189 return;
190
antti@apple.com7f6c5da2007-12-04 19:21:09 +0000191 GraphicsContext* context = paintInfo.context;
192
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000193 if (!hasImage() || errorOccurred()) {
weinigc24ab182006-10-30 22:41:29 +0000194 if (paintInfo.phase == PaintPhaseSelection)
darinb9481ed2006-03-20 02:57:59 +0000195 return;
196
197 if (cWidth > 2 && cHeight > 2) {
bdash20fe5432007-10-14 11:59:35 +0000198 // Draw an outline rect where the image should be.
199 context->setStrokeStyle(SolidStroke);
200 context->setStrokeColor(Color::lightGray);
201 context->setFillColor(Color::transparent);
202 context->drawRect(IntRect(tx + leftBorder + leftPad, ty + topBorder + topPad, cWidth, cHeight));
weinigc24ab182006-10-30 22:41:29 +0000203
darinb9481ed2006-03-20 02:57:59 +0000204 bool errorPictureDrawn = false;
weinigc24ab182006-10-30 22:41:29 +0000205 int imageX = 0;
206 int imageY = 0;
bdash20fe5432007-10-14 11:59:35 +0000207 // When calculating the usable dimensions, exclude the pixels of
208 // the ouline rect so the error image/alt text doesn't draw on it.
209 int usableWidth = cWidth - 2;
210 int usableHeight = cHeight - 2;
weinigc24ab182006-10-30 22:41:29 +0000211
kmcculloadfd67d2007-03-03 02:18:43 +0000212 if (errorOccurred() && !image()->isNull() && (usableWidth >= image()->width()) && (usableHeight >= image()->height())) {
darinb9481ed2006-03-20 02:57:59 +0000213 // Center the error image, accounting for border and padding.
weinigc24ab182006-10-30 22:41:29 +0000214 int centerX = (usableWidth - image()->width()) / 2;
darinb9481ed2006-03-20 02:57:59 +0000215 if (centerX < 0)
216 centerX = 0;
weinigc24ab182006-10-30 22:41:29 +0000217 int centerY = (usableHeight - image()->height()) / 2;
darinb9481ed2006-03-20 02:57:59 +0000218 if (centerY < 0)
219 centerY = 0;
mitz@apple.comc547c0f2007-11-26 01:06:27 +0000220 imageX = leftBorder + leftPad + centerX + 1;
221 imageY = topBorder + topPad + centerY + 1;
weinig0a635f02006-11-01 21:49:13 +0000222 context->drawImage(image(), IntPoint(tx + imageX, ty + imageY));
darinb9481ed2006-03-20 02:57:59 +0000223 errorPictureDrawn = true;
224 }
weinigc24ab182006-10-30 22:41:29 +0000225
darinb9481ed2006-03-20 02:57:59 +0000226 if (!m_altText.isEmpty()) {
darin@apple.com640fa302008-02-15 05:03:55 +0000227 String text = m_altText;
darin7ab31092006-05-10 04:59:57 +0000228 text.replace('\\', backslashAsCurrencySymbol());
weinig0a635f02006-11-01 21:49:13 +0000229 context->setFont(style()->font());
hyatt6ce98622006-12-19 10:20:38 +0000230 context->setFillColor(style()->color());
weinigc24ab182006-10-30 22:41:29 +0000231 int ax = tx + leftBorder + leftPad;
232 int ay = ty + topBorder + topPad;
darinb9481ed2006-03-20 02:57:59 +0000233 const Font& font = style()->font();
234 int ascent = font.ascent();
weinig0a635f02006-11-01 21:49:13 +0000235
darinb9481ed2006-03-20 02:57:59 +0000236 // Only draw the alt text if it'll fit within the content box,
237 // and only if it fits above the error image.
darin@apple.com640fa302008-02-15 05:03:55 +0000238 TextRun textRun(text.characters(), text.length());
hyatt43d6c792006-05-11 10:19:34 +0000239 int textWidth = font.width(textRun);
darinb9481ed2006-03-20 02:57:59 +0000240 if (errorPictureDrawn) {
241 if (usableWidth >= textWidth && font.height() <= imageY)
weinig0a635f02006-11-01 21:49:13 +0000242 context->drawText(textRun, IntPoint(ax, ay + ascent));
darinb9481ed2006-03-20 02:57:59 +0000243 } else if (usableWidth >= textWidth && cHeight >= font.height())
weinig0a635f02006-11-01 21:49:13 +0000244 context->drawText(textRun, IntPoint(ax, ay + ascent));
darinb9481ed2006-03-20 02:57:59 +0000245 }
246 }
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000247 } else if (hasImage() && cWidth > 0 && cHeight > 0) {
248 Image* img = image(cWidth, cHeight);
249 if (!img || img->isNull())
250 return;
251
harrisonddf79c12006-07-13 23:17:08 +0000252#if PLATFORM(MAC)
weinig0a635f02006-11-01 21:49:13 +0000253 if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
weinigc24ab182006-10-30 22:41:29 +0000254 paintCustomHighlight(tx - m_x, ty - m_y, style()->highlight(), true);
harrisonddf79c12006-07-13 23:17:08 +0000255#endif
256
weinigc24ab182006-10-30 22:41:29 +0000257 IntRect rect(IntPoint(tx + leftBorder + leftPad, ty + topBorder + topPad), IntSize(cWidth, cHeight));
258
darinb9481ed2006-03-20 02:57:59 +0000259 HTMLImageElement* imageElt = (element() && element()->hasTagName(imgTag)) ? static_cast<HTMLImageElement*>(element()) : 0;
darin33137f72006-04-21 06:52:11 +0000260 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver;
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000261 context->drawImage(image(cWidth, cHeight), rect, compositeOperator, document()->page()->inLowQualityImageInterpolationMode());
darinb9481ed2006-03-20 02:57:59 +0000262 }
263}
264
antti@apple.com7f6c5da2007-12-04 19:21:09 +0000265int RenderImage::minimumReplacedHeight() const
darinb9481ed2006-03-20 02:57:59 +0000266{
antti@apple.com7f6c5da2007-12-04 19:21:09 +0000267 return errorOccurred() ? intrinsicSize().height() : 0;
darinb9481ed2006-03-20 02:57:59 +0000268}
269
270HTMLMapElement* RenderImage::imageMap()
271{
272 HTMLImageElement* i = element() && element()->hasTagName(imgTag) ? static_cast<HTMLImageElement*>(element()) : 0;
darin@apple.com640fa302008-02-15 05:03:55 +0000273 return i ? i->document()->getImageMap(i->useMap()) : 0;
darinb9481ed2006-03-20 02:57:59 +0000274}
275
bdakinc4d8acc2006-10-31 21:48:20 +0000276bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
darinb9481ed2006-03-20 02:57:59 +0000277{
bdakinc4d8acc2006-10-31 21:48:20 +0000278 bool inside = RenderReplaced::nodeAtPoint(request, result, _x, _y, _tx, _ty, hitTestAction);
darinb9481ed2006-03-20 02:57:59 +0000279
280 if (inside && element()) {
281 int tx = _tx + m_x;
282 int ty = _ty + m_y;
283
284 HTMLMapElement* map = imageMap();
285 if (map) {
286 // we're a client side image map
bdakin1c628c02006-10-29 22:07:47 +0000287 inside = map->mapMouseEvent(_x - tx, _y - ty, IntSize(contentWidth(), contentHeight()), result);
288 result.setInnerNonSharedNode(element());
darinb9481ed2006-03-20 02:57:59 +0000289 }
290 }
291
292 return inside;
293}
294
295void RenderImage::updateAltText()
296{
297 if (!element())
298 return;
weinigc24ab182006-10-30 22:41:29 +0000299
darinb9481ed2006-03-20 02:57:59 +0000300 if (element()->hasTagName(inputTag))
301 m_altText = static_cast<HTMLInputElement*>(element())->altText();
302 else if (element()->hasTagName(imgTag))
303 m_altText = static_cast<HTMLImageElement*>(element())->altText();
304}
305
306bool RenderImage::isWidthSpecified() const
307{
308 switch (style()->width().type()) {
309 case Fixed:
310 case Percent:
311 return true;
antti@apple.com8fd3ecc2008-01-18 19:51:25 +0000312 case Auto:
313 case Relative: // FIXME: Shouldn't this case return true?
314 case Static:
315 case Intrinsic:
316 case MinIntrinsic:
darinb9481ed2006-03-20 02:57:59 +0000317 return false;
318 }
antti@apple.com8fd3ecc2008-01-18 19:51:25 +0000319 ASSERT(false);
320 return false;
darinb9481ed2006-03-20 02:57:59 +0000321}
322
323bool RenderImage::isHeightSpecified() const
324{
325 switch (style()->height().type()) {
326 case Fixed:
327 case Percent:
328 return true;
antti@apple.com8fd3ecc2008-01-18 19:51:25 +0000329 case Auto:
330 case Relative: // FIXME: Shouldn't this case return true?
331 case Static:
332 case Intrinsic:
333 case MinIntrinsic:
darinb9481ed2006-03-20 02:57:59 +0000334 return false;
335 }
antti@apple.com8fd3ecc2008-01-18 19:51:25 +0000336 ASSERT(false);
337 return false;
darinb9481ed2006-03-20 02:57:59 +0000338}
339
340int RenderImage::calcReplacedWidth() const
341{
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000342 if (imageHasRelativeWidth())
bdakin@apple.com05d7e8e2007-12-19 07:53:52 +0000343 if (RenderObject* cb = isPositioned() ? container() : containingBlock())
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000344 setImageContainerSize(IntSize(cb->availableWidth(), cb->availableHeight()));
345
darinb9481ed2006-03-20 02:57:59 +0000346 int width;
347 if (isWidthSpecified())
adelec1116ca2006-06-01 05:28:13 +0000348 width = calcReplacedWidthUsing(style()->width());
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000349 else if (usesImageContainerSize())
350 width = imageSize(style()->effectiveZoom()).width();
351 else if (imageHasRelativeWidth())
bdakin@apple.com05d7e8e2007-12-19 07:53:52 +0000352 width = 0; // If the image is relatively-sized, set the width to 0 until there is a set container size.
darinb9481ed2006-03-20 02:57:59 +0000353 else
354 width = calcAspectRatioWidth();
355
adelec1116ca2006-06-01 05:28:13 +0000356 int minW = calcReplacedWidthUsing(style()->minWidth());
ddkilzerd1687ca2007-01-04 05:28:35 +0000357 int maxW = style()->maxWidth().isUndefined() ? width : calcReplacedWidthUsing(style()->maxWidth());
darinb9481ed2006-03-20 02:57:59 +0000358
darin7bd70952006-04-13 07:07:34 +0000359 return max(minW, min(width, maxW));
darinb9481ed2006-03-20 02:57:59 +0000360}
361
362int RenderImage::calcReplacedHeight() const
363{
364 int height;
365 if (isHeightSpecified())
adelec1116ca2006-06-01 05:28:13 +0000366 height = calcReplacedHeightUsing(style()->height());
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000367 else if (usesImageContainerSize())
368 height = imageSize(style()->effectiveZoom()).height();
369 else if (imageHasRelativeHeight())
bdakin@apple.com05d7e8e2007-12-19 07:53:52 +0000370 height = 0; // If the image is relatively-sized, set the height to 0 until there is a set container size.
darinb9481ed2006-03-20 02:57:59 +0000371 else
372 height = calcAspectRatioHeight();
373
adelec1116ca2006-06-01 05:28:13 +0000374 int minH = calcReplacedHeightUsing(style()->minHeight());
ddkilzerd1687ca2007-01-04 05:28:35 +0000375 int maxH = style()->maxHeight().isUndefined() ? height : calcReplacedHeightUsing(style()->maxHeight());
darinb9481ed2006-03-20 02:57:59 +0000376
darin7bd70952006-04-13 07:07:34 +0000377 return max(minH, min(height, maxH));
darinb9481ed2006-03-20 02:57:59 +0000378}
379
380int RenderImage::calcAspectRatioWidth() const
381{
darin751cf302007-05-01 22:10:41 +0000382 IntSize size = intrinsicSize();
383 if (!size.height())
darinb9481ed2006-03-20 02:57:59 +0000384 return 0;
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000385 if (!hasImage() || errorOccurred())
darin751cf302007-05-01 22:10:41 +0000386 return size.width(); // Don't bother scaling.
387 return RenderReplaced::calcReplacedHeight() * size.width() / size.height();
darinb9481ed2006-03-20 02:57:59 +0000388}
389
390int RenderImage::calcAspectRatioHeight() const
391{
darin751cf302007-05-01 22:10:41 +0000392 IntSize size = intrinsicSize();
393 if (!size.width())
darinb9481ed2006-03-20 02:57:59 +0000394 return 0;
hyatt@apple.com82b7dbb2008-04-14 19:28:53 +0000395 if (!hasImage() || errorOccurred())
darin751cf302007-05-01 22:10:41 +0000396 return size.height(); // Don't bother scaling.
397 return RenderReplaced::calcReplacedWidth() * size.height() / size.width();
darinb9481ed2006-03-20 02:57:59 +0000398}
399
darin7e7c8e42007-04-25 01:14:03 +0000400void RenderImage::calcPrefWidths()
darinb9481ed2006-03-20 02:57:59 +0000401{
darin7e7c8e42007-04-25 01:14:03 +0000402 ASSERT(prefWidthsDirty());
darinb9481ed2006-03-20 02:57:59 +0000403
darin7e7c8e42007-04-25 01:14:03 +0000404 m_maxPrefWidth = calcReplacedWidth() + paddingLeft() + paddingRight() + borderLeft() + borderRight();
darinb9481ed2006-03-20 02:57:59 +0000405
406 if (style()->width().isPercent() || style()->height().isPercent() ||
407 style()->maxWidth().isPercent() || style()->maxHeight().isPercent() ||
408 style()->minWidth().isPercent() || style()->minHeight().isPercent())
darin7e7c8e42007-04-25 01:14:03 +0000409 m_minPrefWidth = 0;
darinb9481ed2006-03-20 02:57:59 +0000410 else
darin7e7c8e42007-04-25 01:14:03 +0000411 m_minPrefWidth = m_maxPrefWidth;
darinb9481ed2006-03-20 02:57:59 +0000412
darin7e7c8e42007-04-25 01:14:03 +0000413 setPrefWidthsDirty(false);
darinb9481ed2006-03-20 02:57:59 +0000414}
415
416Image* RenderImage::nullImage()
417{
eseidela8445792006-12-28 00:48:37 +0000418 static BitmapImage sharedNullImage;
darinb9481ed2006-03-20 02:57:59 +0000419 return &sharedNullImage;
420}
421
weinigc24ab182006-10-30 22:41:29 +0000422} // namespace WebCore