Source/WebCore/ChangeLog

 12013-09-10 Tim Horton <timothy_horton@apple.com>
 2
 3 Apply OVERRIDE and FINAL to Image subclasses and clean them up
 4 https://bugs.webkit.org/show_bug.cgi?id=121086
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Everything other than the copious application of OVERRIDE and FINAL
 9 is explicitly called out below.
 10
 11 * platform/graphics/BitmapImage.cpp:
 12 * platform/graphics/BitmapImage.h:
 13 Drive-by inline isBitmapImage.
 14 Move create(HBITMAP) to be near the other create() functions.
 15 Move all of the members and quite a few functions from protected to private.
 16 Devirtualize frameCount().
 17 Move notSolidColor() near the other solid color functions.
 18
 19 * platform/graphics/CrossfadeGeneratedImage.cpp:
 20 (WebCore::CrossfadeGeneratedImage::CrossfadeGeneratedImage):
 21 (WebCore::CrossfadeGeneratedImage::drawPattern):
 22 * platform/graphics/GeneratorGeneratedImage.cpp:
 23 (WebCore::GeneratorGeneratedImage::draw):
 24 (WebCore::GeneratorGeneratedImage::drawPattern):
 25 Use size() and setContainerSize() instead of directly accessing a
 26 superclass' (now private, previously protected) members.
 27
 28 * platform/graphics/CrossfadeGeneratedImage.h:
 29 * platform/graphics/GeneratedImage.h:
 30 Make m_size private, I don't think we do protected members.
 31
 32 * platform/graphics/GeneratorGeneratedImage.h:
 33 Make all the members private.
 34
 35 * svg/graphics/SVGImage.h:
 36 * svg/graphics/SVGImageForContainer.h:
 37
1382013-09-09 Andreas Kling <akling@apple.com>
239
340 Ref-ify more stack guards.

Source/WebCore/platform/graphics/BitmapImage.cpp

@@BitmapImage::~BitmapImage()
6767 stopAnimation();
6868}
6969
70 bool BitmapImage::isBitmapImage() const
71 {
72  return true;
73 }
74 
7570bool BitmapImage::hasSingleSecurityOrigin() const
7671{
7772 return true;
7873}
7974
80 
8175void BitmapImage::destroyDecodedData(bool destroyAll)
8276{
8377 unsigned frameBytesCleared = 0;

Source/WebCore/platform/graphics/BitmapImage.h

@@public:
9797// BitmapImage Class
9898// =================================================
9999
100 class BitmapImage : public Image {
 100class BitmapImage FINAL : public Image {
101101 friend class GeneratedImage;
102102 friend class CrossfadeGeneratedImage;
103103 friend class GeneratorGeneratedImage;

@@public:
111111 {
112112 return adoptRef(new BitmapImage(observer));
113113 }
 114#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
 115 static PassRefPtr<BitmapImage> create(HBITMAP);
 116#endif
114117 virtual ~BitmapImage();
115118
116  virtual bool isBitmapImage() const;
 119 virtual bool isBitmapImage() const OVERRIDE { return true; }
117120
118  virtual bool hasSingleSecurityOrigin() const;
 121 virtual bool hasSingleSecurityOrigin() const OVERRIDE;
119122
120  virtual IntSize size() const;
 123 virtual IntSize size() const OVERRIDE;
121124 IntSize sizeRespectingOrientation() const;
122125 IntSize currentFrameSize() const;
123  virtual bool getHotSpot(IntPoint&) const;
 126 virtual bool getHotSpot(IntPoint&) const OVERRIDE;
124127
125  virtual bool dataChanged(bool allDataReceived);
126  virtual String filenameExtension() const;
 128 virtual bool dataChanged(bool allDataReceived) OVERRIDE;
 129 virtual String filenameExtension() const OVERRIDE;
127130
128131 // It may look unusual that there is no start animation call as public API. This is because
129132 // we start and stop animating lazily. Animation begins whenever someone draws the image. It will
130133 // automatically pause once all observers no longer want to render the image anywhere.
131  virtual void stopAnimation();
132  virtual void resetAnimation();
 134 virtual void stopAnimation() OVERRIDE;
 135 virtual void resetAnimation() OVERRIDE;
133136
134  virtual unsigned decodedSize() const;
 137 virtual unsigned decodedSize() const OVERRIDE;
135138
136139#if PLATFORM(MAC)
137140 // Accessors for native image formats.
138  virtual NSImage* getNSImage();
139  virtual CFDataRef getTIFFRepresentation();
 141 virtual NSImage* getNSImage() OVERRIDE;
 142 virtual CFDataRef getTIFFRepresentation() OVERRIDE;
140143#endif
141144
142145#if USE(CG)
143  virtual CGImageRef getCGImageRef();
144  virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&);
145  virtual RetainPtr<CFArrayRef> getCGImageArray();
 146 virtual CGImageRef getCGImageRef() OVERRIDE;
 147 virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&) OVERRIDE;
 148 virtual RetainPtr<CFArrayRef> getCGImageArray() OVERRIDE;
146149#endif
147150
148 #if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
149  static PassRefPtr<BitmapImage> create(HBITMAP);
150 #endif
151151#if PLATFORM(WIN)
152  virtual bool getHBITMAP(HBITMAP);
153  virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
 152 virtual bool getHBITMAP(HBITMAP) OVERRIDE;
 153 virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE) OVERRIDE;
