Fix: Avoid redundant draggable region notifications [chromium/src : main]

0 views
Skip to first unread message

Zoraiz Naeem (Gerrit)

unread,
6:50 PM (4 hours ago) 6:50 PM
to Khushal Sagar, Daniel Cheng, Achuith Bhandarkar, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org
Attention needed from Daniel Cheng

Zoraiz Naeem voted and added 1 comment

Votes added by Zoraiz Naeem

Commit-Queue+2

1 comment

Patchset-level comments
File-level comment, Patchset 6:
Daniel Cheng . resolved

It's not clear what problem this fixes or why the update was unexpected/redundant.

Isn't it possible that the caller isn't supposed to be calling this function multiple times in a row if the state hasn't changed?

Also, note that this area is not owned by anyone at Google anymore–and furthermore, changes have a high risk of randomly breaking things since a lot of the drag-and-drop paths are poorly understood. So at minimum, the CL description needs to be a lot clearer about what exactly is broken and what the fix is (so we can have some confidence that this isn't going to break something else that works fine today), and the CL itself needs to include some tests.

Zoraiz Naeem

>> So at minimum, the CL description needs to be a lot clearer...

Done

>> Also, note that this area is not owned by anyone at Google anymore

Acked!

>> Isn't it possible that the caller isn't supposed to be calling this function multiple times in a row if the state hasn't changed?

Basically, `WebContents::SetSupportsDraggableRegions()` is called whenever a web-contents becomes primary. [1] It was done to persist the setting when primary page changed. (See [2] for motivation)

The problem that I am trying to solve arises from the change in [2]. Whenever, a page becomes primary, we call `WebContents::SetSupportsDraggableRegions()` to sync the setting.

In turn `WebViewImpl::SetSupportsDraggableRegions()` is called and set the draggable regions to zero and notify the ChromeClient. [3] This will eventually notify WebContentDelegate via `WebContentsDelegate::DraggableRegionsChanged()`. [4]

Now when we are tracking draggable regions, `WebContentsDelegate::DraggableRegionsChanged()` is only called when there is change in draggable regions. [5]

But when draggable regions are not being tracked, `WebContentsDelegate::DraggableRegionsChanged()` is always called multiple times since for each call to `SetSupportsDraggableRegions(false)`, we notify the ChromeClient [3],

This is unexpected as for webcontents that by default do not track draggable regions, we will `WebContentsDelegate::DraggableRegionsChanged()` for them multiple times which is incorrect/unexpected.

[1] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/web_contents/web_contents_impl.cc;l=11874;drc=5956c13757980696f4bfbb25d32019121d9ff658

[2]
https://chromium-review.googlesource.com/c/chromium/src/+/7043264

[3] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/exported/web_view_impl.cc;l=4205-4212;drc=117d86bef4eb55198d344517b0f53d082868dba3

[4]
https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/web_contents_delegate.h;l=854-856;drc=03aeeb0895ae65122f7b8f201f9a5de8809ff817

[5] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/local_frame_view.cc;l=1804-1808;drc=5956c13757980696f4bfbb25d32019121d9ff658

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idc50a726951af4e9b06af36cec1f31a7003ea322
Gerrit-Change-Number: 7330565
Gerrit-PatchSet: 8
Gerrit-Owner: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
Gerrit-CC: Achuith Bhandarkar <ach...@chromium.org>
Gerrit-CC: Daniel Cheng <dch...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Fri, 26 Dec 2025 23:50:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
satisfied_requirement
open
diffy

Zoraiz Naeem (Gerrit)

unread,
7:41 PM (4 hours ago) 7:41 PM
to Khushal Sagar, Daniel Cheng, Achuith Bhandarkar, AI Code Reviewer, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org
Attention needed from Daniel Cheng

Zoraiz Naeem voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idc50a726951af4e9b06af36cec1f31a7003ea322
Gerrit-Change-Number: 7330565
Gerrit-PatchSet: 11
Gerrit-Owner: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
Gerrit-CC: Achuith Bhandarkar <ach...@chromium.org>
Gerrit-CC: Daniel Cheng <dch...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Sat, 27 Dec 2025 00:41:39 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
8:29 PM (3 hours ago) 8:29 PM
to Zoraiz Naeem, Khushal Sagar, Daniel Cheng, Achuith Bhandarkar, AI Code Reviewer, chromium...@chromium.org, blink-...@chromium.org

Chromium LUCI CQ submitted the change with unreviewed changes

Unreviewed changes

6 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: third_party/blink/renderer/core/exported/web_view_impl.cc
Insertions: 1, Deletions: 3.

@@ -4206,9 +4206,7 @@
if (supports_draggable_regions_) {
local_frame->View()->UpdateDocumentDraggableRegions();
} else {
- std::vector<WebDraggableRegion> web_regions =
- MainFrameImpl()->GetDocument().DraggableRegions();
- if (web_regions.empty()) {
+ if (!local_frame->GetDocument()->HasDraggableRegions()) {
return;
}

```

Change information

Commit message:
Fix: Avoid redundant draggable region notifications

When support for draggable regions is disabled, the code clears any
existing draggable regions and notifies ChromeClient.

This is turn notifies `WebContentsDelegate::DraggableRegionsChanged()`.

Now when draggable regions are being tracked,
`WebContentsDelegate::DraggableRegionsChanged()` is only called when the
draggable regions are changed. [1]

However, there is an edge case:
`WebContents::SetSupportsDraggableRegions()` is called every time a page
becomes primary in order to sync the support for draggable regions. [2]

Now when WebContents that do not support draggable regions (the default
for each WebContent), and every time primary page changes, ChromeClient
will still be notified that draggable regions have changed (which it
hasn't)

This behavior is different than what is described above (in case of
tracking draggable regions). And this CL fixes these
redundant/unexpected notifications,

[1]
[2]
Bug: b:471289924
Change-Id: Idc50a726951af4e9b06af36cec1f31a7003ea322
Reviewed-by: Khushal Sagar <khusha...@chromium.org>
Commit-Queue: Zoraiz Naeem <zorai...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1562823}
Files:
  • M third_party/blink/renderer/core/exported/web_view_impl.cc
Change size: XS
Delta: 1 file changed, 4 insertions(+), 0 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Khushal Sagar
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idc50a726951af4e9b06af36cec1f31a7003ea322
Gerrit-Change-Number: 7330565
Gerrit-PatchSet: 13
Gerrit-Owner: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
Gerrit-CC: Achuith Bhandarkar <ach...@chromium.org>
open
diffy
satisfied_requirement

Daniel Cheng (Gerrit)

unread,
8:31 PM (3 hours ago) 8:31 PM
to Chromium LUCI CQ, Zoraiz Naeem, Khushal Sagar, Daniel Cheng, Achuith Bhandarkar, AI Code Reviewer, chromium...@chromium.org, blink-...@chromium.org
Attention needed from Zoraiz Naeem

Daniel Cheng added 1 comment

Patchset-level comments
File-level comment, Patchset 6:
Daniel Cheng . unresolved

It's not clear what problem this fixes or why the update was unexpected/redundant.

Isn't it possible that the caller isn't supposed to be calling this function multiple times in a row if the state hasn't changed?

Also, note that this area is not owned by anyone at Google anymore–and furthermore, changes have a high risk of randomly breaking things since a lot of the drag-and-drop paths are poorly understood. So at minimum, the CL description needs to be a lot clearer about what exactly is broken and what the fix is (so we can have some confidence that this isn't going to break something else that works fine today), and the CL itself needs to include some tests.

Zoraiz Naeem

>> So at minimum, the CL description needs to be a lot clearer...

Done

>> Also, note that this area is not owned by anyone at Google anymore

Acked!

>> Isn't it possible that the caller isn't supposed to be calling this function multiple times in a row if the state hasn't changed?

Basically, `WebContents::SetSupportsDraggableRegions()` is called whenever a web-contents becomes primary. [1] It was done to persist the setting when primary page changed. (See [2] for motivation)

The problem that I am trying to solve arises from the change in [2]. Whenever, a page becomes primary, we call `WebContents::SetSupportsDraggableRegions()` to sync the setting.

In turn `WebViewImpl::SetSupportsDraggableRegions()` is called and set the draggable regions to zero and notify the ChromeClient. [3] This will eventually notify WebContentDelegate via `WebContentsDelegate::DraggableRegionsChanged()`. [4]

Now when we are tracking draggable regions, `WebContentsDelegate::DraggableRegionsChanged()` is only called when there is change in draggable regions. [5]

But when draggable regions are not being tracked, `WebContentsDelegate::DraggableRegionsChanged()` is always called multiple times since for each call to `SetSupportsDraggableRegions(false)`, we notify the ChromeClient [3],

This is unexpected as for webcontents that by default do not track draggable regions, we will `WebContentsDelegate::DraggableRegionsChanged()` for them multiple times which is incorrect/unexpected.

[1] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/web_contents/web_contents_impl.cc;l=11874;drc=5956c13757980696f4bfbb25d32019121d9ff658

[2]
https://chromium-review.googlesource.com/c/chromium/src/+/7043264

[3] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/exported/web_view_impl.cc;l=4205-4212;drc=117d86bef4eb55198d344517b0f53d082868dba3

[4]
https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/web_contents_delegate.h;l=854-856;drc=03aeeb0895ae65122f7b8f201f9a5de8809ff817

Attention is currently required from:
  • Zoraiz Naeem
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Idc50a726951af4e9b06af36cec1f31a7003ea322
Gerrit-Change-Number: 7330565
Gerrit-PatchSet: 13
Gerrit-Owner: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
Gerrit-CC: Achuith Bhandarkar <ach...@chromium.org>
Gerrit-CC: Daniel Cheng <dch...@chromium.org>
Gerrit-Attention: Zoraiz Naeem <zorai...@chromium.org>
Gerrit-Comment-Date: Sat, 27 Dec 2025 01:30:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Zoraiz Naeem <zorai...@chromium.org>
Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages