1 /*
2 * Copyright (C) 2006, 2007 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
HTMLFrameOwnerElement(const QualifiedName & tagName,Document * document,bool createdByParser)35 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Document* document, bool createdByParser)
36 : HTMLElement(tagName, document)
37 , m_contentFrame(0)
38 , m_createdByParser(createdByParser)
39 {
40 }
41
willRemove()42 void HTMLFrameOwnerElement::willRemove()
43 {
44 if (Frame* frame = contentFrame()) {
45 frame->disconnectOwnerElement();
46 frame->loader()->frameDetached();
47 }
48
49 HTMLElement::willRemove();
50 }
51
~HTMLFrameOwnerElement()52 HTMLFrameOwnerElement::~HTMLFrameOwnerElement()
53 {
54 if (m_contentFrame)
55 m_contentFrame->disconnectOwnerElement();
56 }
57
contentDocument() const58 Document* HTMLFrameOwnerElement::contentDocument() const
59 {
60 return m_contentFrame ? m_contentFrame->document() : 0;
61 }
62
contentWindow() const63 DOMWindow* HTMLFrameOwnerElement::contentWindow() const
64 {
65 return m_contentFrame ? m_contentFrame->domWindow() : 0;
66 }
67
68 #if ENABLE(SVG)
getSVGDocument(ExceptionCode & ec) const69 SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
70 {
71 Document* doc = contentDocument();
72 if (doc && doc->isSVGDocument())
73 return static_cast<SVGDocument*>(doc);
74 // Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
75 ec = NOT_SUPPORTED_ERR;
76 return 0;
77 }
78 #endif
79
80 } // namespace WebCore
81