⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 273764 in webkit


Ignore:
Timestamp:
Mar 2, 2021, 3:22:20 PM (6 years ago)
Author:
Said Abou-Hallawa
Message:

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.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r273761 r273764  
     12021-03-02  Said Abou-Hallawa  <said@apple.com>
     2
     3        The layout of SVGImage should force the layout for its clients
     4        https://bugs.webkit.org/show_bug.cgi?id=221253
     5        <rdar://problem/74138641>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * fast/css/background-svg-image-loading-expected.html: Added.
     10        * fast/css/background-svg-image-loading.html: Added.
     11
    1122021-03-02  Lauro Moura  <lmoura@igalia.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r273758 r273764  
     12021-03-02  Said Abou-Hallawa  <said@apple.com>
     2
     3        The layout of SVGImage should force the layout for its clients
     4        https://bugs.webkit.org/show_bug.cgi?id=221253
     5        <rdar://problem/74138641>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Unlike the bitmap image, the intrinsic size of SVGImage can only be known
     10        after running its layout. Because SVGImage can be used by multiple clients,
     11        CachedImage maintains an SVGImageCache which maps a client to an
     12        SVGImageForContainer. SVGImageForContainer is just a wrapper of SVGImage
     13        with the intrinsic size of the client. Because we may set an entry for
     14        the renderer in SVGImageCache early before running a layout for SVGImage
     15        and because the renderer intrinsic size depends on the intrinsic size of
     16        SVGImage, SVGImageForContainer may have an empty intrinsic size.
     17
     18        So basically it is a race condition: knowing the intrinsic size of the
     19        SVGImage client depends on the intrinsic size of SVGImage itself. And the
     20        intrinsic size of SVGImageForContainer depends on the intrinsic size of
     21        the client. This may lead to not rendering the clients because their sizes
     22        are empty. To fix this issue we need to force calculateBackgroundImageGeometry()
     23        once we finish the layout of the SVGImage which happens after receiving all
     24        its data and calling RenderBox::imageChanged().
     25
     26        Test: fast/css/background-svg-image-loading.html
     27
     28        * loader/cache/CachedImage.cpp:
     29        (WebCore::CachedImage::finishLoading):
     30        * rendering/RenderBox.cpp:
     31        (WebCore::RenderBox::repaintLayerRectsForImage):
     32
    1332021-03-02  Simon Fraser  <simon.fraser@apple.com>
    234
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r271638 r273764  
    585585    }
    586586
     587    setLoading(false);
    587588    notifyObservers();
    588589    CachedResource::finishLoading(data, metrics);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r273753 r273764  
    18511851
    18521852    for (auto* layer = &layers; layer; layer = layer->next()) {
    1853         if (layer->image() && image == layer->image()->data() && layer->image()->canRender(this, style().effectiveZoom())) {
     1853        if (layer->image() && image == layer->image()->data() && (layer->image()->isLoaded() || layer->image()->canRender(this, style().effectiveZoom()))) {
    18541854            // Now that we know this image is being used, compute the renderer and the rect if we haven't already.
    18551855            bool drawingRootBackground = drawingBackground && (isDocumentElementRenderer() || (isBody() && !document().documentElement()->renderer()->hasBackground()));
Note: See TracChangeset for help on using the changeset viewer.