Title: [136256] trunk
Revision
136256
Author
[email protected]
Date
2012-11-30 11:19:46 -0800 (Fri, 30 Nov 2012)

Log Message

Report CSS as initiator instead of elements, except body
https://bugs.webkit.org/show_bug.cgi?id=103546

Reviewed by Tony Gentilcore.

Source/WebCore:

The Resource Timing spec says the initiator should be "css" when the the load comes from a
url() rule in a stylesheet. Separately, WebKit reports <body background> as a CSS load, we
need to override that to match the spec.

Tests: http/tests/w3c/webperf/submission/resource-timing

* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::cachedImage):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage): By default, the initiator is "css".
* css/CSSImageValue.h:
(CSSImageValue):
(WebCore::CSSImageValue::setInitiator): Allow users to manually override it (see body).
* css/StyleResolver.cpp:
(WebCore::StyleResolver::loadPendingImage):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::collectStyleForPresentationAttribute): Record "body" as the initiator.

LayoutTests:

* platform/chromium/fast/loader/resource-request-callbacks-expected.txt: Rebaseline to match new behavior.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136255 => 136256)


--- trunk/LayoutTests/ChangeLog	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/LayoutTests/ChangeLog	2012-11-30 19:19:46 UTC (rev 136256)
@@ -1,3 +1,12 @@
+2012-11-30  James Simonsen  <[email protected]>
+
+        Report CSS as initiator instead of elements, except body
+        https://bugs.webkit.org/show_bug.cgi?id=103546
+
+        Reviewed by Tony Gentilcore.
+
+        * platform/chromium/fast/loader/resource-request-callbacks-expected.txt: Rebaseline to match new behavior.
+
 2012-11-30  Michelangelo De Simone  <[email protected]>
 
         [CSS Shaders] Clamp input colors before blending

Modified: trunk/LayoutTests/platform/chromium/fast/loader/resource-request-callbacks-expected.txt (136255 => 136256)


--- trunk/LayoutTests/platform/chromium/fast/loader/resource-request-callbacks-expected.txt	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/LayoutTests/platform/chromium/fast/loader/resource-request-callbacks-expected.txt	2012-11-30 19:19:46 UTC (rev 136256)
@@ -1,6 +1,6 @@
 main frame - css requested 'gw432047.ttf'
 main frame - css requested 'greenbox-hotspot35-4.cur'
-main frame - element with id 'with-background' requested 'lenna.png'
+main frame - css requested 'lenna.png'
 main frame - element with id 'img-normal' requested 'dice.png'
 main frame - element with id 'img-changing' requested 'dice.png'
 main frame - element with id 'img-not-there' requested 'not-existing.png'
@@ -9,7 +9,7 @@
 main frame - element with id 'img-created' requested 'oval.png'
 main frame - element with id 'img-created-2' requested 'png_per_row_alpha.png'
 main frame - element with id 'script-created' requested 'empty-script.js'
-main frame - element with id 'with-background' requested 'palatted-color-png-gamma-one-color-profile.png'
+main frame - css requested 'palatted-color-png-gamma-one-color-profile.png'
 This test checks that the correct callbacks for resource requests are invoked. It passes if you see the callbacks for eight resources.
 
     

Modified: trunk/Source/WebCore/ChangeLog (136255 => 136256)


--- trunk/Source/WebCore/ChangeLog	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/Source/WebCore/ChangeLog	2012-11-30 19:19:46 UTC (rev 136256)
@@ -1,5 +1,30 @@
 2012-11-30  James Simonsen  <[email protected]>
 
+        Report CSS as initiator instead of elements, except body
+        https://bugs.webkit.org/show_bug.cgi?id=103546
+
+        Reviewed by Tony Gentilcore.
+
+        The Resource Timing spec says the initiator should be "css" when the the load comes from a
+        url() rule in a stylesheet. Separately, WebKit reports <body background> as a CSS load, we
+        need to override that to match the spec.
+
+        Tests: http/tests/w3c/webperf/submission/resource-timing
+
+        * css/CSSCursorImageValue.cpp:
+        (WebCore::CSSCursorImageValue::cachedImage):
+        * css/CSSImageValue.cpp:
+        (WebCore::CSSImageValue::cachedImage): By default, the initiator is "css".
+        * css/CSSImageValue.h:
+        (CSSImageValue):
+        (WebCore::CSSImageValue::setInitiator): Allow users to manually override it (see body).
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::loadPendingImage):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::collectStyleForPresentationAttribute): Record "body" as the initiator.
+
+2012-11-30  James Simonsen  <[email protected]>
+
         Remember the CachedResourceRequest for preloads
         https://bugs.webkit.org/show_bug.cgi?id=102995
 

Modified: trunk/Source/WebCore/css/CSSCursorImageValue.cpp (136255 => 136256)


