Title: [273861] branches/safari-612.1.5-branch
Revision
273861
Author
alanc...@apple.com
Date
2021-03-03 17:00:45 -0800 (Wed, 03 Mar 2021)

Log Message

Cherry-pick r273764. rdar://problem/75009398

    The layout of SVGImage should force the layout for its clients
    https://bugs.webkit.org/show_bug.cgi?id=221253
    <rdar://problem/74138641>

    Reviewed by Simon Fraser.

    Source/WebCore:

    Unlike the bitmap image, the intrinsic size of SVGImage can only be known
    after running its layout. Because SVGImage can be used by multiple clients,
    CachedImage maintains an SVGImageCache which maps a client to an
    SVGImageForContainer. SVGImageForContainer is just a wrapper of SVGImage
    with the intrinsic size of the client. Because we may set an entry for
    the renderer in SVGImageCache early before running a layout for SVGImage
    and because the renderer intrinsic size depends on the intrinsic size of
    SVGImage, SVGImageForContainer may have an empty intrinsic size.

    So basically it is a race condition: knowing the intrinsic size of the
    SVGImage client depends on the intrinsic size of SVGImage itself. And the
    intrinsic size of SVGImageForContainer depends on the intrinsic size of
    the client. This may lead to not rendering the clients because their sizes
    are empty. To fix this issue we need to force calculateBackgroundImageGeometry()
    once we finish the layout of the SVGImage which happens after receiving all
    its data and calling RenderBox::imageChanged().

    Test: fast/css/background-svg-image-loading.html

    * loader/cache/CachedImage.cpp:
    (WebCore::CachedImage::finishLoading):
    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::repaintLayerRectsForImage):

    LayoutTests:

    * fast/css/background-svg-image-loading-expected.html: Added.
    * fast/css/background-svg-image-loading.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273764 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-612.1.5-branch/LayoutTests/ChangeLog (273860 => 273861)


--- branches/safari-612.1.5-branch/LayoutTests/ChangeLog	2021-03-04 01:00:42 UTC (rev 273860)
+++ branches/safari-612.1.5-branch/LayoutTests/ChangeLog	2021-03-04 01:00:45 UTC (rev 273861)
@@ -1,3 +1,58 @@
+2021-03-03  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r273764. rdar://problem/75009398
+
+    The layout of SVGImage should force the layout for its clients
+    https://bugs.webkit.org/show_bug.cgi?id=221253
+    <rdar://problem/74138641>
+    
+    Reviewed by Simon Fraser.
+    
+    Source/WebCore:
+    
+    Unlike the bitmap image, the intrinsic size of SVGImage can only be known
+    after running its layout. Because SVGImage can be used by multiple clients,
+    CachedImage maintains an SVGImageCache which maps a client to an
+    SVGImageForContainer. SVGImageForContainer is just a wrapper of SVGImage
+    with the intrinsic size of the client. Because we may set an entry for
+    the renderer in SVGImageCache early before running a layout for SVGImage
+    and because the renderer intrinsic size depends on the intrinsic size of
+    SVGImage, SVGImageForContainer may have an empty intrinsic size.
+    
+    So basically it is a race condition: knowing the intrinsic size of the
+    SVGImage client depends on the intrinsic size of SVGImage itself. And the
+    intrinsic size of SVGImageForContainer depends on the intrinsic size of
+    the client. This may lead to not rendering the clients because their sizes
+    are empty. To fix this issue we need to force calculateBackgroundImageGeometry()
+    once we finish the layout of the SVGImage which happens after receiving all
+    its data and calling RenderBox::imageChanged().
+    
+    Test: fast/css/background-svg-image-loading.html
+    
+    * loader/cache/CachedImage.cpp:
+    (WebCore::CachedImage::finishLoading):
+    * rendering/RenderBox.cpp:
+    (WebCore::RenderBox::repaintLayerRectsForImage):
+    
+    LayoutTests:
+    
+    * fast/css/background-svg-image-loading-expected.html: Added.
+    * fast/css/background-svg-image-loading.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273764 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-03-02  Said Abou-Hallawa  <s...@apple.com>
+
+            The layout of SVGImage should force the layout for its clients
+            https://bugs.webkit.org/show_bug.cgi?id=221253
+            <rdar://problem/74138641>
+
+            Reviewed by Simon Fraser.
+
+            * fast/css/background-svg-image-loading-expected.html: Added.
+            * fast/css/background-svg-image-loading.html: Added.
+
 2021-03-02  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r273656. rdar://problem/74952887

