|
| 1 | +2017-07-30 Said Abou-Hallawa <sabouhallawa@apple.com> |
| 2 | + |
| 3 | + RenderImageResourceStyleImage::image() should return the nullImage() if the image is not available |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=174874 |
| 5 | + <rdar://problem/33530130> |
| 6 | + |
| 7 | + Reviewed by Darin Adler. |
| 8 | + |
| 9 | + If an <img> element has image content data for a none cached image, e.g. |
| 10 | + -webkit-named-image, RenderImageResourceStyleImage will be created and |
| 11 | + attached to the RenderImage. RenderImageResourceStyleImage::m_cachedImage |
| 12 | + will be set to null because the m_styleImage->isCachedImage() is false in |
| 13 | + this case. When ImageLoader finishes loading the url of the src attribute, |
| 14 | + RenderImageResource::setCachedImage() will be called to set m_cachedImage. |
| 15 | + |
| 16 | + A crash will happen when the RenderImage is destroyed. Destroying the |
| 17 | + RenderImage calls RenderImageResourceStyleImage::shutdown() which checks |
| 18 | + m_cachedImage and finds it not null, so it calls RenderImageResourceStyleImage::image() |
| 19 | + which ends up calling CSSNamedImageValue::image() which returns a null pointer |
| 20 | + because the size is empty. RenderImageResourceStyleImage::shutdown() calls |
| 21 | + image()->stopAnimation() without checking the return value of image(). |
| 22 | + |
| 23 | + Like the base class virtual method RenderImageResource::image(), |
| 24 | + RenderImageResourceStyleImage::image() should return the nullImage() if |
| 25 | + the image is not available. |
| 26 | + |
| 27 | + Test: fast/images/image-element-image-content-data.html |
| 28 | + |
| 29 | + * css/CSSCrossfadeValue.cpp: |
| 30 | + * css/CSSFilterImageValue.cpp: |
| 31 | + * page/EventHandler.cpp: |
| 32 | + * page/PageSerializer.cpp: |
| 33 | + * rendering/RenderElement.cpp: |
| 34 | + * rendering/RenderImageResource.cpp: |
| 35 | + * rendering/RenderImageResourceStyleImage.cpp: |
| 36 | + (WebCore::RenderImageResourceStyleImage::initialize): |
| 37 | + |
| 38 | + (WebCore::RenderImageResourceStyleImage::shutdown): Revert back the changes |
| 39 | + of r208511 in this function. Add a call to image()->stopAnimation() without |
| 40 | + checking the return of image() since it will return the nullImage() if |
| 41 | + the image not available. There is no need to check m_cachedImage before |
| 42 | + calling image() because image() does not check or access m_cachedImage. |
| 43 | + |
| 44 | + (WebCore::RenderImageResourceStyleImage::image): The base class method |
| 45 | + RenderImageResource::image() returns the nullImage() if the image not |
| 46 | + available. This is because CachedImage::imageForRenderer() returns |
| 47 | + the nullImage() if the image is not available; see CachedImage.h. We should |
| 48 | + do the same for the derived class for consistency. |
| 49 | + |
| 50 | + * rendering/style/ContentData.cpp: |
| 51 | + * rendering/style/StyleCachedImage.cpp: |
| 52 | + * style/StylePendingResources.cpp: |
| 53 | + |
1 | 54 | 2017-07-29 Filip Pizlo <fpizlo@apple.com> |
2 | 55 |
|
3 | 56 | Unreviewed, rollout r220044 because it set the bots on fire. |
|
0 commit comments