fix: avoid redundant page-favicon-updated events on setBounds (#49464)

* fix: avoid duplicate calls in electron_api_web_contents

* Style: fix lint errors

* fix: prevent duplicate page-favicon-updated events and add regression test
This commit is contained in:
ANANYA542
2026-03-05 16:00:46 +05:30
committed by GitHub
parent 55106192af
commit 9b15976136
2 changed files with 9 additions and 0 deletions

View File

@@ -2267,6 +2267,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);
}

View File

@@ -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|.