154154#endif
155155
156156#if PLATFORM(GTK)
157  virtual GdkPixbuf* getGdkPixbuf();
 157 virtual GdkPixbuf* getGdkPixbuf() OVERRIDE;
158158#endif
159159
160160#if PLATFORM(EFL)
161  virtual Evas_Object* getEvasObject(Evas*);
 161 virtual Evas_Object* getEvasObject(Evas*) OVERRIDE;
162162#endif
163163
164164 virtual PassNativeImagePtr nativeImageForCurrentFrame() OVERRIDE;
165165 virtual ImageOrientation orientationForCurrentFrame() OVERRIDE { return frameOrientationAtIndex(currentFrame()); }
166166
167167 virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
168 
169 #if !ASSERT_DISABLED
170  virtual bool notSolidColor();
171 #endif
172168
173169 bool canAnimate();
174170
175171private:
176172 void updateSize() const;
177173
178 protected:
179174 enum RepetitionCountStatus {
180175 Unknown, // We haven't checked the source's repetition count.
181176 Uncertain, // We have a repetition count, but it might be wrong (some GIFs have a count after the image data, and will report "loop once" until all data has been decoded).

@@protected:
186181 BitmapImage(ImageObserver* = 0);
187182
188183#if PLATFORM(WIN)
189  virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator);
 184 virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator) OVERRIDE;
190185#endif
191  virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
 186 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) OVERRIDE;
192187#if USE(CG) || USE(CAIRO) || PLATFORM(BLACKBERRY)
193188 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, ImageOrientationDescription) OVERRIDE;
194189#endif
195190
196191#if USE(WINGDI)
197192 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
198  const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
 193 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect) OVERRIDE;
199194#endif
200195
201196 size_t currentFrame() const { return m_currentFrame; }
202  virtual size_t frameCount();
 197 size_t frameCount();
203198 PassNativeImagePtr frameAtIndex(size_t);
204199 bool frameIsCompleteAtIndex(size_t);
205200 float frameDurationAtIndex(size_t);

@@protected:
217212 // cache. If |destroyAll| is false, we only delete frames up to the current
218213 // one; this is used while animating large images to keep memory footprint
219214 // low without redecoding the whole image on every frame.
220  virtual void destroyDecodedData(bool destroyAll = true);
 215 virtual void destroyDecodedData(bool destroyAll = true) OVERRIDE;
221216
222217 // If the image is large enough, calls destroyDecodedData() and passes
223218 // |destroyAll| along.

@@protected:
240235 // Animation.
241236 int repetitionCount(bool imageKnownToBeComplete); // |imageKnownToBeComplete| should be set if the caller knows the entire image has been decoded.
242237 bool shouldAnimate();
243  virtual void startAnimation(bool catchUpIfNecessary = true);
 238 virtual void startAnimation(bool catchUpIfNecessary = true) OVERRIDE;
244239 void advanceAnimation(Timer<BitmapImage>*);
245240
246241 // Function that does the real work of advancing the animation. When

@@protected:
258253 // changed.
259254 void checkForSolidColor();
260255
261  virtual bool mayFillWithSolidColor();
262  virtual Color solidColor() const;
263 
 256 virtual bool mayFillWithSolidColor() OVERRIDE;
 257 virtual Color solidColor() const OVERRIDE;
 258
 259#if !ASSERT_DISABLED
 260 virtual bool notSolidColor() OVERRIDE;
 261#endif
 262
264263 ImageSource m_source;
265264 mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
266265 mutable IntSize m_sizeRespectingOrientation;

Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp

