• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)35  HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tagName, Document* document)
36      : HTMLElement(tagName, document)
37      , m_contentFrame(0)
38  {
39  }
40  
willRemove()41  void HTMLFrameOwnerElement::willRemove()
42  {
43      if (Frame* frame = contentFrame()) {
44          frame->disconnectOwnerElement();
45          frame->loader()->frameDetached();
46      }
47  
48      HTMLElement::willRemove();
49  }
50  
~HTMLFrameOwnerElement()51  HTMLFrameOwnerElement::~HTMLFrameOwnerElement()
52  {
53      if (m_contentFrame)
54          m_contentFrame->disconnectOwnerElement();
55  }
56  
contentDocument() const57  Document* HTMLFrameOwnerElement::contentDocument() const
58  {
59      return m_contentFrame ? m_contentFrame->document() : 0;
60  }
61  
contentWindow() const62  DOMWindow* HTMLFrameOwnerElement::contentWindow() const
63  {
64      return m_contentFrame ? m_contentFrame->domWindow() : 0;
65  }
66  
67  #if ENABLE(SVG)
getSVGDocument(ExceptionCode & ec) const68  SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
69  {
70      Document* doc = contentDocument();
71      if (doc && doc->isSVGDocument())
72          return static_cast<SVGDocument*>(doc);
73      // Spec: http://www.w3.org/TR/SVG/struct.html#InterfaceGetSVGDocument
74      ec = NOT_SUPPORTED_ERR;
75      return 0;
76  }
77  #endif
78  
79  } // namespace WebCore
80