HTMLFrameOwnerElement.cpp [plain text]
#include "config.h"
#include "HTMLFrameOwnerElement.h"
#include "DOMWindow.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "RenderPart.h"
#if ENABLE(SVG)
#include "ExceptionCode.h"
#include "SVGDocument.h"
#endif
namespace WebCore {
HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Document* document)
: HTMLElement(tagName, document)
, m_contentFrame(0)
, m_sandboxFlags(SandboxNone)
{
}
RenderPart* HTMLFrameOwnerElement::renderPart() const
{
if (!renderer() || !renderer()->isRenderPart())
return 0;
return toRenderPart(renderer());
}
void HTMLFrameOwnerElement::willRemove()
{
if (Frame* frame = contentFrame()) {
RefPtr<Frame> protect(frame);
frame->loader()->frameDetached();
frame->disconnectOwnerElement();
}
HTMLElement::willRemove();
}
HTMLFrameOwnerElement::~HTMLFrameOwnerElement()
{
if (m_contentFrame)
m_contentFrame->disconnectOwnerElement();
}
Document* HTMLFrameOwnerElement::contentDocument() const
{
return m_contentFrame ? m_contentFrame->document() : 0;
}
DOMWindow* HTMLFrameOwnerElement::contentWindow() const
{
return m_contentFrame ? m_contentFrame->domWindow() : 0;
}
void HTMLFrameOwnerElement::setSandboxFlags(SandboxFlags flags)
{
if (m_sandboxFlags == flags)
return;
m_sandboxFlags = flags;
if (Frame* frame = contentFrame())
frame->loader()->ownerElementSandboxFlagsChanged();
}
bool HTMLFrameOwnerElement::isKeyboardFocusable(KeyboardEvent* event) const
{
return m_contentFrame && HTMLElement::isKeyboardFocusable(event);
}
#if ENABLE(SVG)
SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
{
Document* doc = contentDocument();
if (doc && doc->isSVGDocument())
return static_cast<SVGDocument*>(doc);
ec = NOT_SUPPORTED_ERR;
return 0;
}
#endif
}