mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: avoid redundant page-favicon-updated events on setBounds (#50084)
* fix: avoid duplicate calls in electron_api_web_contents Co-authored-by: ANANYA542 <ananyashrma6512@gmail.com> * Style: fix lint errors Co-authored-by: ANANYA542 <ananyashrma6512@gmail.com> * fix: prevent duplicate page-favicon-updated events and add regression test Co-authored-by: Ananya542 <ananyashrma6512@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: ANANYA542 <ananyashrma6512@gmail.com>
This commit is contained in:
@@ -2201,6 +2201,11 @@ void WebContents::DidUpdateFaviconURL(
|
||||
iter->icon_url.is_valid())
|
||||
unique_urls.insert(iter->icon_url);
|
||||
}
|
||||
// Only emit if favicon URLs actually changed
|
||||
if (unique_urls == last_favicon_urls_)
|
||||
return;
|
||||
last_favicon_urls_ = unique_urls;
|
||||
|
||||
Emit("page-favicon-updated", unique_urls);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/raw_ptr_exclusion.h"
|
||||
@@ -462,6 +463,9 @@ class WebContents final : public ExclusiveAccessContext,
|
||||
WebContents& operator=(const WebContents&) = delete;
|
||||
|
||||
private:
|
||||
// Store last emitted favicon URLs to avoid duplicate page-favicon-updated
|
||||
// events
|
||||
base::flat_set<GURL> last_favicon_urls_;
|
||||
// Does not manage lifetime of |web_contents|.
|
||||
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
|
||||
// Takes over ownership of |web_contents|.
|
||||
|
||||
Reference in New Issue
Block a user