Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.h

Issue 2325733003: Document SVGImage with a class-level comment (Closed)
Patch Set: Rebase with clean tree this time Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 24 matching lines...) Expand all
35 #include "wtf/Allocator.h" 35 #include "wtf/Allocator.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 class Document; 39 class Document;
40 class Page; 40 class Page;
41 class LayoutReplaced; 41 class LayoutReplaced;
42 class SVGImageChromeClient; 42 class SVGImageChromeClient;
43 class SVGImageForContainer; 43 class SVGImageForContainer;
44 44
45 // SVGImage does not use Skia to draw images (as BitmapImage does) but instead
46 // handles drawing itself. Internally, SVGImage creates a detached & sandboxed
47 // Page containing an SVGDocument and reuses the existing paint code in Blink to
48 // draw the image. Because a single SVGImage can be referenced by multiple
49 // containers (see: SVGImageForContainer.h), each call to SVGImage::draw() may
50 // require (re-)laying out the inner SVGDocument.
51 //
52 // Using Page was an architectural hack and has surprising side-effects. Ideally
53 // SVGImage would use a lighter container around an SVGDocument that does not
54 // have the full Page machinery but still has the sandboxing security guarantees
55 // needed by SVGImage.
45 class CORE_EXPORT SVGImage final : public Image { 56 class CORE_EXPORT SVGImage final : public Image {
46 public: 57 public:
47 static PassRefPtr<SVGImage> create(ImageObserver* observer) 58 static PassRefPtr<SVGImage> create(ImageObserver* observer)
48 { 59 {
49 return adoptRef(new SVGImage(observer)); 60 return adoptRef(new SVGImage(observer));
50 } 61 }
51 62
52 static bool isInSVGImage(const Node*); 63 static bool isInSVGImage(const Node*);
53 64
54 LayoutReplaced* embeddedReplacedContent() const; 65 LayoutReplaced* embeddedReplacedContent() const;
(...skipping 28 matching lines...) Expand all
83 94
84 bool hasIntrinsicDimensions() const; 95 bool hasIntrinsicDimensions() const;
85 96
86 private: 97 private:
87 // Accesses m_page. 98 // Accesses m_page.
88 friend class SVGImageChromeClient; 99 friend class SVGImageChromeClient;
89 // Forwards calls to the various *ForContainer methods and other parts of 100 // Forwards calls to the various *ForContainer methods and other parts of
90 // the the Image interface. 101 // the the Image interface.
91 friend class SVGImageForContainer; 102 friend class SVGImageForContainer;
92 103
104 SVGImage(ImageObserver*);
93 ~SVGImage() override; 105 ~SVGImage() override;
94 106
95 String filenameExtension() const override; 107 String filenameExtension() const override;
96 108
97 IntSize containerSize() const; 109 IntSize containerSize() const;
98 bool usesContainerSize() const override { return true; } 110 bool usesContainerSize() const override { return true; }
99 111
100 SizeAvailability dataChanged(bool allDataReceived) override; 112 SizeAvailability dataChanged(bool allDataReceived) override;
101 113
102 // FIXME: SVGImages are underreporting decoded sizes and will be unable 114 // FIXME: SVGImages are underreporting decoded sizes and will be unable
103 // to prune because these functions are not implemented yet. 115 // to prune because these functions are not implemented yet.
104 void destroyDecodedData() override { } 116 void destroyDecodedData() override { }
105 117
106 // FIXME: Implement this to be less conservative. 118 // FIXME: Implement this to be less conservative.
107 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } 119 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override
120 {
121 return false;
122 }
108 123
109 SVGImage(ImageObserver*); 124 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect,
110 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override; 125 const FloatRect& toRect, RespectImageOrientationEnum,
111 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con st FloatRect&, const FloatRect&, const KURL&); 126 ImageClampingMode) override;
112 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&, 127 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float,
113 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons t KURL&); 128 const FloatRect&, const FloatRect&, const KURL&);
114 sk_sp<SkImage> imageForCurrentFrameForContainer(const KURL&, const IntSize& containerSize); 129 void drawPatternForContainer(GraphicsContext&, const FloatSize, float,
115 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons t FloatRect& toRect, RespectImageOrientationEnum, 130 const FloatRect&, const FloatSize&, const FloatPoint&,
116 ImageClampingMode, const KURL&); 131 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing,
132 const KURL&);
133 sk_sp<SkImage> imageForCurrentFrameForContainer(const KURL&,
134 const IntSize& containerSize);
135 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect,
136 const FloatRect& toRect, RespectImageOrientationEnum, ImageClampingMode,
137 const KURL&);
117 138
118 void stopAnimation(); 139 void stopAnimation();
119 void scheduleTimelineRewind(); 140 void scheduleTimelineRewind();
120 void flushPendingTimelineRewind(); 141 void flushPendingTimelineRewind();
121 142
122 Persistent<SVGImageChromeClient> m_chromeClient; 143 Persistent<SVGImageChromeClient> m_chromeClient;
123 Persistent<Page> m_page; 144 Persistent<Page> m_page;
124 145
125 // When an SVG image has no intrinsic size the size depends on the 146 // When an SVG image has no intrinsic size, the size depends on the default
126 // default object size, which in turn depends on the 147 // object size, which in turn depends on the container. One SVGImage may
127 // container. SVGImage may belong to multiple containers so the 148 // belong to multiple containers so the final image size can't be known in
128 // final image size can't be known in 149 // SVGImage. SVGImageForContainer carries the final image size, also called
129 // SVGImage. SVGImageForContainer carried the final image size, 150 // the "concrete object size". For more, see: SVGImageForContainer.h
130 // also called concrete object size.
131 IntSize m_intrinsicSize; 151 IntSize m_intrinsicSize;
132 bool m_hasPendingTimelineRewind; 152 bool m_hasPendingTimelineRewind;
133 }; 153 };
134 154
135 DEFINE_IMAGE_TYPE_CASTS(SVGImage); 155 DEFINE_IMAGE_TYPE_CASTS(SVGImage);
136 156
137 class ImageObserverDisabler { 157 class ImageObserverDisabler {
138 STACK_ALLOCATED(); 158 STACK_ALLOCATED();
139 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler); 159 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler);
140 public: 160 public:
141 ImageObserverDisabler(Image* image) 161 ImageObserverDisabler(Image* image)
142 : m_image(image) 162 : m_image(image)
143 { 163 {
144 m_image->setImageObserverDisabled(true); 164 m_image->setImageObserverDisabled(true);
145 } 165 }
146 166
147 ~ImageObserverDisabler() 167 ~ImageObserverDisabler()
148 { 168 {
149 m_image->setImageObserverDisabled(false); 169 m_image->setImageObserverDisabled(false);
150 } 170 }
151 private: 171 private:
152 Image* m_image; 172 Image* m_image;
153 }; 173 };
154 174
155 } // namespace blink 175 } // namespace blink
156 176
157 #endif // SVGImage_h 177 #endif // SVGImage_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698