Commit 2a1dff26 authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

Reland "Add in-place reload behavior to ImagesEnabled setting" with optimizations

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

Patch by Bo Liu <boliu@chromium.org> on 2012-09-24
Reviewed by Adam Barth.

Relanding 128780, 128676, 128645. Was reverted in 128914 due to
performance regression in Chromium.

New changes in addition to previously reverted patches:

Refactored CachedResource::requestResource, loadResource, and
revalidateResource. Moved CachedResource::load method to end of
requestResource so there is one place where load is called for all
resources.

Added a enum parameter for requestResource and
determineRevalidationPolicy so that FrameLoaderClient::allowImage call
do not need to be called multiple times.

Removed CachedImage::load call in requestImage so it is not called
twice.

Removed unnecessary Frame.h includes in CachedResource and
CachedImage.

Removed dead load() method declaration in CachedImage.

Updated text expectation for two image-permissions tests to reflect
the removed calls to allowImage.

.:

* Source/autotools/symbols.filter:

Source/WebCore:

Tests: fast/loader/display-image-unset-allows-cached-image-load.html
       fast/loader/display-image-unset-can-block-image-and-can-reload-in-place.html
       fast/loader/images-enabled-unset-can-block-image-and-can-reload-in-place.html

* WebCore.exp.in:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didBeginDocument):
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequest):
* loader/cache/CachedImage.cpp:
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::didAddClient):
* loader/cache/CachedResource.h:
(WebCore):
(WebCore::CachedResource::stillNeedsLoad):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::CachedResourceLoader):
(WebCore::CachedResourceLoader::requestImage):
(WebCore::CachedResourceLoader::canRequest):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::revalidateResource):
(WebCore::CachedResourceLoader::loadResource):
(WebCore::CachedResourceLoader::determineRevalidationPolicy):
(WebCore::CachedResourceLoader::setAutoLoadImages):
(WebCore):
(WebCore::CachedResourceLoader::setImagesEnabled):
(WebCore::CachedResourceLoader::clientDefersImage):
(WebCore::CachedResourceLoader::shouldDeferImageLoad):
(WebCore::CachedResourceLoader::reloadImagesIfNotDeferred):
* loader/cache/CachedResourceLoader.h:
(CachedResourceLoader):
* page/Settings.cpp:
(WebCore::setImageLoadingSettings):
(WebCore::Settings::Settings):
(WebCore::Settings::setLoadsImagesAutomatically):
(WebCore::Settings::imageLoadingSettingsTimerFired):
(WebCore::Settings::setImagesEnabled):
* page/Settings.h:
(Settings):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setImagesEnabled):
(WebCore):
* testing/InternalSettings.h:
(Backup):
(InternalSettings):
* testing/InternalSettings.idl:

Source/WebKit2:

* win/WebKit2.def:

LayoutTests:

