Fix timing issue with OnDraggableRegionsChanged

When bfcache is disabled use the RenderFrameObserver::DidFinishLoad notification
instead of the DidStopLoading notification that originates from the browser
process. During fast navigation the DidStopLoading notification may arrive in
the renderer after a new navigation has commenced and cause the wrong regions to
be reported.
This commit is contained in:
Marshall Greenblatt 2022-06-22 18:57:49 +03:00
parent 100b457743
commit ec8076536e
1 changed files with 16 additions and 4 deletions

View File

@ -49,6 +49,7 @@
#include "third_party/blink/public/web/web_navigation_control.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace {
@ -337,6 +338,14 @@ void CefFrameImpl::OnDidFinishLoad() {
if (blink_glue::HasPluginFrameOwner(frame_))
return;
if (!blink::RuntimeEnabledFeatures::BackForwardCacheEnabled() && IsMain()) {
// Refresh draggable regions. Otherwise, we may not receive updated regions
// after navigation because LocalFrameView::UpdateDocumentAnnotatedRegion
// lacks sufficient context. When bfcache is disabled we use this method
// instead of DidStopLoading() because it provides more accurate timing.
OnDraggableRegionsChanged();
}
blink::WebDocumentLoader* dl = frame_->GetDocumentLoader();
const int http_status_code = dl->GetWebResponse().HttpStatusCode();
@ -711,10 +720,13 @@ void CefFrameImpl::DidStopLoading() {
// OnLoadingStateChange.
browser_->OnLoadingStateChange(false);
// Refresh draggable regions. Otherwise, we may not receive updated regions
// after navigation because LocalFrameView::UpdateDocumentAnnotatedRegion
// lacks sufficient context.
OnDraggableRegionsChanged();
if (blink::RuntimeEnabledFeatures::BackForwardCacheEnabled()) {
// Refresh draggable regions. Otherwise, we may not receive updated regions
// after navigation because LocalFrameView::UpdateDocumentAnnotatedRegion
// lacks sufficient context. When bfcache is enabled we can't rely on
// OnDidFinishLoad() as the frame may not actually be reloaded.
OnDraggableRegionsChanged();
}
}
void CefFrameImpl::ContextLifecycleStateChanged(