Title: [281067] trunk/Source/WebCore
- Revision
- 281067
- Author
- [email protected]
- Date
- 2021-08-15 13:46:16 -0700 (Sun, 15 Aug 2021)
Log Message
[LFC Display] Make Display::ImageBox a CachedImageClient to get image repaint working
https://bugs.webkit.org/show_bug.cgi?id=229125
Reviewed by Anders Carlsson.
Make Display::ImageBox hold a CachedResourceHandle<CachedImage> so it can register
as a client and get notified about image changes, for repainting.
* display/css/DisplayBoxFactory.cpp:
(WebCore::Display::BoxFactory::displayBoxForLayoutBox const):
* display/css/DisplayImageBox.cpp:
(WebCore::Display::ImageBox::ImageBox):
(WebCore::Display::m_cachedImage):
(WebCore::Display::ImageBox::~ImageBox):
(WebCore::Display::ImageBox::image const):
(WebCore::Display::ImageBox::imageChanged):
(WebCore::Display::ImageBox::debugDescription const):
(WebCore::Display::m_image): Deleted.
* display/css/DisplayImageBox.h:
(WebCore::Display::ImageBox::image const): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (281066 => 281067)
--- trunk/Source/WebCore/ChangeLog 2021-08-15 20:05:28 UTC (rev 281066)
+++ trunk/Source/WebCore/ChangeLog 2021-08-15 20:46:16 UTC (rev 281067)
@@ -1,3 +1,26 @@
+2021-08-15 Simon Fraser <[email protected]>
+
+ [LFC Display] Make Display::ImageBox a CachedImageClient to get image repaint working
+ https://bugs.webkit.org/show_bug.cgi?id=229125
+
+ Reviewed by Anders Carlsson.
+
+ Make Display::ImageBox hold a CachedResourceHandle<CachedImage> so it can register
+ as a client and get notified about image changes, for repainting.
+
+ * display/css/DisplayBoxFactory.cpp:
+ (WebCore::Display::BoxFactory::displayBoxForLayoutBox const):
+ * display/css/DisplayImageBox.cpp:
+ (WebCore::Display::ImageBox::ImageBox):
+ (WebCore::Display::m_cachedImage):
+ (WebCore::Display::ImageBox::~ImageBox):
+ (WebCore::Display::ImageBox::image const):
+ (WebCore::Display::ImageBox::imageChanged):
+ (WebCore::Display::ImageBox::debugDescription const):
+ (WebCore::Display::m_image): Deleted.
+ * display/css/DisplayImageBox.h:
+ (WebCore::Display::ImageBox::image const): Deleted.
+
2021-08-15 David Kilzer <[email protected]>
Bug 229112: ThreadSanitizer: data races of WTF::String in WebResourceLoadStatisticsStore
Modified: trunk/Source/WebCore/display/css/DisplayBoxFactory.cpp (281066 => 281067)
--- trunk/Source/WebCore/display/css/DisplayBoxFactory.cpp 2021-08-15 20:05:28 UTC (rev 281066)
+++ trunk/Source/WebCore/display/css/DisplayBoxFactory.cpp 2021-08-15 20:46:16 UTC (rev 281067)
@@ -122,11 +122,8 @@
if (is<Layout::ReplacedBox>(layoutBox)) {
// FIXME: Don't assume it's an image.
- RefPtr<Image> image;
- if (auto* cachedImage = downcast<Layout::ReplacedBox>(layoutBox).cachedImage())
- image = cachedImage->image();
-
- auto imageBox = makeUnique<ImageBox>(m_treeBuilder.tree(), pixelSnappedBorderBoxRect, WTFMove(style), WTFMove(image));
+ CachedResourceHandle<CachedImage> cachedImageHandle = downcast<Layout::ReplacedBox>(layoutBox).cachedImage();
+ auto imageBox = makeUnique<ImageBox>(m_treeBuilder.tree(), pixelSnappedBorderBoxRect, WTFMove(style), WTFMove(cachedImageHandle));
setupBoxModelBox(*imageBox, layoutBox, geometry, containingBlockContext, styleForBackground);
return imageBox;
}
Modified: trunk/Source/WebCore/display/css/DisplayImageBox.cpp (281066 => 281067)
--- trunk/Source/WebCore/display/css/DisplayImageBox.cpp 2021-08-15 20:05:28 UTC (rev 281066)
+++ trunk/Source/WebCore/display/css/DisplayImageBox.cpp 2021-08-15 20:46:16 UTC (rev 281067)
@@ -28,7 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "Image.h"
+#include "CachedImage.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
@@ -36,12 +36,30 @@
DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBox);
-ImageBox::ImageBox(Tree& tree, UnadjustedAbsoluteFloatRect borderBox, Style&& displayStyle, RefPtr<Image>&& image)
+ImageBox::ImageBox(Tree& tree, UnadjustedAbsoluteFloatRect borderBox, Style&& displayStyle, CachedResourceHandle<CachedImage>&& image)
: ReplacedBox(tree, borderBox, WTFMove(displayStyle), { TypeFlags::ImageBox })
- , m_image(WTFMove(image))
+ , m_cachedImage(WTFMove(image))
{
+ if (m_cachedImage)
+ m_cachedImage->addClient(*this);
}
+ImageBox::~ImageBox()
+{
+ if (m_cachedImage)
+ m_cachedImage->removeClient(*this);
+}
+
+Image* ImageBox::image() const
+{
+ return m_cachedImage ? m_cachedImage->image() : nullptr;
+}
+
+void ImageBox::imageChanged(CachedImage*, const IntRect*)
+{
+ setNeedsDisplay(); // FIXME: Compute correct rect.
+}
+
const char* ImageBox::boxName() const
{
return "image box";
@@ -50,7 +68,7 @@
String ImageBox::debugDescription() const
{
TextStream stream;
- stream << boxName() << " " << absoluteBorderBoxRect() << " (" << this << ") replaced content rect: " << replacedContentRect() << " image: " << m_image.get();
+ stream << boxName() << " " << absoluteBorderBoxRect() << " (" << this << ") replaced content rect: " << replacedContentRect() << " image: " << m_cachedImage.get();
return stream.release();
}
Modified: trunk/Source/WebCore/display/css/DisplayImageBox.h (281066 => 281067)
--- trunk/Source/WebCore/display/css/DisplayImageBox.h 2021-08-15 20:05:28 UTC (rev 281066)
+++ trunk/Source/WebCore/display/css/DisplayImageBox.h 2021-08-15 20:46:16 UTC (rev 281067)
@@ -27,29 +27,35 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "CachedImageClient.h"
+#include "CachedResourceHandle.h"
#include "DisplayReplacedBox.h"
namespace WebCore {
-class Image;
-
namespace Display {
class Style;
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBox);
-class ImageBox : public ReplacedBox {
+
+class ImageBox : public ReplacedBox, public CachedImageClient {
WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(ImageBox);
public:
- ImageBox(Tree&, UnadjustedAbsoluteFloatRect borderBox, Style&&, RefPtr<Image>&&);
+ ImageBox(Tree&, UnadjustedAbsoluteFloatRect borderBox, Style&&, CachedResourceHandle<CachedImage>&&);
+ ~ImageBox();
- Image* image() const { return m_image.get(); }
+ Image* image() const;
private:
+
+ // CachedImageClient
+ void imageChanged(CachedImage*, const IntRect*) final;
+
const char* boxName() const final;
String debugDescription() const final;
- RefPtr<Image> m_image;
+ CachedResourceHandle<CachedImage> m_cachedImage;
};
} // namespace Display
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes