| 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 701c2bad60f31aba91f7d30ed0ab002a7649c379..e59f0f5d461acfa418e75b603bdfbb4d26974a57 100644
|
| --- a/third_party/WebKit/Source/core/dom/Document.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/Document.cpp
|
| @@ -598,10 +598,10 @@ void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
|
| {
|
| DCHECK(newScroller);
|
|
|
| - if (ownerElement()) {
|
| + if (!frame() || !frame()->isMainFrame()) {
|
| exceptionState.throwDOMException(
|
| WrongDocumentError,
|
| - "Root scroller cannot be set on a document within a frame.");
|
| + "Root scroller can only be set on the top window's document.");
|
| return;
|
| }
|
|
|
| @@ -628,7 +628,8 @@ void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
|
|
|
| Element* Document::rootScroller()
|
| {
|
| - if (ownerElement())
|
| + // TODO(bokan): Should child frames return the documentElement or nullptr?
|
| + if (!isInMainFrame())
|
| return documentElement();
|
|
|
| FrameHost* host = frameHost();
|
| @@ -643,6 +644,11 @@ Element* Document::rootScroller()
|
| return rootScroller->get();
|
| }
|
|
|
| +bool Document::isInMainFrame() const
|
| +{
|
| + return frame() && frame()->isMainFrame();
|
| +}
|
| +
|
| AtomicString Document::convertLocalName(const AtomicString& name)
|
| {
|
| return isHTMLDocument() ? name.lower() : name;
|
| @@ -1886,7 +1892,7 @@ void Document::updateLayout()
|
| return;
|
| }
|
|
|
| - if (HTMLFrameOwnerElement* owner = ownerElement())
|
| + if (HTMLFrameOwnerElement* owner = localOwner())
|
| owner->document().updateLayout();
|
|
|
| updateLayoutTree();
|
| @@ -1924,9 +1930,9 @@ void Document::layoutUpdated()
|
| m_documentTiming.markFirstLayout();
|
| }
|
|
|
| - if (!ownerElement() && frameHost()) {
|
| - if (RootScroller* rootScroller = frameHost()->rootScroller())
|
| - rootScroller->didUpdateTopDocumentLayout();
|
| + if (isInMainFrame() && frameHost()) {
|
| + DCHECK(frameHost()->rootScroller());
|
| + frameHost()->rootScroller()->didUpdateTopDocumentLayout();
|
| }
|
| }
|
|
|
| @@ -2649,7 +2655,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 (!localOwner() || (localOwner()->layoutObject() && !localOwner()->layoutObject()->needsLayout())) {
|
| updateLayoutTree();
|
|
|
| // Always do a layout after loading if needed.
|
| @@ -4032,7 +4038,7 @@ void Document::addListenerTypeIfNeeded(const AtomicString& eventType)
|
| }
|
| }
|
|
|
| -HTMLFrameOwnerElement* Document::ownerElement() const
|
| +HTMLFrameOwnerElement* Document::localOwner() const
|
| {
|
| if (!frame())
|
| return 0;
|
| @@ -4042,9 +4048,10 @@ HTMLFrameOwnerElement* Document::ownerElement() const
|
|
|
| bool Document::isInInvisibleSubframe() const
|
| {
|
| - if (!ownerElement())
|
| - return false; // this is the root element
|
| + if (!localOwner())
|
| + return false; // this is a local root element
|
|
|
| + // TODO(bokan): This looks like it doesn't work in OOPIF.
|
| DCHECK(frame());
|
| return !frame()->ownerLayoutObject();
|
| }
|
| @@ -4633,7 +4640,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->localOwner(); element; element = doc->localOwner())
|
| doc = &element->document();
|
|
|
| DCHECK(doc);
|
| @@ -5545,7 +5552,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().localOwner();
|
| }
|
|
|
| updateDistribution();
|
|
|