Changeset 179340 in webkit
- Timestamp:
- Jan 29, 2015, 3:32:53 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
html/HTMLImageLoader.cpp (modified) (1 diff)
-
html/HTMLImageLoader.h (modified) (1 diff)
-
loader/ImageLoader.cpp (modified) (3 diffs)
-
loader/ImageLoader.h (modified) (1 diff)
-
loader/cache/CachedImage.cpp (modified) (1 diff)
-
loader/cache/CachedImageClient.h (modified) (1 diff)
-
rendering/RenderImage.cpp (modified) (1 diff)
-
rendering/RenderImage.h (modified) (1 diff)
-
svg/SVGFEImageElement.cpp (modified) (1 diff)
-
svg/SVGFEImageElement.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r179335 r179340 1 2015-01-29 Julien Isorce <j.isorce@samsung.com> 2 3 CachedImage: ensure clients overrides imageChanged instead of notifyFinished 4 https://bugs.webkit.org/show_bug.cgi?id=140722 5 6 Reviewed by Tim Horton. 7 8 imageChanged is called whenever a frame of an image changes 9 because we got more data from the network. 10 11 notifyFinished was called when the image was entirely loaded. 12 13 The problem was that some clients were implementing only 14 imageChanged (ex: RenderBox), some only notifyFinished and 15 some both (ex: RenderImage) which made the situation difficult 16 to understand and to maintain. 17 18 For example when the image finished loading, both imageChanged 19 and notifyFinished were called with the difference that for the 20 first one isLoaded() returned false. 21 It could result in functions being called twice in a row, 22 ex: contentChanged(ImageChanged). 23 24 So this patch tries to simplify the situation by marking 25 CachedImageClient::notifyFinished final in order to prevent 26 clients from implementing it. 27 Indeed this patch ensure that CachedImage clients implement 28 and only implement imageChanged function. 29 30 Also Clients can now differentiate intermediate and end 31 calls by checking isLoaded() in imageChanged. 32 33 * html/HTMLImageLoader.cpp: 34 (WebCore::HTMLImageLoader::imageChanged): Added instead 35 of notifyFinished. 36 (WebCore::HTMLImageLoader::notifyFinished): Deleted. 37 * html/HTMLImageLoader.h: 38 39 * loader/ImageLoader.cpp: 40 (WebCore::ImageLoader::imageChanged): Added instead 41 of notifyFinished. 42 (WebCore::ImageLoader::notifyFinished): Deleted. 43 * loader/ImageLoader.h: 44 45 * loader/cache/CachedImage.cpp: 46 (WebCore::CachedImage::finishLoading): Explicilty mark image as 47 loaded and before notifying observers. So that it avoids to call 48 notifyFinished (from CachedResource::finishLoading). 49 50 * loader/cache/CachedImageClient.h: 51 Make CachedImageClient::notifyFinished final to make sure 52 sub classes implement imageChanged instead. 53 54 * rendering/RenderImage.cpp: 55 (WebCore::RenderImage::notifyFinished): Deleted. 56 ImageChanged already exists and is more clever than notifyFinished. 57 Indeed invalidateBackgroundObscurationStatus() will be called by 58 RenderReplaced::layout() upon call to setNeedsLayout() in 59 RenderImage::imageDimensionsChanged. 60 Also contentChanged(ImageChanged) is now called only when necessary. 61 * rendering/RenderImage.h: 62 63 * svg/SVGFEImageElement.cpp: 64 (WebCore::SVGFEImageElement::imageChanged): Added instead 65 of notifyFinished. 66 (WebCore::SVGFEImageElement::notifyFinished): Deleted. 67 * svg/SVGFEImageElement.h: 68 1 69 2015-01-28 Said Abou-Hallawa <sabouhallawa@apple.com> 2 70 -
trunk/Source/WebCore/html/HTMLImageLoader.cpp
r175527 r179340 73 73 } 74 74 75 void HTMLImageLoader:: notifyFinished(CachedResource*)75 void HTMLImageLoader::imageChanged(CachedImage* cachedImage, const IntRect*) 76 76 { 77 CachedImage* cachedImage = image(); 77 ASSERT(cachedImage == image().get()); 78 79 if (!cachedImage->isLoaded()) 80 return; 78 81 79 82 Ref<Element> protect(element()); 80 ImageLoader:: notifyFinished(cachedImage);83 ImageLoader::imageChanged(cachedImage); 81 84 82 85 bool loadError = cachedImage->errorOccurred() || cachedImage->response().httpStatusCode() >= 400; -
trunk/Source/WebCore/html/HTMLImageLoader.h
r165676 r179340 36 36 virtual String sourceURI(const AtomicString&) const override; 37 37 38 virtual void notifyFinished(CachedResource*) override;38 virtual void imageChanged(CachedImage*, const IntRect* = nullptr) override; 39 39 }; 40 40 -
trunk/Source/WebCore/loader/ImageLoader.cpp
r179242 r179340 273 273 } 274 274 275 void ImageLoader:: notifyFinished(CachedResource* resource)275 void ImageLoader::imageChanged(CachedImage* cachedImage, const IntRect*) 276 276 { 277 277 ASSERT(m_failedLoadURL.isEmpty()); 278 ASSERT(resource == m_image.get()); 278 ASSERT(cachedImage == m_image.get()); 279 280 if (!cachedImage->isLoaded()) 281 return; 279 282 280 283 m_imageComplete = true; … … 287 290 if (element().fastHasAttribute(HTMLNames::crossoriginAttr) 288 291 && !element().document().securityOrigin()->canRequest(image()->response().url()) 289 && ! resource->passesAccessControlCheck(element().document().securityOrigin())) {292 && !cachedImage->passesAccessControlCheck(element().document().securityOrigin())) { 290 293 291 294 setImageWithoutConsideringPendingLoadEvent(0); … … 305 308 } 306 309 307 if ( resource->wasCanceled()) {310 if (cachedImage->wasCanceled()) { 308 311 m_hasPendingLoadEvent = false; 309 312 // Only consider updating the protection ref-count of the Element immediately before returning -
trunk/Source/WebCore/loader/ImageLoader.h
r176459 r179340 74 74 protected: 75 75 explicit ImageLoader(Element&); 76 virtual void notifyFinished(CachedResource*) override;76 virtual void imageChanged(CachedImage*, const IntRect* = nullptr) override; 77 77 78 78 private: -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r179242 r179340 427 427 } 428 428 429 if (m_image) 430 setEncodedSize(m_image->data() ? m_image->data()->size() : 0); 431 432 setLoading(false); 429 433 notifyObservers(); 430 if (m_image)431 setEncodedSize(m_image->data() ? m_image->data()->size() : 0);432 CachedResource::finishLoading(data);433 434 } 434 435 -
trunk/Source/WebCore/loader/cache/CachedImageClient.h
r163928 r179340 39 39 // Called whenever a frame of an image changes because we got more data from the network. 40 40 // If not null, the IntRect is the changed rect of the image. 41 virtual void imageChanged(CachedImage*, const IntRect* = 0) { }41 virtual void imageChanged(CachedImage*, const IntRect* = nullptr) { } 42 42 43 43 // Called when GIF animation progresses. 44 44 virtual void newImageAnimationFrameAvailable(CachedImage& image) { imageChanged(&image); } 45 46 // Use imageChanged instead. 47 virtual void notifyFinished(CachedResource*) override final { } 45 48 }; 46 49 -
trunk/Source/WebCore/rendering/RenderImage.cpp
r178510 r179340 366 366 } 367 367 368 void RenderImage::notifyFinished(CachedResource* newImage)369 {370 if (documentBeingDestroyed())371 return;372 373 invalidateBackgroundObscurationStatus();374 375 if (newImage == imageResource().cachedImage()) {376 // tell any potential compositing layers377 // that the image is done and they can reference it directly.378 contentChanged(ImageChanged);379 }380 }381 382 368 void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 383 369 { -
trunk/Source/WebCore/rendering/RenderImage.h
r177259 r179340 100 100 virtual LayoutUnit minimumReplacedHeight() const override; 101 101 102 virtual void notifyFinished(CachedResource*) override final;103 102 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override final; 104 103 -
trunk/Source/WebCore/svg/SVGFEImageElement.cpp
r179242 r179340 192 192 } 193 193 194 void SVGFEImageElement::notifyFinished(CachedResource*) 195 { 194 void SVGFEImageElement::imageChanged(CachedImage* cachedImage, const IntRect*) 195 { 196 if (!cachedImage || !cachedImage->isLoaded()) 197 return; 198 196 199 if (!inDocument()) 197 200 return; -
trunk/Source/WebCore/svg/SVGFEImageElement.h
r178048 r179340 52 52 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; 53 53 virtual void svgAttributeChanged(const QualifiedName&) override; 54 virtual void notifyFinished(CachedResource*) override;54 virtual void imageChanged(CachedImage*, const IntRect* = nullptr) override; 55 55 56 56 virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const override;
Note:
See TracChangeset
for help on using the changeset viewer.