Added: branches/safari-612.1.5-branch/LayoutTests/fast/css/background-svg-image-loading-expected.html (0 => 273861)


--- branches/safari-612.1.5-branch/LayoutTests/fast/css/background-svg-image-loading-expected.html	                        (rev 0)
+++ branches/safari-612.1.5-branch/LayoutTests/fast/css/background-svg-image-loading-expected.html	2021-03-04 01:00:45 UTC (rev 273861)
@@ -0,0 +1,18 @@
+<style>
+    .container {
+        width: 900px;
+    }
+    .line {
+        background-color: green;
+        background-size: 24px;
+    }
+</style>
+<body>
+    <p>PASS when all the lines below have visible background images.<p>
+    <div class="container">
+        <div class="line">should have a visible background image</div>
+        <div class="line">should have a visible background image</div>
+        <div class="line">should have a visible background image</div>
+        <div class="line">should have a visible background image</div>
+    </div>
+<body>

Added: branches/safari-612.1.5-branch/LayoutTests/fast/css/background-svg-image-loading.html (0 => 273861)


--- branches/safari-612.1.5-branch/LayoutTests/fast/css/background-svg-image-loading.html	                        (rev 0)
+++ branches/safari-612.1.5-branch/LayoutTests/fast/css/background-svg-image-loading.html	2021-03-04 01:00:45 UTC (rev 273861)
@@ -0,0 +1,21 @@
+<style>
+    .container {
+        width: 900px;
+    }
+    .line {
+        background-image: url('data:image/svg+xml;utf8,\
+            <svg xmlns="http://www.w3.org/2000/svg" height="24" width="24">\
+                <rect width="100%" height="100%" fill="green"/>\
+            </svg>');
+        background-size: 24px;
+    }
+</style>
+<body>
+    <p>PASS when all the lines below have visible background images.<p>
+    <div class="container">
+        <div class="line">should have a visible background image</div>
+        <div class="line">should have a visible background image</div>
+        <div class="line">should have a visible background image</div>
+        <div class="line">should have a visible background image</div>
+    </div>
+<body>

Modified: branches/safari-612.1.5-branch/Source/WebCore/ChangeLog (273860 => 273861)


