Bug 207902 - Lazy load images using base URL at parse time
Summary: Lazy load images using base URL at parse time
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks: 196698
  Show dependency treegraph
 
Reported: 2020-02-18 12:32 PST by Rob Buis
Modified: 2022-08-15 18:29 PDT (History)
10 users (show)

See Also:


Attachments
Patch (5.71 KB, patch)
2020-02-19 03:18 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (6.09 KB, patch)
2020-02-19 11:56 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (6.17 KB, patch)
2020-02-20 05:20 PST, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Buis 2020-02-18 12:32:36 PST
The spec says to use the base url at parse time for request url, ignoring change to base url after that.
https://html.spec.whatwg.org/multipage/images.html#update-the-image-data
Comment 1 Rob Buis 2020-02-19 03:18:05 PST
Created attachment 391150 [details]
Patch
Comment 2 Rob Buis 2020-02-19 11:56:04 PST
Created attachment 391184 [details]
Patch
Comment 3 Darin Adler 2020-02-19 21:31:53 PST
Comment on attachment 391184 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=391184&action=review

> Source/WebCore/loader/ImageLoader.cpp:189
> +        auto uri = document.completeURL(sourceURI(attr));
> +        if (m_lazyImageLoadState == LazyImageLoadState::LoadImmediately)
> +            uri = m_image->url();

Seems a little strange to call this URI.

Seems wasteful to compute the URL, then check m_lazyImageLoadState, then overwrite it. Iā€™d write this:

    URL imageURL = m_lazyImageLoadState == LazyImageLoadState::LoadImmediately
        ? m_image->url() : document.completeURL(sourceURI(attr));

But also, i think this needs  "why" comment. The concept here of "LoadImmediately" and special URL rules seems subtle and a bit tricky.
Comment 4 Rob Buis 2020-02-20 05:20:58 PST
Created attachment 391278 [details]
Patch
Comment 5 WebKit Commit Bot 2020-02-20 06:46:10 PST
Comment on attachment 391278 [details]
Patch

Clearing flags on attachment: 391278

Committed r257054: <https://trac.webkit.org/changeset/257054>
Comment 6 WebKit Commit Bot 2020-02-20 06:46:12 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2020-02-20 06:47:14 PST
<rdar://problem/59627874>
Comment 8 Simon Fraser (smfr) 2022-08-15 18:29:13 PDT
The relevant tests were renamed to:

html/semantics/embedded-content/the-img-element/image-loading-lazy-base-url-2.html
html/semantics/embedded-content/the-img-element/image-loading-lazy-base-url.html