PreloadScanner preloads external CSS with non-matching media attribute
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 Aug 2013 13:43:24 +0000 (13:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 3 Aug 2013 13:43:24 +0000 (13:43 +0000)
commit73487cd6e3054c925719c36b504042a5009495d3
tree436352fd75de83247f68a64e690e7721b9ae27fa
parentc82558a1783967144e744557bce8ba85f150bbd0
PreloadScanner preloads external CSS with non-matching media attribute
https://bugs.webkit.org/show_bug.cgi?id=106198

Patch by Yoav Weiss <yoav@yoav.ws> on 2013-08-03
Reviewed by Dean Jackson.

Source/WebCore:

Test: http/tests/loading/preload-css-test.html

* html/parser/HTMLPreloadScanner.cpp:
Remove m_linkMediaAttributeIsScreen
Remove MediaQueryEvaluator calls
Add m_mediaAttribute that gets the value of the "media" attribute
Pass m_mediaAttribute to PreloadRequest
(WebCore::TokenPreloadScanner::StartTagScanner::StartTagScanner):
(WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest):
(WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
(WebCore::TokenPreloadScanner::StartTagScanner::resourceType):
(WebCore::TokenPreloadScanner::StartTagScanner::shouldPreload):
* html/parser/HTMLResourcePreloader.cpp:
Add MediaQueryEvaluator calls to see if "media" matches
Perform preload only to resource with a matching media (if media exists)
(WebCore::PreloadRequest::isSafeToSendToAnotherThread):
(WebCore::mediaAttributeMatches):
(WebCore::HTMLResourcePreloader::preload):
* html/parser/HTMLResourcePreloader.h:
Add a constructor with a mediaAttribute value
Add m_mediaAttribute & its getter.
(WebCore::PreloadRequest::create):
(WebCore::PreloadRequest::media):
(WebCore::PreloadRequest::PreloadRequest):

LayoutTests:

* http/tests/loading/preload-css-test-expected.txt: Added.
* http/tests/loading/preload-css-test.html: Added.
* http/tests/loading/resources/big_mq.css: Added.
* http/tests/loading/resources/small_mq.css: Added.
* http/tests/local/link-stylesheet-load-order-preload-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153689 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/preload-css-test-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/preload-css-test.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resources/big_mq.css [new file with mode: 0644]
LayoutTests/http/tests/loading/resources/small_mq.css [new file with mode: 0644]
LayoutTests/http/tests/local/link-stylesheet-load-order-preload-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/html/parser/HTMLPreloadScanner.cpp
Source/WebCore/html/parser/HTMLResourcePreloader.cpp
Source/WebCore/html/parser/HTMLResourcePreloader.h