diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLFrameElementBase.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/html/HTMLFrameElementBase.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLFrameElementBase.cpp | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/Source/WebCore/html/HTMLFrameElementBase.cpp b/Source/WebCore/html/HTMLFrameElementBase.cpp index 3b34af5bb..2ee3a53ad 100644 --- a/Source/WebCore/html/HTMLFrameElementBase.cpp +++ b/Source/WebCore/html/HTMLFrameElementBase.cpp @@ -3,7 +3,7 @@ * (C) 1999 Antti Koivisto (koivisto@kde.org) * (C) 2000 Simon Hausmann (hausmann@kde.org) * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2004-2017 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,21 +24,20 @@ #include "config.h" #include "HTMLFrameElementBase.h" -#include "Attribute.h" #include "Document.h" -#include "EventNames.h" #include "FocusController.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameView.h" #include "HTMLNames.h" #include "HTMLParserIdioms.h" -#include "URL.h" +#include "JSDOMBindingSecurity.h" #include "Page.h" #include "RenderWidget.h" #include "ScriptController.h" #include "Settings.h" #include "SubframeLoader.h" +#include "URL.h" namespace WebCore { @@ -49,22 +48,27 @@ HTMLFrameElementBase::HTMLFrameElementBase(const QualifiedName& tagName, Documen , m_scrolling(ScrollbarAuto) , m_marginWidth(-1) , m_marginHeight(-1) - , m_viewSource(false) { setHasCustomStyleResolveCallbacks(); } bool HTMLFrameElementBase::isURLAllowed() const { + if (m_URL.isEmpty()) + return true; + + return isURLAllowed(document().completeURL(m_URL)); +} + +bool HTMLFrameElementBase::isURLAllowed(const URL& completeURL) const +{ if (document().page() && document().page()->subframeCount() >= Page::maxNumberOfFrames) return false; - if (m_URL.isEmpty()) + if (completeURL.isEmpty()) return true; - const URL& completeURL = document().completeURL(m_URL); - - if (protocolIsJavaScript(completeURL)) { + if (protocolIsJavaScript(completeURL)) { Document* contentDoc = this->contentDocument(); if (contentDoc && !ScriptController::canAccessFromCurrentOrigin(contentDoc->frame())) return false; @@ -77,7 +81,7 @@ bool HTMLFrameElementBase::isURLAllowed() const return true; } -void HTMLFrameElementBase::openURL(bool lockHistory, bool lockBackForwardList) +void HTMLFrameElementBase::openURL(LockHistory lockHistory, LockBackForwardList lockBackForwardList) { if (!isURLAllowed()) return; @@ -90,20 +94,19 @@ void HTMLFrameElementBase::openURL(bool lockHistory, bool lockBackForwardList) return; parentFrame->loader().subframeLoader().requestFrame(*this, m_URL, m_frameName, lockHistory, lockBackForwardList); - if (contentFrame()) - contentFrame()->setInViewSourceMode(viewSourceMode()); } void HTMLFrameElementBase::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == srcdocAttr) setLocation("about:srcdoc"); - else if (name == srcAttr && !fastHasAttribute(srcdocAttr)) + else if (name == srcAttr && !hasAttributeWithoutSynchronization(srcdocAttr)) setLocation(stripLeadingAndTrailingHTMLSpaces(value)); - else if (isIdAttributeName(name)) { - // Important to call through to base for the id attribute so the hasID bit gets set. + else if (name == idAttr) { HTMLFrameOwnerElement::parseAttribute(name, value); - m_frameName = value; + // Falling back to using the 'id' attribute is not standard but some content relies on this behavior. + if (!hasAttributeWithoutSynchronization(nameAttr)) + m_frameName = value; } else if (name == nameAttr) { m_frameName = value; // FIXME: If we are already attached, this doesn't actually change the frame's name. @@ -117,16 +120,11 @@ void HTMLFrameElementBase::parseAttribute(const QualifiedName& name, const Atomi // FIXME: If we are already attached, this has no effect. } else if (name == scrollingAttr) { // Auto and yes both simply mean "allow scrolling." No means "don't allow scrolling." - if (equalIgnoringCase(value, "auto") || equalIgnoringCase(value, "yes")) + if (equalLettersIgnoringASCIICase(value, "auto") || equalLettersIgnoringASCIICase(value, "yes")) m_scrolling = document().frameElementsShouldIgnoreScrolling() ? ScrollbarAlwaysOff : ScrollbarAuto; - else if (equalIgnoringCase(value, "no")) + else if (equalLettersIgnoringASCIICase(value, "no")) m_scrolling = ScrollbarAlwaysOff; // FIXME: If we are already attached, this has no effect. - } else if (name == onbeforeloadAttr) - setAttributeEventListener(eventNames().beforeloadEvent, name, value); - else if (name == onbeforeunloadAttr) { - // FIXME: should <frame> elements have beforeunload handlers? - setAttributeEventListener(eventNames().beforeunloadEvent, name, value); } else HTMLFrameOwnerElement::parseAttribute(name, value); } @@ -134,6 +132,7 @@ void HTMLFrameElementBase::parseAttribute(const QualifiedName& name, const Atomi void HTMLFrameElementBase::setNameAndOpenURL() { m_frameName = getNameAttribute(); + // Falling back to using the 'id' attribute is not standard but some content relies on this behavior. if (m_frameName.isNull()) m_frameName = getIdAttribute(); openURL(); @@ -142,17 +141,17 @@ void HTMLFrameElementBase::setNameAndOpenURL() Node::InsertionNotificationRequest HTMLFrameElementBase::insertedInto(ContainerNode& insertionPoint) { HTMLFrameOwnerElement::insertedInto(insertionPoint); - if (insertionPoint.inDocument()) - return InsertionShouldCallDidNotifySubtreeInsertions; + if (insertionPoint.isConnected()) + return InsertionShouldCallFinishedInsertingSubtree; return InsertionDone; } -void HTMLFrameElementBase::didNotifySubtreeInsertions(ContainerNode*) +void HTMLFrameElementBase::finishedInsertingSubtree() { - if (!inDocument()) + if (!isConnected()) return; - // DocumentFragments don't kick of any loads. + // DocumentFragments don't kick off any loads. if (!document().frame()) return; @@ -160,7 +159,7 @@ void HTMLFrameElementBase::didNotifySubtreeInsertions(ContainerNode*) return; if (!renderer()) - setNeedsStyleRecalc(ReconstructRenderTree); + invalidateStyleAndRenderersForSubtree(); setNameAndOpenURL(); } @@ -174,21 +173,30 @@ void HTMLFrameElementBase::didAttachRenderers() URL HTMLFrameElementBase::location() const { - if (fastHasAttribute(srcdocAttr)) + if (hasAttributeWithoutSynchronization(srcdocAttr)) return URL(ParsedURLString, "about:srcdoc"); - return document().completeURL(getAttribute(srcAttr)); + return document().completeURL(attributeWithoutSynchronization(srcAttr)); } void HTMLFrameElementBase::setLocation(const String& str) { - Settings* settings = document().settings(); - if (settings && settings->needsAcrobatFrameReloadingQuirk() && m_URL == str) + if (document().settings().needsAcrobatFrameReloadingQuirk() && m_URL == str) return; m_URL = AtomicString(str); - if (inDocument()) - openURL(false, false); + if (isConnected()) + openURL(LockHistory::No, LockBackForwardList::No); +} + +void HTMLFrameElementBase::setLocation(JSC::ExecState& state, const String& newLocation) +{ + if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(newLocation))) { + if (!BindingSecurity::shouldAllowAccessToNode(state, contentDocument())) + return; + } + + setLocation(newLocation); } bool HTMLFrameElementBase::supportsFocus() const @@ -209,7 +217,7 @@ void HTMLFrameElementBase::setFocus(bool received) bool HTMLFrameElementBase::isURLAttribute(const Attribute& attribute) const { - return attribute.name() == srcAttr || HTMLFrameOwnerElement::isURLAttribute(attribute); + return attribute.name() == srcAttr || attribute.name() == longdescAttr || HTMLFrameOwnerElement::isURLAttribute(attribute); } bool HTMLFrameElementBase::isHTMLContentAttribute(const Attribute& attribute) const |