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.
21 #ifndef HTMLFrameOwnerElement_h
22 #define HTMLFrameOwnerElement_h
24 #include "core/dom/Document.h"
25 #include "core/frame/FrameOwner.h"
26 #include "core/html/HTMLElement.h"
27 #include "platform/heap/Handle.h"
28 #include "platform/scroll/ScrollTypes.h"
29 #include "wtf/HashCountedSet.h"
39 class HTMLFrameOwnerElement : public HTMLElement, public FrameOwner {
40 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLFrameOwnerElement);
42 virtual ~HTMLFrameOwnerElement();
44 Frame* contentFrame() const { return m_contentFrame; }
45 LocalDOMWindow* contentWindow() const;
46 Document* contentDocument() const;
48 void setContentFrame(Frame&);
49 void clearContentFrame();
51 virtual void disconnectContentFrame();
53 // Most subclasses use RenderPart (either RenderEmbeddedObject or RenderIFrame)
54 // except for HTMLObjectElement and HTMLEmbedElement which may return any
55 // RenderObject when using fallback content.
56 RenderPart* renderPart() const;
58 Document* getSVGDocument(ExceptionState&) const;
60 virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; }
62 virtual bool loadedNonEmptyDocument() const { return false; }
63 virtual void didLoadNonEmptyDocument() { }
65 virtual void renderFallbackContent() { }
67 virtual bool isObjectElement() const { return false; }
68 void setWidget(PassRefPtrWillBeRawPtr<Widget>);
69 Widget* ownedWidget() const;
71 class UpdateSuspendScope {
74 ~UpdateSuspendScope();
77 void performDeferredWidgetTreeOperations();
80 virtual void trace(Visitor*) override;
83 HTMLFrameOwnerElement(const QualifiedName& tagName, Document&);
84 void setSandboxFlags(SandboxFlags);
86 bool loadOrRedirectSubframe(const KURL&, const AtomicString& frameName, bool lockBackForwardList);
89 virtual bool isKeyboardFocusable() const override;
90 virtual bool isFrameOwnerElement() const override final { return true; }
92 // FrameOwner overrides:
93 virtual bool isLocal() const { return true; }
94 virtual SandboxFlags sandboxFlags() const override { return m_sandboxFlags; }
95 virtual void dispatchLoad() override;
97 RawPtrWillBeMember<Frame> m_contentFrame;
98 RefPtrWillBeMember<Widget> m_widget;
99 SandboxFlags m_sandboxFlags;
102 DEFINE_ELEMENT_TYPE_CASTS(HTMLFrameOwnerElement, isFrameOwnerElement());
104 class SubframeLoadingDisabler {
107 explicit SubframeLoadingDisabler(Node& root)
110 disabledSubtreeRoots().add(m_root);
113 ~SubframeLoadingDisabler()
115 disabledSubtreeRoots().remove(m_root);
118 static bool canLoadFrame(HTMLFrameOwnerElement& owner)
120 if (owner.document().unloadStarted())
122 for (Node* node = &owner; node; node = node->parentOrShadowHostNode()) {
123 if (disabledSubtreeRoots().contains(node))
130 static WillBeHeapHashCountedSet<RawPtrWillBeMember<Node>>& disabledSubtreeRoots();
132 RawPtrWillBeMember<Node> m_root;
135 DEFINE_TYPE_CASTS(HTMLFrameOwnerElement, FrameOwner, owner, owner->isLocal(), owner.isLocal());
139 #endif // HTMLFrameOwnerElement_h