Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index 63b4370f8d4f1162b4f6e1580327a29d0ac32455..3b885ccf8c58def6de798d926fe6cfc739525539 100644 |
--- a/Source/core/dom/Document.cpp |
+++ b/Source/core/dom/Document.cpp |
@@ -2166,13 +2166,19 @@ void Document::detach(const AttachContext& context) |
void Document::prepareForDestruction() |
{ |
- m_markers->prepareForDestruction(); |
- disconnectDescendantFrames(); |
+ ASSERT(!m_frame || m_frame->tree().childCount() == 0); |
- // The process of disconnecting descendant frames could have already detached us. |
if (!isActive()) |
return; |
+ ScriptForbiddenScope forbidScript; |
+ // We detach the FrameView's custom scroll bars as early as |
+ // possible to prevent detach() from messing with the view |
+ // such that its scroll bars won't be torn down. |
+ // |
+ // FIXME: We should revisit this. |
+ view()->prepareForDetach(); |
+ m_markers->prepareForDestruction(); |
if (LocalDOMWindow* window = this->domWindow()) |
window->willDetachDocumentFromFrame(); |
detach(); |