Commit 6f72f782 authored by antti@apple.com's avatar antti@apple.com

WebCore: https://bugs.webkit.org/show_bug.cgi?id=50758

<rdar://problem/8722094> 
Defer loading print stylesheets
        
Reviewed by Alexey Proskuryakov.

- Make preload scanner skip stylesheets with non-screen media types.
- Make it possible to specify non-default load priority from the client.
- Use this mechanism to load print stylesheets using very low priority so they get loaded after everything else.
- Move default priority code from Loader to CachedResource.
- Move ResourceLoadScheduler::Priority enum to a separate file (as ResourceLoadPriority).
- Add a way to make ResourceLoadScheduler load resources one at the time so the above functionality can be tested reliably.

Tests: http/tests/local/link-stylesheet-load-order-preload.html
       http/tests/local/link-stylesheet-load-order.html

* WebCore.exp.in:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLNames::PreloadTask::PreloadTask):
(WebCore::HTMLNames::PreloadTask::processAttributes):
(WebCore::HTMLNames::PreloadTask::relAttributeIsStyleSheet):
(WebCore::HTMLNames::PreloadTask::linkMediaAttributeIsScreen):
(WebCore::HTMLNames::PreloadTask::preload):
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/ResourceLoadPriority.h: Added.
* loader/ResourceLoadScheduler.cpp:
(WebCore::ResourceLoadScheduler::ResourceLoadScheduler):
(WebCore::ResourceLoadScheduler::scheduleSubresourceLoad):
(WebCore::ResourceLoadScheduler::schedulePluginStreamLoad):
(WebCore::ResourceLoadScheduler::scheduleLoad):
(WebCore::ResourceLoadScheduler::servePendingRequests):
(WebCore::ResourceLoadScheduler::HostInformation::~HostInformation):
(WebCore::ResourceLoadScheduler::HostInformation::schedule):
(WebCore::ResourceLoadScheduler::HostInformation::remove):
(WebCore::ResourceLoadScheduler::HostInformation::hasRequests):
(WebCore::ResourceLoadScheduler::HostInformation::limitRequests):
* loader/ResourceLoadScheduler.h:
(WebCore::ResourceLoadScheduler::isSerialLoadingEnabled):
(WebCore::ResourceLoadScheduler::setSerialLoadingEnabled):
(WebCore::ResourceLoadScheduler::HostInformation::requestsPending):
* loader/cache/CachedResource.cpp:
(WebCore::defaultPriorityForResourceType):
(WebCore::CachedResource::CachedResource):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::loadPriority):
(WebCore::CachedResource::setLoadPriority):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestCSSStyleSheet):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::requestPreload):
* loader/cache/CachedResourceLoader.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::requestResource):
* loader/cache/MemoryCache.h:
* loader/loader.cpp:
(WebCore::Loader::load):

WebKit/mac: https://bugs.webkit.org/show_bug.cgi?id=50758
<rdar://problem/8722094> 
Defer loading print stylesheets
        
Reviewed by Alexey Proskuryakov.

Expose SPI for DRT for making resources load serially. This is useful for testing resource load order.

* WebView/WebView.mm:
(+[WebView _setLoadResourcesSerially:forHost:]):
* WebView/WebViewPrivate.h:

WebKitTools: Add setSerializeHTTPLoads function to allow testing resource load order on OS X.
https://bugs.webkit.org/show_bug.cgi?id=50758

Reviewed by Alexey Proskuryakov.

* DumpRenderTree/LayoutTestController.cpp:
(setSerializeHTTPLoadsCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
* DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
(LayoutTestController::setSerializeHTTPLoads):
* DumpRenderTree/mac/DumpRenderTree.mm:
(resetDefaultsToConsistentValues):
* DumpRenderTree/mac/LayoutTestControllerMac.mm:
(LayoutTestController::setSerializeHTTPLoads):
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::setSerializeHTTPLoads):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=50758
<rdar://problem/8722094> 
Defer loading print stylesheets
        
Reviewed by Alexey Proskuryakov.

Test load ordering.

