haikuwebkit/LayoutTests/resources/srcset-helper.js

34 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

fast/hidpi/image-srcset-change-dynamically-from-js-2x.html is flaky https://bugs.webkit.org/show_bug.cgi?id=140649 fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html is failing on some bots https://bugs.webkit.org/show_bug.cgi?id=134769 Reviewed by Darin Adler. Streamline resources/srcset-helper.js and remove races. * TestExpectations: Unskip fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html. * fast/hidpi/resources/srcset-helper.js: Deleted. We aleady had a copy in /resources, no need for two copies. * resources/srcset-helper.js: This script used to depend on setBackingScaleFactor invoke its callback really fast, which is not guaranteed. Also, it had broken logic that used non-existent window.deviceScaleFactor. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Updated to run the tests from runTest() function, not a load event handler. Where appropriate, changed from testRunner.dumpResourceLoadCallbacks() to testRunner.dumpResourceResponseMIMETypes(), because the latter doesn't unnecessarily include reloaded scripts. It feels somewhat hacky, but the hack is already used in fast/hidpi, and it improves output. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-fraction-1.5x.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size.html: * fast/hidpi/image-srcset-invalid-descriptor.html: * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-nomodifier.html: * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x.html: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier.html: * fast/hidpi/image-srcset-space-prefix-nomodifier.html: * fast/hidpi/image-srcset-space-suffix-nomodifier.html: * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: * fast/hidpi/image-srcset-src-selection-1x-both.html: * fast/hidpi/image-srcset-src-selection-1x.html: * fast/hidpi/image-srcset-src-selection-2x.html: * fast/hidpi/image-srcset-viewport-modifiers.html: Updated to run the tests from runTest() function, not a load event handler. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Updated results for srcset-helper.js now always starting the redirect after the load is fully finished. * svg/css/svg-resource-fragment-identifier-img-src.html: Updated for the unified location of the script. Canonical link: https://commits.webkit.org/158650@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-20 18:26:00 +00:00
window.addEventListener("load", function () {
Add support for HTMLImageElement's sizes attribute https://bugs.webkit.org/show_bug.cgi?id=133620 Reviewed by Dean Jackson. .: Added an ENABLE_PICTURE_SIZES compile flag. * Source/cmake/WebKitFeatures.cmake: * Source/cmakeconfig.h.cmake: Source/JavaScriptCore: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Tests: fast/dom/HTMLImageElement/sizes/image-sizes-1x.html fast/dom/HTMLImageElement/sizes/image-sizes-2x.html fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html http/tests/loading/sizes/preload-image-sizes-2x.html http/tests/loading/sizes/preload-image-sizes.html This patch adds support for HTMLImageElement's sizes attribute and the related srcset extended syntax as defined in http://picture.responsiveimages.org/. This sizes attribute syntax is added to the CSSGrammar and parsed by the CSSParser. The SourceSizeList class is generated by the parser, and used to get the final source size. HTMLImageElement and HTMLPreloadScanner send this value to HTMLSrcsetParser. HTMLSrcsetParser uses this value in order to pick the right resource. * CMakeLists.txt: Added css/SourceSizeList.cpp. * Configurations/FeatureDefines.xcconfig: Added the PICTURE_SIZES flag. * WebCore.vcxproj/WebCore.vcxproj: Added css/SourceSizeList.*. * WebCore.vcxproj/WebCore.vcxproj.filters: Added css/SourceSizeList.*. * WebCore.xcodeproj/project.pbxproj: Added css/SourceSizeList.*. * css/CSSGrammar.y.in: Added 4 grammar rules that define a Media condition, Source size list, Source size length and source size. * css/CSSParser.cpp: (WebCore::CSSParser::parseSizesAttribute): Parse the sizes attribute. (WebCore::CSSParser::detectAtToken): Set the token to SIZESATTR. * css/CSSParser.h: * css/SourceSizeList.cpp: Added. Defined the SourceSize and SourceSizeList classes. (WebCore::SourceSize::match): (WebCore::computeLength): (WebCore::defaultValue): (WebCore::SourceSize::length): (WebCore::SourceSizeList::parseSizesAttribute): (WebCore::SourceSizeList::getEffectiveSize): * css/SourceSizeList.h: Added. (WebCore::SourceSize::SourceSize): (WebCore::SourceSizeList::append): * html/HTMLImageElement.cpp: Integrated sizes attribute parsing and added currentSrc. (WebCore::HTMLImageElement::setBestFitURLAndDPRFromImageCandidate): (WebCore::HTMLImageElement::parseAttribute): (WebCore::HTMLImageElement::currentSrc): * html/HTMLImageElement.h: * html/HTMLImageElement.idl: * html/parser/HTMLDocumentParser.cpp: Added information required for sizes parsing to HTMLPreloadScanner calls. (WebCore::HTMLDocumentParser::pumpTokenizer): (WebCore::HTMLDocumentParser::insert): (WebCore::HTMLDocumentParser::append): (WebCore::HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan): * html/parser/HTMLPreloadScanner.cpp: Integrated sizes attribute parsing. (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): (WebCore::TokenPreloadScanner::scan): (WebCore::HTMLPreloadScanner::scan): * html/parser/HTMLPreloadScanner.h: * html/parser/HTMLSrcsetParser.cpp: Added 'w' descriptor parsing sizes based normalization. (WebCore::parseDescriptors): (WebCore::pickBestImageCandidate): (WebCore::bestFitSourceForImageAttributes): * html/parser/HTMLSrcsetParser.h: Source/WebKit/mac: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit2: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Tools: Added an ENABLE_PICTURE_SIZES compile flag. * Scripts/webkitperl/FeatureList.pm: LayoutTests: These layout tests check that the sizes attribute and the related srcset syntax are well supported, that the right resource is displayed, that the currentSrc attribute is well supported and also that the right resource is preloaded. * fast/dom/HTMLImageElement/resources/currentSrcHelper.js: Added. (fileName): (currentSrcFileName): * fast/dom/HTMLImageElement/resources/image-set-4x.png: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Added. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes-2x.html: Added. * http/tests/loading/sizes/preload-image-sizes-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes.html: Added. Canonical link: https://commits.webkit.org/152413@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-30 04:07:08 +00:00
if (!window.testRunner || !window.sessionStorage)
return;
if (!window.targetScaleFactor)
window.targetScaleFactor = 2;
fast/hidpi/image-srcset-change-dynamically-from-js-2x.html is flaky https://bugs.webkit.org/show_bug.cgi?id=140649 fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html is failing on some bots https://bugs.webkit.org/show_bug.cgi?id=134769 Reviewed by Darin Adler. Streamline resources/srcset-helper.js and remove races. * TestExpectations: Unskip fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html. * fast/hidpi/resources/srcset-helper.js: Deleted. We aleady had a copy in /resources, no need for two copies. * resources/srcset-helper.js: This script used to depend on setBackingScaleFactor invoke its callback really fast, which is not guaranteed. Also, it had broken logic that used non-existent window.deviceScaleFactor. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Updated to run the tests from runTest() function, not a load event handler. Where appropriate, changed from testRunner.dumpResourceLoadCallbacks() to testRunner.dumpResourceResponseMIMETypes(), because the latter doesn't unnecessarily include reloaded scripts. It feels somewhat hacky, but the hack is already used in fast/hidpi, and it improves output. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-fraction-1.5x.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size.html: * fast/hidpi/image-srcset-invalid-descriptor.html: * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-nomodifier.html: * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x.html: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier.html: * fast/hidpi/image-srcset-space-prefix-nomodifier.html: * fast/hidpi/image-srcset-space-suffix-nomodifier.html: * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: * fast/hidpi/image-srcset-src-selection-1x-both.html: * fast/hidpi/image-srcset-src-selection-1x.html: * fast/hidpi/image-srcset-src-selection-2x.html: * fast/hidpi/image-srcset-viewport-modifiers.html: Updated to run the tests from runTest() function, not a load event handler. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Updated results for srcset-helper.js now always starting the redirect after the load is fully finished. * svg/css/svg-resource-fragment-identifier-img-src.html: Updated for the unified location of the script. Canonical link: https://commits.webkit.org/158650@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-20 18:26:00 +00:00
var needsBackingScaleFactorChange = window.targetScaleFactor != 1 && !sessionStorage.pageReloaded;
Add support for HTMLImageElement's sizes attribute https://bugs.webkit.org/show_bug.cgi?id=133620 Reviewed by Dean Jackson. .: Added an ENABLE_PICTURE_SIZES compile flag. * Source/cmake/WebKitFeatures.cmake: * Source/cmakeconfig.h.cmake: Source/JavaScriptCore: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Tests: fast/dom/HTMLImageElement/sizes/image-sizes-1x.html fast/dom/HTMLImageElement/sizes/image-sizes-2x.html fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html http/tests/loading/sizes/preload-image-sizes-2x.html http/tests/loading/sizes/preload-image-sizes.html This patch adds support for HTMLImageElement's sizes attribute and the related srcset extended syntax as defined in http://picture.responsiveimages.org/. This sizes attribute syntax is added to the CSSGrammar and parsed by the CSSParser. The SourceSizeList class is generated by the parser, and used to get the final source size. HTMLImageElement and HTMLPreloadScanner send this value to HTMLSrcsetParser. HTMLSrcsetParser uses this value in order to pick the right resource. * CMakeLists.txt: Added css/SourceSizeList.cpp. * Configurations/FeatureDefines.xcconfig: Added the PICTURE_SIZES flag. * WebCore.vcxproj/WebCore.vcxproj: Added css/SourceSizeList.*. * WebCore.vcxproj/WebCore.vcxproj.filters: Added css/SourceSizeList.*. * WebCore.xcodeproj/project.pbxproj: Added css/SourceSizeList.*. * css/CSSGrammar.y.in: Added 4 grammar rules that define a Media condition, Source size list, Source size length and source size. * css/CSSParser.cpp: (WebCore::CSSParser::parseSizesAttribute): Parse the sizes attribute. (WebCore::CSSParser::detectAtToken): Set the token to SIZESATTR. * css/CSSParser.h: * css/SourceSizeList.cpp: Added. Defined the SourceSize and SourceSizeList classes. (WebCore::SourceSize::match): (WebCore::computeLength): (WebCore::defaultValue): (WebCore::SourceSize::length): (WebCore::SourceSizeList::parseSizesAttribute): (WebCore::SourceSizeList::getEffectiveSize): * css/SourceSizeList.h: Added. (WebCore::SourceSize::SourceSize): (WebCore::SourceSizeList::append): * html/HTMLImageElement.cpp: Integrated sizes attribute parsing and added currentSrc. (WebCore::HTMLImageElement::setBestFitURLAndDPRFromImageCandidate): (WebCore::HTMLImageElement::parseAttribute): (WebCore::HTMLImageElement::currentSrc): * html/HTMLImageElement.h: * html/HTMLImageElement.idl: * html/parser/HTMLDocumentParser.cpp: Added information required for sizes parsing to HTMLPreloadScanner calls. (WebCore::HTMLDocumentParser::pumpTokenizer): (WebCore::HTMLDocumentParser::insert): (WebCore::HTMLDocumentParser::append): (WebCore::HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan): * html/parser/HTMLPreloadScanner.cpp: Integrated sizes attribute parsing. (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): (WebCore::TokenPreloadScanner::scan): (WebCore::HTMLPreloadScanner::scan): * html/parser/HTMLPreloadScanner.h: * html/parser/HTMLSrcsetParser.cpp: Added 'w' descriptor parsing sizes based normalization. (WebCore::parseDescriptors): (WebCore::pickBestImageCandidate): (WebCore::bestFitSourceForImageAttributes): * html/parser/HTMLSrcsetParser.h: Source/WebKit/mac: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit2: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Tools: Added an ENABLE_PICTURE_SIZES compile flag. * Scripts/webkitperl/FeatureList.pm: LayoutTests: These layout tests check that the sizes attribute and the related srcset syntax are well supported, that the right resource is displayed, that the currentSrc attribute is well supported and also that the right resource is preloaded. * fast/dom/HTMLImageElement/resources/currentSrcHelper.js: Added. (fileName): (currentSrcFileName): * fast/dom/HTMLImageElement/resources/image-set-4x.png: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Added. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes-2x.html: Added. * http/tests/loading/sizes/preload-image-sizes-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes.html: Added. Canonical link: https://commits.webkit.org/152413@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-30 04:07:08 +00:00
fast/hidpi/image-srcset-change-dynamically-from-js-2x.html is flaky https://bugs.webkit.org/show_bug.cgi?id=140649 fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html is failing on some bots https://bugs.webkit.org/show_bug.cgi?id=134769 Reviewed by Darin Adler. Streamline resources/srcset-helper.js and remove races. * TestExpectations: Unskip fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html. * fast/hidpi/resources/srcset-helper.js: Deleted. We aleady had a copy in /resources, no need for two copies. * resources/srcset-helper.js: This script used to depend on setBackingScaleFactor invoke its callback really fast, which is not guaranteed. Also, it had broken logic that used non-existent window.deviceScaleFactor. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Updated to run the tests from runTest() function, not a load event handler. Where appropriate, changed from testRunner.dumpResourceLoadCallbacks() to testRunner.dumpResourceResponseMIMETypes(), because the latter doesn't unnecessarily include reloaded scripts. It feels somewhat hacky, but the hack is already used in fast/hidpi, and it improves output. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-fraction-1.5x.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size.html: * fast/hidpi/image-srcset-invalid-descriptor.html: * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-nomodifier.html: * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x.html: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier.html: * fast/hidpi/image-srcset-space-prefix-nomodifier.html: * fast/hidpi/image-srcset-space-suffix-nomodifier.html: * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: * fast/hidpi/image-srcset-src-selection-1x-both.html: * fast/hidpi/image-srcset-src-selection-1x.html: * fast/hidpi/image-srcset-src-selection-2x.html: * fast/hidpi/image-srcset-viewport-modifiers.html: Updated to run the tests from runTest() function, not a load event handler. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Updated results for srcset-helper.js now always starting the redirect after the load is fully finished. * svg/css/svg-resource-fragment-identifier-img-src.html: Updated for the unified location of the script. Canonical link: https://commits.webkit.org/158650@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-20 18:26:00 +00:00
if (needsBackingScaleFactorChange) {
Add support for HTMLImageElement's sizes attribute https://bugs.webkit.org/show_bug.cgi?id=133620 Reviewed by Dean Jackson. .: Added an ENABLE_PICTURE_SIZES compile flag. * Source/cmake/WebKitFeatures.cmake: * Source/cmakeconfig.h.cmake: Source/JavaScriptCore: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Tests: fast/dom/HTMLImageElement/sizes/image-sizes-1x.html fast/dom/HTMLImageElement/sizes/image-sizes-2x.html fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html http/tests/loading/sizes/preload-image-sizes-2x.html http/tests/loading/sizes/preload-image-sizes.html This patch adds support for HTMLImageElement's sizes attribute and the related srcset extended syntax as defined in http://picture.responsiveimages.org/. This sizes attribute syntax is added to the CSSGrammar and parsed by the CSSParser. The SourceSizeList class is generated by the parser, and used to get the final source size. HTMLImageElement and HTMLPreloadScanner send this value to HTMLSrcsetParser. HTMLSrcsetParser uses this value in order to pick the right resource. * CMakeLists.txt: Added css/SourceSizeList.cpp. * Configurations/FeatureDefines.xcconfig: Added the PICTURE_SIZES flag. * WebCore.vcxproj/WebCore.vcxproj: Added css/SourceSizeList.*. * WebCore.vcxproj/WebCore.vcxproj.filters: Added css/SourceSizeList.*. * WebCore.xcodeproj/project.pbxproj: Added css/SourceSizeList.*. * css/CSSGrammar.y.in: Added 4 grammar rules that define a Media condition, Source size list, Source size length and source size. * css/CSSParser.cpp: (WebCore::CSSParser::parseSizesAttribute): Parse the sizes attribute. (WebCore::CSSParser::detectAtToken): Set the token to SIZESATTR. * css/CSSParser.h: * css/SourceSizeList.cpp: Added. Defined the SourceSize and SourceSizeList classes. (WebCore::SourceSize::match): (WebCore::computeLength): (WebCore::defaultValue): (WebCore::SourceSize::length): (WebCore::SourceSizeList::parseSizesAttribute): (WebCore::SourceSizeList::getEffectiveSize): * css/SourceSizeList.h: Added. (WebCore::SourceSize::SourceSize): (WebCore::SourceSizeList::append): * html/HTMLImageElement.cpp: Integrated sizes attribute parsing and added currentSrc. (WebCore::HTMLImageElement::setBestFitURLAndDPRFromImageCandidate): (WebCore::HTMLImageElement::parseAttribute): (WebCore::HTMLImageElement::currentSrc): * html/HTMLImageElement.h: * html/HTMLImageElement.idl: * html/parser/HTMLDocumentParser.cpp: Added information required for sizes parsing to HTMLPreloadScanner calls. (WebCore::HTMLDocumentParser::pumpTokenizer): (WebCore::HTMLDocumentParser::insert): (WebCore::HTMLDocumentParser::append): (WebCore::HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan): * html/parser/HTMLPreloadScanner.cpp: Integrated sizes attribute parsing. (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): (WebCore::TokenPreloadScanner::scan): (WebCore::HTMLPreloadScanner::scan): * html/parser/HTMLPreloadScanner.h: * html/parser/HTMLSrcsetParser.cpp: Added 'w' descriptor parsing sizes based normalization. (WebCore::parseDescriptors): (WebCore::pickBestImageCandidate): (WebCore::bestFitSourceForImageAttributes): * html/parser/HTMLSrcsetParser.h: Source/WebKit/mac: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit2: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Tools: Added an ENABLE_PICTURE_SIZES compile flag. * Scripts/webkitperl/FeatureList.pm: LayoutTests: These layout tests check that the sizes attribute and the related srcset syntax are well supported, that the right resource is displayed, that the currentSrc attribute is well supported and also that the right resource is preloaded. * fast/dom/HTMLImageElement/resources/currentSrcHelper.js: Added. (fileName): (currentSrcFileName): * fast/dom/HTMLImageElement/resources/image-set-4x.png: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Added. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes-2x.html: Added. * http/tests/loading/sizes/preload-image-sizes-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes.html: Added. Canonical link: https://commits.webkit.org/152413@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-30 04:07:08 +00:00
testRunner.waitUntilDone();
fast/hidpi/image-srcset-change-dynamically-from-js-2x.html is flaky https://bugs.webkit.org/show_bug.cgi?id=140649 fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html is failing on some bots https://bugs.webkit.org/show_bug.cgi?id=134769 Reviewed by Darin Adler. Streamline resources/srcset-helper.js and remove races. * TestExpectations: Unskip fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html. * fast/hidpi/resources/srcset-helper.js: Deleted. We aleady had a copy in /resources, no need for two copies. * resources/srcset-helper.js: This script used to depend on setBackingScaleFactor invoke its callback really fast, which is not guaranteed. Also, it had broken logic that used non-existent window.deviceScaleFactor. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Updated to run the tests from runTest() function, not a load event handler. Where appropriate, changed from testRunner.dumpResourceLoadCallbacks() to testRunner.dumpResourceResponseMIMETypes(), because the latter doesn't unnecessarily include reloaded scripts. It feels somewhat hacky, but the hack is already used in fast/hidpi, and it improves output. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-fraction-1.5x.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size.html: * fast/hidpi/image-srcset-invalid-descriptor.html: * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-nomodifier.html: * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x.html: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier.html: * fast/hidpi/image-srcset-space-prefix-nomodifier.html: * fast/hidpi/image-srcset-space-suffix-nomodifier.html: * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: * fast/hidpi/image-srcset-src-selection-1x-both.html: * fast/hidpi/image-srcset-src-selection-1x.html: * fast/hidpi/image-srcset-src-selection-2x.html: * fast/hidpi/image-srcset-viewport-modifiers.html: Updated to run the tests from runTest() function, not a load event handler. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Updated results for srcset-helper.js now always starting the redirect after the load is fully finished. * svg/css/svg-resource-fragment-identifier-img-src.html: Updated for the unified location of the script. Canonical link: https://commits.webkit.org/158650@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-20 18:26:00 +00:00
testRunner.setBackingScaleFactor(targetScaleFactor, function() {
// Right now there is a bug that srcset does not properly deal with dynamic changes to the scale factor,
// so to work around that, we must reload the page to get the new image.
sessionStorage.pageReloaded = true;
setTimeout(function() { document.location.reload(true) }, 0);
});
return;
Add support for HTMLImageElement's sizes attribute https://bugs.webkit.org/show_bug.cgi?id=133620 Reviewed by Dean Jackson. .: Added an ENABLE_PICTURE_SIZES compile flag. * Source/cmake/WebKitFeatures.cmake: * Source/cmakeconfig.h.cmake: Source/JavaScriptCore: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Tests: fast/dom/HTMLImageElement/sizes/image-sizes-1x.html fast/dom/HTMLImageElement/sizes/image-sizes-2x.html fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html http/tests/loading/sizes/preload-image-sizes-2x.html http/tests/loading/sizes/preload-image-sizes.html This patch adds support for HTMLImageElement's sizes attribute and the related srcset extended syntax as defined in http://picture.responsiveimages.org/. This sizes attribute syntax is added to the CSSGrammar and parsed by the CSSParser. The SourceSizeList class is generated by the parser, and used to get the final source size. HTMLImageElement and HTMLPreloadScanner send this value to HTMLSrcsetParser. HTMLSrcsetParser uses this value in order to pick the right resource. * CMakeLists.txt: Added css/SourceSizeList.cpp. * Configurations/FeatureDefines.xcconfig: Added the PICTURE_SIZES flag. * WebCore.vcxproj/WebCore.vcxproj: Added css/SourceSizeList.*. * WebCore.vcxproj/WebCore.vcxproj.filters: Added css/SourceSizeList.*. * WebCore.xcodeproj/project.pbxproj: Added css/SourceSizeList.*. * css/CSSGrammar.y.in: Added 4 grammar rules that define a Media condition, Source size list, Source size length and source size. * css/CSSParser.cpp: (WebCore::CSSParser::parseSizesAttribute): Parse the sizes attribute. (WebCore::CSSParser::detectAtToken): Set the token to SIZESATTR. * css/CSSParser.h: * css/SourceSizeList.cpp: Added. Defined the SourceSize and SourceSizeList classes. (WebCore::SourceSize::match): (WebCore::computeLength): (WebCore::defaultValue): (WebCore::SourceSize::length): (WebCore::SourceSizeList::parseSizesAttribute): (WebCore::SourceSizeList::getEffectiveSize): * css/SourceSizeList.h: Added. (WebCore::SourceSize::SourceSize): (WebCore::SourceSizeList::append): * html/HTMLImageElement.cpp: Integrated sizes attribute parsing and added currentSrc. (WebCore::HTMLImageElement::setBestFitURLAndDPRFromImageCandidate): (WebCore::HTMLImageElement::parseAttribute): (WebCore::HTMLImageElement::currentSrc): * html/HTMLImageElement.h: * html/HTMLImageElement.idl: * html/parser/HTMLDocumentParser.cpp: Added information required for sizes parsing to HTMLPreloadScanner calls. (WebCore::HTMLDocumentParser::pumpTokenizer): (WebCore::HTMLDocumentParser::insert): (WebCore::HTMLDocumentParser::append): (WebCore::HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan): * html/parser/HTMLPreloadScanner.cpp: Integrated sizes attribute parsing. (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): (WebCore::TokenPreloadScanner::scan): (WebCore::HTMLPreloadScanner::scan): * html/parser/HTMLPreloadScanner.h: * html/parser/HTMLSrcsetParser.cpp: Added 'w' descriptor parsing sizes based normalization. (WebCore::parseDescriptors): (WebCore::pickBestImageCandidate): (WebCore::bestFitSourceForImageAttributes): * html/parser/HTMLSrcsetParser.h: Source/WebKit/mac: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit2: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Tools: Added an ENABLE_PICTURE_SIZES compile flag. * Scripts/webkitperl/FeatureList.pm: LayoutTests: These layout tests check that the sizes attribute and the related srcset syntax are well supported, that the right resource is displayed, that the currentSrc attribute is well supported and also that the right resource is preloaded. * fast/dom/HTMLImageElement/resources/currentSrcHelper.js: Added. (fileName): (currentSrcFileName): * fast/dom/HTMLImageElement/resources/image-set-4x.png: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Added. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes-2x.html: Added. * http/tests/loading/sizes/preload-image-sizes-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes.html: Added. Canonical link: https://commits.webkit.org/152413@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-30 04:07:08 +00:00
}
fast/hidpi/image-srcset-change-dynamically-from-js-2x.html is flaky https://bugs.webkit.org/show_bug.cgi?id=140649 fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html is failing on some bots https://bugs.webkit.org/show_bug.cgi?id=134769 Reviewed by Darin Adler. Streamline resources/srcset-helper.js and remove races. * TestExpectations: Unskip fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html. * fast/hidpi/resources/srcset-helper.js: Deleted. We aleady had a copy in /resources, no need for two copies. * resources/srcset-helper.js: This script used to depend on setBackingScaleFactor invoke its callback really fast, which is not guaranteed. Also, it had broken logic that used non-existent window.deviceScaleFactor. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Updated to run the tests from runTest() function, not a load event handler. Where appropriate, changed from testRunner.dumpResourceLoadCallbacks() to testRunner.dumpResourceResponseMIMETypes(), because the latter doesn't unnecessarily include reloaded scripts. It feels somewhat hacky, but the hack is already used in fast/hidpi, and it improves output. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-fraction-1.5x.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size.html: * fast/hidpi/image-srcset-invalid-descriptor.html: * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-nomodifier.html: * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x.html: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier.html: * fast/hidpi/image-srcset-space-prefix-nomodifier.html: * fast/hidpi/image-srcset-space-suffix-nomodifier.html: * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: * fast/hidpi/image-srcset-src-selection-1x-both.html: * fast/hidpi/image-srcset-src-selection-1x.html: * fast/hidpi/image-srcset-src-selection-2x.html: * fast/hidpi/image-srcset-viewport-modifiers.html: Updated to run the tests from runTest() function, not a load event handler. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Updated results for srcset-helper.js now always starting the redirect after the load is fully finished. * svg/css/svg-resource-fragment-identifier-img-src.html: Updated for the unified location of the script. Canonical link: https://commits.webkit.org/158650@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-20 18:26:00 +00:00
try {
if (window.runTest)
runTest();
} catch (ex) {
testFailed("Uncaught exception" + ex);
Add support for HTMLImageElement's sizes attribute https://bugs.webkit.org/show_bug.cgi?id=133620 Reviewed by Dean Jackson. .: Added an ENABLE_PICTURE_SIZES compile flag. * Source/cmake/WebKitFeatures.cmake: * Source/cmakeconfig.h.cmake: Source/JavaScriptCore: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Tests: fast/dom/HTMLImageElement/sizes/image-sizes-1x.html fast/dom/HTMLImageElement/sizes/image-sizes-2x.html fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html http/tests/loading/sizes/preload-image-sizes-2x.html http/tests/loading/sizes/preload-image-sizes.html This patch adds support for HTMLImageElement's sizes attribute and the related srcset extended syntax as defined in http://picture.responsiveimages.org/. This sizes attribute syntax is added to the CSSGrammar and parsed by the CSSParser. The SourceSizeList class is generated by the parser, and used to get the final source size. HTMLImageElement and HTMLPreloadScanner send this value to HTMLSrcsetParser. HTMLSrcsetParser uses this value in order to pick the right resource. * CMakeLists.txt: Added css/SourceSizeList.cpp. * Configurations/FeatureDefines.xcconfig: Added the PICTURE_SIZES flag. * WebCore.vcxproj/WebCore.vcxproj: Added css/SourceSizeList.*. * WebCore.vcxproj/WebCore.vcxproj.filters: Added css/SourceSizeList.*. * WebCore.xcodeproj/project.pbxproj: Added css/SourceSizeList.*. * css/CSSGrammar.y.in: Added 4 grammar rules that define a Media condition, Source size list, Source size length and source size. * css/CSSParser.cpp: (WebCore::CSSParser::parseSizesAttribute): Parse the sizes attribute. (WebCore::CSSParser::detectAtToken): Set the token to SIZESATTR. * css/CSSParser.h: * css/SourceSizeList.cpp: Added. Defined the SourceSize and SourceSizeList classes. (WebCore::SourceSize::match): (WebCore::computeLength): (WebCore::defaultValue): (WebCore::SourceSize::length): (WebCore::SourceSizeList::parseSizesAttribute): (WebCore::SourceSizeList::getEffectiveSize): * css/SourceSizeList.h: Added. (WebCore::SourceSize::SourceSize): (WebCore::SourceSizeList::append): * html/HTMLImageElement.cpp: Integrated sizes attribute parsing and added currentSrc. (WebCore::HTMLImageElement::setBestFitURLAndDPRFromImageCandidate): (WebCore::HTMLImageElement::parseAttribute): (WebCore::HTMLImageElement::currentSrc): * html/HTMLImageElement.h: * html/HTMLImageElement.idl: * html/parser/HTMLDocumentParser.cpp: Added information required for sizes parsing to HTMLPreloadScanner calls. (WebCore::HTMLDocumentParser::pumpTokenizer): (WebCore::HTMLDocumentParser::insert): (WebCore::HTMLDocumentParser::append): (WebCore::HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan): * html/parser/HTMLPreloadScanner.cpp: Integrated sizes attribute parsing. (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): (WebCore::TokenPreloadScanner::scan): (WebCore::HTMLPreloadScanner::scan): * html/parser/HTMLPreloadScanner.h: * html/parser/HTMLSrcsetParser.cpp: Added 'w' descriptor parsing sizes based normalization. (WebCore::parseDescriptors): (WebCore::pickBestImageCandidate): (WebCore::bestFitSourceForImageAttributes): * html/parser/HTMLSrcsetParser.h: Source/WebKit/mac: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit2: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Tools: Added an ENABLE_PICTURE_SIZES compile flag. * Scripts/webkitperl/FeatureList.pm: LayoutTests: These layout tests check that the sizes attribute and the related srcset syntax are well supported, that the right resource is displayed, that the currentSrc attribute is well supported and also that the right resource is preloaded. * fast/dom/HTMLImageElement/resources/currentSrcHelper.js: Added. (fileName): (currentSrcFileName): * fast/dom/HTMLImageElement/resources/image-set-4x.png: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Added. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes-2x.html: Added. * http/tests/loading/sizes/preload-image-sizes-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes.html: Added. Canonical link: https://commits.webkit.org/152413@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-30 04:07:08 +00:00
}
fast/hidpi/image-srcset-change-dynamically-from-js-2x.html is flaky https://bugs.webkit.org/show_bug.cgi?id=140649 fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html is failing on some bots https://bugs.webkit.org/show_bug.cgi?id=134769 Reviewed by Darin Adler. Streamline resources/srcset-helper.js and remove races. * TestExpectations: Unskip fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html. * fast/hidpi/resources/srcset-helper.js: Deleted. We aleady had a copy in /resources, no need for two copies. * resources/srcset-helper.js: This script used to depend on setBackingScaleFactor invoke its callback really fast, which is not guaranteed. Also, it had broken logic that used non-existent window.deviceScaleFactor. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Updated to run the tests from runTest() function, not a load event handler. Where appropriate, changed from testRunner.dumpResourceLoadCallbacks() to testRunner.dumpResourceResponseMIMETypes(), because the latter doesn't unnecessarily include reloaded scripts. It feels somewhat hacky, but the hack is already used in fast/hidpi, and it improves output. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-fraction-1.5x.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size.html: * fast/hidpi/image-srcset-invalid-descriptor.html: * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-nomodifier.html: * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x.html: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier.html: * fast/hidpi/image-srcset-space-prefix-nomodifier.html: * fast/hidpi/image-srcset-space-suffix-nomodifier.html: * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: * fast/hidpi/image-srcset-src-selection-1x-both.html: * fast/hidpi/image-srcset-src-selection-1x.html: * fast/hidpi/image-srcset-src-selection-2x.html: * fast/hidpi/image-srcset-viewport-modifiers.html: Updated to run the tests from runTest() function, not a load event handler. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Updated results for srcset-helper.js now always starting the redirect after the load is fully finished. * svg/css/svg-resource-fragment-identifier-img-src.html: Updated for the unified location of the script. Canonical link: https://commits.webkit.org/158650@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-20 18:26:00 +00:00
var didReload = sessionStorage.pageReloaded;
delete sessionStorage.pageReloaded;
Add support for HTMLImageElement's sizes attribute https://bugs.webkit.org/show_bug.cgi?id=133620 Reviewed by Dean Jackson. .: Added an ENABLE_PICTURE_SIZES compile flag. * Source/cmake/WebKitFeatures.cmake: * Source/cmakeconfig.h.cmake: Source/JavaScriptCore: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: Tests: fast/dom/HTMLImageElement/sizes/image-sizes-1x.html fast/dom/HTMLImageElement/sizes/image-sizes-2x.html fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html http/tests/loading/sizes/preload-image-sizes-2x.html http/tests/loading/sizes/preload-image-sizes.html This patch adds support for HTMLImageElement's sizes attribute and the related srcset extended syntax as defined in http://picture.responsiveimages.org/. This sizes attribute syntax is added to the CSSGrammar and parsed by the CSSParser. The SourceSizeList class is generated by the parser, and used to get the final source size. HTMLImageElement and HTMLPreloadScanner send this value to HTMLSrcsetParser. HTMLSrcsetParser uses this value in order to pick the right resource. * CMakeLists.txt: Added css/SourceSizeList.cpp. * Configurations/FeatureDefines.xcconfig: Added the PICTURE_SIZES flag. * WebCore.vcxproj/WebCore.vcxproj: Added css/SourceSizeList.*. * WebCore.vcxproj/WebCore.vcxproj.filters: Added css/SourceSizeList.*. * WebCore.xcodeproj/project.pbxproj: Added css/SourceSizeList.*. * css/CSSGrammar.y.in: Added 4 grammar rules that define a Media condition, Source size list, Source size length and source size. * css/CSSParser.cpp: (WebCore::CSSParser::parseSizesAttribute): Parse the sizes attribute. (WebCore::CSSParser::detectAtToken): Set the token to SIZESATTR. * css/CSSParser.h: * css/SourceSizeList.cpp: Added. Defined the SourceSize and SourceSizeList classes. (WebCore::SourceSize::match): (WebCore::computeLength): (WebCore::defaultValue): (WebCore::SourceSize::length): (WebCore::SourceSizeList::parseSizesAttribute): (WebCore::SourceSizeList::getEffectiveSize): * css/SourceSizeList.h: Added. (WebCore::SourceSize::SourceSize): (WebCore::SourceSizeList::append): * html/HTMLImageElement.cpp: Integrated sizes attribute parsing and added currentSrc. (WebCore::HTMLImageElement::setBestFitURLAndDPRFromImageCandidate): (WebCore::HTMLImageElement::parseAttribute): (WebCore::HTMLImageElement::currentSrc): * html/HTMLImageElement.h: * html/HTMLImageElement.idl: * html/parser/HTMLDocumentParser.cpp: Added information required for sizes parsing to HTMLPreloadScanner calls. (WebCore::HTMLDocumentParser::pumpTokenizer): (WebCore::HTMLDocumentParser::insert): (WebCore::HTMLDocumentParser::append): (WebCore::HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan): * html/parser/HTMLPreloadScanner.cpp: Integrated sizes attribute parsing. (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): (WebCore::TokenPreloadScanner::scan): (WebCore::HTMLPreloadScanner::scan): * html/parser/HTMLPreloadScanner.h: * html/parser/HTMLSrcsetParser.cpp: Added 'w' descriptor parsing sizes based normalization. (WebCore::parseDescriptors): (WebCore::pickBestImageCandidate): (WebCore::bestFitSourceForImageAttributes): * html/parser/HTMLSrcsetParser.h: Source/WebKit/mac: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit2: Added an ENABLE_PICTURE_SIZES compile flag. * Configurations/FeatureDefines.xcconfig: Tools: Added an ENABLE_PICTURE_SIZES compile flag. * Scripts/webkitperl/FeatureList.pm: LayoutTests: These layout tests check that the sizes attribute and the related srcset syntax are well supported, that the right resource is displayed, that the currentSrc attribute is well supported and also that the right resource is preloaded. * fast/dom/HTMLImageElement/resources/currentSrcHelper.js: Added. (fileName): (currentSrcFileName): * fast/dom/HTMLImageElement/resources/image-set-4x.png: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-1x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: Added. * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Added. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes-2x.html: Added. * http/tests/loading/sizes/preload-image-sizes-expected.txt: Added. * http/tests/loading/sizes/preload-image-sizes.html: Added. Canonical link: https://commits.webkit.org/152413@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-06-30 04:07:08 +00:00
fast/hidpi/image-srcset-change-dynamically-from-js-2x.html is flaky https://bugs.webkit.org/show_bug.cgi?id=140649 fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html is failing on some bots https://bugs.webkit.org/show_bug.cgi?id=134769 Reviewed by Darin Adler. Streamline resources/srcset-helper.js and remove races. * TestExpectations: Unskip fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html. * fast/hidpi/resources/srcset-helper.js: Deleted. We aleady had a copy in /resources, no need for two copies. * resources/srcset-helper.js: This script used to depend on setBackingScaleFactor invoke its callback really fast, which is not guaranteed. Also, it had broken logic that used non-existent window.deviceScaleFactor. * fast/dom/HTMLImageElement/sizes/image-sizes-2x.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-change.html: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml-expected.txt: * fast/dom/HTMLImageElement/sizes/image-sizes-js-innerhtml.html: Updated to run the tests from runTest() function, not a load event handler. Where appropriate, changed from testRunner.dumpResourceLoadCallbacks() to testRunner.dumpResourceResponseMIMETypes(), because the latter doesn't unnecessarily include reloaded scripts. It feels somewhat hacky, but the hack is already used in fast/hidpi, and it improves output. * fast/hidpi/image-srcset-change-dynamically-from-js-1x.html: * fast/hidpi/image-srcset-change-dynamically-from-js-2x.html: * fast/hidpi/image-srcset-fraction-1.5x.html: * fast/hidpi/image-srcset-fraction.html: * fast/hidpi/image-srcset-intrinsic-size.html: * fast/hidpi/image-srcset-invalid-descriptor.html: * fast/hidpi/image-srcset-invalid-inputs-except-one.html: * fast/hidpi/image-srcset-nomodifier.html: * fast/hidpi/image-srcset-only-src-attribute.html: * fast/hidpi/image-srcset-remove-dynamically-from-js.html: * fast/hidpi/image-srcset-same-alternative-for-both-attributes.html: * fast/hidpi/image-srcset-simple-1x.html: * fast/hidpi/image-srcset-simple-2x.html: * fast/hidpi/image-srcset-space-left-nomodifier.html: * fast/hidpi/image-srcset-space-prefix-nomodifier.html: * fast/hidpi/image-srcset-space-suffix-nomodifier.html: * fast/hidpi/image-srcset-space-surrounded-nomodifier.html: * fast/hidpi/image-srcset-src-selection-1x-both.html: * fast/hidpi/image-srcset-src-selection-1x.html: * fast/hidpi/image-srcset-src-selection-2x.html: * fast/hidpi/image-srcset-viewport-modifiers.html: Updated to run the tests from runTest() function, not a load event handler. * http/tests/loading/sizes/preload-image-sizes-2x-expected.txt: Updated results for srcset-helper.js now always starting the redirect after the load is fully finished. * svg/css/svg-resource-fragment-identifier-img-src.html: Updated for the unified location of the script. Canonical link: https://commits.webkit.org/158650@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-20 18:26:00 +00:00
if (didReload)
testRunner.notifyDone();
});