| 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 b4fde8e7cfcc90578583eb715896d7731fe159c5..03e484e07463a3b0108cbc2338fde661a647aae7 100644
|
| --- a/third_party/WebKit/Source/core/dom/Document.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Document.cpp
|
| @@ -598,7 +598,14 @@ void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
|
| {
|
| DCHECK(newScroller);
|
|
|
| - if (ownerElement()) {
|
| + if (!frame()) {
|
| + exceptionState.throwDOMException(
|
| + InvalidStateError,
|
| + "Root scroller cannot be set on a document not attached to a window.");
|
| + return;
|
| + }
|
| +
|
| + if (!frame()->isMainFrame()) {
|
| exceptionState.throwDOMException(
|
| WrongDocumentError,
|
| "Root scroller cannot be set on a document within a frame.");
|
| @@ -628,7 +635,11 @@ void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
|
|
|
| Element* Document::rootScroller()
|
| {
|
| - if (ownerElement())
|
| + if (!frame())
|
| + return nullptr;
|
| +
|
| + // TODO(bokan): Should child frames return the documentElement or nullptr?
|
| + if (!frame()->isMainFrame())
|
| return documentElement();
|
|
|
| FrameHost* host = frameHost();
|
| @@ -1902,7 +1913,7 @@ void Document::updateLayout()
|
| return;
|
| }
|
|
|
| - if (HTMLFrameOwnerElement* owner = ownerElement())
|
| + if (HTMLFrameOwnerElement* owner = localOwnerElement())
|
| owner->document().updateLayout();
|
|
|
| updateLayoutTree();
|
| @@ -1940,7 +1951,7 @@ void Document::layoutUpdated()
|
| m_documentTiming.markFirstLayout();
|
| }
|
|
|
| - if (!ownerElement() && frameHost()) {
|
| + if (!localOwnerElement() && frameHost()) {
|
| if (RootScroller* rootScroller = frameHost()->rootScroller())
|
| rootScroller->didUpdateTopDocumentLayout();
|
| }
|
| @@ -2669,7 +2680,7 @@ void Document::implicitClose()
|
| // We used to force a synchronous display and flush here. This really isn't
|
| // necessary and can in fact be actively harmful if pages are loading at a rate of > 60fps
|
| // (if your platform is syncing flushes and limiting them to 60fps).
|
| - if (!ownerElement() || (ownerElement()->layoutObject() && !ownerElement()->layoutObject()->needsLayout())) {
|
| + if (!localOwnerElement() || (localOwnerElement()->layoutObject() && !localOwnerElement()->layoutObject()->needsLayout())) {
|
| updateLayoutTree();
|
|
|
| // Always do a layout after loading if needed.
|
| @@ -4046,7 +4057,7 @@ void Document::addListenerTypeIfNeeded(const AtomicString& eventType)
|
| }
|
| }
|
|
|
| -HTMLFrameOwnerElement* Document::ownerElement() const
|
| +HTMLFrameOwnerElement* Document::localOwnerElement() const
|
| {
|
| if (!frame())
|
| return 0;
|
| @@ -4056,7 +4067,7 @@ HTMLFrameOwnerElement* Document::ownerElement() const
|
|
|
| bool Document::isInInvisibleSubframe() const
|
| {
|
| - if (!ownerElement())
|
| + if (!localOwnerElement())
|
| return false; // this is the root element
|
|
|
| DCHECK(frame());
|
| @@ -4641,7 +4652,7 @@ Document& Document::topDocument() const
|
| // FIXME: Not clear what topDocument() should do in the OOPI case--should it return the topmost
|
| // available Document, or something else?
|
| Document* doc = const_cast<Document*>(this);
|
| - for (HTMLFrameOwnerElement* element = doc->ownerElement(); element; element = doc->ownerElement())
|
| + for (HTMLFrameOwnerElement* element = doc->localOwnerElement(); element; element = doc->localOwnerElement())
|
| doc = &element->document();
|
|
|
| DCHECK(doc);
|
| @@ -5547,7 +5558,7 @@ void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
|
| Element* innerElementInDocument = innerElement;
|
| while (innerElementInDocument && innerElementInDocument->document() != this) {
|
| innerElementInDocument->document().updateHoverActiveState(request, innerElementInDocument);
|
| - innerElementInDocument = innerElementInDocument->document().ownerElement();
|
| + innerElementInDocument = innerElementInDocument->document().localOwnerElement();
|
| }
|
|
|
| updateDistribution();
|
|
|