--- branches/safari-612.1.5-branch/Source/WebCore/ChangeLog	2021-03-04 01:00:42 UTC (rev 273860)
+++ branches/safari-612.1.5-branch/Source/WebCore/ChangeLog	2021-03-04 01:00:45 UTC (rev 273861)
@@ -1,3 +1,79 @@
+2021-03-03  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r273764. rdar://problem/75009398
+
+    The layout of SVGImage should force the layout for its clients
+    https://bugs.webkit.org/show_bug.cgi?id=221253
+    <rdar://problem/74138641>
+    
+    Reviewed by Simon Fraser.
+    
+    Source/WebCore:
+    
+    Unlike the bitmap image, the intrinsic size of SVGImage can only be known
+    after running its layout. Because SVGImage can be used by multiple clients,
+    CachedImage maintains an SVGImageCache which maps a client to an
+    SVGImageForContainer. SVGImageForContainer is just a wrapper of SVGImage
+    with the intrinsic size of the client. Because we may set an entry for
+    the renderer in SVGImageCache early before running a layout for SVGImage
+    and because the renderer intrinsic size depends on the intrinsic size of
+    SVGImage, SVGImageForContainer may have an empty intrinsic size.
+    
+    So basically it is a race condition: knowing the intrinsic size of the
+    SVGImage client depends on the intrinsic size of SVGImage itself. And the
+    intrinsic size of SVGImageForContainer depends on the intrinsic size of
+    the client. This may lead to not rendering the clients because their sizes
+    are empty. To fix this issue we need to force calculateBackgroundImageGeometry()
+    once we finish the layout of the SVGImage which happens after receiving all
+    its data and calling RenderBox::imageChanged().
+    
+    Test: fast/css/background-svg-image-loading.html
+    
+    * loader/cache/CachedImage.cpp:
+    (WebCore::CachedImage::finishLoading):
+    * rendering/RenderBox.cpp:
+    (WebCore::RenderBox::repaintLayerRectsForImage):
+    
+    LayoutTests:
+    
+    * fast/css/background-svg-image-loading-expected.html: Added.
+    * fast/css/background-svg-image-loading.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273764 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-03-02  Said Abou-Hallawa  <s...@apple.com>
+
+            The layout of SVGImage should force the layout for its clients
+            https://bugs.webkit.org/show_bug.cgi?id=221253
+            <rdar://problem/74138641>
+
+            Reviewed by Simon Fraser.
+
+            Unlike the bitmap image, the intrinsic size of SVGImage can only be known
+            after running its layout. Because SVGImage can be used by multiple clients,
+            CachedImage maintains an SVGImageCache which maps a client to an
+            SVGImageForContainer. SVGImageForContainer is just a wrapper of SVGImage
+            with the intrinsic size of the client. Because we may set an entry for
+            the renderer in SVGImageCache early before running a layout for SVGImage
+            and because the renderer intrinsic size depends on the intrinsic size of
+            SVGImage, SVGImageForContainer may have an empty intrinsic size.
+
+            So basically it is a race condition: knowing the intrinsic size of the
+            SVGImage client depends on the intrinsic size of SVGImage itself. And the
+            intrinsic size of SVGImageForContainer depends on the intrinsic size of
+            the client. This may lead to not rendering the clients because their sizes
+            are empty. To fix this issue we need to force calculateBackgroundImageGeometry()
+            once we finish the layout of the SVGImage which happens after receiving all
+            its data and calling RenderBox::imageChanged().
+
+            Test: fast/css/background-svg-image-loading.html
+
+            * loader/cache/CachedImage.cpp:
+            (WebCore::CachedImage::finishLoading):
+            * rendering/RenderBox.cpp:
+            (WebCore::RenderBox::repaintLayerRectsForImage):
+
 2021-03-02  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r273721. rdar://problem/74952690

Modified: branches/safari-612.1.5-branch/Source/WebCore/loader/cache/CachedImage.cpp (273860 => 273861)


--- branches/safari-612.1.5-branch/Source/WebCore/loader/cache/CachedImage.cpp	2021-03-04 01:00:42 UTC (rev 273860)
+++ branches/safari-612.1.5-branch/Source/WebCore/loader/cache/CachedImage.cpp	2021-03-04 01:00:45 UTC (rev 273861)
@@ -584,6 +584,7 @@
         return;
     }
 
+    setLoading(false);
     notifyObservers();
     CachedResource::finishLoading(data, metrics);
 }

Modified: branches/safari-612.1.5-branch/Source/WebCore/rendering/RenderBox.cpp (273860 => 273861)


--- branches/safari-612.1.5-branch/Source/WebCore/rendering/RenderBox.cpp	2021-03-04 01:00:42 UTC (rev 273860)
+++ branches/safari-612.1.5-branch/Source/WebCore/rendering/RenderBox.cpp	2021-03-04 01:00:45 UTC (rev 273861)
@@ -1850,7 +1850,7 @@
     RenderBox* layerRenderer = nullptr;
 
     for (auto* layer = &layers; layer; layer = layer->next()) {
-        if (layer->image() && image == layer->image()->data() && layer->image()->canRender(this, style().effectiveZoom())) {
+        if (layer->image() && image == layer->image()->data() && (layer->image()->isLoaded() || layer->image()->canRender(this, style().effectiveZoom()))) {
             // Now that we know this image is being used, compute the renderer and the rect if we haven't already.
             bool drawingRootBackground = drawingBackground && (isDocumentElementRenderer() || (isBody() && !document().documentElement()->renderer()->hasBackground()));
             if (!layerRenderer) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to