Title: [214842] trunk
Revision
214842
Author
cdu...@apple.com
Date
2017-04-03 15:06:51 -0700 (Mon, 03 Apr 2017)

Log Message

REGRESSION (r206744): CSS background-image in style attribute ignored when using createHTMLDocument method of DOM parsing
https://bugs.webkit.org/show_bug.cgi?id=170285
<rdar://problem/31378543>

Reviewed by Andy Estes.

Source/WebCore:

r206744 caused up to stop trying to resolve relative URLs when trying to load an image
referred to by CSS. We already try to resolve the relative URL when parsing the CSS
property so this will usually work fine. However, in the case when the CSS property
is parsed in detached document and then moved to another document, we will not have
the complete URL.

Test: fast/images/background-image-relative-url-changes-document.html

* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::loadImage):

LayoutTests:

Add layout test coverage.

* fast/images/background-image-relative-url-changes-document-expected.html: Added.
* fast/images/background-image-relative-url-changes-document.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (214841 => 214842)


--- trunk/LayoutTests/ChangeLog	2017-04-03 22:06:24 UTC (rev 214841)
+++ trunk/LayoutTests/ChangeLog	2017-04-03 22:06:51 UTC (rev 214842)
@@ -1,3 +1,16 @@
+2017-04-03  Chris Dumez  <cdu...@apple.com>
+
+        REGRESSION (r206744): CSS background-image in style attribute ignored when using createHTMLDocument method of DOM parsing
+        https://bugs.webkit.org/show_bug.cgi?id=170285
+        <rdar://problem/31378543>
+
+        Reviewed by Andy Estes.
+
+        Add layout test coverage.
+
+        * fast/images/background-image-relative-url-changes-document-expected.html: Added.
+        * fast/images/background-image-relative-url-changes-document.html: Added.
+
 2017-04-03  John Wilander  <wilan...@apple.com>
 
         Remove timeout expectations after bug fix

Added: trunk/LayoutTests/fast/images/background-image-relative-url-changes-document-expected.html (0 => 214842)


--- trunk/LayoutTests/fast/images/background-image-relative-url-changes-document-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/background-image-relative-url-changes-document-expected.html	2017-04-03 22:06:51 UTC (rev 214842)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Makes sure background-images with relative URLs are properly loaded when moved to a new document.</p>
+<div style="background-image: url(resources/green-256x256.jpg); width: 256px; height: 256px;"></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/images/background-image-relative-url-changes-document.html (0 => 214842)


--- trunk/LayoutTests/fast/images/background-image-relative-url-changes-document.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/background-image-relative-url-changes-document.html	2017-04-03 22:06:51 UTC (rev 214842)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Makes sure background-images with relative URLs are properly loaded when moved to a new document.</p>
+<script>
+const htmlDocument = document.implementation.createHTMLDocument('template');
+htmlDocument.documentElement.innerHTML = '<div style="background-image: url(resources/green-256x256.jpg); width: 256px; height: 256px;"></div>';
+const data = ""
+for (var i = 0; i < data.length; i++)
+    document.body.appendChild(data[i]);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (214841 => 214842)


--- trunk/Source/WebCore/ChangeLog	2017-04-03 22:06:24 UTC (rev 214841)
+++ trunk/Source/WebCore/ChangeLog	2017-04-03 22:06:51 UTC (rev 214842)
@@ -1,3 +1,22 @@
+2017-04-03  Chris Dumez  <cdu...@apple.com>
+
+        REGRESSION (r206744): CSS background-image in style attribute ignored when using createHTMLDocument method of DOM parsing
+        https://bugs.webkit.org/show_bug.cgi?id=170285
+        <rdar://problem/31378543>
+
+        Reviewed by Andy Estes.
+
+        r206744 caused up to stop trying to resolve relative URLs when trying to load an image
+        referred to by CSS. We already try to resolve the relative URL when parsing the CSS
+        property so this will usually work fine. However, in the case when the CSS property
+        is parsed in detached document and then moved to another document, we will not have
+        the complete URL.
+
+        Test: fast/images/background-image-relative-url-changes-document.html
+
+        * css/CSSImageValue.cpp:
+        (WebCore::CSSImageValue::loadImage):
+
 2017-04-03  Jeremy Jones  <jere...@apple.com>
 
         Do not set WebAVPlayerLayerView background to black in fullscreen.

Modified: trunk/Source/WebCore/css/CSSImageValue.cpp (214841 => 214842)


--- trunk/Source/WebCore/css/CSSImageValue.cpp	2017-04-03 22:06:24 UTC (rev 214841)
+++ trunk/Source/WebCore/css/CSSImageValue.cpp	2017-04-03 22:06:51 UTC (rev 214842)
@@ -66,7 +66,7 @@
     if (!m_accessedImage) {
         m_accessedImage = true;
 
-        CachedResourceRequest request(ResourceRequest(m_url), options);
+        CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url.string())), options);
         if (m_initiatorName.isEmpty())
             request.setInitiator(cachedResourceRequestInitiators().css);
         else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to