Make it possible to add a border around loading or failed-to-load images
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Jun 2018 00:52:56 +0000 (00:52 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Jun 2018 00:52:56 +0000 (00:52 +0000)
commit1fd6c8c9ac8d6d6d159a1d331edfdce5724a338c
treed04bfb4a5c3855cfce2c499a90af7f66c42f179c
parentac35a8ffa36b1ba0a1493337ec0008ca22143886
Make it possible to add a border around loading or failed-to-load images
https://bugs.webkit.org/show_bug.cgi?id=186614
<rdar://problem/39050152>

Reviewed by Zalan Bujtas.

Source/WebCore:

Tests: http/tests/images/loading-image-border.html
       http/tests/images/loading-image-no-border.html

* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintIncompleteImageOutline):
(WebCore::RenderImage::paintReplaced):
* rendering/RenderImage.h:
Factor the missing-image outline out, and - if desired - paint it in
cases where the image is still loading or otherwise pending, not just
when the image fails to load.

* page/Settings.yaml:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setIncompleteImageBorderEnabled):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:
Add and expose a setting to enable the feature.

Source/WebKit:

* Shared/WebPreferences.yaml:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _setColorFilterEnabled:]):
(-[WKWebViewConfiguration _incompleteImageBorderEnabled]):
(-[WKWebViewConfiguration _setIncompleteImageBorderEnabled:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
Plumb the setting to WebKit2.

LayoutTests:

* http/tests/images/loading-image-border-expected.html: Added.
* http/tests/images/loading-image-border.html: Added.
* http/tests/images/loading-image-no-border-expected.html: Added.
* http/tests/images/loading-image-no-border.html: Added.
* platform/wk2/TestExpectations:
Add a test ensuring that the setting works correctly.
These and similar tests do not currently work in WebKitTestRunner, so they are skipped there.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/images/loading-image-border-expected.html [new file with mode: 0644]
LayoutTests/http/tests/images/loading-image-border.html [new file with mode: 0644]
LayoutTests/http/tests/images/loading-image-no-border-expected.html [new file with mode: 0644]
LayoutTests/http/tests/images/loading-image-no-border.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.yaml
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderImage.h
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h