Bug 207902

Summary: Lazy load images using base URL at parse time
Product: WebKit Reporter: Rob Buis <rbuis>
Component: New BugsAssignee: Rob Buis <rbuis>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, beidson, cdumez, commit-queue, darin, dbates, ews-watchlist, japhet, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=237703
Bug Depends on:    
Bug Blocks: 196698    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

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