2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
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.
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.
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.
22 #include "HTMLFrameOwnerElement.h"
24 #include "DOMWindow.h"
26 #include "FrameLoader.h"
27 #include "RenderPart.h"
30 #include "ExceptionCode.h"
31 #include "SVGDocument.h"
36 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Document* document)
37 : HTMLElement(tagName, document)
39 , m_sandboxFlags(SandboxNone)
43 RenderPart* HTMLFrameOwnerElement::renderPart() const
45 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers
46 // when using fallback content.
47 if (!renderer() || !renderer()->isRenderPart())
49 return toRenderPart(renderer());
52 void HTMLFrameOwnerElement::willRemove()
54 // FIXME: It is unclear why this can't be moved to removedFromDocument()
55 // this is the only implementation of willRemove in WebCore!
56 if (Frame* frame = contentFrame()) {
57 RefPtr<Frame> protect(frame);
58 frame->loader()->frameDetached();
59 frame->disconnectOwnerElement();
62 HTMLElement::willRemove();
65 HTMLFrameOwnerElement::~HTMLFrameOwnerElement()
68 m_contentFrame->disconnectOwnerElement();
71 Document* HTMLFrameOwnerElement::contentDocument() const
73 return m_contentFrame ? m_contentFrame->document() : 0;
76 DOMWindow* HTMLFrameOwnerElement::contentWindow() const
78 return m_contentFrame ? m_contentFrame->domWindow() : 0;
81 void HTMLFrameOwnerElement::setSandboxFlags(SandboxFlags flags)
83 if (m_sandboxFlags == flags)
86 m_sandboxFlags = flags;
88 if (Frame* frame = contentFrame())
89 frame->loader()->ownerElementSandboxFlagsChanged();
92 bool HTMLFrameOwnerElement::isKeyboardFocusable(KeyboardEvent* event) const
94 return m_contentFrame && HTMLElement::isKeyboardFocusable(event);
98 SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
100 Document* doc = contentDocument();
101 if (doc && doc->isSVGDocument())
102 return static_cast<SVGDocument*>(doc);
103 // Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
104 ec = NOT_SUPPORTED_ERR;
109 } // namespace WebCore