* http/tests/local/link-stylesheet-load-order-expected.txt: Added.
* http/tests/local/link-stylesheet-load-order-preload-expected.txt: Added.
* http/tests/local/link-stylesheet-load-order-preload.html: Added.
* http/tests/local/link-stylesheet-load-order.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73938 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 662a2110
2010-12-09 Antti Koivisto <antti@apple.com>
Reviewed by Alexey Proskuryakov.
https://bugs.webkit.org/show_bug.cgi?id=50758
<rdar://problem/8722094>
Defer loading print stylesheets
Test load ordering.
* http/tests/local/link-stylesheet-load-order-expected.txt: Added.
* http/tests/local/link-stylesheet-load-order-preload-expected.txt: Added.
* http/tests/local/link-stylesheet-load-order-preload.html: Added.
* http/tests/local/link-stylesheet-load-order.html: Added.
2010-12-13 Justin Schuh <jschuh@chromium.org>
Reviewed by Dimitri Glazkov.
......
Test stylesheet load scheduling. Resource loads for screen stylesheets should be scheduled first, others should be scheduled last.
Resource requests:
no-media.css
media-empty.css
media-all.css
media-screen.css
media-screen-query-success.css
media-braille-screen.css
media-screen-query-fail.css
no-media-2.css
media-empty-2.css
media-all-2.css
media-screen-2.css
media-screen-query-success-2.css
media-braille-screen-2.css
media-screen-query-fail-2.css
script.js
image.jpg
media-print.css
media-aural.css
media-braille.css
median-handheld.css
media-projection.css
media-tty.css
media-tv.css
media-print-2.css
Test stylesheet load scheduling with preload scanner. Resource loads for screen stylesheets should be scheduled first, others should be scheduled last.
Resource requests:
script.js
no-media.css
media-empty.css
media-all.css
media-screen.css
media-braille-screen.css
no-media-2.css
media-empty-2.css
media-all-2.css
media-screen-2.css
media-braille-screen-2.css
media-screen-query-success.css
media-screen-query-fail.css
media-screen-query-success-2.css
media-screen-query-fail-2.css
script-2.js
image.jpg
media-print.css
media-aural.css
media-braille.css
median-handheld.css
media-projection.css
media-tty.css
media-tv.css
media-print-2.css
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
// Prevent networking layer from reordering loads.
if (layoutTestController.setSerializeHTTPLoads)
layoutTestController.setSerializeHTTPLoads();
}
function CallCommand(cmd)
{
try {
var req = new XMLHttpRequest;
req.open("GET", "http://127.0.0.1:8000/resources/network-simulator.php?command=" + cmd, false);
req.send(null);
return req.responseText;
} catch (ex) {
return "";
}
}
function endTest()
{
getResourceLog();
CallCommand("clear-resource-request-log");
if (window.layoutTestController)
layoutTestController.notifyDone();
}
function getResourceLog()
{
var log = CallCommand("get-resource-request-log");
var logLines = log.split('\n');
document.getElementById('result').innerText = logLines.join('\n');
}
CallCommand("start-resource-request-log");
window.addEventListener('load', endTest, false);
</script>
<!-- This will trigger the preload scanner -->
<script src="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=script.js"></script>
<link rel=stylesheet href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=no-media.css">
<link rel=stylesheet media="" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-empty.css">
<link rel=stylesheet media="all" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-all.css">
<link rel=stylesheet media="print" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-print.css">
<link rel=stylesheet media="screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen.css">
<link rel=stylesheet media="screen and (min-width: 1px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-success.css">
<link rel=stylesheet media="braille, screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-braille-screen.css">
<link rel=stylesheet media="screen and (min-width: 1000000px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-fail.css">
<link rel=stylesheet media="aural" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-aural.css">
<link rel=stylesheet media="braille" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-braille.css">
<link rel=stylesheet media="handheld" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=median-handheld.css">
<link rel=stylesheet media="projection" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-projection.css">
<link rel=stylesheet media="tty" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-tty.css">
<link rel=stylesheet media="tv" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-tv.css">
<link rel=stylesheet href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=no-media-2.css">
<link rel=stylesheet media="" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-empty-2.css">
<link rel=stylesheet media="all" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-all-2.css">
<link rel=stylesheet media="print" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-print-2.css">
<link rel=stylesheet media="screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-2.css">
<link rel=stylesheet media="screen and (min-width: 1px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-success-2.css">
<link rel=stylesheet media="braille, screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-braille-screen-2.css">
<link rel=stylesheet media="screen and (min-width: 1000000px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-fail-2.css">
</head>
<body>
<img src="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=image.jpg">
<script src="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=script-2.js"></script>
Test stylesheet load scheduling with preload scanner. Resource loads for screen stylesheets should be scheduled first, others should be scheduled last.
<h2>Resource requests:</h2>
<pre id="result">Request log goes here in DRT</pre>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
// Prevent networking layer from reordering loads.
if (layoutTestController.setSerializeHTTPLoads)
layoutTestController.setSerializeHTTPLoads();
}
function CallCommand(cmd)
{
try {
var req = new XMLHttpRequest;
req.open("GET", "http://127.0.0.1:8000/resources/network-simulator.php?command=" + cmd, false);
req.send(null);
return req.responseText;
} catch (ex) {
return "";
}
}
function endTest()
{
getResourceLog();
CallCommand("clear-resource-request-log");
if (window.layoutTestController)
layoutTestController.notifyDone();
}
function getResourceLog()
{
var log = CallCommand("get-resource-request-log");
var logLines = log.split('\n');
document.getElementById('result').innerText = logLines.join('\n');
}
CallCommand("start-resource-request-log");
window.addEventListener('load', endTest, false);
</script>
<link rel=stylesheet href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=no-media.css">
<link rel=stylesheet media="" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-empty.css">
<link rel=stylesheet media="all" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-all.css">
<link rel=stylesheet media="print" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-print.css">
<link rel=stylesheet media="screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen.css">
<link rel=stylesheet media="screen and (min-width: 1px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-success.css">
<link rel=stylesheet media="braille, screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-braille-screen.css">
<link rel=stylesheet media="screen and (min-width: 1000000px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-fail.css">
<link rel=stylesheet media="aural" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-aural.css">
<link rel=stylesheet media="braille" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-braille.css">
<link rel=stylesheet media="handheld" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=median-handheld.css">
<link rel=stylesheet media="projection" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-projection.css">
<link rel=stylesheet media="tty" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-tty.css">
<link rel=stylesheet media="tv" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-tv.css">
<link rel=stylesheet href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=no-media-2.css">
<link rel=stylesheet media="" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-empty-2.css">
<link rel=stylesheet media="all" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-all-2.css">
<link rel=stylesheet media="print" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-print-2.css">
<link rel=stylesheet media="screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-2.css">
<link rel=stylesheet media="screen and (min-width: 1px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-success-2.css">
<link rel=stylesheet media="braille, screen" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-braille-screen-2.css">
<link rel=stylesheet media="screen and (min-width: 1000000px)" href="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=media-screen-query-fail-2.css">
</head>
<body>
<img src="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=image.jpg">
<script src="http://127.0.0.1:8000/resources/network-simulator.php?command=log-resource-request&path=script.js"></script>
Test stylesheet load scheduling. Resource loads for screen stylesheets should be scheduled first, others should be scheduled last.
<h2>Resource requests:</h2>
<pre id="result">Request log goes here in DRT</pre>
</body>
</html>
......@@ -1093,3 +1093,8 @@ editing/text-iterator/findString.html
# The relevant bugs are https://bugs.webkit.org/show_bug.cgi?id=47849/47817.
fast/frames/location-redirect-user-gesture.html
fast/frames/meta-refresh-user-gesture.html
# For https://bugs.webkit.org/show_bug.cgi?id=50758
# These require DRT setSerializeHTTPLoads implementation to be reliable.
http/tests/local/link-stylesheet-load-order.html
http/tests/local/link-stylesheet-load-order-preload.html
2010-12-13 Antti Koivisto <antti@apple.com>
Reviewed by Alexey Proskuryakov.
https://bugs.webkit.org/show_bug.cgi?id=50758
<rdar://problem/8722094>
Defer loading print stylesheets
- Make preload scanner skip stylesheets with non-screen media types.
- Make it possible to specify non-default load priority from the client.
- Use this mechanism to load print stylesheets using very low priority so they get loaded after everything else.
- Move default priority code from Loader to CachedResource.
- Move ResourceLoadScheduler::Priority enum to a separate file (as ResourceLoadPriority).
- Add a way to make ResourceLoadScheduler load resources one at the time so the above functionality can be tested reliably.
Tests: http/tests/local/link-stylesheet-load-order-preload.html
http/tests/local/link-stylesheet-load-order.html
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLNames::PreloadTask::PreloadTask):
(WebCore::HTMLNames::PreloadTask::processAttributes):
(WebCore::HTMLNames::PreloadTask::relAttributeIsStyleSheet):
(WebCore::HTMLNames::PreloadTask::linkMediaAttributeIsScreen):
(WebCore::HTMLNames::PreloadTask::preload):
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/ResourceLoadPriority.h: Added.
* loader/ResourceLoadScheduler.cpp:
(WebCore::ResourceLoadScheduler::ResourceLoadScheduler):
(WebCore::ResourceLoadScheduler::scheduleSubresourceLoad):
(WebCore::ResourceLoadScheduler::schedulePluginStreamLoad):
(WebCore::ResourceLoadScheduler::scheduleLoad):
(WebCore::ResourceLoadScheduler::servePendingRequests):
(WebCore::ResourceLoadScheduler::HostInformation::~HostInformation):
(WebCore::ResourceLoadScheduler::HostInformation::schedule):
(WebCore::ResourceLoadScheduler::HostInformation::remove):
(WebCore::ResourceLoadScheduler::HostInformation::hasRequests):
(WebCore::ResourceLoadScheduler::HostInformation::limitRequests):
* loader/ResourceLoadScheduler.h:
(WebCore::ResourceLoadScheduler::isSerialLoadingEnabled):
(WebCore::ResourceLoadScheduler::setSerialLoadingEnabled):
(WebCore::ResourceLoadScheduler::HostInformation::requestsPending):
* loader/cache/CachedResource.cpp:
(WebCore::defaultPriorityForResourceType):
(WebCore::CachedResource::CachedResource):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::loadPriority):
(WebCore::CachedResource::setLoadPriority):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestCSSStyleSheet):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::requestPreload):
* loader/cache/CachedResourceLoader.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::requestResource):
* loader/cache/MemoryCache.h:
* loader/loader.cpp:
(WebCore::Loader::load):
2010-12-13 Justin Schuh <jschuh@chromium.org>
Reviewed by Dimitri Glazkov.
......
......@@ -491,7 +491,7 @@ __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
__ZN7WebCore21BackForwardController11itemAtIndexEi
__ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb
__ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent
__ZN7WebCore21ResourceLoadScheduler20servePendingRequestsENS0_8PriorityE
__ZN7WebCore21ResourceLoadScheduler20servePendingRequestsENS_20ResourceLoadPriorityE
__ZN7WebCore21ResourceLoadScheduler24schedulePluginStreamLoadEPNS_5FrameEPNS_32NetscapePlugInStreamLoaderClientERKNS_15ResourceRequestE
__ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKN3WTF6StringEPNS_14SVGSMILElementEd
__ZN7WebCore21SerializedScriptValue11deserializeEPK15OpaqueJSContextPPK13OpaqueJSValue
......
......@@ -2163,6 +2163,7 @@
'loader/ResourceLoader.h',
'loader/ResourceLoadNotifier.cpp',
'loader/ResourceLoadNotifier.h',
'loader/ResourceLoadPriority.h',
'loader/ResourceLoadScheduler.cpp',
'loader/ResourceLoadScheduler.h',
'loader/SinkDocument.cpp',
......
......@@ -1978,6 +1978,7 @@ HEADERS += \
loader/PlaceholderDocument.h \
loader/ProgressTracker.h \
loader/ResourceLoader.h \
loader/ResourceLoadPriority.h \
loader/SubresourceLoader.h \
loader/TextResourceDecoder.h \
loader/ThreadableLoader.h \
......
......@@ -24725,8 +24725,12 @@
<Filter
Name="loader"
>
<File
RelativePath="..\loader\ResourceLoadPriority.h"
>
</File>
<File
RelativePath="..\loader\ ResourceLoadScheduler.h"
RelativePath="..\loader\ResourceLoadScheduler.h"
>
</File>
<File
......@@ -5486,6 +5486,7 @@
E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
E415F1690D9A165D0033CE97 /* DOMElementTimeControl.h in Headers */ = {isa = PBXBuildFile; fileRef = E415F1680D9A165D0033CE97 /* DOMElementTimeControl.h */; };
E415F1840D9A1A830033CE97 /* ElementTimeControl.h in Headers */ = {isa = PBXBuildFile; fileRef = E415F1830D9A1A830033CE97 /* ElementTimeControl.h */; };
E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */ = {isa = PBXBuildFile; fileRef = E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */; settings = {ATTRIBUTES = (Private, ); }; };
E44613A10CD6331000FADA75 /* HTMLAudioElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */; };
E44613A20CD6331000FADA75 /* HTMLAudioElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613900CD6331000FADA75 /* HTMLAudioElement.h */; };
E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44613920CD6331000FADA75 /* HTMLMediaElement.cpp */; };
......@@ -11779,6 +11780,7 @@
E415F1830D9A1A830033CE97 /* ElementTimeControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementTimeControl.h; sourceTree = "<group>"; };
E41EA038119836DB00710BC5 /* CSSPropertyNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPropertyNames.cpp; sourceTree = "<group>"; };
E41EA0391198374900710BC5 /* CSSValueKeywords.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSValueKeywords.cpp; sourceTree = "<group>"; };
E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadPriority.h; sourceTree = "<group>"; };
E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLAudioElement.cpp; sourceTree = "<group>"; };
E44613900CD6331000FADA75 /* HTMLAudioElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLAudioElement.h; sourceTree = "<group>"; };
E44613910CD6331000FADA75 /* HTMLAudioElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLAudioElement.idl; sourceTree = "<group>"; };
......@@ -17870,6 +17872,7 @@
656D37270ADBA5DE00A4554D /* ResourceLoader.h */,
973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */,
973E325510883B7C005BC493 /* ResourceLoadNotifier.h */,
E4295FA312B0614E00D1ACE0 /* ResourceLoadPriority.h */,
D0CE58F6125E4CC200F3F199 /* ResourceLoadScheduler.cpp */,
D0CE58F7125E4CC200F3F199 /* ResourceLoadScheduler.h */,
51327D5F11A33A2B004F9D65 /* SinkDocument.cpp */,
......@@ -22114,6 +22117,7 @@
499B3EC5128CCC4700E726C2 /* PlatformCALayer.h in Headers */,
499B3ED7128CD31400E726C2 /* GraphicsLayerCA.h in Headers */,
499B3EDD128DB50200E726C2 /* PlatformCAAnimation.h in Headers */,
E4295FA412B0614E00D1ACE0 /* ResourceLoadPriority.h in Headers */,
FD315FF712B0267600C1A359 /* AudioBasicProcessorNode.h in Headers */,
FD315FF912B0267600C1A359 /* AudioBuffer.h in Headers */,
FD315FFC12B0267600C1A359 /* AudioBufferSourceNode.h in Headers */,
......@@ -74,7 +74,7 @@ StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const
cachedImage = loader->requestImage(url);
else {
// FIXME: Should find a way to make these images sit in their own memory partition, since they are user agent images.
cachedImage = static_cast<CachedImage*>(cache()->requestResource(0, CachedResource::ImageResource, KURL(ParsedURLString, url), String()));
cachedImage = static_cast<CachedImage*>(cache()->requestResource(0, CachedResource::ImageResource, KURL(ParsedURLString, url), String(), ResourceLoadPriorityUnresolved));
}
if (cachedImage) {
......
......@@ -224,10 +224,15 @@ void HTMLLinkElement::process()
bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet();
// Stylesheet
// This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh
if (m_disabledState != Disabled && (m_relAttribute.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css"))) && document()->frame() && m_url.isValid()) {
// also, don't load style sheets for standalone documents
bool mediaIsScreen = true;
if (!m_media.isEmpty()) {
RefPtr<MediaList> media = MediaList::createAllowingDescriptionSyntax(m_media);
MediaQueryEvaluator screenEvaluator("screen", true);
mediaIsScreen = screenEvaluator.eval(media.get());
}
if (m_disabledState != Disabled && (m_relAttribute.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css")))
&& document()->frame() && m_url.isValid()) {
String charset = getAttribute(charsetAttr);
if (charset.isEmpty() && document()->frame())
......@@ -250,7 +255,9 @@ void HTMLLinkElement::process()
if (!isAlternate())
document()->addPendingSheet();
m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(m_url, charset);
// Load non-screen stylesheets with low priority so they don't affect normal page loading.
ResourceLoadPriority priority = mediaIsScreen ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(m_url, charset, priority);
if (m_cachedSheet)
m_cachedSheet->addClient(this);
......
......@@ -35,6 +35,8 @@
#include "HTMLLinkElement.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
namespace WebCore {
......@@ -47,6 +49,7 @@ public:
PreloadTask(const HTMLToken& token)
: m_tagName(token.name().data(), token.name().size())
, m_linkIsStyleSheet(false)
, m_linkMediaAttributeIsScreen(true)
{
processAttributes(token.attributes());
}
......@@ -72,17 +75,31 @@ public:
setUrlToLoad(attributeValue);
else if (attributeName == relAttr)
m_linkIsStyleSheet = relAttributeIsStyleSheet(attributeValue);
else if (attributeName == mediaAttr)
m_linkMediaAttributeIsScreen = linkMediaAttributeIsScreen(attributeValue);
}
}
}
bool relAttributeIsStyleSheet(const String& attributeValue)
static bool relAttributeIsStyleSheet(const String& attributeValue)
{
ASSERT(m_tagName == linkTag);
HTMLLinkElement::RelAttribute rel;
HTMLLinkElement::tokenizeRelAttribute(attributeValue, rel);
return rel.m_isStyleSheet && !rel.m_isAlternate && !rel.m_isIcon && !rel.m_isDNSPrefetch;
}
static bool linkMediaAttributeIsScreen(const String& attributeValue)
{
if (attributeValue.isEmpty())
return true;
RefPtr<MediaList> mediaList = MediaList::createAllowingDescriptionSyntax(attributeValue);
// Only preload screen media stylesheets. Used this way, the evaluator evaluates to true for any
// rules containing complex queries (full evaluation is possible but it requires a frame and a style selector which
// may be problematic here).
MediaQueryEvaluator mediaQueryEvaluator("screen");
return mediaQueryEvaluator.eval(mediaList.get());
}
void setUrlToLoad(const String& attributeValue)
{
......@@ -103,7 +120,7 @@ public:
cachedResourceLoader->preload(CachedResource::Script, m_urlToLoad, m_charset, scanningBody);
else if (m_tagName == imgTag)
cachedResourceLoader->preload(CachedResource::ImageResource, m_urlToLoad, String(), scanningBody);
else if (m_tagName == linkTag && m_linkIsStyleSheet)
else if (m_tagName == linkTag && m_linkIsStyleSheet && m_linkMediaAttributeIsScreen)
cachedResourceLoader->preload(CachedResource::CSSStyleSheet, m_urlToLoad, m_charset, scanningBody);
}
......@@ -114,6 +131,7 @@ private:
String m_urlToLoad;
String m_charset;
bool m_linkIsStyleSheet;
bool m_linkMediaAttributeIsScreen;
};
} // namespace
......
......@@ -320,7 +320,7 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Secur
// Clear the loader so that any callbacks from SubresourceLoader::create will not have the old loader.
m_loader = 0;
m_loader = resourceLoadScheduler()->scheduleSubresourceLoad(m_document->frame(), this, request, ResourceLoadScheduler::Medium, securityCheck, sendLoadCallbacks, sniffContent);
m_loader = resourceLoadScheduler()->scheduleSubresourceLoad(m_document->frame(), this, request, ResourceLoadPriorityMedium, securityCheck, sendLoadCallbacks, sniffContent);
return;
}
......
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ResourceLoadPriority_h
#define ResourceLoadPriority_h
namespace WebCore {
enum ResourceLoadPriority {
ResourceLoadPriorityVeryLow,
ResourceLoadPriorityLow,
ResourceLoadPriorityMedium,
ResourceLoadPriorityHigh,
ResourceLoadPriorityLowest = ResourceLoadPriorityVeryLow,
ResourceLoadPriorityHighest = ResourceLoadPriorityHigh,
// The unresolved priority is here for the convenience of the clients. It should not be passed to the ResourceLoadScheduler.
ResourceLoadPriorityUnresolved,
};
}
#endif
......@@ -76,13 +76,14 @@ ResourceLoadScheduler::ResourceLoadScheduler()
: m_nonHTTPProtocolHost(new HostInformation(String(), maxRequestsInFlightForNonHTTPProtocols))
, m_requestTimer(this, &ResourceLoadScheduler::requestTimerFired)
, m_isSuspendingPendingRequests(false)
, m_isSerialLoadingEnabled(false)
{
#if REQUEST_MANAGEMENT_ENABLED
maxRequestsInFlightPerHost = initializeMaximumHTTPConnectionCountPerHost();
#endif
}
PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request, Priority priority, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks, bool shouldContentSniff)
PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Frame* frame, SubresourceLoaderClient* client, const ResourceRequest& request, ResourceLoadPriority priority, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks, bool shouldContentSniff)
{
PassRefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, client, request, securityCheck, sendResourceLoadCallbacks, shouldContentSniff);
if (loader)
......@@ -94,7 +95,7 @@ PassRefPtr<NetscapePlugInStreamLoader> ResourceLoadScheduler::schedulePluginStre
{
PassRefPtr<NetscapePlugInStreamLoader> loader = NetscapePlugInStreamLoader::create(frame, client, request);
if (loader)
scheduleLoad(loader.get(), Low);
scheduleLoad(loader.get(), ResourceLoadPriorityLow);
return loader;
}
......@@ -103,11 +104,12 @@ void ResourceLoadScheduler::addMainResourceLoad(ResourceLoader* resourceLoader)
hostForURL(resourceLoader->url(), CreateIfNotFound)->addLoadInProgress(resourceLoader);
}
void ResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, Priority priority)
void ResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, ResourceLoadPriority priority)
{
ASSERT(resourceLoader);
ASSERT(priority != ResourceLoadPriorityUnresolved);
#if !REQUEST_MANAGEMENT_ENABLED
priority = HighestPriority;
priority = ResourceLoadPriorityHighest;
#endif
LOG(ResourceLoading, "ResourceLoadScheduler::load resource %p '%s'", resourceLoader, resourceLoader->url().string().latin1().data());
......@@ -115,7 +117,7 @@ void ResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, Priorit
bool hadRequests = host->hasRequests();
host->schedule(resourceLoader, priority);
if (priority > Low || !resourceLoader->url().protocolInHTTPFamily() || (priority == Low && !hadRequests)) {
if (priority > ResourceLoadPriorityLow || !resourceLoader->url().protocolInHTTPFamily() || (priority == ResourceLoadPriorityLow && !hadRequests)) {
// Try to request important resources immediately.
servePendingRequests(host, priority);
} else {
......@@ -148,7 +150,7 @@ void ResourceLoadScheduler::crossOriginRedirectReceived(ResourceLoader* resource
oldHost->remove(resourceLoader);
}
void ResourceLoadScheduler::servePendingRequests(Priority minimumPriority)
void ResourceLoadScheduler::servePendingRequests(ResourceLoadPriority minimumPriority)