Commit 71b91a42 authored by marius.mlynski's avatar marius.mlynski Committed by Commit bot

Clear the owner element's widget in Document::shutdown().

FrameView::dispose() doesn't guarantee that the owner's widget is cleared
and this could be problematic when it's overwritten in
LocalFrame::createView() a short time later.

BUG=673170

Review-Url: https://codereview.chromium.org/2563313002
Cr-Commit-Position: refs/heads/master@{#438977}
parent 7121b312
...@@ -2405,6 +2405,15 @@ void Document::shutdown() { ...@@ -2405,6 +2405,15 @@ void Document::shutdown() {
ScriptForbiddenScope forbidScript; ScriptForbiddenScope forbidScript;
view()->dispose(); view()->dispose();
// If the widget of the document's frame owner doesn't match view() then
// FrameView::dispose() didn't clear the owner's widget. If we don't clear it
// here, it may be clobbered later in LocalFrame::createView(). See also
// https://crbug.com/673170 and the comment in FrameView::dispose().
HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
if (ownerElement)
ownerElement->setWidget(nullptr);
m_markers->prepareForDestruction(); m_markers->prepareForDestruction();
m_lifecycle.advanceTo(DocumentLifecycle::Stopping); m_lifecycle.advanceTo(DocumentLifecycle::Stopping);
......
...@@ -350,8 +350,11 @@ void FrameView::dispose() { ...@@ -350,8 +350,11 @@ void FrameView::dispose() {
// FIXME: Do we need to do something here for OOPI? // FIXME: Do we need to do something here for OOPI?
HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
// TODO(dcheng): It seems buggy that we can have an owner element that // TODO(dcheng): It seems buggy that we can have an owner element that points
// points to another Widget. // to another Widget. This can happen when a plugin element loads a frame
// (widget A of type FrameView) and then loads a plugin (widget B of type
// WebPluginContainerImpl). In this case, the frame's view is A and the frame
// element's owned widget is B. See https://crbug.com/673170 for an example.
if (ownerElement && ownerElement->ownedWidget() == this) if (ownerElement && ownerElement->ownedWidget() == this)
ownerElement->setWidget(nullptr); ownerElement->setWidget(nullptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment