Home | History | Annotate | Download | only in html
      1 /*
      2  * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  *
     19  */
     20 
     21 #include "config.h"
     22 #include "HTMLFrameOwnerElement.h"
     23 
     24 #include "DOMWindow.h"
     25 #include "Frame.h"
     26 #include "FrameLoader.h"
     27 
     28 #if ENABLE(SVG)
     29 #include "ExceptionCode.h"
     30 #include "SVGDocument.h"
     31 #endif
     32 
     33 namespace WebCore {
     34 
     35 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Document* document)
     36     : HTMLElement(tagName, document, CreateElement)
     37     , m_contentFrame(0)
     38     , m_sandboxFlags(SandboxNone)
     39 {
     40 }
     41 
     42 void HTMLFrameOwnerElement::willRemove()
     43 {
     44     if (Frame* frame = contentFrame()) {
     45         frame->disconnectOwnerElement();
     46         frame->loader()->frameDetached();
     47     }
     48 
     49     HTMLElement::willRemove();
     50 }
     51 
     52 HTMLFrameOwnerElement::~HTMLFrameOwnerElement()
     53 {
     54     if (m_contentFrame)
     55         m_contentFrame->disconnectOwnerElement();
     56 }
     57 
     58 Document* HTMLFrameOwnerElement::contentDocument() const
     59 {
     60     return m_contentFrame ? m_contentFrame->document() : 0;
     61 }
     62 
     63 DOMWindow* HTMLFrameOwnerElement::contentWindow() const
     64 {
     65     return m_contentFrame ? m_contentFrame->domWindow() : 0;
     66 }
     67 
     68 void HTMLFrameOwnerElement::setSandboxFlags(SandboxFlags flags)
     69 {
     70     if (m_sandboxFlags == flags)
     71         return;
     72 
     73     m_sandboxFlags = flags;
     74 
     75     if (Frame* frame = contentFrame())
     76         frame->loader()->ownerElementSandboxFlagsChanged();
     77 }
     78 
     79 #if ENABLE(SVG)
     80 SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
     81 {
     82     Document* doc = contentDocument();
     83     if (doc && doc->isSVGDocument())
     84         return static_cast<SVGDocument*>(doc);
     85     // Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
     86     ec = NOT_SUPPORTED_ERR;
     87     return 0;
     88 }
     89 #endif
     90 
     91 } // namespace WebCore
     92