@@CrossfadeGeneratedImage::CrossfadeGeneratedImage(Image* fromImage, Image* toImag
4040 , m_percentage(percentage)
4141 , m_crossfadeSize(crossfadeSize)
4242{
43  m_size = size;
 43 setContainerSize(size);
4444}
4545
4646void CrossfadeGeneratedImage::drawCrossfade(GraphicsContext* context)

@@void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& ds
9595
9696void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode)
9797{
98  OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size, 1, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
 98 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(size(), 1, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
9999 if (!imageBuffer)
100100 return;
101101

Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h

@@namespace WebCore {
3636
3737class CSSCrossfadeValue;
3838
39 class CrossfadeGeneratedImage : public GeneratedImage {
 39class CrossfadeGeneratedImage FINAL : public GeneratedImage {
4040public:
4141 static PassRefPtr<CrossfadeGeneratedImage> create(Image* fromImage, Image* toImage, float percentage, IntSize crossfadeSize, const IntSize& size)
4242 {
4343 return adoptRef(new CrossfadeGeneratedImage(fromImage, toImage, percentage, crossfadeSize, size));
4444 }
4545
46  virtual void setContainerSize(const IntSize&) { }
47  virtual bool usesContainerSize() const { return false; }
48  virtual bool hasRelativeWidth() const { return false; }
49  virtual bool hasRelativeHeight() const { return false; }
 46 virtual void setContainerSize(const IntSize&) OVERRIDE { }
 47 virtual bool usesContainerSize() const OVERRIDE { return false; }
 48 virtual bool hasRelativeWidth() const OVERRIDE { return false; }
 49 virtual bool hasRelativeHeight() const OVERRIDE { return false; }
5050
51  virtual IntSize size() const { return m_crossfadeSize; }
 51 virtual IntSize size() const OVERRIDE { return m_crossfadeSize; }
5252
5353protected:
54  virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
55  virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& dstRect, BlendMode);
 54 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) OVERRIDE;
 55 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& dstRect, BlendMode) OVERRIDE;
5656
5757 CrossfadeGeneratedImage(Image* fromImage, Image* toImage, float percentage, IntSize crossfadeSize, const IntSize&);
5858

Source/WebCore/platform/graphics/GeneratedImage.h

@@namespace WebCore {
3535
3636class GeneratedImage : public Image {
3737public:
38  virtual bool hasSingleSecurityOrigin() const { return true; }
 38 virtual bool hasSingleSecurityOrigin() const OVERRIDE { return true; }
3939
40  virtual void setContainerSize(const IntSize& size) { m_size = size; }
41  virtual bool usesContainerSize() const { return true; }
42  virtual bool hasRelativeWidth() const { return true; }
43  virtual bool hasRelativeHeight() const { return true; }
44  virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
 40 virtual void setContainerSize(const IntSize& size) OVERRIDE { m_size = size; }
 41 virtual bool usesContainerSize() const OVERRIDE { return true; }
 42 virtual bool hasRelativeWidth() const OVERRIDE { return true; }
 43 virtual bool hasRelativeHeight() const OVERRIDE { return true; }
 44 virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) OVERRIDE;
4545
46  virtual IntSize size() const { return m_size; }
 46 virtual IntSize size() const OVERRIDE { return m_size; }
4747
4848 // Assume that generated content has no decoded data we need to worry about
49  virtual void destroyDecodedData(bool /*destroyAll*/ = true) { }
50  virtual unsigned decodedSize() const { return 0; }
 49 virtual void destroyDecodedData(bool /*destroyAll*/ = true) OVERRIDE { }
 50 virtual unsigned decodedSize() const OVERRIDE { return 0; }
5151
5252protected:
53  virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) = 0;
 53 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) OVERRIDE = 0;
5454 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
55  const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode) = 0;
 55 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode) OVERRIDE = 0;
5656
5757 // FIXME: Implement this to be less conservative.
5858 virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
5959
6060 GeneratedImage() { }
6161
 62private:
6263 IntSize m_size;
6364};
6465

Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp

@@void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect
4141 if (destRect.size() != srcRect.size())
4242 destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRect.height() / srcRect.height()));
4343 destContext->translate(-srcRect.x(), -srcRect.y());
44  destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_gradient.get());
 44 destContext->fillRect(FloatRect(FloatPoint(), size()), *m_gradient.get());
