Files
brave-core/patches
Simon Hong 88ef0fb73c Fixed invalid mouse location bug in web contents on macOS (#33226)
Resolves brave/brave-browser#51844

This PR reverts workarounds and fixes original issue brave/brave-browser#51788

This issue came from missing ContentsWebView re-layout when BridgedContentView::setFrameSize()
is called with final size.

After BridgedContentView::setFrameSize() sets final size to itself([super setFrameSize:newSize];),
it calls _bridge->host()->OnViewSizeChanged();.
In chromium, it triggers root view's layout and it reaches to ContentsWebView's layout.
Then, its native view(WebContentsViewCocoa's) can get final bounds by WebContentsNSViewBridge::SetBounds().

However, that layout chain is cut off before going to ContentsWebView because BrowserView's invalidated
layout is already cleared before calling _bridge->host()->OnViewSizeChanged();.
This made behavioral difference between Brave and Chromium when resizing happens from macOS.

BridgedContentView::setFrameSize() notifies UI about ths size change by _bridge->UpdateWindowGeometry()
before set its size([super setFrameSize:newSize];). I'll call these as first step and second step.
I think browser UI prepares for upcoming window resizing during this notification handling.
Then it goes final UI state by handling _bridge->host()->OnViewSizeChanged();. It's third step.
That's what Chromium does when window resizing.
In first step, we cleared BrowserView's needs layout bit. So, it's not re-layouted during the third step.
This clearing happens at VerticalTabStripWidgetDelegateView::ChildPreferredSizeChanged().
It asks immediate layout to BrowserView. - host_->parent()->DeprecatedLayoutImmediately(); when browser widget bounds changed.

In ChildPreferredSizeChanged(), it's sufficient to schedule layout instead of forcing it
because UpdateWidgetBounds() will be called when host bounds changed.

Some test are updated as synchronous browser view layout was gone.

Manual test on macOS:
    1. Load settings page in non restored window(not fullscreen or maximized)
    2. Check any element in settings page responded properly when mouse moved there
    3. Click green button to enter fullscreen
    4. Repeat step 2
2026-01-16 08:05:11 +09:00
..