2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
28 #include "RenderImageResource.h"
29 #include "RenderReplaced.h"
33 class HTMLAreaElement;
36 class RenderImage : public RenderReplaced {
39 virtual ~RenderImage();
41 void setImageResource(PassOwnPtr<RenderImageResource>);
43 RenderImageResource* imageResource() { return m_imageResource.get(); }
44 const RenderImageResource* imageResource() const { return m_imageResource.get(); }
45 CachedImage* cachedImage() const { return m_imageResource ? m_imageResource->cachedImage() : 0; }
47 bool setImageSizeForAltText(CachedImage* newImage = 0);
51 HTMLMapElement* imageMap() const;
52 void areaElementFocusChanged(HTMLAreaElement*);
54 void highQualityRepaintTimerFired(Timer<RenderImage>*);
57 virtual void styleDidChange(StyleDifference, const RenderStyle*);
59 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
61 virtual void paintIntoRect(GraphicsContext*, const IntRect&);
62 virtual void paint(PaintInfo&, const LayoutPoint&);
64 bool isLogicalWidthSpecified() const;
65 bool isLogicalHeightSpecified() const;
67 virtual void intrinsicSizeChanged()
70 imageChanged(m_imageResource->imagePtr());
74 virtual const char* renderName() const { return "RenderImage"; }
76 virtual bool isImage() const { return true; }
77 virtual bool isRenderImage() const { return true; }
79 virtual void paintReplaced(PaintInfo&, const IntPoint&);
81 virtual bool backgroundIsObscured() const;
83 virtual int minimumReplacedHeight() const;
85 virtual void notifyFinished(CachedResource*);
86 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
88 virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
89 virtual LayoutUnit computeReplacedLogicalHeight() const;
91 IntSize imageSizeForError(CachedImage*) const;
92 void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0);
94 int calcAspectRatioLogicalWidth() const;
95 int calcAspectRatioLogicalHeight() const;
97 void paintAreaElementFocusRing(PaintInfo&);
99 // Text to display as long as the image isn't available.
101 OwnPtr<RenderImageResource> m_imageResource;
102 bool m_needsToSetSizeForAltText;
103 bool m_didIncrementVisuallyNonEmptyPixelCount;
105 friend class RenderImageScaleObserver;
108 inline RenderImage* toRenderImage(RenderObject* object)
110 ASSERT(!object || object->isRenderImage());
111 return static_cast<RenderImage*>(object);
114 inline const RenderImage* toRenderImage(const RenderObject* object)
116 ASSERT(!object || object->isRenderImage());
117 return static_cast<const RenderImage*>(object);
120 // This will catch anyone doing an unnecessary cast.
121 void toRenderImage(const RenderImage*);
123 } // namespace WebCore
125 #endif // RenderImage_h