* fast/loader/display-image-unset-allows-cached-image-load-expected.txt: Added.
* fast/loader/display-image-unset-allows-cached-image-load.html: Added.
* fast/loader/display-image-unset-can-block-image-and-can-reload-in-place-expected.txt: Added.
* fast/loader/display-image-unset-can-block-image-and-can-reload-in-place.html: Added.
* fast/loader/images-enabled-unset-can-block-image-and-can-reload-in-place-expected.txt: Added.
* fast/loader/images-enabled-unset-can-block-image-and-can-reload-in-place.html: Added.
* fast/loader/resources/image1.html: Added.
* fast/loader/resources/image2.html: Added.
* platform/chromium/permissionclient/image-permissions-expected.txt:
* platform/chromium/permissionclient/image-permissions.html:
* platform/chromium/permissionclient/resources/image.html:
* platform/wk2/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129388 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e884aa4d
2012-09-24 Bo Liu <boliu@chromium.org>
Reland "Add in-place reload behavior to ImagesEnabled setting" with optimizations
https://bugs.webkit.org/show_bug.cgi?id=97055
Reviewed by Adam Barth.
Relanding 128780, 128676, 128645. Was reverted in 128914 due to
performance regression in Chromium.
New changes in addition to previously reverted patches:
Refactored CachedResource::requestResource, loadResource, and
revalidateResource. Moved CachedResource::load method to end of
requestResource so there is one place where load is called for all
resources.
Added a enum parameter for requestResource and
determineRevalidationPolicy so that FrameLoaderClient::allowImage call
do not need to be called multiple times.
Removed CachedImage::load call in requestImage so it is not called
twice.
Removed unnecessary Frame.h includes in CachedResource and
CachedImage.
Removed dead load() method declaration in CachedImage.
Updated text expectation for two image-permissions tests to reflect
the removed calls to allowImage.
* Source/autotools/symbols.filter:
2012-09-24 Vivek Galatage <vivekgalatage@gmail.com>
Web Inspector: implement testing harness for pure protocol tests.
......
2012-09-24 Bo Liu <boliu@chromium.org>
Reland "Add in-place reload behavior to ImagesEnabled setting" with optimizations
https://bugs.webkit.org/show_bug.cgi?id=97055
Reviewed by Adam Barth.
Relanding 128780, 128676, 128645. Was reverted in 128914 due to
performance regression in Chromium.
New changes in addition to previously reverted patches:
Refactored CachedResource::requestResource, loadResource, and
revalidateResource. Moved CachedResource::load method to end of
requestResource so there is one place where load is called for all
resources.
Added a enum parameter for requestResource and
determineRevalidationPolicy so that FrameLoaderClient::allowImage call
do not need to be called multiple times.
Removed CachedImage::load call in requestImage so it is not called
twice.
Removed unnecessary Frame.h includes in CachedResource and
CachedImage.
Removed dead load() method declaration in CachedImage.
Updated text expectation for two image-permissions tests to reflect
the removed calls to allowImage.
* fast/loader/display-image-unset-allows-cached-image-load-expected.txt: Added.
* fast/loader/display-image-unset-allows-cached-image-load.html: Added.
* fast/loader/display-image-unset-can-block-image-and-can-reload-in-place-expected.txt: Added.
* fast/loader/display-image-unset-can-block-image-and-can-reload-in-place.html: Added.
* fast/loader/images-enabled-unset-can-block-image-and-can-reload-in-place-expected.txt: Added.
* fast/loader/images-enabled-unset-can-block-image-and-can-reload-in-place.html: Added.
* fast/loader/resources/image1.html: Added.
* fast/loader/resources/image2.html: Added.
* platform/chromium/permissionclient/image-permissions-expected.txt:
* platform/chromium/permissionclient/image-permissions.html:
* platform/chromium/permissionclient/resources/image.html:
* platform/wk2/Skipped:
2012-09-24 Emil A Eklund <eae@chromium.org>
 
