diff options
author | Pierre-Antoine LaFayette <plafayet@codeaurora.org> | 2011-12-29 15:13:33 +0100 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2013-01-20 18:38:26 -0800 |
commit | 70f026a42cf1bee061389fa6ce790ea1186f0703 (patch) | |
tree | b0de5b5676433d2382e7cf1307b54edc19fc42a5 /Source/WebCore/loader | |
parent | a815c626d7df7e24ba9e0df27c27735d4e069ffd (diff) | |
download | external_webkit-70f026a42cf1bee061389fa6ce790ea1186f0703.zip external_webkit-70f026a42cf1bee061389fa6ce790ea1186f0703.tar.gz external_webkit-70f026a42cf1bee061389fa6ce790ea1186f0703.tar.bz2 |
WebGL implementation for Android
Implementation of WebGL in Android WebKit. Exposes a low level 3D
graphics API based on OpenGL ES 2.0 to JavaScript. WebGL is not compiled
by default. It can be enabled by setting ENABLE_WEBGL = true in your
device BoardConfig.mk or directly in external/webkit/Android.mk.
Includes runtime enablement through Browser Settings -> Labs menu.
Enable WebGL debug logs and FPS timing with: adb shell setprop debug.webgl 1
Includes Cross-origin resource sharing support.
Includes fixes for the following Khronos WebGL 1.0.1. tests:
- premultiplyalpha-test.html
- struct-nesting-exceeds-maximum.html
- index-validation.html
- context-attributes-alpha-depth-stencil-antialias.html
- program-test.html
- object-deletion-behaviour.html
Squashed patches:
-----------------------------------------------------------
WebGL implementation for Android
Implementation of WebGL in Android WebKit. Exposes a low level 3D
graphics API based on OpenGL ES 2.0 to JavaScript. WebGL is not compiled
by default. It can be enabled by setting ENABLE_WEBGL = true in your
device BoardConfig.mk or directly in external/webkit/Android.mk. It is
also disabled by default (in WebSettings.cpp) as required by Khronos
until it reaches 100% conformance.
--
From: Anders Edenbrandt <anders.edenbrandt@sonyericsson.com>
Date: Thu, 26 Jan 2012 11:48:41 +0100
WebGL bug fixes and updates
Some updates:
- stability fixes
- image decoder
- redesign of how the FBOs are used
- other bug fixes
--
From: Anders Edenbrandt <anders.edenbrandt@sonyericsson.com>
Date: Tue, 31 Jan 2012 17:20:13 +0100
WebGL code cleanup and bug fixes
--
From: Anders Edenbrandt <anders.edenbrandt@sonyericsson.com>
Date: Thu Mar 15 10:15:33 2012 +0100
More improvements and bug fixes
Updates:
- cleaned up buffer handling, allowing for arbitrary number of buffers
- removed rect from invalidation
- removed screen update request from drawGL
- releasing buffers when the browser is paused
- added missing method 'slice' for typed arrays
- fixed bug in bindFramebuffer
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=c72ff2aa562941d94ceb51ba685d60809ca882a6
Updates to fix some test failures in Khronos Conformance Test Suite:
- Increase max identifier length in shaders to 256
- Add length check on uniforms and attributes
- Add minimal support for compressed textures
(that is, just return the correct error codes)
- Add support for Uint8ClampedByteArray
- Modify how error checking is done on framebuffer operations
- Activate the GL_OES_packed_depth_stencil extension
- Activate the GL_OES_texture_float extension
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=5bfe05848c12a2894697fbb503cfa79981eb96bd
Fix WebGL 1.0.1 premultiplyalpha-test conformance test
Fixing bug with toDataURL when called against a Canvas in which WebGL
content is being rendered and make sure paintRenderingResultsToImageData
isn't used for the premultiplied case.
ihttps://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=5834a1e00f89d898a7a0039d47916b196e40a2c8
Update ANGLE to r1009 to fix WebGL 1.0.1 conformance test
Fixes struct-nesting-exceeds-maximum Khronos WebGL conformance test.
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=ae2392db6360b41a5717f3770a9e63b1bcea45d6
vertexAttribPointer needs to reject large negative offsets
https://bugs.webkit.org/show_bug.cgi?id=85117
Reviewed by Kenneth Russell.
Source/WebCore:
* html/canvas/WebGLRenderingContext.cpp: Use long long for GLsizeiptr and GLintptr
(WebCore):
(WebCore::WebGLRenderingContext::bufferData):
(WebCore::WebGLRenderingContext::bufferSubData):
(WebCore::WebGLRenderingContext::drawElements):
(WebCore::WebGLRenderingContext::getVertexAttribOffset):
(WebCore::WebGLRenderingContext::vertexAttribPointer):
* html/canvas/WebGLRenderingContext.h: Ditto
(WebGLRenderingContext):
* html/canvas/WebGLRenderingContext.idl: Ditto
LayoutTests:
* fast/canvas/webgl/index-validation-expected.txt:
* fast/canvas/webgl/index-validation.html: Add a test case for large negative offset.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@116374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=b3a02a0942a0e2c44d23961382145fad6016b2ef
Fix for context-attributes-alpha-depth-stencil-antialias
Support for alpha, depth and stencil to fix WebGL Khronos 1.0.1
conformance test. Report back that antialiasing is not supported on our
platform.
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=22e98195ac73e7e12a59d5b9a42dfc4e2252b475
WebGLRenderingContext should defer caching program info
https://bugs.webkit.org/show_bug.cgi?id=83513
Reviewed by Kenneth Russell.
* html/canvas/WebGLProgram.cpp:
(WebCore::WebGLProgram::WebGLProgram):
(WebCore::WebGLProgram::numActiveAttribLocations): call cacheInfoIfNeeded();
(WebCore::WebGLProgram::getActiveAttribLocation): Ditto.
(WebCore::WebGLProgram::isUsingVertexAttrib0): Ditto.
(WebCore::WebGLProgram::getLinkStatus): Ditto.
(WebCore):
(WebCore::WebGLProgram::cacheActiveAttribLocations):
(WebCore::WebGLProgram::cacheInfoIfNeeded): Cache link status, active attire locations, etc if needed.
(WebCore::WebGLProgram::increaseLinkCount): also invalidate cached info.
* html/canvas/WebGLProgram.h:
(WebGLProgram):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::linkProgram): Do not cache program info immediately.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113915 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=66bc9c1b9eb5151b1b236199d0eeb17df0557b47
Runtime enablement of WebGL
Hooks up with the Java side to enable/disable WebGL through the debug
menu.
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=75aab57859de45a0aaec5a7cad41a12111e9a82e
Support the usage of CORS for WebGL and the 2D canvas
Factor CORS request preparation out of DocumentThreadableLoader
https://bugs.webkit.org/show_bug.cgi?id=61209
2011-05-20 Adam Barth <abarth@webkit.org>
Reviewed by Alexey Proskuryakov.
Factor CORS request preparation out of DocumentThreadableLoader
https://bugs.webkit.org/show_bug.cgi?id=61209
DocumentThreadableLoader has two jobs:
1) Proxy loads between threads.
2) Run the CORS state machine.
This patch begins the work of separating those concerns, allowing CORS
to be used elsewhere in the loading pipeline. In particular, this
patch moves knowledge of how to prepare CORS requests out of
DocumentThreadableLoder.
* loader/CrossOriginAccessControl.cpp:
(WebCore::isOnAccessControlSimpleRequestHeaderWhitelist):
(WebCore::updateRequestForAccessControl):
(WebCore::createAccessControlPreflightRequest):
* loader/CrossOriginAccessControl.h:
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
(WebCore::DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest):
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add rel type prerender to distinguish prerender from prefetch
https://bugs.webkit.org/show_bug.cgi?id=61079
2011-05-21 Gavin Peters <gavinp@chromium.org>
Reviewed by Adam Barth.
Add rel type prerender to distinguish prerender from prefetch
https://bugs.webkit.org/show_bug.cgi?id=61079
Chrome right now uses <link rel=prefetch ...> for one of two things,
to warm the cache in the same way as firefox, or to launch a speculative
rendering of a web page, for faster "loading" when the user navigates to it.
This new rel type will let us distinguish the two cases; the rel type prerender
isn't used on the web today, but the Google Web Search example prerendering application
is ready to experiment with it.
* fast/dom/HTMLLinkElement/prerender-expected.txt: Added.
* fast/dom/HTMLLinkElement/prerender.html: Added.
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
2011-05-21 Gavin Peters <gavinp@chromium.org>
Reviewed by Adam Barth.
Add rel type prerender to distinguish prerender from prefetch
https://bugs.webkit.org/show_bug.cgi?id=61079
Chrome right now uses <link rel=prefetch ...> for one of two things,
to warm the cache in the same way as firefox, or to launch a speculative
rendering of a web page, for faster "loading" when the user navigates to it.
This new rel type will let us distinguish the two cases; the rel type prerender
isn't used on the web today, but the Google Web Search example prerendering application
is ready to experiment with it.
Test: fast/dom/HTMLLinkElement/prerender.html
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::tokenizeRelAttribute):
(WebCore::HTMLLinkElement::process):
* html/HTMLLinkElement.h:
(WebCore::HTMLLinkElement::RelAttribute::RelAttribute):
* loader/cache/CachedResource.cpp:
(WebCore::defaultPriorityForResourceType):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::isLinkResource):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::createResource):
(WebCore::CachedResourceLoader::requestLinkResource):
(WebCore::CachedResourceLoader::canRequest):
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedResourceRequest.cpp:
(WebCore::cachedResourceTypeToTargetType):
(WebCore::CachedResourceRequest::load):
* platform/network/ResourceRequestBase.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make CachedResource take a ResourceRequest instead of just a url string.
2011-05-24 Nate Chapin <japhet@chromium.org>
Reviewed by Adam Barth.
Change CachedResources to take a ResourceRequest instead of
a url in their constructors and provide a very minimal set of
cases for avoiding reusing a CachedResource. The ResourceRequest
part of this change requires pushing responsibility
for calling Document::completeURL() to the caller, instead of
CachedResourceLoader, since ResourceRequest ASSERTs if it
is constructed with an invalid url.
https://bugs.webkit.org/show_bug.cgi?id=61318
Refactor, no new tests.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::insertedIntoParent):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestScript):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/cache/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::CachedCSSStyleSheet):
(WebCore::CachedCSSStyleSheet::didAddClient):
(WebCore::CachedCSSStyleSheet::checkNotify):
* loader/cache/CachedCSSStyleSheet.h:
* loader/cache/CachedFont.cpp:
(WebCore::CachedFont::CachedFont):
* loader/cache/CachedFont.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::CachedImage):
(WebCore::CachedImage::checkShouldPaintBrokenImage):
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
(WebCore::reuseRequest):
(WebCore::CachedResource::allowReuseOfRequest):
(WebCore::CachedResource::removeClient):
(WebCore::CachedResource::canUseCacheValidator):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::resourceRequest):
(WebCore::CachedResource::url):
* loader/cache/CachedResourceLoader.cpp:
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::load):
* loader/cache/CachedScript.cpp:
(WebCore::CachedScript::CachedScript):
* loader/cache/CachedScript.h:
* loader/cache/CachedXSLStyleSheet.cpp:
(WebCore::CachedXSLStyleSheet::CachedXSLStyleSheet):
(WebCore::CachedXSLStyleSheet::didAddClient):
(WebCore::CachedXSLStyleSheet::checkNotify):
* loader/cache/CachedXSLStyleSheet.h:
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::requestImageResource):
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::loadFont):
* xml/XSLImportRule.cpp:
(WebCore::XSLImportRule::loadSheet):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Support cross-origin property for images
2011-05-26 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
Support cross-origin property for images
https://bugs.webkit.org/show_bug.cgi?id=61015
Test various cases involving CORS requests and canvas tainting.
* http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html: Added.
* http/tests/security/canvas-remote-read-remote-image-allowed.html: Added.
* http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html: Added.
* http/tests/security/resources/abe-allow-credentials.php: Added.
* http/tests/security/resources/abe-allow-star.php: Added.
2011-05-26 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
Support cross-origin property for images
https://bugs.webkit.org/show_bug.cgi?id=61015
This patch add support for the crossorigin attribute of images and
teaches 2D canvas to respect that flag and not taint a canvas if the
image drawn on the canvas is allowed by CORS.
While I was editing this code, I couldn't resist a couple touch-up
changes.
Tests: http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html
http/tests/security/canvas-remote-read-remote-image-allowed.html
http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html
* html/HTMLAttributeNames.in:
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::securityOrigin):
* html/HTMLCanvasElement.h:
* html/HTMLImageElement.idl:
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::checkOrigin):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::createPattern):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::passesAccessControlCheck):
* loader/cache/CachedResource.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87473 268f45cc-cd09-0410-ab3c-d52691b4dbfc
HTMLVideoElement::currentSrc() should return a KURL
2011-05-27 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
HTMLVideoElement::currentSrc() should return a KURL
https://bugs.webkit.org/show_bug.cgi?id=61578
I suspect we got into this mess because the author of this code didn't
know about the URL attribute in WebKit IDL, which is super useful!
Bad news: The line of code in question seems to have another bug, which
I've documented in a FIXME. Let the yak shaving continue!
* html/HTMLMediaElement.cpp:
(WebCore::urlForLogging):
(WebCore::HTMLMediaElement::loadResource):
(WebCore::HTMLMediaElement::isSafeToLoadURL):
(WebCore::HTMLMediaElement::selectNextSourceChild):
(WebCore::HTMLMediaElement::getPluginProxyParams):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::currentSrc):
(WebCore::HTMLMediaElement::currentURL):
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::checkOrigin):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absoluteMediaURL):
- This complete URL call was unnecessary because currentSrc is
already absolute.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Disallow use of cross-domain media (images, video) in WebGL
2011-06-09 Kenneth Russell <kbr@google.com>
Reviewed by Adam Barth.
Disallow use of cross-domain media (images, video) in WebGL
https://bugs.webkit.org/show_bug.cgi?id=62257
Updated WebGL implementation to track recent spec updates in this area.
Tests: http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html
http/tests/security/webgl-remote-read-remote-image-allowed.html
http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::wouldTaintOrigin):
(WebCore::CanvasRenderingContext::checkOrigin):
* html/canvas/CanvasRenderingContext.h:
(WebCore::CanvasRenderingContext::checkOrigin):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::readPixels):
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::videoFrameToImage):
(WebCore::WebGLRenderingContext::texSubImage2D):
* html/canvas/WebGLRenderingContext.h:
2011-06-09 Kenneth Russell <kbr@google.com>
Reviewed by Adam Barth.
Disallow use of cross-domain media (images, video) in WebGL
https://bugs.webkit.org/show_bug.cgi?id=62257
Updated origin-clean-conformance.html to track upstream version in
Khronos repository. Added new layout tests mirroring those added
in bug 61015 which verify that new CORS support for images is
working in the context of WebGL.
Verified new tests in WebKit and Chromium. Skipped tests on
platforms where WebGL is disabled.
* http/tests/canvas/webgl/origin-clean-conformance-expected.txt:
* http/tests/canvas/webgl/origin-clean-conformance.html:
* http/tests/security/webgl-remote-read-remote-image-allowed-expected.txt: Added.
* http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials-expected.txt: Added.
* http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html: Added.
* http/tests/security/webgl-remote-read-remote-image-allowed.html: Added.
* http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin-expected.txt: Added.
* http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html: Added.
* platform/gtk/Skipped:
* platform/mac-leopard/Skipped:
* platform/mac-wk2/Skipped:
* platform/qt/Skipped:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@88489 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=0ddd7c1d91c08fbee6c99b79fa9971a7ac914384
Runtime enablement of WebGL logs
Allows enabling WebGL method level logging using:
adb shell setprop debug.webgl 1
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=307d4a2b5b20f2609497ceaea1eca2e29a8a781f
Adding WebGL FPS timing to logs
Samples WebGL average FPS every 15 frames and outputs to WebGL debug log.
TODO: Add setting to browser debug settings that overlays FPS on web
pages.
Postpone deleteRenderbuffer/deleteTexture until all framebuffer attachment points are removed.
https://bugs.webkit.org/show_bug.cgi?id=74741
Reviewed by Kenneth Russell.
Source/WebCore:
Use WebGLObject's attachment count mechanism to track if a renderbuffer/texture
is still attached to framebuffers, and if its deletion should be delated or not.
* html/canvas/WebGLFramebuffer.cpp:
(WebCore::WebGLFramebuffer::setAttachmentForBoundFramebuffer):
(WebCore::WebGLFramebuffer::getAttachment):
(WebCore::WebGLFramebuffer::removeAttachmentFromBoundFramebuffer):
(WebCore::WebGLFramebuffer::deleteObjectImpl):
(WebCore::WebGLFramebuffer::isBound):
* html/canvas/WebGLFramebuffer.h:
LayoutTests:
* fast/canvas/webgl/object-deletion-behaviour-expected.txt:
* fast/canvas/webgl/object-deletion-behaviour.html: synced with khronos side.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://www.codeaurora.org/gitweb/quic/la/?p=platform/external/webkit.git;a=commit;h=9def386340c74f2a745fb041b1cb11daa30d1a82
-----------------------------------------------------------
(cherry-picked from commit 6d9d732ff06a6b265d02b18d7034068a68ef0fde)
Conflicts:
Android.mk
Source/WebCore/ChangeLog
Change-Id: I3bbf993fe5a3d6cea53e019c8fa3912ecd2bd429
Diffstat (limited to 'Source/WebCore/loader')
20 files changed, 262 insertions, 208 deletions
diff --git a/Source/WebCore/loader/CrossOriginAccessControl.cpp b/Source/WebCore/loader/CrossOriginAccessControl.cpp index 8ca821e..671c185 100644 --- a/Source/WebCore/loader/CrossOriginAccessControl.cpp +++ b/Source/WebCore/loader/CrossOriginAccessControl.cpp @@ -43,7 +43,10 @@ bool isOnAccessControlSimpleRequestMethodWhitelist(const String& method) bool isOnAccessControlSimpleRequestHeaderWhitelist(const String& name, const String& value) { - if (equalIgnoringCase(name, "accept") || equalIgnoringCase(name, "accept-language") || equalIgnoringCase(name, "content-language")) + if (equalIgnoringCase(name, "accept") + || equalIgnoringCase(name, "accept-language") + || equalIgnoringCase(name, "content-language") + || equalIgnoringCase(name, "origin")) return true; // Preflight is required for MIME types that can not be sent via form submission. @@ -93,6 +96,42 @@ bool isOnAccessControlResponseHeaderWhitelist(const String& name) return allowedCrossOriginResponseHeaders->contains(name); } +void updateRequestForAccessControl(ResourceRequest& request, SecurityOrigin* securityOrigin, bool allowCredentials) +{ + request.removeCredentials(); + request.setAllowCookies(allowCredentials); + request.setHTTPOrigin(securityOrigin->toString()); +} + +ResourceRequest createAccessControlPreflightRequest(const ResourceRequest& request, SecurityOrigin* securityOrigin, bool allowCredentials) +{ + ResourceRequest preflightRequest(request.url()); + updateRequestForAccessControl(preflightRequest, securityOrigin, allowCredentials); + preflightRequest.setHTTPMethod("OPTIONS"); + preflightRequest.setHTTPHeaderField("Access-Control-Request-Method", request.httpMethod()); + preflightRequest.setPriority(request.priority()); + + const HTTPHeaderMap& requestHeaderFields = request.httpHeaderFields(); + + if (requestHeaderFields.size() > 0) { + Vector<UChar> headerBuffer; + HTTPHeaderMap::const_iterator it = requestHeaderFields.begin(); + append(headerBuffer, it->first); + ++it; + + HTTPHeaderMap::const_iterator end = requestHeaderFields.end(); + for (; it != end; ++it) { + headerBuffer.append(','); + headerBuffer.append(' '); + append(headerBuffer, it->first); + } + + preflightRequest.setHTTPHeaderField("Access-Control-Request-Headers", String::adopt(headerBuffer)); + } + + return preflightRequest; +} + bool passesAccessControlCheck(const ResourceResponse& response, bool includeCredentials, SecurityOrigin* securityOrigin, String& errorDescription) { // A wildcard Access-Control-Allow-Origin can not be used if credentials are to be sent, diff --git a/Source/WebCore/loader/CrossOriginAccessControl.h b/Source/WebCore/loader/CrossOriginAccessControl.h index 50c231e..74b4d58 100644 --- a/Source/WebCore/loader/CrossOriginAccessControl.h +++ b/Source/WebCore/loader/CrossOriginAccessControl.h @@ -27,20 +27,24 @@ #ifndef CrossOriginAccessControl_h #define CrossOriginAccessControl_h +#include "ResourceRequest.h" #include <wtf/Forward.h> namespace WebCore { - class HTTPHeaderMap; - class ResourceResponse; - class SecurityOrigin; +class HTTPHeaderMap; +class ResourceResponse; +class SecurityOrigin; - bool isSimpleCrossOriginAccessRequest(const String& method, const HTTPHeaderMap&); - bool isOnAccessControlSimpleRequestMethodWhitelist(const String&); - bool isOnAccessControlSimpleRequestHeaderWhitelist(const String& name, const String& value); - bool isOnAccessControlResponseHeaderWhitelist(const String&); +bool isSimpleCrossOriginAccessRequest(const String& method, const HTTPHeaderMap&); +bool isOnAccessControlSimpleRequestMethodWhitelist(const String&); +bool isOnAccessControlSimpleRequestHeaderWhitelist(const String& name, const String& value); +bool isOnAccessControlResponseHeaderWhitelist(const String&); - bool passesAccessControlCheck(const ResourceResponse&, bool includeCredentials, SecurityOrigin*, String& errorDescription); +void updateRequestForAccessControl(ResourceRequest&, SecurityOrigin*, bool allowCredentials); +ResourceRequest createAccessControlPreflightRequest(const ResourceRequest&, SecurityOrigin*, bool allowCredentials); + +bool passesAccessControlCheck(const ResourceResponse&, bool includeCredentials, SecurityOrigin*, String& errorDescription); } // namespace WebCore diff --git a/Source/WebCore/loader/DocumentThreadableLoader.cpp b/Source/WebCore/loader/DocumentThreadableLoader.cpp index 2fbf324..7f545a1 100644 --- a/Source/WebCore/loader/DocumentThreadableLoader.cpp +++ b/Source/WebCore/loader/DocumentThreadableLoader.cpp @@ -89,8 +89,7 @@ DocumentThreadableLoader::DocumentThreadableLoader(Document* document, Threadabl ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); OwnPtr<ResourceRequest> crossOriginRequest = adoptPtr(new ResourceRequest(request)); - crossOriginRequest->removeCredentials(); - crossOriginRequest->setAllowCookies(m_options.allowCredentials); + updateRequestForAccessControl(*crossOriginRequest, m_document->securityOrigin(), m_options.allowCredentials); if (!m_options.forcePreflight && isSimpleCrossOriginAccessRequest(crossOriginRequest->httpMethod(), crossOriginRequest->httpHeaderFields())) makeSimpleCrossOriginAccessRequest(*crossOriginRequest); @@ -109,47 +108,18 @@ void DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest(const Resource ASSERT(isSimpleCrossOriginAccessRequest(request.httpMethod(), request.httpHeaderFields())); // Cross-origin requests are only defined for HTTP. We would catch this when checking response headers later, but there is no reason to send a request that's guaranteed to be denied. + // FIXME: Consider allowing simple CORS requests to non-HTTP URLs. if (!request.url().protocolInHTTPFamily()) { m_client->didFail(ResourceError(errorDomainWebKitInternal, 0, request.url().string(), "Cross origin requests are only supported for HTTP.")); return; } - // Make a copy of the passed request so that we can modify some details. - ResourceRequest crossOriginRequest(request); - crossOriginRequest.setHTTPOrigin(m_document->securityOrigin()->toString()); - - loadRequest(crossOriginRequest, DoSecurityCheck); + loadRequest(request, DoSecurityCheck); } void DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight(const ResourceRequest& request) { - ResourceRequest preflightRequest(request.url()); - preflightRequest.removeCredentials(); - preflightRequest.setHTTPOrigin(m_document->securityOrigin()->toString()); - preflightRequest.setAllowCookies(m_options.allowCredentials); - preflightRequest.setHTTPMethod("OPTIONS"); - preflightRequest.setHTTPHeaderField("Access-Control-Request-Method", request.httpMethod()); - - const HTTPHeaderMap& requestHeaderFields = request.httpHeaderFields(); - - if (requestHeaderFields.size() > 0) { - Vector<UChar> headerBuffer; - HTTPHeaderMap::const_iterator it = requestHeaderFields.begin(); - append(headerBuffer, it->first); - ++it; - - HTTPHeaderMap::const_iterator end = requestHeaderFields.end(); - for (; it != end; ++it) { - headerBuffer.append(','); - headerBuffer.append(' '); - append(headerBuffer, it->first); - } - - preflightRequest.setHTTPHeaderField("Access-Control-Request-Headers", String::adopt(headerBuffer)); - } - - preflightRequest.setPriority(request.priority()); - + ResourceRequest preflightRequest = createAccessControlPreflightRequest(request, m_document->securityOrigin(), m_options.allowCredentials); loadRequest(preflightRequest, DoSecurityCheck); } diff --git a/Source/WebCore/loader/ImageLoader.cpp b/Source/WebCore/loader/ImageLoader.cpp index 069b40e..0c1fe99 100644 --- a/Source/WebCore/loader/ImageLoader.cpp +++ b/Source/WebCore/loader/ImageLoader.cpp @@ -24,6 +24,7 @@ #include "CachedImage.h" #include "CachedResourceLoader.h" +#include "CrossOriginAccessControl.h" #include "Document.h" #include "Element.h" #include "HTMLNames.h" @@ -160,16 +161,24 @@ void ImageLoader::updateFromElement() // need (<rdar://problem/5994621>). CachedImage* newImage = 0; if (!(attr.isNull() || (attr.isEmpty() && document->baseURI().isLocalFile()))) { + ResourceRequest request = ResourceRequest(document->completeURL(sourceURI(attr))); + + String crossOriginMode = m_element->fastGetAttribute(HTMLNames::crossoriginAttr); + if (!crossOriginMode.isNull()) { + bool allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials"); + updateRequestForAccessControl(request, document->securityOrigin(), allowCredentials); + } + if (m_loadManually) { bool autoLoadOtherImages = document->cachedResourceLoader()->autoLoadImages(); document->cachedResourceLoader()->setAutoLoadImages(false); - newImage = new CachedImage(sourceURI(attr)); + newImage = new CachedImage(request); newImage->setLoading(true); newImage->setOwningCachedResourceLoader(document->cachedResourceLoader()); document->cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage); document->cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages); } else - newImage = document->cachedResourceLoader()->requestImage(sourceURI(attr)); + newImage = document->cachedResourceLoader()->requestImage(request); // If we do not have an image here, it means that a cross-site // violation occurred. diff --git a/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp b/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp index ae7a03c..53a04fb 100644 --- a/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp +++ b/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp @@ -37,8 +37,8 @@ namespace WebCore { -CachedCSSStyleSheet::CachedCSSStyleSheet(const String& url, const String& charset) - : CachedResource(url, CSSStyleSheet) +CachedCSSStyleSheet::CachedCSSStyleSheet(const ResourceRequest& resourceRequest, const String& charset) + : CachedResource(resourceRequest, CSSStyleSheet) , m_decoder(TextResourceDecoder::create("text/css", charset)) { // Prefer text/css but accept any type (dell.com serves a stylesheet @@ -53,7 +53,7 @@ CachedCSSStyleSheet::~CachedCSSStyleSheet() void CachedCSSStyleSheet::didAddClient(CachedResourceClient *c) { if (!isLoading()) - c->setCSSStyleSheet(m_url, m_response.url(), m_decoder->encoding().name(), this); + c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this); } void CachedCSSStyleSheet::allClientsRemoved() @@ -113,7 +113,7 @@ void CachedCSSStyleSheet::checkNotify() CachedResourceClientWalker w(m_clients); while (CachedResourceClient *c = w.next()) - c->setCSSStyleSheet(m_url, m_response.url(), m_decoder->encoding().name(), this); + c->setCSSStyleSheet(m_resourceRequest.url(), m_response.url(), m_decoder->encoding().name(), this); } void CachedCSSStyleSheet::error(CachedResource::Status status) diff --git a/Source/WebCore/loader/cache/CachedCSSStyleSheet.h b/Source/WebCore/loader/cache/CachedCSSStyleSheet.h index a982e03..6398717 100644 --- a/Source/WebCore/loader/cache/CachedCSSStyleSheet.h +++ b/Source/WebCore/loader/cache/CachedCSSStyleSheet.h @@ -37,7 +37,7 @@ namespace WebCore { class CachedCSSStyleSheet : public CachedResource { public: - CachedCSSStyleSheet(const String& URL, const String& charset); + CachedCSSStyleSheet(const ResourceRequest&, const String& charset); virtual ~CachedCSSStyleSheet(); const String sheetText(bool enforceMIMEType = true, bool* hasValidMIMEType = 0) const; diff --git a/Source/WebCore/loader/cache/CachedFont.cpp b/Source/WebCore/loader/cache/CachedFont.cpp index 60f0d6c..3e8508c 100644 --- a/Source/WebCore/loader/cache/CachedFont.cpp +++ b/Source/WebCore/loader/cache/CachedFont.cpp @@ -55,8 +55,8 @@ namespace WebCore { -CachedFont::CachedFont(const String &url) - : CachedResource(url, FontResource) +CachedFont::CachedFont(const ResourceRequest& resourceRequest) + : CachedResource(resourceRequest, FontResource) , m_fontData(0) , m_loadInitiated(false) { diff --git a/Source/WebCore/loader/cache/CachedFont.h b/Source/WebCore/loader/cache/CachedFont.h index dd9d60e..68dd01d 100644 --- a/Source/WebCore/loader/cache/CachedFont.h +++ b/Source/WebCore/loader/cache/CachedFont.h @@ -49,7 +49,7 @@ struct FontCustomPlatformData; class CachedFont : public CachedResource { public: - CachedFont(const String& url); + CachedFont(const ResourceRequest&); virtual ~CachedFont(); virtual void load(CachedResourceLoader* cachedResourceLoader); diff --git a/Source/WebCore/loader/cache/CachedImage.cpp b/Source/WebCore/loader/cache/CachedImage.cpp index 6867302..e96d784 100644 --- a/Source/WebCore/loader/cache/CachedImage.cpp +++ b/Source/WebCore/loader/cache/CachedImage.cpp @@ -52,8 +52,8 @@ using std::max; namespace WebCore { -CachedImage::CachedImage(const String& url) - : CachedResource(url, ImageResource) +CachedImage::CachedImage(const ResourceRequest& resourceRequest) + : CachedResource(resourceRequest, ImageResource) , m_image(0) , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired) , m_shouldPaintBrokenImage(true) @@ -63,7 +63,7 @@ CachedImage::CachedImage(const String& url) } CachedImage::CachedImage(Image* image) - : CachedResource(String(), ImageResource) + : CachedResource(ResourceRequest(), ImageResource) , m_image(image) , m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired) , m_shouldPaintBrokenImage(true) @@ -86,7 +86,7 @@ void CachedImage::decodedDataDeletionTimerFired(Timer<CachedImage>*) void CachedImage::load(CachedResourceLoader* cachedResourceLoader) { #ifdef ANDROID_BLOCK_NETWORK_IMAGE - if (!cachedResourceLoader || (cachedResourceLoader->autoLoadImages() && !cachedResourceLoader->shouldBlockNetworkImage(m_url))) + if (!cachedResourceLoader || (cachedResourceLoader->autoLoadImages() && !cachedResourceLoader->shouldBlockNetworkImage(m_resourceRequest.url()))) #else if (!cachedResourceLoader || cachedResourceLoader->autoLoadImages()) #endif @@ -231,7 +231,7 @@ void CachedImage::checkShouldPaintBrokenImage() if (!frame) return; - m_shouldPaintBrokenImage = frame->loader()->client()->shouldPaintBrokenImage(KURL(ParsedURLString, m_url)); + m_shouldPaintBrokenImage = frame->loader()->client()->shouldPaintBrokenImage(m_resourceRequest.url()); } void CachedImage::clear() diff --git a/Source/WebCore/loader/cache/CachedImage.h b/Source/WebCore/loader/cache/CachedImage.h index 79643d7..dc12ba2 100644 --- a/Source/WebCore/loader/cache/CachedImage.h +++ b/Source/WebCore/loader/cache/CachedImage.h @@ -38,7 +38,7 @@ class CachedImage : public CachedResource, public ImageObserver { friend class MemoryCache; public: - CachedImage(const String& url); + CachedImage(const ResourceRequest&); CachedImage(Image*); virtual ~CachedImage(); diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp index e599769..ab92bec 100644 --- a/Source/WebCore/loader/cache/CachedResource.cpp +++ b/Source/WebCore/loader/cache/CachedResource.cpp @@ -31,6 +31,7 @@ #include "CachedResourceHandle.h" #include "CachedResourceLoader.h" #include "CachedResourceRequest.h" +#include "CrossOriginAccessControl.h" #include "Frame.h" #include "FrameLoaderClient.h" #include "KURL.h" @@ -62,7 +63,11 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type case CachedResource::ImageResource: return ResourceLoadPriorityLow; #if ENABLE(LINK_PREFETCH) - case CachedResource::LinkResource: + case CachedResource::LinkPrefetch: + return ResourceLoadPriorityVeryLow; + case CachedResource::LinkPrerender: + return ResourceLoadPriorityVeryLow; + case CachedResource::LinkSubresource: return ResourceLoadPriorityVeryLow; #endif } @@ -74,8 +79,8 @@ static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type static RefCountedLeakCounter cachedResourceLeakCounter("CachedResource"); #endif -CachedResource::CachedResource(const String& url, Type type) - : m_url(url) +CachedResource::CachedResource(const ResourceRequest& request, Type type) + : m_resourceRequest(request) , m_request(0) , m_loadPriority(defaultPriorityForResourceType(type)) , m_responseTimestamp(currentTime()) @@ -168,6 +173,12 @@ void CachedResource::finish() m_status = Cached; } +bool CachedResource::passesAccessControlCheck(SecurityOrigin* securityOrigin) +{ + String errorDescription; + return WebCore::passesAccessControlCheck(m_response, resourceRequest().allowCookies(), securityOrigin, errorDescription); +} + bool CachedResource::isExpired() const { if (m_response.isNull()) diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h index 2f33ac7..f216527 100644 --- a/Source/WebCore/loader/cache/CachedResource.h +++ b/Source/WebCore/loader/cache/CachedResource.h @@ -28,6 +28,7 @@ #include "PlatformString.h" #include "PurgePriority.h" #include "ResourceLoadPriority.h" +#include "ResourceRequest.h" #include "ResourceResponse.h" #include <wtf/HashCountedSet.h> #include <wtf/HashSet.h> @@ -46,6 +47,7 @@ class CachedResourceRequest; class Frame; class InspectorResource; class PurgeableBuffer; +class SecurityOrigin; // A resource that is held in the cache. Classes who want to use this object should derive // from CachedResourceClient, to get the function calls in case the requested data has arrived. @@ -54,7 +56,7 @@ class CachedResource { WTF_MAKE_NONCOPYABLE(CachedResource); WTF_MAKE_FAST_ALLOCATED; friend class MemoryCache; friend class InspectorResource; - + public: enum Type { ImageResource, @@ -65,7 +67,9 @@ public: , XSLStyleSheet #endif #if ENABLE(LINK_PREFETCH) - , LinkResource + , LinkPrefetch + , LinkPrerender + , LinkSubresource #endif }; @@ -77,9 +81,9 @@ public: DecodeError }; - CachedResource(const String& url, Type); + CachedResource(const ResourceRequest&, Type); virtual ~CachedResource(); - + virtual void load(CachedResourceLoader* cachedResourceLoader) { load(cachedResourceLoader, false, DoSecurityCheck, true); } void load(CachedResourceLoader*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks); @@ -90,9 +94,10 @@ public: virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; } - const String &url() const { return m_url; } + ResourceRequest& resourceRequest() { return m_resourceRequest; } + const KURL& url() const { return m_resourceRequest.url();} Type type() const { return static_cast<Type>(m_type); } - + ResourceLoadPriority loadPriority() const { return m_loadPriority; } void setLoadPriority(ResourceLoadPriority); @@ -122,7 +127,7 @@ public: unsigned encodedSize() const { return m_encodedSize; } unsigned decodedSize() const { return m_decodedSize; } unsigned overheadSize() const; - + bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccurate. Loading might not have started yet. bool isLoading() const { return m_loading; } @@ -133,7 +138,7 @@ public: bool isLinkResource() const { #if ENABLE(LINK_PREFETCH) - return type() == LinkResource; + return type() == LinkPrefetch || type() == LinkPrerender || type() == LinkSubresource; #else return false; #endif @@ -142,20 +147,22 @@ public: unsigned accessCount() const { return m_accessCount; } void increaseAccessCount() { m_accessCount++; } - // Computes the status of an object after loading. + // Computes the status of an object after loading. // Updates the expire date on the cache entry file void finish(); + bool passesAccessControlCheck(SecurityOrigin*); + // Called by the cache if the object has been removed from the cache // while still being referenced. This means the object should delete itself // if the number of clients observing it ever drops to 0. // The resource can be brought back to cache after successful revalidation. void setInCache(bool inCache) { m_inCache = inCache; } bool inCache() const { return m_inCache; } - + void setInLiveDecodedResourcesList(bool b) { m_inLiveDecodedResourcesList = b; } bool inLiveDecodedResourcesList() { return m_inLiveDecodedResourcesList; } - + void setRequest(CachedResourceRequest*); SharedBuffer* data() const { ASSERT(!m_purgeableData); return m_data.get(); } @@ -186,26 +193,26 @@ public: bool errorOccurred() const { return (status() == LoadError || status() == DecodeError); } bool sendResourceLoadCallbacks() const { return m_sendResourceLoadCallbacks; } - + virtual void destroyDecodedData() { } void setOwningCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) { m_owningCachedResourceLoader = cachedResourceLoader; } - + bool isPreloaded() const { return m_preloadCount; } void increasePreloadCount() { ++m_preloadCount; } void decreasePreloadCount() { ASSERT(m_preloadCount); --m_preloadCount; } - + void registerHandle(CachedResourceHandleBase* h); void unregisterHandle(CachedResourceHandleBase* h); - + bool canUseCacheValidator() const; bool mustRevalidateDueToCacheHeaders(CachePolicy) const; bool isCacheValidator() const { return m_resourceToRevalidate; } CachedResource* resourceToRevalidate() const { return m_resourceToRevalidate; } - + bool isPurgeable() const; bool wasPurged() const; - + // This is used by the archive machinery to get at a purged resource without // triggering a load. We should make it protected again if we can find a // better way to handle the archive case. @@ -225,10 +232,10 @@ protected: void didAccessDecodedData(double timeStamp); bool isSafeToMakePurgeable() const; - + HashCountedSet<CachedResourceClient*> m_clients; - String m_url; + ResourceRequest m_resourceRequest; String m_accept; CachedResourceRequest* m_request; ResourceLoadPriority m_loadPriority; @@ -276,12 +283,12 @@ private: CachedResource* m_nextInAllResourcesList; CachedResource* m_prevInAllResourcesList; - + CachedResource* m_nextInLiveResourcesList; CachedResource* m_prevInLiveResourcesList; CachedResourceLoader* m_owningCachedResourceLoader; // only non-0 for resources that are not in the cache - + // If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date // using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved // to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp index fe25a93..6511b5e 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp +++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp @@ -55,24 +55,28 @@ namespace WebCore { -static CachedResource* createResource(CachedResource::Type type, const KURL& url, const String& charset) +static CachedResource* createResource(CachedResource::Type type, ResourceRequest& request, const String& charset) { switch (type) { case CachedResource::ImageResource: - return new CachedImage(url.string()); + return new CachedImage(request); case CachedResource::CSSStyleSheet: - return new CachedCSSStyleSheet(url.string(), charset); + return new CachedCSSStyleSheet(request, charset); case CachedResource::Script: - return new CachedScript(url.string(), charset); + return new CachedScript(request, charset); case CachedResource::FontResource: - return new CachedFont(url.string()); + return new CachedFont(request); #if ENABLE(XSLT) case CachedResource::XSLStyleSheet: - return new CachedXSLStyleSheet(url.string()); + return new CachedXSLStyleSheet(request); #endif #if ENABLE(LINK_PREFETCH) - case CachedResource::LinkResource: - return new CachedResource(url.string(), CachedResource::LinkResource); + case CachedResource::LinkPrefetch: + return new CachedResource(request, CachedResource::LinkPrefetch); + case CachedResource::LinkPrerender: + return new CachedResource(request, CachedResource::LinkPrerender); + case CachedResource::LinkSubresource: + return new CachedResource(request, CachedResource::LinkSubresource); #endif } ASSERT_NOT_REACHED(); @@ -106,16 +110,16 @@ CachedResourceLoader::~CachedResourceLoader() ASSERT(m_requestCount == 0); } -CachedResource* CachedResourceLoader::cachedResource(const String& resourceURL) const +CachedResource* CachedResourceLoader::cachedResource(const String& resourceURL) const { KURL url = m_document->completeURL(resourceURL); - return cachedResource(url); + return cachedResource(url); } CachedResource* CachedResourceLoader::cachedResource(const KURL& resourceURL) const { KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(resourceURL); - return m_documentResources.get(url).get(); + return m_documentResources.get(url).get(); } Frame* CachedResourceLoader::frame() const @@ -123,7 +127,7 @@ Frame* CachedResourceLoader::frame() const return m_document ? m_document->frame() : 0; } -CachedImage* CachedResourceLoader::requestImage(const String& url) +CachedImage* CachedResourceLoader::requestImage(ResourceRequest& request) { if (Frame* f = frame()) { Settings* settings = f->settings(); @@ -131,22 +135,22 @@ CachedImage* CachedResourceLoader::requestImage(const String& url) return 0; if (f->loader()->pageDismissalEventBeingDispatched()) { - KURL completeURL = m_document->completeURL(url); - if (completeURL.isValid() && canRequest(CachedResource::ImageResource, completeURL)) - PingLoader::loadImage(f, completeURL); + KURL requestURL = request.url(); + if (requestURL.isValid() && canRequest(CachedResource::ImageResource, requestURL)) + PingLoader::loadImage(f, requestURL); return 0; } } - CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, url, String())); + CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, request, String())); if (resource) { #ifdef ANDROID_BLOCK_NETWORK_IMAGE - resource->setAutoLoadWasPreventedBySettings(!autoLoadImages() || shouldBlockNetworkImage(url)); + resource->setAutoLoadWasPreventedBySettings(!autoLoadImages() || shouldBlockNetworkImage(request.url())); #else resource->setAutoLoadWasPreventedBySettings(!autoLoadImages()); #endif if (autoLoadImages() && resource->stillNeedsLoad()) { #ifdef ANDROID_BLOCK_NETWORK_IMAGE - if (shouldBlockNetworkImage(url)) { + if (shouldBlockNetworkImage(request.url())) { return resource; } #endif @@ -157,56 +161,60 @@ CachedImage* CachedResourceLoader::requestImage(const String& url) return resource; } -CachedFont* CachedResourceLoader::requestFont(const String& url) +CachedFont* CachedResourceLoader::requestFont(ResourceRequest& request) { - return static_cast<CachedFont*>(requestResource(CachedResource::FontResource, url, String())); + return static_cast<CachedFont*>(requestResource(CachedResource::FontResource, request, String())); } -CachedCSSStyleSheet* CachedResourceLoader::requestCSSStyleSheet(const String& url, const String& charset, ResourceLoadPriority priority) +CachedCSSStyleSheet* CachedResourceLoader::requestCSSStyleSheet(ResourceRequest& request, const String& charset, ResourceLoadPriority priority) { - return static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, url, charset, priority)); + return static_cast<CachedCSSStyleSheet*>(requestResource(CachedResource::CSSStyleSheet, request, charset, priority)); } -CachedCSSStyleSheet* CachedResourceLoader::requestUserCSSStyleSheet(const String& requestURL, const String& charset) +CachedCSSStyleSheet* CachedResourceLoader::requestUserCSSStyleSheet(ResourceRequest& request, const String& charset) { - KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(KURL(KURL(), requestURL)); + KURL url = MemoryCache::removeFragmentIdentifierIfNeeded(request.url()); if (CachedResource* existing = memoryCache()->resourceForURL(url)) { if (existing->type() == CachedResource::CSSStyleSheet) return static_cast<CachedCSSStyleSheet*>(existing); memoryCache()->remove(existing); } - CachedCSSStyleSheet* userSheet = new CachedCSSStyleSheet(url, charset); - + if (url.string() != request.url()) + request.setURL(url); + + CachedCSSStyleSheet* userSheet = new CachedCSSStyleSheet(request, charset); + bool inCache = memoryCache()->add(userSheet); if (!inCache) userSheet->setInCache(true); - + userSheet->load(this, /*incremental*/ false, SkipSecurityCheck, /*sendResourceLoadCallbacks*/ false); if (!inCache) userSheet->setInCache(false); - + return userSheet; } -CachedScript* CachedResourceLoader::requestScript(const String& url, const String& charset) +CachedScript* CachedResourceLoader::requestScript(ResourceRequest& request, const String& charset) { - return static_cast<CachedScript*>(requestResource(CachedResource::Script, url, charset)); + return static_cast<CachedScript*>(requestResource(CachedResource::Script, request, charset)); } #if ENABLE(XSLT) -CachedXSLStyleSheet* CachedResourceLoader::requestXSLStyleSheet(const String& url) +CachedXSLStyleSheet* CachedResourceLoader::requestXSLStyleSheet(ResourceRequest& request) { - return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, url, String())); + return static_cast<CachedXSLStyleSheet*>(requestResource(CachedResource::XSLStyleSheet, request, String())); } #endif #if ENABLE(LINK_PREFETCH) -CachedResource* CachedResourceLoader::requestLinkResource(const String& url, ResourceLoadPriority priority) +CachedResource* CachedResourceLoader::requestLinkResource(CachedResource::Type type, ResourceRequest& request, ResourceLoadPriority priority) { ASSERT(frame()); - return requestResource(CachedResource::LinkResource, url, String(), priority); + ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkPrerender || type == CachedResource::LinkSubresource); + return requestResource(type, request, String(), priority); } #endif @@ -221,7 +229,9 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url case CachedResource::Script: case CachedResource::FontResource: #if ENABLE(LINK_PREFETCH) - case CachedResource::LinkResource: + case CachedResource::LinkPrefetch: + case CachedResource::LinkPrerender: + case CachedResource::LinkSubresource: #endif // These types of resources can be loaded from any origin. // FIXME: Are we sure about CachedResource::FontResource? @@ -242,7 +252,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url // Note: Currently, we always allow mixed content, but we generate a // callback to the FrameLoaderClient in case the embedder wants to // update any security indicators. - // + // switch (type) { case CachedResource::Script: #if ENABLE(XSLT) @@ -263,7 +273,9 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url break; } #if ENABLE(LINK_PREFETCH) - case CachedResource::LinkResource: + case CachedResource::LinkPrefetch: + case CachedResource::LinkPrerender: + case CachedResource::LinkSubresource: // Prefetch cannot affect the current document. break; #endif @@ -292,9 +304,9 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url break; } #if ENABLE(LINK_PREFETCH) - case CachedResource::LinkResource: - if (!m_document->settings()->linkPrefetchEnabled()) - return false; + case CachedResource::LinkPrefetch: + case CachedResource::LinkPrerender: + case CachedResource::LinkSubresource: break; #endif } @@ -302,18 +314,18 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url return true; } -CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, const String& resourceURL, const String& charset, ResourceLoadPriority priority, bool forPreload) +CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, ResourceRequest& request, const String& charset, ResourceLoadPriority priority, bool forPreload) { - KURL url = m_document->completeURL(resourceURL); - + KURL url = request.url(); + LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.string().latin1().data(), charset.latin1().data(), priority, forPreload); - + // If only the fragment identifiers differ, it is the same resource. url = MemoryCache::removeFragmentIdentifierIfNeeded(url); if (!url.isValid()) return 0; - + if (!canRequest(type, url)) return 0; @@ -336,13 +348,16 @@ CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, // See if we can use an existing resource from the cache. CachedResource* resource = memoryCache()->resourceForURL(url); + if (request.url() != url) + request.setURL(url); + switch (determineRevalidationPolicy(type, forPreload, resource)) { case Load: - resource = loadResource(type, url, charset, priority); + resource = loadResource(type, request, charset, priority); break; case Reload: memoryCache()->remove(resource); - resource = loadResource(type, url, charset, priority); + resource = loadResource(type, request, charset, priority); break; case Revalidate: resource = revalidateResource(resource, priority); @@ -358,10 +373,10 @@ CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, ASSERT(resource->url() == url.string()); m_documentResources.set(resource->url(), resource); - + return resource; } - + CachedResource* CachedResourceLoader::revalidateResource(CachedResource* resource, ResourceLoadPriority priority) { ASSERT(resource); @@ -369,42 +384,42 @@ CachedResource* CachedResourceLoader::revalidateResource(CachedResource* resourc ASSERT(!memoryCache()->disabled()); ASSERT(resource->canUseCacheValidator()); ASSERT(!resource->resourceToRevalidate()); - + // Copy the URL out of the resource to be revalidated in case it gets deleted by the remove() call below. String url = resource->url(); - CachedResource* newResource = createResource(resource->type(), KURL(ParsedURLString, url), resource->encoding()); - + CachedResource* newResource = createResource(resource->type(), resource->resourceRequest(), resource->encoding()); + LOG(ResourceLoading, "Resource %p created to revalidate %p", newResource, resource); newResource->setResourceToRevalidate(resource); - + memoryCache()->remove(resource); memoryCache()->add(newResource); - + newResource->setLoadPriority(priority); newResource->load(this); - + m_validatedURLs.add(url); return newResource; } -CachedResource* CachedResourceLoader::loadResource(CachedResource::Type type, const KURL& url, const String& charset, ResourceLoadPriority priority) +CachedResource* CachedResourceLoader::loadResource(CachedResource::Type type, ResourceRequest& request, const String& charset, ResourceLoadPriority priority) { - ASSERT(!memoryCache()->resourceForURL(url)); - - LOG(ResourceLoading, "Loading CachedResource for '%s'.", url.string().latin1().data()); - - CachedResource* resource = createResource(type, url, charset); - + ASSERT(!memoryCache()->resourceForURL(request.url())); + + LOG(ResourceLoading, "Loading CachedResource for '%s'.", request.url().string().latin1().data()); + + CachedResource* resource = createResource(type, request, charset); + bool inCache = memoryCache()->add(resource); - + // Pretend the resource is in the cache, to prevent it from being deleted during the load() call. // FIXME: CachedResource should just use normal refcounting instead. if (!inCache) resource->setInCache(true); - + resource->setLoadPriority(priority); resource->load(this); - + if (!inCache) { resource->setOwningCachedResourceLoader(this); resource->setInCache(false); @@ -419,7 +434,7 @@ CachedResource* CachedResourceLoader::loadResource(CachedResource::Type type, co return 0; } - m_validatedURLs.add(url.string()); + m_validatedURLs.add(request.url()); return resource; } @@ -427,25 +442,25 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida { if (!existingResource) return Load; - + // We already have a preload going for this URL. if (forPreload && existingResource->isPreloaded()) return Use; - + // If the same URL has been loaded as a different type, we need to reload. if (existingResource->type() != type) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to type mismatch."); return Reload; } - + // Don't reload resources while pasting. if (m_allowStaleResources) return Use; - + // Alwaus use preloads. if (existingResource->isPreloaded()) return Use; - + // CachePolicyHistoryBuffer uses the cache no matter what. if (cachePolicy() == CachePolicyHistoryBuffer) return Use; @@ -459,19 +474,19 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida // Avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to. if (m_validatedURLs.contains(existingResource->url())) return Use; - + // CachePolicyReload always reloads if (cachePolicy() == CachePolicyReload) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to CachePolicyReload."); return Reload; } - + // We'll try to reload the resource if it failed last time. if (existingResource->errorOccurred()) { LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicye reloading due to resource being in the error state"); return Reload; } - + // For resources that are not yet loaded we ignore the cache policy. if (existingResource->isLoading()) return Use; @@ -481,9 +496,9 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida // See if the resource has usable ETag or Last-modified headers. if (existingResource->canUseCacheValidator()) return Revalidate; - + // No, must reload. - LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to missing cache validators."); + LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to missing cache validators."); return Reload; } @@ -675,8 +690,8 @@ int CachedResourceLoader::requestCount() return m_requestCount + 1; return m_requestCount; } - -void CachedResourceLoader::preload(CachedResource::Type type, const String& url, const String& charset, bool referencedFromBody) + +void CachedResourceLoader::preload(CachedResource::Type type, ResourceRequest& request, const String& charset, bool referencedFromBody) { // FIXME: Rip this out when we are sure it is no longer necessary (even for mobile). UNUSED_PARAM(referencedFromBody); @@ -686,33 +701,33 @@ void CachedResourceLoader::preload(CachedResource::Type type, const String& url, if (!hasRendering && !canBlockParser) { // Don't preload subresources that can't block the parser before we have something to draw. // This helps prevent preloads from delaying first display when bandwidth is limited. - PendingPreload pendingPreload = { type, url, charset }; + PendingPreload pendingPreload = { type, request, charset }; m_pendingPreloads.append(pendingPreload); return; } - requestPreload(type, url, charset); + requestPreload(type, request, charset); } -void CachedResourceLoader::checkForPendingPreloads() +void CachedResourceLoader::checkForPendingPreloads() { if (m_pendingPreloads.isEmpty() || !m_document->body() || !m_document->body()->renderer()) return; while (!m_pendingPreloads.isEmpty()) { PendingPreload preload = m_pendingPreloads.takeFirst(); // Don't request preload if the resource already loaded normally (this will result in double load if the page is being reloaded with cached results ignored). - if (!cachedResource(m_document->completeURL(preload.m_url))) - requestPreload(preload.m_type, preload.m_url, preload.m_charset); + if (!cachedResource(preload.m_request.url())) + requestPreload(preload.m_type, preload.m_request, preload.m_charset); } m_pendingPreloads.clear(); } -void CachedResourceLoader::requestPreload(CachedResource::Type type, const String& url, const String& charset) +void CachedResourceLoader::requestPreload(CachedResource::Type type, ResourceRequest& request, const String& charset) { String encoding; if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet) encoding = charset.isEmpty() ? m_document->charset() : charset; - CachedResource* resource = requestResource(type, url, encoding, ResourceLoadPriorityUnresolved, true); + CachedResource* resource = requestResource(type, request, encoding, ResourceLoadPriorityUnresolved, true); if (!resource || (m_preloads && m_preloads->contains(resource))) return; resource->increasePreloadCount(); @@ -769,7 +784,7 @@ void CachedResourceLoader::printPreloadStats() printf("HIT COMPLETE PRELOAD %s\n", res->url().latin1().data()); else if (res->preloadResult() == CachedResource::PreloadReferencedWhileLoading) printf("HIT LOADING PRELOAD %s\n", res->url().latin1().data()); - + if (res->type() == CachedResource::Script) { scripts++; if (res->preloadResult() < CachedResource::PreloadReferencedWhileLoading) @@ -783,14 +798,14 @@ void CachedResourceLoader::printPreloadStats() if (res->preloadResult() < CachedResource::PreloadReferencedWhileLoading) imageMisses++; } - + if (res->errorOccurred()) memoryCache()->remove(res); - + res->decreasePreloadCount(); } m_preloads.clear(); - + if (scripts) printf("SCRIPTS: %d (%d hits, hit rate %d%%)\n", scripts, scripts - scriptMisses, (scripts - scriptMisses) * 100 / scripts); if (stylesheets) @@ -799,5 +814,5 @@ void CachedResourceLoader::printPreloadStats() printf("IMAGES: %d (%d hits, hit rate %d%%)\n", images, images - imageMisses, (images - imageMisses) * 100 / images); } #endif - + } diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.h b/Source/WebCore/loader/cache/CachedResourceLoader.h index 79c63b9..a3933f3 100644 --- a/Source/WebCore/loader/cache/CachedResourceLoader.h +++ b/Source/WebCore/loader/cache/CachedResourceLoader.h @@ -59,17 +59,17 @@ public: CachedResourceLoader(Document*); ~CachedResourceLoader(); - CachedImage* requestImage(const String& url); - CachedCSSStyleSheet* requestCSSStyleSheet(const String& url, const String& charset, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved); - CachedCSSStyleSheet* requestUserCSSStyleSheet(const String& url, const String& charset); - CachedScript* requestScript(const String& url, const String& charset); - CachedFont* requestFont(const String& url); + CachedImage* requestImage(ResourceRequest&); + CachedCSSStyleSheet* requestCSSStyleSheet(ResourceRequest&, const String& charset, ResourceLoadPriority = ResourceLoadPriorityUnresolved); + CachedCSSStyleSheet* requestUserCSSStyleSheet(ResourceRequest&, const String& charset); + CachedScript* requestScript(ResourceRequest&, const String& charset); + CachedFont* requestFont(ResourceRequest&); #if ENABLE(XSLT) - CachedXSLStyleSheet* requestXSLStyleSheet(const String& url); + CachedXSLStyleSheet* requestXSLStyleSheet(ResourceRequest&); #endif #if ENABLE(LINK_PREFETCH) - CachedResource* requestLinkResource(const String &url, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved); + CachedResource* requestLinkResource(CachedResource::Type, ResourceRequest&, ResourceLoadPriority = ResourceLoadPriorityUnresolved); #endif // Logs an access denied message to the console for the specified URL. @@ -110,15 +110,15 @@ public: void clearPreloads(); void clearPendingPreloads(); - void preload(CachedResource::Type, const String& url, const String& charset, bool referencedFromBody); + void preload(CachedResource::Type, ResourceRequest&, const String& charset, bool referencedFromBody); void checkForPendingPreloads(); void printPreloadStats(); private: - CachedResource* requestResource(CachedResource::Type, const String& url, const String& charset, ResourceLoadPriority priority = ResourceLoadPriorityUnresolved, bool isPreload = false); + CachedResource* requestResource(CachedResource::Type, ResourceRequest&, const String& charset, ResourceLoadPriority = ResourceLoadPriorityUnresolved, bool isPreload = false); CachedResource* revalidateResource(CachedResource*, ResourceLoadPriority priority); - CachedResource* loadResource(CachedResource::Type, const KURL&, const String& charset, ResourceLoadPriority priority); - void requestPreload(CachedResource::Type, const String& url, const String& charset); + CachedResource* loadResource(CachedResource::Type, ResourceRequest&, const String& charset, ResourceLoadPriority); + void requestPreload(CachedResource::Type, ResourceRequest& url, const String& charset); enum RevalidationPolicy { Use, Revalidate, Reload, Load }; RevalidationPolicy determineRevalidationPolicy(CachedResource::Type, bool forPreload, CachedResource* existingResource) const; @@ -142,7 +142,7 @@ private: OwnPtr<ListHashSet<CachedResource*> > m_preloads; struct PendingPreload { CachedResource::Type m_type; - String m_url; + ResourceRequest m_request; String m_charset; }; Deque<PendingPreload> m_pendingPreloads; diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.cpp b/Source/WebCore/loader/cache/CachedResourceRequest.cpp index 9e7fe8f..e4e6b8b 100644 --- a/Source/WebCore/loader/cache/CachedResourceRequest.cpp +++ b/Source/WebCore/loader/cache/CachedResourceRequest.cpp @@ -42,11 +42,8 @@ namespace WebCore { -static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type, ResourceLoadPriority priority) +static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type) { -#if !ENABLE(LINK_PREFETCH) - UNUSED_PARAM(priority); -#endif switch (type) { case CachedResource::CSSStyleSheet: #if ENABLE(XSLT) @@ -60,9 +57,11 @@ static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource case CachedResource::ImageResource: return ResourceRequest::TargetIsImage; #if ENABLE(LINK_PREFETCH) - case CachedResource::LinkResource: - if (priority == ResourceLoadPriorityLowest) - return ResourceRequest::TargetIsPrefetch; + case CachedResource::LinkPrefetch: + return ResourceRequest::TargetIsPrefetch; + case CachedResource::LinkPrerender: + return ResourceRequest::TargetIsSubresource; + case CachedResource::LinkSubresource: return ResourceRequest::TargetIsSubresource; #endif } @@ -89,8 +88,8 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad { RefPtr<CachedResourceRequest> request = adoptRef(new CachedResourceRequest(cachedResourceLoader, resource, incremental)); - ResourceRequest resourceRequest(resource->url()); - resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type(), resource->loadPriority())); + ResourceRequest resourceRequest = resource->resourceRequest(); + resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type())); if (!resource->accept().isEmpty()) resourceRequest.setHTTPAccept(resource->accept()); @@ -113,7 +112,7 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad } #if ENABLE(LINK_PREFETCH) - if (resource->type() == CachedResource::LinkResource) + if (resource->type() == CachedResource::LinkPrefetch || resource->type() == CachedResource::LinkPrerender || resource->type() == CachedResource::LinkSubresource) resourceRequest.setHTTPHeaderField("Purpose", "prefetch"); #endif @@ -124,7 +123,7 @@ PassRefPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad request.get(), resourceRequest, priority, securityCheck, sendResourceLoadCallbacks); if (!loader || loader->reachedTerminalState()) { // FIXME: What if resources in other frames were waiting for this revalidation? - LOG(ResourceLoading, "Cannot start loading '%s'", resource->url().latin1().data()); + LOG(ResourceLoading, "Cannot start loading '%s'", resource->url().string().latin1().data()); cachedResourceLoader->decrementRequestCount(resource); cachedResourceLoader->loadFinishing(); if (resource->resourceToRevalidate()) @@ -149,7 +148,7 @@ void CachedResourceRequest::didFinishLoading(SubresourceLoader* loader, double) ASSERT(loader == m_loader.get()); ASSERT(!m_resource->resourceToRevalidate()); - LOG(ResourceLoading, "Received '%s'.", m_resource->url().latin1().data()); + LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().data()); // Prevent the document from being destroyed before we are done with // the cachedResourceLoader that it will delete when the document gets deleted. @@ -181,7 +180,7 @@ void CachedResourceRequest::didFail(bool cancelled) if (m_finishing) return; - LOG(ResourceLoading, "Failed to load '%s' (cancelled=%d).\n", m_resource->url().latin1().data(), cancelled); + LOG(ResourceLoading, "Failed to load '%s' (cancelled=%d).\n", m_resource->url().string().latin1().data(), cancelled); // Prevent the document from being destroyed before we are done with // the cachedResourceLoader that it will delete when the document gets deleted. diff --git a/Source/WebCore/loader/cache/CachedScript.cpp b/Source/WebCore/loader/cache/CachedScript.cpp index e1a8a32..8c83bca 100644 --- a/Source/WebCore/loader/cache/CachedScript.cpp +++ b/Source/WebCore/loader/cache/CachedScript.cpp @@ -40,8 +40,8 @@ namespace WebCore { -CachedScript::CachedScript(const String& url, const String& charset) - : CachedResource(url, Script) +CachedScript::CachedScript(const ResourceRequest& resourceRequest, const String& charset) + : CachedResource(resourceRequest, Script) , m_decoder(TextResourceDecoder::create("application/javascript", charset)) , m_decodedDataDeletionTimer(this, &CachedScript::decodedDataDeletionTimerFired) { diff --git a/Source/WebCore/loader/cache/CachedScript.h b/Source/WebCore/loader/cache/CachedScript.h index a4ea453..1a76c18 100644 --- a/Source/WebCore/loader/cache/CachedScript.h +++ b/Source/WebCore/loader/cache/CachedScript.h @@ -42,7 +42,7 @@ namespace WebCore { class CachedScript : public CachedResource { public: - CachedScript(const String& url, const String& charset); + CachedScript(const ResourceRequest&, const String& charset); virtual ~CachedScript(); const String& script(); diff --git a/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp b/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp index ca7bf13..62e5048 100644 --- a/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp +++ b/Source/WebCore/loader/cache/CachedXSLStyleSheet.cpp @@ -37,8 +37,8 @@ namespace WebCore { #if ENABLE(XSLT) -CachedXSLStyleSheet::CachedXSLStyleSheet(const String &url) - : CachedResource(url, XSLStyleSheet) +CachedXSLStyleSheet::CachedXSLStyleSheet(const ResourceRequest& resourceRequest) + : CachedResource(resourceRequest, XSLStyleSheet) , m_decoder(TextResourceDecoder::create("text/xsl")) { // It's XML we want. @@ -49,7 +49,7 @@ CachedXSLStyleSheet::CachedXSLStyleSheet(const String &url) void CachedXSLStyleSheet::didAddClient(CachedResourceClient* c) { if (!isLoading()) - c->setXSLStyleSheet(m_url, m_response.url(), m_sheet); + c->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet); } void CachedXSLStyleSheet::setEncoding(const String& chs) @@ -84,7 +84,7 @@ void CachedXSLStyleSheet::checkNotify() CachedResourceClientWalker w(m_clients); while (CachedResourceClient *c = w.next()) - c->setXSLStyleSheet(m_url, m_response.url(), m_sheet); + c->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet); } void CachedXSLStyleSheet::error(CachedResource::Status status) diff --git a/Source/WebCore/loader/cache/CachedXSLStyleSheet.h b/Source/WebCore/loader/cache/CachedXSLStyleSheet.h index 8b29792..b8f7283 100644 --- a/Source/WebCore/loader/cache/CachedXSLStyleSheet.h +++ b/Source/WebCore/loader/cache/CachedXSLStyleSheet.h @@ -37,7 +37,7 @@ namespace WebCore { #if ENABLE(XSLT) class CachedXSLStyleSheet : public CachedResource { public: - CachedXSLStyleSheet(const String& url); + CachedXSLStyleSheet(const ResourceRequest&); const String& sheet() const { return m_sheet; } diff --git a/Source/WebCore/loader/cache/MemoryCache.cpp b/Source/WebCore/loader/cache/MemoryCache.cpp index cb11e15..363668c 100644 --- a/Source/WebCore/loader/cache/MemoryCache.cpp +++ b/Source/WebCore/loader/cache/MemoryCache.cpp @@ -93,7 +93,7 @@ bool MemoryCache::add(CachedResource* resource) resourceAccessed(resource); - LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource->url().latin1().data(), resource); + LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource->url().string().latin1().data(), resource); return true; } @@ -323,7 +323,7 @@ bool MemoryCache::makeResourcePurgeable(CachedResource* resource) void MemoryCache::evict(CachedResource* resource) { - LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().latin1().data()); + LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().string().latin1().data()); // The resource may have already been removed by someone other than our caller, // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>. if (resource->inCache()) { |