Title: [219905] trunk/Source
Revision
219905
Author
[email protected]
Date
2017-07-25 23:19:47 -0700 (Tue, 25 Jul 2017)

Log Message

Icon loader error on startup
https://bugs.webkit.org/show_bug.cgi?id=174787

Reviewed by Brady Eidson.

Source/WebCore:

This is a regression of the new icon loading, it happens with pages that shouldn't have a favicon, like about
pages. IconController::startLoader() did several checks before starting the load that
DocumentLoader::startIconLoading() is not doing. It checked that the frame is the main one, the document can have
an icon (document url is not empty and not about:blank) and that favicon url is in HTTP family. We should do the
same checks now before starting to load icons.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startIconLoading):

Source/WebKit:

Ignore non HTTP favicons in glib API.

* UIProcess/API/glib/WebKitIconLoadingClient.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219904 => 219905)


--- trunk/Source/WebCore/ChangeLog	2017-07-26 05:44:05 UTC (rev 219904)
+++ trunk/Source/WebCore/ChangeLog	2017-07-26 06:19:47 UTC (rev 219905)
@@ -1,3 +1,19 @@
+2017-07-25  Carlos Garcia Campos  <[email protected]>
+
+        Icon loader error on startup
+        https://bugs.webkit.org/show_bug.cgi?id=174787
+
+        Reviewed by Brady Eidson.
+
+        This is a regression of the new icon loading, it happens with pages that shouldn't have a favicon, like about
+        pages. IconController::startLoader() did several checks before starting the load that
+        DocumentLoader::startIconLoading() is not doing. It checked that the frame is the main one, the document can have
+        an icon (document url is not empty and not about:blank) and that favicon url is in HTTP family. We should do the
+        same checks now before starting to load icons.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::startIconLoading):
+
 2017-07-25  Sam Weinig  <[email protected]>
 
         [WebIDL] Remove custom bindings for HTMLCanvasElement

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (219904 => 219905)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-07-26 05:44:05 UTC (rev 219904)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-07-26 06:19:47 UTC (rev 219905)
@@ -1613,18 +1613,20 @@
     if (!document)
         return;
 
+    if (!m_frame->isMainFrame())
+        return;
+
+    if (document->url().isEmpty() || document->url().isBlankURL())
+        return;
+
     m_linkIcons = LinkIconCollector { *document }.iconsOfTypes({ LinkIconType::Favicon, LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon });
 
-    bool hasFavicon = false;
-    for (auto& icon : m_linkIcons) {
-        if (icon.type == LinkIconType::Favicon) {
-            hasFavicon = true;
-            break;
-        }
-    }
+    auto findResult = m_linkIcons.findMatching([](auto& icon) { return icon.type == LinkIconType::Favicon; });
+    if (findResult == notFound)
+        m_linkIcons.append({ document->completeURL(ASCIILiteral("/favicon.ico")), LinkIconType::Favicon, String(), std::nullopt });
 
-    if (!hasFavicon)
-        m_linkIcons.append({ m_frame->document()->completeURL(ASCIILiteral("/favicon.ico")), LinkIconType::Favicon, String(), std::nullopt });
+    if (!m_linkIcons.size())
+        return;
 
     Vector<std::pair<WebCore::LinkIcon&, uint64_t>> iconDecisions;
     iconDecisions.reserveInitialCapacity(m_linkIcons.size());

Modified: trunk/Source/WebKit/ChangeLog (219904 => 219905)


--- trunk/Source/WebKit/ChangeLog	2017-07-26 05:44:05 UTC (rev 219904)
+++ trunk/Source/WebKit/ChangeLog	2017-07-26 06:19:47 UTC (rev 219905)
@@ -1,3 +1,14 @@
+2017-07-25  Carlos Garcia Campos  <[email protected]>
+
+        Icon loader error on startup
+        https://bugs.webkit.org/show_bug.cgi?id=174787
+
+        Reviewed by Brady Eidson.
+
+        Ignore non HTTP favicons in glib API.
+
+        * UIProcess/API/glib/WebKitIconLoadingClient.cpp:
+
 2017-07-25  Brady Eidson  <[email protected]>
 
         ResourceLoadStatistics grandfathering happens much too often.

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitIconLoadingClient.cpp (219904 => 219905)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitIconLoadingClient.cpp	2017-07-26 05:44:05 UTC (rev 219904)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitIconLoadingClient.cpp	2017-07-26 06:19:47 UTC (rev 219905)
@@ -35,6 +35,12 @@
 private:
     void getLoadDecisionForIcon(const WebCore::LinkIcon& icon, Function<void (Function<void (API::Data*, CallbackBase::Error)>&&)>&& completionHandler) override
     {
+        // WebCore can send non HTTP icons.
+        if (!icon.url.protocolIsInHTTPFamily()) {
+            completionHandler(nullptr);
+            return;
+        }
+
         WebCore::LinkIcon copiedIcon = icon;
         webkitWebViewGetLoadDecisionForIcon(m_webView, icon, [protectedWebView = GRefPtr<WebKitWebView>(m_webView), icon = WTFMove(copiedIcon), completionHandler = WTFMove(completionHandler)] (bool loadIcon) mutable {
             if (!loadIcon) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to