--- trunk/Source/WebCore/css/CSSCursorImageValue.cpp	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/Source/WebCore/css/CSSCursorImageValue.cpp	2012-11-30 19:19:46 UTC (rev 136256)
@@ -135,7 +135,7 @@
     if (isSVGCursorIdentifier(url()) && loader && loader->document()) {
         // FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
         if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url(), loader->document()))
-            return CSSImageValue::cachedImage(loader, cursorElement->href(), cursorElement);
+            return CSSImageValue::cachedImage(loader, cursorElement->href());
     }
 #endif
 

Modified: trunk/Source/WebCore/css/CSSImageValue.cpp (136255 => 136256)


--- trunk/Source/WebCore/css/CSSImageValue.cpp	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/Source/WebCore/css/CSSImageValue.cpp	2012-11-30 19:19:46 UTC (rev 136256)
@@ -71,14 +71,14 @@
     return m_image.get();
 }
 
-StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, Element* initiatorElement)
+StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader)
 {
     if (isCursorImageValue())
         return static_cast<CSSCursorImageValue*>(this)->cachedImage(loader);
-    return cachedImage(loader, m_url, initiatorElement);
+    return cachedImage(loader, m_url);
 }
 
-StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const String& url, Element* initiatorElement)
+StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader* loader, const String& url)
 {
     ASSERT(loader);
 
@@ -86,10 +86,10 @@
         m_accessedImage = true;
 
         CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(url)));
-        if (initiatorElement)
-            request.setInitiator(initiatorElement);
+        if (m_initiatorName.isEmpty())
+            request.setInitiator(cachedResourceRequestInitiators().css);
         else
-            request.setInitiator(cachedResourceRequestInitiators().css);
+            request.setInitiator(m_initiatorName);
         if (CachedResourceHandle<CachedImage> cachedImage = loader->requestImage(request))
             m_image = StyleCachedImage::create(cachedImage.get());
     }

Modified: trunk/Source/WebCore/css/CSSImageValue.h (136255 => 136256)


--- trunk/Source/WebCore/css/CSSImageValue.h	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/Source/WebCore/css/CSSImageValue.h	2012-11-30 19:19:46 UTC (rev 136256)
@@ -38,7 +38,7 @@
     static PassRefPtr<CSSImageValue> create(const String& url, StyleImage* image) { return adoptRef(new CSSImageValue(url, image)); }
     ~CSSImageValue();
 
-    StyleCachedImage* cachedImage(CachedResourceLoader*, Element* initiatorElement = 0);
+    StyleCachedImage* cachedImage(CachedResourceLoader*);
     // Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.
     StyleImage* cachedOrPendingImage();
 
@@ -54,10 +54,12 @@
 
     bool hasAlpha(const RenderObject*) const;
 
+    void setInitiator(const AtomicString& name) { m_initiatorName = name; }
+
 protected:
     CSSImageValue(ClassType, const String& url);
 
-    StyleCachedImage* cachedImage(CachedResourceLoader*, const String& url, Element* initiatorElement = 0);
+    StyleCachedImage* cachedImage(CachedResourceLoader*, const String& url);
     String cachedImageURL();
     void clearCachedImage();
 
@@ -68,6 +70,7 @@
     String m_url;
     RefPtr<StyleImage> m_image;
     bool m_accessedImage;
+    AtomicString m_initiatorName;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (136255 => 136256)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-11-30 19:19:46 UTC (rev 136256)
@@ -5007,7 +5007,7 @@
 
     if (pendingImage->cssImageValue()) {
         CSSImageValue* imageValue = pendingImage->cssImageValue();
-        return imageValue->cachedImage(cachedResourceLoader, m_element);
+        return imageValue->cachedImage(cachedResourceLoader);
     }
 
     if (pendingImage->cssImageGeneratorValue()) {

Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (136255 => 136256)


--- trunk/Source/WebCore/html/HTMLBodyElement.cpp	2012-11-30 19:17:45 UTC (rev 136255)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp	2012-11-30 19:19:46 UTC (rev 136256)
@@ -72,8 +72,11 @@
 {
     if (attribute.name() == backgroundAttr) {
         String url = ""
-        if (!url.isEmpty())
-            style->setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document()->completeURL(url).string())));
+        if (!url.isEmpty()) {
+            RefPtr<CSSImageValue> imageValue = CSSImageValue::create(document()->completeURL(url).string());
+            imageValue->setInitiator(localName());
+            style->setProperty(CSSProperty(CSSPropertyBackgroundImage, imageValue));
+        }
     } else if (attribute.name() == marginwidthAttr || attribute.name() == leftmarginAttr) {
         addHTMLLengthToStyle(style, CSSPropertyMarginRight, attribute.value());
         addHTMLLengthToStyle(style, CSSPropertyMarginLeft, attribute.value());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to