mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Fix draggable region update with BackForwardCache enabled (see issue #2421)
When BackForwardCache is enabled and the user navigates the main frame back/forward a new RFH may be created for an existing main frame GlobalId value and CefFrameHostImpl (e.g. an object that was previously Detach()ed after main frame navigation called SetMainFrame, but for which RenderFrameDeleted was not subsequently called due to insertion in the BackForwardCache). In this case we can re-attach the new RFH to the existing main frame CefFrameHostImpl in RenderFrameHostStateChanged and resume processing of messages. Swapping back/forward to an existing (already loaded) renderer does not trigger new notifications for draggable regions (e.g. RenderFrameObserver:: DraggableRegionsChanged is not called by default). We therefore explicitly request an update of draggable regions by sending the DidStopLoading message to the renderer. A new |reattached| parameter is added to CefFrameHandler::OnFrameAttached to support identification of BackForwardCache usage by the client. To test with unit tests: Run `ceftests --gtest_filter=DraggableRegionsTest.DraggableRegionsCrossOrigin --enable-features=BackForwardCache` To test manually: 1. Run `cefclient --enable-features=BackForwardCache --use-views --url=http://tests/draggable`, note that draggable regions work. 2. Load https://www.google.com via the address bar, note that draggable regions are removed. 3. Go back to http://tests/draggable, note that draggable regions work. 4. Go forward to https://www.google.com, note that draggable regions are removed.
This commit is contained in:
@@ -335,6 +335,12 @@ void CefFrameImpl::OnDidFinishLoad() {
|
||||
}
|
||||
|
||||
void CefFrameImpl::OnDraggableRegionsChanged() {
|
||||
// Match the behavior in ChromeRenderFrameObserver::DraggableRegionsChanged.
|
||||
// Only the main frame is allowed to control draggable regions, to avoid other
|
||||
// frames manipulate the regions in the browser process.
|
||||
if (frame_->Parent() != nullptr)
|
||||
return;
|
||||
|
||||
blink::WebVector<blink::WebDraggableRegion> webregions =
|
||||
frame_->GetDocument().DraggableRegions();
|
||||
std::vector<cef::mojom::DraggableRegionEntryPtr> regions;
|
||||
@@ -508,6 +514,11 @@ void CefFrameImpl::DidStopLoading() {
|
||||
// the same browser then the other occurrences will be discarded in
|
||||
// OnLoadingStateChange.
|
||||
browser_->OnLoadingStateChange(false);
|
||||
|
||||
// Refresh draggable regions. Otherwise, we may not receive updated regions
|
||||
// after navigation because LocalFrameView::UpdateDocumentAnnotatedRegion
|
||||
// lacks sufficient context.
|
||||
OnDraggableRegionsChanged();
|
||||
}
|
||||
|
||||
void CefFrameImpl::MoveOrResizeStarted() {
|
||||
|
Reference in New Issue
Block a user