Unreviewed chromium linux/windows rebaseline for r129370.
Test that WebKitDisplayImagesKey unset does not block image in cache.
PASS
<html>
<head>
<script>
// Opens two windows containing the same image. First window will populate the cache with
// image. The second window is opened with WebKitDisplayImagesKey unset, but image should
// still load since it is in cache.
function runTest()
{
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setCanOpenWindows();
testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
document.getElementById('result').innerHTML = 'FAILURE: image1.html not loaded';
window.open("resources/image1.html", "_blank");
}
}
function image1Loaded()
{
testRunner.overridePreference('WebKitDisplayImagesKey', 0);
document.getElementById('result').innerHTML = 'FAILURE: image2.html not loaded';
window.setTimeout(function() {window.open("resources/image2.html", "_blank");}, 0);
}
function image2Loaded()
{
document.getElementById('result').innerHTML = 'PASS';
testRunner.notifyDone();
}
</script>
</head>
<body onload="runTest()">
Test that WebKitDisplayImagesKey unset does not block image in cache.
<div id="result">FAILURE: Test script didn't run.</div>
</body>
</html>
Test that DisplayImages disabled can block http image and can be reloaded in-place when toggled.
SUCCESS
<html>
<head>
<script>
// Setting WebKitDisplayImagesKey is asynchronous, so using queueReload and setInterval to check when the setting actually take effect.
var intervalId;
var imageOnloadFired = 0;
if (window.testRunner) {
testRunner.dumpAsText();
window.internals.settings.setImagesEnabled(true);
testRunner.overridePreference('WebKitDisplayImagesKey', 0);
testRunner.queueReload();
}
function runTest()
{
var image = document.getElementById('image');
if (image.naturalHeight != 0 || image.naturalWidth != 0 || imageOnloadFired != 0) {
document.getElementById('result').innerHTML = 'FAILURE: Image should not be loaded when DisplayImage is unset';
return;
}
testRunner.overridePreference('WebKitDisplayImagesKey', 1);
document.getElementById('result').innerHTML = 'FAILURE: Image should reload in-place when DispalyImage is changes from unset to set';
testRunner.waitUntilDone();
intervalId = window.setInterval(runTestRest, 10);
}
function runTestRest()
{
var image = document.getElementById('image');
if (image.naturalHeight == 33 && image.naturalWidth == 37 && imageOnloadFired == 1) {
document.getElementById('result').innerHTML = 'SUCCESS';
window.clearInterval(intervalId);
testRunner.notifyDone();
}
}
</script>
</head>
<body onload="runTest()">
Test that DisplayImages disabled can block http image and can be reloaded in-place when toggled.
<div id="result">FAILURE: Test script didn't run.</div>
<img id="image" src="../images/resources/oval.png" onload="imageOnloadFired=1;">
</body>
</html>
Test that EnableImages unset can block image and can be reloaded in-place when toggled.
SUCCESS
<html>
<head>
<script>
// Setting ImagesEnabled is asynchronous, so using queueReload and setInterval to check when the setting actually take effect.
var intervalId;
var imageOnloadFired = 0;
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.overridePreference('WebKitDisplayImagesKey', 1);
window.internals.settings.setImagesEnabled(false);
testRunner.queueReload();
}
function runTest()
{
var image = document.getElementById('image');
if (image.naturalHeight != 0 || image.naturalWidth != 0 || imageOnloadFired != 0) {
document.getElementById('result').innerHTML = 'FAILURE: Image should not be loaded when ImagesEnabled is unset';
return;
}
window.internals.settings.setImagesEnabled(true);
document.getElementById('result').innerHTML = 'FAILURE: Image should reload in-place when ImagesEnabled is changes from unset to set';
testRunner.waitUntilDone();
intervalId = window.setInterval(runTestRest, 10);
}
function runTestRest()
{
var image = document.getElementById('image');
if (image.naturalHeight == 33 && image.naturalWidth == 37 || imageOnloadFired == 1) {
document.getElementById('result').innerHTML = 'SUCCESS';
window.clearInterval(intervalId);
testRunner.notifyDone();
}
}
</script>
</head>
<body onload="runTest()">
Test that EnableImages unset can block image and can be reloaded in-place when toggled.
<div id="result">FAILURE: Test script didn't run.</div>
<img id="image" src="../images/resources/oval.png" onload="imageOnloadFired=1;">
</body>
</html>
<html>
<body>
<img src="../../images/resources/oval.png" onload="window.opener.image1Loaded();">
</body>
</html>
<html>
<body>
<img src="../../images/resources/oval.png" onload="window.opener.image2Loaded();">
</body>
</html>
......@@ -5,6 +5,4 @@ PERMISSION CLIENT: allowImage((file test):platform/chromium/permissionclient/res
PASS: first image loaded
PASS: error event for not cached image
PASS: error event for image from cache
<html>
<head>
<script>
// Blocked images can be reloaded, so neither onload nor onerror is called.
// Only check here that onload is never called when image is blocked.
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.dumpPermissionClientCallbacks();
......@@ -21,14 +24,12 @@ function loaded()
// Load an image not in cache.
var img = document.createElement('img');
img.onerror = function () { log("PASS: error event for not cached image"); }
img.onload = function () { log("FAIL: not cached image loaded"); }
img.src = "resources/boston.gif?nocache";
document.getElementById("img").appendChild(img);
// Load an image from cache.
var imgFromCache = document.createElement('img');
imgFromCache.onerror = function () { log("PASS: error event for image from cache"); }
imgFromCache.onload = function () { log("FAIL: image from cache loaded"); }
imgFromCache.src = "resources/boston.gif";
document.getElementById("img").appendChild(imgFromCache);
......@@ -41,7 +42,7 @@ function loaded()
</script>
</head>
<body>
<img src="resources/boston.gif" onload="loaded()" onerror="log('FAIL: error event for first image')">
<img src="resources/boston.gif" onload="loaded()">
<div id="img"></div>
<div id="results"></div>
</body>
......
......@@ -8,7 +8,7 @@ function log(a)
</script>
</head>
<body>
<img src="boston.gif" onload="log('FAIL: load event for iframed image)" onerror="log('FAIL: error event for iframed image')">
<img src="boston.gif" onload="log('FAIL: load event for iframed image')">
<div id="results"></div>
</body>
</html>
......@@ -203,6 +203,7 @@ fast/canvas/webgl/webgl-specific.html
fast/canvas/webgl/oes-vertex-array-object.html
fast/harness/override-preferences-2.html
fast/images/animated-gif-restored-from-bfcache.html
fast/loader/display-image-unset-allows-cached-image-load.html
fast/text/zero-font-size.html
# WebKitTestRunner needs to support layoutTestController.dumpDOMAsWebArchive
......@@ -317,6 +318,8 @@ svg/custom/svg-allowed-in-dashboard-object.html
# <https://bugs.webkit.org/show_bug.cgi?id=42672>
fast/css/compare-content-style.html
fast/frames/frame-display-none-focus.html
fast/loader/display-image-unset-can-block-image-and-can-reload-in-place.html
fast/loader/images-enabled-unset-can-block-image-and-can-reload-in-place.html
fast/loader/reload-policy-delegate.html
# WebKitTestRunner needs layoutTestController.queueLoad
......
2012-09-24 Bo Liu <boliu@chromium.org>
Reland "Add in-place reload behavior to ImagesEnabled setting" with optimizations
https://bugs.webkit.org/show_bug.cgi?id=97055
Reviewed by Adam Barth.
Relanding 128780, 128676, 128645. Was reverted in 128914 due to
performance regression in Chromium.
New changes in addition to previously reverted patches:
Refactored CachedResource::requestResource, loadResource, and
revalidateResource. Moved CachedResource::load method to end of
requestResource so there is one place where load is called for all
resources.
Added a enum parameter for requestResource and
determineRevalidationPolicy so that FrameLoaderClient::allowImage call
do not need to be called multiple times.
Removed CachedImage::load call in requestImage so it is not called
twice.
Removed unnecessary Frame.h includes in CachedResource and
CachedImage.
Removed dead load() method declaration in CachedImage.
Updated text expectation for two image-permissions tests to reflect
the removed calls to allowImage.
Tests: fast/loader/display-image-unset-allows-cached-image-load.html
fast/loader/display-image-unset-can-block-image-and-can-reload-in-place.html
fast/loader/images-enabled-unset-can-block-image-and-can-reload-in-place.html
* WebCore.exp.in:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didBeginDocument):
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequest):
* loader/cache/CachedImage.cpp:
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::didAddClient):
* loader/cache/CachedResource.h:
(WebCore):
(WebCore::CachedResource::stillNeedsLoad):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::CachedResourceLoader):
(WebCore::CachedResourceLoader::requestImage):
(WebCore::CachedResourceLoader::canRequest):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::revalidateResource):
(WebCore::CachedResourceLoader::loadResource):
(WebCore::CachedResourceLoader::determineRevalidationPolicy):
(WebCore::CachedResourceLoader::setAutoLoadImages):
(WebCore):
(WebCore::CachedResourceLoader::setImagesEnabled):
(WebCore::CachedResourceLoader::clientDefersImage):
(WebCore::CachedResourceLoader::shouldDeferImageLoad):
(WebCore::CachedResourceLoader::reloadImagesIfNotDeferred):
* loader/cache/CachedResourceLoader.h:
(CachedResourceLoader):
* page/Settings.cpp:
(WebCore::setImageLoadingSettings):
(WebCore::Settings::Settings):
(WebCore::Settings::setLoadsImagesAutomatically):
(WebCore::Settings::imageLoadingSettingsTimerFired):
(WebCore::Settings::setImagesEnabled):
* page/Settings.h:
(Settings):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setImagesEnabled):
(WebCore):
* testing/InternalSettings.h:
(Backup):
(InternalSettings):
* testing/InternalSettings.idl:
2012-09-24 Joone Hur <joone.hur@intel.com>, Gustavo Noronha Silva <gustavo.noronha@collabora.com>
 
