Title: [220694] trunk/Source/WebKit
Revision
220694
Author
[email protected]
Date
2017-08-14 08:44:02 -0700 (Mon, 14 Aug 2017)

Log Message

[GTK][WPE] Avoid emitting WebKitFaviconDatabase::favicon-changed multiple times while setting an icon
https://bugs.webkit.org/show_bug.cgi?id=175531

Reviewed by Michael Catanzaro.

When webkitFaviconDatabaseSetIconForPageURL() is called, both setIconURLForPageURL() and setIconDataForIconURL()
might notify the client, which ends up emitting the WebKitFaviconDatabase::favicon-changed signal and calling
webkitFaviconDatabaseSetIconURLForPageURL(). Both things are already done by
webkitFaviconDatabaseSetIconForPageURL() itself, so we can just ignore the client notification while setting a
new icon.

* UIProcess/API/glib/WebKitFaviconDatabase.cpp:
(webkitFaviconDatabaseSetIconURLForPageURL): Return early if isSettingIcon is true.
(webkitFaviconDatabaseSetIconForPageURL): Set isSettingIcon to true for the scope.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (220693 => 220694)


--- trunk/Source/WebKit/ChangeLog	2017-08-14 15:38:56 UTC (rev 220693)
+++ trunk/Source/WebKit/ChangeLog	2017-08-14 15:44:02 UTC (rev 220694)
@@ -1,5 +1,22 @@
 2017-08-14  Carlos Garcia Campos  <[email protected]>
 
+        [GTK][WPE] Avoid emitting WebKitFaviconDatabase::favicon-changed multiple times while setting an icon
+        https://bugs.webkit.org/show_bug.cgi?id=175531
+
+        Reviewed by Michael Catanzaro.
+
+        When webkitFaviconDatabaseSetIconForPageURL() is called, both setIconURLForPageURL() and setIconDataForIconURL()
+        might notify the client, which ends up emitting the WebKitFaviconDatabase::favicon-changed signal and calling
+        webkitFaviconDatabaseSetIconURLForPageURL(). Both things are already done by
+        webkitFaviconDatabaseSetIconForPageURL() itself, so we can just ignore the client notification while setting a
+        new icon.
+
+        * UIProcess/API/glib/WebKitFaviconDatabase.cpp:
+        (webkitFaviconDatabaseSetIconURLForPageURL): Return early if isSettingIcon is true.
+        (webkitFaviconDatabaseSetIconForPageURL): Set isSettingIcon to true for the scope.
+
+2017-08-14  Carlos Garcia Campos  <[email protected]>
+
         [GTK][WPE] Crash in IconDatabase::IconRecord::setImageData()
         https://bugs.webkit.org/show_bug.cgi?id=175527
 

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitFaviconDatabase.cpp (220693 => 220694)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitFaviconDatabase.cpp	2017-08-14 15:38:56 UTC (rev 220693)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitFaviconDatabase.cpp	2017-08-14 15:44:02 UTC (rev 220694)
@@ -29,6 +29,7 @@
 #include <WebCore/RefPtrCairo.h>
 #include <glib/gi18n-lib.h>
 #include <wtf/RunLoop.h>
+#include <wtf/SetForScope.h>
 #include <wtf/glib/GRefPtr.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/glib/WTFGType.h>
@@ -75,6 +76,7 @@
     PendingIconRequestMap pendingIconRequests;
     HashMap<String, String> pageURLToIconURLMap;
     bool isURLImportCompleted;
+    bool isSettingIcon;
 };
 
 WEBKIT_DEFINE_TYPE(WebKitFaviconDatabase, webkit_favicon_database, G_TYPE_OBJECT)
@@ -193,6 +195,9 @@
         return;
 
     priv->pageURLToIconURLMap.set(pageURL, iconURL);
+    if (priv->isSettingIcon)
+        return;
+
     g_signal_emit(database, signals[FAVICON_CHANGED], 0, pageURL.utf8().data(), iconURL.utf8().data());
 }
 
@@ -212,6 +217,8 @@
 
     void didChangeIconForPageURL(const String& pageURL) override
     {
+        if (m_database->priv->isSettingIcon)
+            return;
         String iconURL = m_database->priv->iconDatabase->synchronousIconURLForPageURL(pageURL);
         webkitFaviconDatabaseSetIconURLForPageURL(m_database, iconURL, pageURL);
     }
@@ -305,6 +312,7 @@
         return;
 
     WebKitFaviconDatabasePrivate* priv = database->priv;
+    SetForScope<bool> change(priv->isSettingIcon, true);
     priv->iconDatabase->setIconURLForPageURL(icon.url.string(), pageURL);
     priv->iconDatabase->setIconDataForIconURL(SharedBuffer::create(iconData.bytes(), iconData.size()), icon.url.string());
     webkitFaviconDatabaseSetIconURLForPageURL(database, icon.url.string(), pageURL);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to