| Index: third_party/WebKit/Source/core/dom/Document.cpp
 | 
| diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
 | 
| index c518dcc62546412e7d180c0de22139abe78270f6..a1481a308f4261799da7bd1290155e90156eb33d 100644
 | 
| --- a/third_party/WebKit/Source/core/dom/Document.cpp
 | 
| +++ b/third_party/WebKit/Source/core/dom/Document.cpp
 | 
| @@ -2473,6 +2473,7 @@ void Document::shutdown() {
 | 
|    // detaching Document is not in a consistent state.
 | 
|    ScriptForbiddenScope forbidScript;
 | 
|  
 | 
| +  m_lifecycle.advanceTo(DocumentLifecycle::Stopping);
 | 
|    view()->dispose();
 | 
|  
 | 
|    // If the FrameViewBase of the document's frame owner doesn't match view()
 | 
| @@ -2485,8 +2486,6 @@ void Document::shutdown() {
 | 
|  
 | 
|    m_markers->prepareForDestruction();
 | 
|  
 | 
| -  m_lifecycle.advanceTo(DocumentLifecycle::Stopping);
 | 
| -
 | 
|    if (page())
 | 
|      page()->documentDetached(this);
 | 
|    probe::documentDetached(this);
 | 
| @@ -4581,13 +4580,19 @@ HTMLFrameOwnerElement* Document::localOwner() const {
 | 
|  
 | 
|  void Document::willChangeFrameOwnerProperties(int marginWidth,
 | 
|                                                int marginHeight,
 | 
| -                                              ScrollbarMode scrollingMode) {
 | 
| -  if (!body())
 | 
| -    return;
 | 
| -
 | 
| +                                              ScrollbarMode scrollingMode,
 | 
| +                                              bool isDisplayNone) {
 | 
|    DCHECK(frame() && frame()->owner());
 | 
|    FrameOwner* owner = frame()->owner();
 | 
|  
 | 
| +  if (documentElement()) {
 | 
| +    if (isDisplayNone != owner->isDisplayNone())
 | 
| +      documentElement()->lazyReattachIfAttached();
 | 
| +  }
 | 
| +
 | 
| +  if (!body())
 | 
| +    return;
 | 
| +
 | 
|    if (marginWidth != owner->marginWidth())
 | 
|      body()->setIntegralAttribute(marginwidthAttr, marginWidth);
 | 
|    if (marginHeight != owner->marginHeight())
 | 
| 
 |