[GTK] Implement GraphicsLayer using Clutter
......@@ -852,6 +852,7 @@ __ZN7WebCore8GradientC1ERKNS_10FloatPointES3_
__ZN7WebCore8PositionC1EN3WTF10PassRefPtrINS_4NodeEEEiNS0_10AnchorTypeE
__ZN7WebCore8Settings14setJavaEnabledEb
__ZN7WebCore8Settings15setWebGLEnabledEb
__ZN7WebCore8Settings16setImagesEnabledEb
__ZN7WebCore8Settings16setScriptEnabledEb
__ZN7WebCore8Settings16setUsesPageCacheEb
__ZN7WebCore8Settings17setPluginsEnabledEb
......
......@@ -647,6 +647,7 @@ void FrameLoader::didBeginDocument(bool dispatch)
m_frame->document()->initContentSecurityPolicy();
Settings* settings = m_frame->document()->settings();
m_frame->document()->cachedResourceLoader()->setImagesEnabled(!settings || settings->areImagesEnabled());
m_frame->document()->cachedResourceLoader()->setAutoLoadImages(settings && settings->loadsImagesAutomatically());
if (m_documentLoader) {
......
......@@ -167,11 +167,13 @@ void SubresourceLoader::willSendRequest(ResourceRequest& newRequest, const Resou
ResourceLoader::willSendRequest(newRequest, redirectResponse);
if (!previousURL.isNull() && !newRequest.isNull() && previousURL != newRequest.url()) {
if (!m_document->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url())) {
cancel();
return;
if (m_document->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url())) {
if (m_resource->type() != CachedResource::ImageResource || !m_document->cachedResourceLoader()->shouldDeferImageLoad(newRequest.url())) {
m_resource->willSendRequest(newRequest, redirectResponse);
return;
}
}
m_resource->willSendRequest(newRequest, redirectResponse);
cancel();
}
}
......
......@@ -29,7 +29,6 @@
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "CachedResourceLoader.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "FrameLoaderTypes.h"
#include "FrameView.h"
......
......@@ -82,8 +82,7 @@ public:
virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; }
virtual bool isImage() const { return true; }
bool stillNeedsLoad() const { return !errorOccurred() && status() == Unknown && !isLoading(); }
void load();
virtual bool stillNeedsLoad() const OVERRIDE { return !errorOccurred() && status() == Unknown && !isLoading(); }
// ImageObserver
virtual void decodedSizeChanged(const Image* image, int delta);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment