Changeset 36712 in webkit
- Timestamp:
- Sep 20, 2008 1:19:45 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 15 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r36709 r36712 1 2008-09-20 Nikolas Zimmermann <zimmermann@kde.org> 2 3 Reviewed by Eric. 4 5 Refactor HTMLImageLoader/SVGImageLoader code. 6 Move html/HTMLImageLoader.* to loader/ImageLoader.* 7 8 Let HTMLImageLoader & SVGImageLoader inherit from the new base class. 9 SVGImageLoader used to inherit from HTMLImageLoader which is awkward. 10 11 * GNUmakefile.am: 12 * WebCore.pro: 13 * WebCore.vcproj/WebCore.vcproj: 14 * WebCore.xcodeproj/project.pbxproj: 15 * WebCoreSources.bkl: 16 * dom/Document.cpp: 17 (WebCore::Document::dispatchImageLoadEventSoon): 18 (WebCore::Document::removeImage): 19 (WebCore::Document::dispatchImageLoadEventsNow): 20 * dom/Document.h: 21 * html/HTMLImageLoader.cpp: 22 (WebCore::HTMLImageLoader::HTMLImageLoader): 23 (WebCore::HTMLImageLoader::~HTMLImageLoader): 24 (WebCore::HTMLImageLoader::sourceURI): 25 (WebCore::HTMLImageLoader::notifyFinished): 26 * html/HTMLImageLoader.h: 27 * loader/DocLoader.h: 28 * loader/ImageLoader.cpp: Copied from html/HTMLImageLoader.cpp. 29 (WebCore::ImageLoader::ImageLoader): 30 (WebCore::ImageLoader::~ImageLoader): 31 (WebCore::ImageLoader::setImage): 32 (WebCore::ImageLoader::setLoadingImage): 33 (WebCore::ImageLoader::updateFromElement): 34 (WebCore::ImageLoader::notifyFinished): 35 * loader/ImageLoader.h: Copied from html/HTMLImageLoader.h. 36 * svg/SVGImageElement.cpp: 37 (WebCore::SVGImageElement::attach): 38 (WebCore::SVGImageElement::insertedIntoDocument): 39 (WebCore::SVGImageElement::imageSourceAttributeName): 40 * svg/SVGImageElement.h: 41 * svg/SVGImageLoader.cpp: 42 (WebCore::SVGImageLoader::SVGImageLoader): 43 (WebCore::SVGImageLoader::dispatchLoadEvent): 44 (WebCore::SVGImageLoader::sourceURI): 45 * svg/SVGImageLoader.h: 46 1 47 2008-09-20 Holger Hans Peter Freyther <zecke@selfish.org> 2 48 -
trunk/WebCore/GNUmakefile.am
r36658 r36712 1360 1360 WebCore/loader/ImageDocument.cpp \ 1361 1361 WebCore/loader/ImageDocument.h \ 1362 WebCore/loader/ImageLoader.cpp \ 1363 WebCore/loader/ImageLoader.h \ 1362 1364 WebCore/loader/MainResourceLoader.cpp \ 1363 1365 WebCore/loader/MainResourceLoader.h \ -
trunk/WebCore/WebCore.pro
r36653 r36712 720 720 loader/icon/IconLoader.cpp \ 721 721 loader/ImageDocument.cpp \ 722 loader/ImageLoader.cpp \ 722 723 loader/loader.cpp \ 723 724 loader/MainResourceLoader.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r36653 r36712 2897 2897 </File> 2898 2898 <File 2899 RelativePath="..\loader\ImageLoader.cpp" 2900 > 2901 </File> 2902 <File 2903 RelativePath="..\loader\ImageLoader.h" 2904 > 2905 </File> 2906 <File 2899 2907 RelativePath="..\loader\loader.cpp" 2900 2908 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r36676 r36712 40 40 06E81ED70AB5D5E900C87837 /* LocalCurrentGraphicsContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */; }; 41 41 06E81EEC0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */; }; 42 089582550E857A7E00F82C83 /* ImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 089582530E857A7E00F82C83 /* ImageLoader.cpp */; }; 43 089582560E857A7E00F82C83 /* ImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 089582540E857A7E00F82C83 /* ImageLoader.h */; }; 42 44 08A484770E5272C500C3FE76 /* ScriptElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08A484750E5272C500C3FE76 /* ScriptElement.cpp */; }; 43 45 08A484780E5272C500C3FE76 /* ScriptElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08A484760E5272C500C3FE76 /* ScriptElement.h */; }; … … 4660 4662 06E81ED60AB5D5E900C87837 /* LocalCurrentGraphicsContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalCurrentGraphicsContext.h; sourceTree = "<group>"; }; 4661 4663 06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentGraphicsContext.mm; sourceTree = "<group>"; }; 4664 089582530E857A7E00F82C83 /* ImageLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageLoader.cpp; sourceTree = "<group>"; }; 4665 089582540E857A7E00F82C83 /* ImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageLoader.h; sourceTree = "<group>"; }; 4662 4666 08A484750E5272C500C3FE76 /* ScriptElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptElement.cpp; sourceTree = "<group>"; }; 4663 4667 08A484760E5272C500C3FE76 /* ScriptElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptElement.h; sourceTree = "<group>"; }; … … 12980 12984 1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */, 12981 12985 1A820D900A13EBA600AF843C /* ImageDocument.h */, 12986 089582530E857A7E00F82C83 /* ImageLoader.cpp */, 12987 089582540E857A7E00F82C83 /* ImageLoader.h */, 12982 12988 BCB16C130979C3BD00467741 /* loader.cpp */, 12983 12989 BCB16C140979C3BD00467741 /* loader.h */, … … 15846 15852 BC22747B0E8366E200E7F975 /* SVGRenderStyleDefs.h in Headers */, 15847 15853 B2F34FE60E82F81400F627CD /* DNS.h in Headers */, 15854 089582560E857A7E00F82C83 /* ImageLoader.h in Headers */, 15848 15855 ); 15849 15856 runOnlyForDeploymentPostprocessing = 0; … … 17679 17686 B2F34FE90E82F82700F627CD /* DNSCFNet.cpp in Sources */, 17680 17687 BCEF869F0E844E9D00A85CD5 /* ScrollbarThemeMac.mm in Sources */, 17688 089582550E857A7E00F82C83 /* ImageLoader.cpp in Sources */, 17681 17689 ); 17682 17690 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/WebCoreSources.bkl
r36630 r36712 600 600 loader/FTPDirectoryParser.cpp 601 601 loader/ImageDocument.cpp 602 loader/ImageLoader.cpp 602 603 loader/MainResourceLoader.cpp 603 604 loader/MediaDocument.cpp -
trunk/WebCore/dom/Document.cpp
r36706 r36712 61 61 #include "HTMLFrameOwnerElement.h" 62 62 #include "HTMLHeadElement.h" 63 #include "HTMLImageLoader.h"64 63 #include "HTMLInputElement.h" 65 64 #include "HTMLLinkElement.h" … … 73 72 #include "HitTestRequest.h" 74 73 #include "HitTestResult.h" 74 #include "ImageLoader.h" 75 75 #include "KeyboardEvent.h" 76 76 #include "Logging.h" … … 2777 2777 } 2778 2778 2779 void Document::dispatchImageLoadEventSoon( HTMLImageLoader *image)2779 void Document::dispatchImageLoadEventSoon(ImageLoader* image) 2780 2780 { 2781 2781 m_imageLoadEventDispatchSoonList.append(image); … … 2784 2784 } 2785 2785 2786 void Document::removeImage( HTMLImageLoader* image)2786 void Document::removeImage(ImageLoader* image) 2787 2787 { 2788 2788 // Remove instances of this image from both lists. … … 2799 2799 // scheduled before the parent finishes processing the list, they 2800 2800 // will set a timer and eventually be processed 2801 if (!m_imageLoadEventDispatchingList.isEmpty()) { 2802 return; 2803 } 2801 if (!m_imageLoadEventDispatchingList.isEmpty()) 2802 return; 2804 2803 2805 2804 m_imageLoadEventTimer.stop(); … … 2807 2806 m_imageLoadEventDispatchingList = m_imageLoadEventDispatchSoonList; 2808 2807 m_imageLoadEventDispatchSoonList.clear(); 2809 for (DeprecatedPtrListIterator< HTMLImageLoader> it(m_imageLoadEventDispatchingList); it.current();) {2810 HTMLImageLoader* image = it.current();2808 for (DeprecatedPtrListIterator<ImageLoader> it(m_imageLoadEventDispatchingList); it.current();) { 2809 ImageLoader* image = it.current(); 2811 2810 // Must advance iterator *before* dispatching call. 2812 2811 // Otherwise, it might be advanced automatically if dispatching the call had a side effect 2813 // of destroying the current HTMLImageLoader, and then we would advance past the *next* item,2812 // of destroying the current ImageLoader, and then we would advance past the *next* item, 2814 2813 // missing one altogether. 2815 2814 ++it; -
trunk/WebCore/dom/Document.h
r36706 r36712 81 81 class HTMLFormElement; 82 82 class HTMLHeadElement; 83 class HTMLImageLoader;84 83 class HTMLInputElement; 85 84 class HTMLMapElement; 85 class ImageLoader; 86 86 class IntPoint; 87 87 class JSNode; … … 611 611 void processHttpEquiv(const String& equiv, const String& content); 612 612 613 void dispatchImageLoadEventSoon( HTMLImageLoader*);613 void dispatchImageLoadEventSoon(ImageLoader*); 614 614 void dispatchImageLoadEventsNow(); 615 void removeImage( HTMLImageLoader*);615 void removeImage(ImageLoader*); 616 616 617 617 // Returns the owning element in the parent document. … … 886 886 mutable AXObjectCache* m_axObjectCache; 887 887 888 DeprecatedPtrList< HTMLImageLoader> m_imageLoadEventDispatchSoonList;889 DeprecatedPtrList< HTMLImageLoader> m_imageLoadEventDispatchingList;888 DeprecatedPtrList<ImageLoader> m_imageLoadEventDispatchSoonList; 889 DeprecatedPtrList<ImageLoader> m_imageLoadEventDispatchingList; 890 890 Timer<Document> m_imageLoadEventTimer; 891 891 -
trunk/WebCore/html/HTMLImageLoader.cpp
r36466 r36712 25 25 #include "CSSHelper.h" 26 26 #include "CachedImage.h" 27 #include "DocLoader.h"28 #include "Document.h"29 27 #include "Element.h" 30 28 #include "EventNames.h" 31 29 #include "HTMLNames.h" 32 30 #include "HTMLObjectElement.h" 33 #include "RenderImage.h"34 35 using namespace std;36 31 37 32 namespace WebCore { 38 33 39 34 using namespace EventNames; 40 using namespace HTMLNames;41 35 42 HTMLImageLoader::HTMLImageLoader(Element* elt) 43 : m_element(elt) 44 , m_image(0) 45 , m_firedLoad(true) 46 , m_imageComplete(true) 47 , m_loadManually(false) 36 HTMLImageLoader::HTMLImageLoader(Element* node) 37 : ImageLoader(node) 48 38 { 49 39 } … … 51 41 HTMLImageLoader::~HTMLImageLoader() 52 42 { 53 if (m_image)54 m_image->removeClient(this);55 m_element->document()->removeImage(this);56 }57 58 void HTMLImageLoader::setImage(CachedImage *newImage)59 {60 CachedImage *oldImage = m_image.get();61 if (newImage != oldImage) {62 setLoadingImage(newImage);63 m_firedLoad = true;64 m_imageComplete = true;65 if (newImage)66 newImage->addClient(this);67 if (oldImage)68 oldImage->removeClient(this);69 }70 71 if (RenderObject* renderer = element()->renderer())72 if (renderer->isImage())73 static_cast<RenderImage*>(renderer)->resetAnimation();74 }75 76 void HTMLImageLoader::setLoadingImage(CachedImage *loadingImage)77 {78 m_firedLoad = false;79 m_imageComplete = false;80 m_image = loadingImage;81 }82 83 void HTMLImageLoader::updateFromElement()84 {85 // If we're not making renderers for the page, then don't load images. We don't want to slow86 // down the raw HTML parsing case by loading images we don't intend to display.87 Element* elem = element();88 Document* doc = elem->document();89 if (!doc->renderer())90 return;91 92 AtomicString attr = elem->getAttribute(elem->imageSourceAttributeName());93 94 // Do not load any image if the 'src' attribute is missing or if it is95 // an empty string referring to a local file. The latter condition is96 // a quirk that preserves old behavior that Dashboard widgets97 // need (<rdar://problem/5994621>).98 CachedImage *newImage = 0;99 if (!(attr.isNull() || attr.isEmpty() && doc->baseURI().isLocalFile())) {100 if (m_loadManually) {101 doc->docLoader()->setAutoLoadImages(false);102 newImage = new CachedImage(parseURL(attr));103 newImage->setLoading(true);104 newImage->setDocLoader(doc->docLoader());105 doc->docLoader()->m_docResources.set(newImage->url(), newImage);106 } else107 newImage = doc->docLoader()->requestImage(parseURL(attr));108 }109 110 CachedImage *oldImage = m_image.get();111 if (newImage != oldImage) {112 #ifdef INSTRUMENT_LAYOUT_SCHEDULING113 if (!doc->ownerElement() && newImage)114 printf("Image requested at %d\n", doc->elapsedTime());115 #endif116 setLoadingImage(newImage);117 if (newImage)118 newImage->addClient(this);119 if (oldImage)120 oldImage->removeClient(this);121 }122 123 if (RenderObject* renderer = elem->renderer())124 if (renderer->isImage())125 static_cast<RenderImage*>(renderer)->resetAnimation();126 43 } 127 44 … … 134 51 } 135 52 136 void HTMLImageLoader::notifyFinished(CachedResource *image) 53 String HTMLImageLoader::sourceURI(const AtomicString& attr) const 137 54 { 138 m_imageComplete = true; 55 return parseURL(attr); 56 } 57 58 void HTMLImageLoader::notifyFinished(CachedResource* image) 59 { 139 60 Element* elem = element(); 140 Document* doc = elem->document(); 141 doc->dispatchImageLoadEventSoon(this); 142 #ifdef INSTRUMENT_LAYOUT_SCHEDULING 143 if (!doc->ownerElement()) 144 printf("Image loaded at %d\n", doc->elapsedTime()); 145 #endif 146 if (RenderObject* renderer = elem->renderer()) 147 if (renderer->isImage()) 148 static_cast<RenderImage*>(renderer)->setCachedImage(m_image.get()); 149 150 if (image->errorOccurred() && elem->hasTagName(objectTag)) 61 ImageLoader::notifyFinished(image); 62 63 if (image->errorOccurred() && elem->hasTagName(HTMLNames::objectTag)) 151 64 static_cast<HTMLObjectElement*>(elem)->renderFallbackContent(); 152 65 } -
trunk/WebCore/html/HTMLImageLoader.h
r36109 r36712 26 26 #define HTMLImageLoader_h 27 27 28 #include "CachedResourceClient.h" 29 #include "CachedResourceHandle.h" 28 #include "ImageLoader.h" 30 29 31 30 namespace WebCore { 32 31 33 class Element; 34 35 class HTMLImageLoader : public CachedResourceClient { 32 class HTMLImageLoader : public ImageLoader { 36 33 public: 37 34 HTMLImageLoader(Element*); 38 35 virtual ~HTMLImageLoader(); 39 36 40 virtual void updateFromElement(); 37 virtual void dispatchLoadEvent(); 38 virtual String sourceURI(const AtomicString&) const; 41 39 42 virtual void dispatchLoadEvent();43 44 Element* element() const { return m_element; }45 bool imageComplete() const { return m_imageComplete; }46 47 CachedImage* image() const { return m_image.get(); }48 void setImage(CachedImage*);49 50 void setLoadManually(bool loadManually) { m_loadManually = loadManually; }51 52 // CachedResourceClient API53 40 virtual void notifyFinished(CachedResource*); 54 55 bool haveFiredLoadEvent() const { return m_firedLoad; }56 protected:57 void setLoadingImage(CachedImage*);58 59 void setHaveFiredLoadEvent(bool firedLoad) { m_firedLoad = firedLoad; }60 61 private:62 Element* m_element;63 CachedResourceHandle<CachedImage> m_image;64 bool m_firedLoad : 1;65 bool m_imageComplete : 1;66 bool m_loadManually : 1;67 41 }; 68 42 69 } //namespace43 } 70 44 71 45 #endif -
trunk/WebCore/loader/DocLoader.h
r35801 r36712 42 42 class Document; 43 43 class Frame; 44 class HTMLImageLoader;44 class ImageLoader; 45 45 class KURL; 46 46 … … 49 49 { 50 50 friend class Cache; 51 friend class HTMLImageLoader;51 friend class ImageLoader; 52 52 53 53 public: -
trunk/WebCore/loader/ImageLoader.cpp
r36711 r36712 21 21 22 22 #include "config.h" 23 #include " HTMLImageLoader.h"23 #include "ImageLoader.h" 24 24 25 25 #include "CSSHelper.h" … … 29 29 #include "Element.h" 30 30 #include "EventNames.h" 31 #include "HTMLNames.h"32 #include "HTMLObjectElement.h"33 31 #include "RenderImage.h" 34 35 using namespace std;36 32 37 33 namespace WebCore { 38 34 39 35 using namespace EventNames; 40 using namespace HTMLNames;41 36 42 HTMLImageLoader::HTMLImageLoader(Element* elt)37 ImageLoader::ImageLoader(Element* elt) 43 38 : m_element(elt) 44 39 , m_image(0) … … 49 44 } 50 45 51 HTMLImageLoader::~HTMLImageLoader()46 ImageLoader::~ImageLoader() 52 47 { 53 48 if (m_image) … … 56 51 } 57 52 58 void HTMLImageLoader::setImage(CachedImage *newImage)53 void ImageLoader::setImage(CachedImage* newImage) 59 54 { 60 CachedImage *oldImage = m_image.get();55 CachedImage* oldImage = m_image.get(); 61 56 if (newImage != oldImage) { 62 57 setLoadingImage(newImage); … … 69 64 } 70 65 71 if (RenderObject* renderer = element()->renderer()) 72 if (renderer->isImage()) 73 static_cast<RenderImage*>(renderer)->resetAnimation(); 66 if (RenderObject* renderer = element()->renderer()) { 67 if (!renderer->isImage()) 68 return; 69 70 static_cast<RenderImage*>(renderer)->resetAnimation(); 71 } 74 72 } 75 73 76 void HTMLImageLoader::setLoadingImage(CachedImage *loadingImage)74 void ImageLoader::setLoadingImage(CachedImage* loadingImage) 77 75 { 78 76 m_firedLoad = false; … … 81 79 } 82 80 83 void HTMLImageLoader::updateFromElement()81 void ImageLoader::updateFromElement() 84 82 { 85 83 // If we're not making renderers for the page, then don't load images. We don't want to slow … … 91 89 92 90 AtomicString attr = elem->getAttribute(elem->imageSourceAttributeName()); 93 91 94 92 // Do not load any image if the 'src' attribute is missing or if it is 95 93 // an empty string referring to a local file. The latter condition is 96 94 // a quirk that preserves old behavior that Dashboard widgets 97 95 // need (<rdar://problem/5994621>). 98 CachedImage *newImage = 0;96 CachedImage* newImage = 0; 99 97 if (!(attr.isNull() || attr.isEmpty() && doc->baseURI().isLocalFile())) { 100 98 if (m_loadManually) { 101 99 doc->docLoader()->setAutoLoadImages(false); 102 newImage = new CachedImage( parseURL(attr));100 newImage = new CachedImage(sourceURI(attr)); 103 101 newImage->setLoading(true); 104 102 newImage->setDocLoader(doc->docLoader()); 105 103 doc->docLoader()->m_docResources.set(newImage->url(), newImage); 106 104 } else 107 newImage = doc->docLoader()->requestImage( parseURL(attr));105 newImage = doc->docLoader()->requestImage(sourceURI(attr)); 108 106 } 109 107 110 CachedImage *oldImage = m_image.get();108 CachedImage* oldImage = m_image.get(); 111 109 if (newImage != oldImage) { 112 #ifdef INSTRUMENT_LAYOUT_SCHEDULING113 if (!doc->ownerElement() && newImage)114 printf("Image requested at %d\n", doc->elapsedTime());115 #endif116 110 setLoadingImage(newImage); 117 111 if (newImage) … … 121 115 } 122 116 123 if (RenderObject* renderer = elem->renderer()) 124 if (renderer->isImage()) 125 static_cast<RenderImage*>(renderer)->resetAnimation(); 126 } 117 if (RenderObject* renderer = elem->renderer()) { 118 if (!renderer->isImage()) 119 return; 127 120 128 void HTMLImageLoader::dispatchLoadEvent() 129 { 130 if (!haveFiredLoadEvent() && image()) { 131 setHaveFiredLoadEvent(true); 132 element()->dispatchEventForType(image()->errorOccurred() ? errorEvent : loadEvent, false, false); 121 static_cast<RenderImage*>(renderer)->resetAnimation(); 133 122 } 134 123 } 135 124 136 void HTMLImageLoader::notifyFinished(CachedResource *image)125 void ImageLoader::notifyFinished(CachedResource *image) 137 126 { 138 127 m_imageComplete = true; 128 139 129 Element* elem = element(); 140 Document* doc = elem->document(); 141 doc->dispatchImageLoadEventSoon(this); 142 #ifdef INSTRUMENT_LAYOUT_SCHEDULING 143 if (!doc->ownerElement()) 144 printf("Image loaded at %d\n", doc->elapsedTime()); 145 #endif 146 if (RenderObject* renderer = elem->renderer()) 147 if (renderer->isImage()) 148 static_cast<RenderImage*>(renderer)->setCachedImage(m_image.get()); 149 150 if (image->errorOccurred() && elem->hasTagName(objectTag)) 151 static_cast<HTMLObjectElement*>(elem)->renderFallbackContent(); 130 elem->document()->dispatchImageLoadEventSoon(this); 131 132 if (RenderObject* renderer = elem->renderer()) { 133 if (!renderer->isImage()) 134 return; 135 136 static_cast<RenderImage*>(renderer)->setCachedImage(m_image.get()); 137 } 152 138 } 153 139 -
trunk/WebCore/loader/ImageLoader.h
r36711 r36712 23 23 */ 24 24 25 #ifndef HTMLImageLoader_h26 #define HTMLImageLoader_h25 #ifndef ImageLoader_h 26 #define ImageLoader_h 27 27 28 28 #include "CachedResourceClient.h" … … 31 31 namespace WebCore { 32 32 33 class AtomicString; 33 34 class Element; 34 35 35 class HTMLImageLoader : public CachedResourceClient {36 class ImageLoader : public CachedResourceClient { 36 37 public: 37 HTMLImageLoader(Element*);38 virtual ~ HTMLImageLoader();38 ImageLoader(Element*); 39 virtual ~ImageLoader(); 39 40 40 v irtual void updateFromElement();41 void updateFromElement(); 41 42 42 virtual void dispatchLoadEvent(); 43 virtual void dispatchLoadEvent() = 0; 44 virtual String sourceURI(const AtomicString&) const = 0; 43 45 44 46 Element* element() const { return m_element; } … … 67 69 }; 68 70 69 } //namespace71 } 70 72 71 73 #endif -
trunk/WebCore/svg/SVGImageElement.cpp
r35679 r36712 132 132 { 133 133 SVGStyledTransformableElement::attach(); 134 135 if (RenderSVGImage* imageObj = static_cast<RenderSVGImage*>(renderer())) { 136 if (imageObj->hasImage()) 137 return; 138 139 imageObj->setCachedImage(m_imageLoader.image()); 140 } 141 } 142 143 void SVGImageElement::insertedIntoDocument() 144 { 145 SVGStyledTransformableElement::insertedIntoDocument(); 146 147 // Update image loader, as soon as we're living in the tree. 148 // We can only resolve base URIs properly, after that! 134 149 m_imageLoader.updateFromElement(); 135 if (RenderSVGImage* imageObj = static_cast<RenderSVGImage*>(renderer())) 136 imageObj->setCachedImage(m_imageLoader.image()); 150 } 151 152 const QualifiedName& SVGImageElement::imageSourceAttributeName() const 153 { 154 return XLinkNames::hrefAttr; 137 155 } 138 156 -
trunk/WebCore/svg/SVGImageElement.h
r35248 r36712 52 52 53 53 virtual void attach(); 54 virtual void insertedIntoDocument(); 54 55 55 56 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 56 57 58 virtual const QualifiedName& imageSourceAttributeName() const; 57 59 virtual void getSubresourceAttributeStrings(Vector<String>&) const; 58 60 -
trunk/WebCore/svg/SVGImageLoader.cpp
r32738 r36712 22 22 23 23 #include "config.h" 24 24 25 #if ENABLE(SVG) 26 #include "SVGImageLoader.h" 25 27 26 #include "Attr.h" 27 #include "DocLoader.h" 28 #include "Document.h" 29 28 #include "EventNames.h" 30 29 #include "SVGImageElement.h" 31 #include "SVGLength.h"32 #include "SVGNames.h"33 34 30 #include "RenderImage.h" 35 31 … … 37 33 38 34 SVGImageLoader::SVGImageLoader(SVGImageElement* node) 39 : HTMLImageLoader(node)35 : ImageLoader(node) 40 36 { 41 37 } … … 45 41 } 46 42 47 // FIXME - Refactor most of this code into WebCore::HTMLImageLoader or a shared WebCore::ImageLoader base class48 void SVGImageLoader::updateFromElement()49 {50 SVGImageElement *imageElement = static_cast<SVGImageElement *>(element());51 WebCore::Document* doc = imageElement->ownerDocument();52 53 CachedImage *newImage = 0;54 if (!imageElement->href().isEmpty()) {55 KURL uri = imageElement->baseURI();56 if (!uri.isEmpty())57 uri = KURL(uri, imageElement->href());58 else59 uri = KURL(imageElement->href());60 newImage = doc->docLoader()->requestImage(uri.string());61 }62 63 CachedImage* oldImage = image();64 if (newImage != oldImage) {65 setLoadingImage(newImage);66 if (newImage)67 newImage->addClient(this);68 if (oldImage)69 oldImage->removeClient(this);70 }71 72 if (RenderImage* renderer = static_cast<RenderImage*>(imageElement->renderer()))73 renderer->resetAnimation();74 }75 76 43 void SVGImageLoader::dispatchLoadEvent() 77 44 { 78 45 if (!haveFiredLoadEvent() && image()) { 79 46 setHaveFiredLoadEvent(true); 80 if (image()->errorOccurred()) { 81 // FIXME: We're supposed to put the document in an "error state" per the spec. 82 } else if (static_cast<SVGImageElement*>(element())->externalResourcesRequiredBaseValue()) 83 static_cast<SVGElement*>(element())->sendSVGLoadEventIfPossible(true); 47 48 if (image()->errorOccurred()) 49 element()->dispatchEventForType(EventNames::errorEvent, false, false); 50 else { 51 SVGImageElement* imageElement = static_cast<SVGImageElement*>(element()); 52 if (imageElement->externalResourcesRequiredBaseValue()) 53 imageElement->sendSVGLoadEventIfPossible(true); 54 } 84 55 } 56 } 57 58 String SVGImageLoader::sourceURI(const AtomicString& attr) const 59 { 60 return parseURL(KURL(element()->baseURI(), attr).string()); 85 61 } 86 62 -
trunk/WebCore/svg/SVGImageLoader.h
r28258 r36712 22 22 #ifndef SVGImageLoader_h 23 23 #define SVGImageLoader_h 24 24 25 #if ENABLE(SVG) 25 26 #include "HTMLImageLoader.h" 26 #include "ImageLoader.h" 27 27 28 28 namespace WebCore { … … 30 30 class SVGImageElement; 31 31 32 class SVGImageLoader : public HTMLImageLoader {32 class SVGImageLoader : public ImageLoader { 33 33 public: 34 34 SVGImageLoader(SVGImageElement*); 35 35 virtual ~SVGImageLoader(); 36 37 virtual void updateFromElement(); 36 38 37 virtual void dispatchLoadEvent(); 38 virtual String sourceURI(const AtomicString&) const; 39 39 }; 40 40 … … 43 43 #endif // ENABLE(SVG) 44 44 #endif // SVGImageLoader_h 45 46 // vim:ts=4:noet
Note: See TracChangeset
for help on using the changeset viewer.