4545}
4646
4747void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
4848 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect, BlendMode)
4949{
5050 // Allow the generator to provide visually-equivalent tiling parameters for better performance.
51  IntSize adjustedSize = m_size;
 51 IntSize adjustedSize = size();
5252 FloatRect adjustedSrcRect = srcRect;
5353 m_gradient->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
5454

Source/WebCore/platform/graphics/GeneratorGeneratedImage.h

3535
3636namespace WebCore {
3737
38 class GeneratorGeneratedImage : public GeneratedImage {
 38class GeneratorGeneratedImage FINAL : public GeneratedImage {
3939public:
4040 static PassRefPtr<GeneratorGeneratedImage> create(PassRefPtr<Gradient> generator, const IntSize& size)
4141 {

@@public:
4545 virtual ~GeneratorGeneratedImage() { }
4646
4747protected:
48  virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
 48 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) OVERRIDE;
4949 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
50  const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode);
 50 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode) OVERRIDE;
5151
5252 GeneratorGeneratedImage(PassRefPtr<Gradient> generator, const IntSize& size)
5353 : m_gradient(generator)
5454 {
55  m_size = size;
 55 setContainerSize(size);
5656 }
5757
 58private:
5859 RefPtr<Gradient> m_gradient;
5960 OwnPtr<ImageBuffer> m_cachedImageBuffer;
6061 IntSize m_cachedAdjustedSize;

Source/WebCore/svg/graphics/SVGImage.h

@@class RenderBox;
4141class SVGImageChromeClient;
4242class SVGImageForContainer;
4343
44 class SVGImage : public Image {
 44class SVGImage FINAL : public Image {
4545public:
4646 static PassRefPtr<SVGImage> create(ImageObserver* observer)
4747 {

@@public:
5151 RenderBox* embeddedContentBox() const;
5252 FrameView* frameView() const;
5353
54  virtual bool isSVGImage() const { return true; }
 54 virtual bool isSVGImage() const OVERRIDE { return true; }
5555 virtual IntSize size() const OVERRIDE { return m_intrinsicSize; }
5656
5757 virtual bool hasSingleSecurityOrigin() const OVERRIDE;
5858
59  virtual bool hasRelativeWidth() const;
60  virtual bool hasRelativeHeight() const;
 59 virtual bool hasRelativeWidth() const OVERRIDE;
 60 virtual bool hasRelativeHeight() const OVERRIDE;
6161
6262 virtual void startAnimation(bool /*catchUpIfNecessary*/ = true) OVERRIDE;
6363 virtual void stopAnimation() OVERRIDE;

@@private:
7373
7474 virtual ~SVGImage();
7575
76  virtual String filenameExtension() const;
 76 virtual String filenameExtension() const OVERRIDE;
7777
78  virtual void setContainerSize(const IntSize&);
 78 virtual void setContainerSize(const IntSize&) OVERRIDE;
7979 IntSize containerSize() const;
80  virtual bool usesContainerSize() const { return true; }
81  virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
 80 virtual bool usesContainerSize() const OVERRIDE { return true; }
 81 virtual void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio) OVERRIDE;
8282
83  virtual bool dataChanged(bool allDataReceived);
 83 virtual bool dataChanged(bool allDataReceived) OVERRIDE;
8484
8585 // FIXME: SVGImages are underreporting decoded sizes and will be unable
8686 // to prune because these functions are not implemented yet.
87  virtual void destroyDecodedData(bool) { }
88  virtual unsigned decodedSize() const { return 0; }
 87 virtual void destroyDecodedData(bool) OVERRIDE { }
 88 virtual unsigned decodedSize() const OVERRIDE { return 0; }
8989
9090 // FIXME: Implement this to be less conservative.
9191 virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
9292
9393 SVGImage(ImageObserver*);
94  virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
 94 virtual void draw(GraphicsContext*, const FloatRect& fromRect, const FloatRect& toRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) OVERRIDE;
9595 void drawForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const FloatRect&, ColorSpace, CompositeOperator, BlendMode);
9696 void drawPatternForContainer(GraphicsContext*, const FloatSize, float, const FloatRect&, const AffineTransform&, const FloatPoint&, ColorSpace,
9797 CompositeOperator, const FloatRect&);

Source/WebCore/svg/graphics/SVGImageForContainer.h

3636
3737namespace WebCore {
3838
39 class SVGImageForContainer : public Image {
 39class SVGImageForContainer FINAL : public Image {
4040public:
4141 static PassRefPtr<SVGImageForContainer> create(SVGImage* image, const FloatSize& containerSize, float zoom)
4242 {

@@private:
7272 {
7373 }
7474
75  virtual void destroyDecodedData(bool /*destroyAll*/ = true) { }
76  virtual unsigned decodedSize() const { return 0; }
 75 virtual void destroyDecodedData(bool /*destroyAll*/ = true) OVERRIDE { }
 76 virtual unsigned decodedSize() const OVERRIDE { return 0; }
7777
7878 SVGImage* m_image;
7979 const FloatSize m_containerSize;