Implement imagesrcset and imagesizes attributes on link rel=preload
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 20:34:42 +0000 (20:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2019 20:34:42 +0000 (20:34 +0000)
commit25be23008d94a2e4c05fccab1a8931ac0ea2fd11
treeb219378a0fa912251c1231ab35b262300ff81669
parent008ce24d306bd141a9a00a52abd21c581dda61fc
Implement imagesrcset and imagesizes attributes on link rel=preload
https://bugs.webkit.org/show_bug.cgi?id=192950

Patch by Rob Buis <rbuis@igalia.com> on 2019-05-17
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Import relevant tests for this feature.

* web-platform-tests/preload/dynamic-adding-preload-imagesrcset-expected.txt: Added.
* web-platform-tests/preload/dynamic-adding-preload-imagesrcset.html: Added.
* web-platform-tests/preload/link-header-preload-delay-onload-expected.txt: Added.
* web-platform-tests/preload/link-header-preload-delay-onload.html: Added.
* web-platform-tests/preload/link-header-preload-delay-onload.html.headers: Added.
* web-platform-tests/preload/link-header-preload-expected.txt: Added.
* web-platform-tests/preload/link-header-preload-imagesrcset-expected.txt: Added.
* web-platform-tests/preload/link-header-preload-imagesrcset.html: Added.
* web-platform-tests/preload/link-header-preload-imagesrcset.html.headers: Added.
* web-platform-tests/preload/link-header-preload-nonce-expected.txt: Added.
* web-platform-tests/preload/link-header-preload-nonce.html: Added.
* web-platform-tests/preload/link-header-preload-nonce.html.headers: Added.
* web-platform-tests/preload/link-header-preload.html: Added.
* web-platform-tests/preload/link-header-preload.html.headers: Added.
* web-platform-tests/preload/onload-event-expected.txt: Added.
* web-platform-tests/preload/onload-event.html: Added.
* web-platform-tests/preload/preload-csp.sub-expected.txt:
* web-platform-tests/preload/preload-csp.sub.html:
* web-platform-tests/preload/preload-default-csp.sub-expected.txt:
* web-platform-tests/preload/preload-default-csp.sub.html:
* web-platform-tests/preload/preload-with-type-expected.txt: Added.
* web-platform-tests/preload/preload-with-type.html: Added.
* web-platform-tests/preload/resources/A4.ogv: Added.
* web-platform-tests/preload/resources/A4.ogv.sub.headers: Added.
* web-platform-tests/preload/resources/cross-origin-module.py: Added.
(main):
* web-platform-tests/preload/resources/dummy-preloads-subresource.css: Added.
* web-platform-tests/preload/resources/dummy-preloads-subresource.css.sub.headers: Added.
* web-platform-tests/preload/resources/empty.html: Added.
* web-platform-tests/preload/resources/empty.html.sub.headers: Added.
* web-platform-tests/preload/resources/foo.vtt.sub.headers: Added.
* web-platform-tests/preload/resources/module1.js: Added.
* web-platform-tests/preload/resources/module2.js: Added.
* web-platform-tests/preload/resources/preload_helper.js:
(verifyNumberOfResourceTimingEntries):
(numberOfResourceTimingEntries):
(verifyLoadedAndNoDoubleDownload):
* web-platform-tests/preload/single-download-preload-expected.txt:
* web-platform-tests/preload/single-download-preload.html:

Source/WebCore:

Implement imagesrcset and imagesizes attributes for both Link header
and link element.

Tests: imported/w3c/web-platform-tests/preload/dynamic-adding-preload-imagesrcset.html
       imported/w3c/web-platform-tests/preload/link-header-preload-delay-onload.html
       imported/w3c/web-platform-tests/preload/link-header-preload-imagesrcset.html
       imported/w3c/web-platform-tests/preload/link-header-preload-nonce.html
       imported/w3c/web-platform-tests/preload/link-header-preload.html
       imported/w3c/web-platform-tests/preload/onload-event.html
       imported/w3c/web-platform-tests/preload/preload-with-type.html

* html/HTMLAttributeNames.in:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* html/HTMLLinkElement.idl:
* loader/LinkHeader.cpp:
(WebCore::paramterNameFromString):
(WebCore::LinkHeader::setValue):
(WebCore::LinkHeader::LinkHeader):
* loader/LinkHeader.h:
(WebCore::LinkHeader::imageSrcSet const):
(WebCore::LinkHeader::imageSizes const):
(WebCore::LinkHeader::isViewportDependent const):
* loader/LinkLoader.cpp:
(WebCore::LinkLoader::loadLinksFromHeader):
(WebCore::LinkLoader::preloadIfNeeded):
(WebCore::LinkLoader::loadLink):
* loader/LinkLoader.h:

LayoutTests:

Write special expectation for link-header-preload-imagesrcset.html because test runner
uses different dimensions on iOS.

* platform/ios-simulator-12-wk2/imported/w3c/web-platform-tests/preload/dynamic-adding-preload-imagesrcset-expected.txt: Added.
* platform/ios-simulator-12-wk2/imported/w3c/web-platform-tests/preload/link-header-preload-imagesrcset-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245475 268f45cc-cd09-0410-ab3c-d52691b4dbfc
45 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/preload/dynamic-adding-preload-imagesrcset-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/dynamic-adding-preload-imagesrcset.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-delay-onload-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-delay-onload.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-delay-onload.html.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-imagesrcset-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-imagesrcset.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-imagesrcset.html.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-nonce-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-nonce.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload-nonce.html.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/link-header-preload.html.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/onload-event-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/onload-event.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/preload-csp.sub-expected.txt
LayoutTests/imported/w3c/web-platform-tests/preload/preload-csp.sub.html
LayoutTests/imported/w3c/web-platform-tests/preload/preload-default-csp.sub-expected.txt
LayoutTests/imported/w3c/web-platform-tests/preload/preload-default-csp.sub.html
LayoutTests/imported/w3c/web-platform-tests/preload/preload-with-type-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/preload-with-type.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/A4.ogv [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/A4.ogv.sub.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/cross-origin-module.py [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/dummy-preloads-subresource.css [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/dummy-preloads-subresource.css.sub.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/empty.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/empty.html.sub.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/foo.vtt.sub.headers [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/module1.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/module2.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/preload/resources/preload_helper.js
LayoutTests/platform/ios-simulator-12-wk2/imported/w3c/web-platform-tests/preload/dynamic-adding-preload-imagesrcset-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator-12-wk2/imported/w3c/web-platform-tests/preload/link-header-preload-imagesrcset-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAttributeNames.in
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/HTMLLinkElement.idl
Source/WebCore/loader/LinkHeader.cpp
Source/WebCore/loader/LinkHeader.h
Source/WebCore/loader/LinkLoader.cpp
Source/WebCore/loader/LinkLoader.h