Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / core / html / HTMLFrameOwnerElement.h
blobf0236a61cdf5a2dde0c7aeb34f669f7818437433
1 /*
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/CoreExport.h"
25 #include "core/dom/Document.h"
26 #include "core/frame/FrameOwner.h"
27 #include "core/html/HTMLElement.h"
28 #include "platform/heap/Handle.h"
29 #include "platform/scroll/ScrollTypes.h"
30 #include "platform/weborigin/SecurityPolicy.h"
31 #include "wtf/HashCountedSet.h"
33 namespace blink {
35 class LocalDOMWindow;
36 class ExceptionState;
37 class Frame;
38 class LayoutPart;
39 class Widget;
41 class CORE_EXPORT HTMLFrameOwnerElement : public HTMLElement, public FrameOwner {
42 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLFrameOwnerElement);
43 public:
44 ~HTMLFrameOwnerElement() override;
46 Frame* contentFrame() const { return m_contentFrame; }
47 DOMWindow* contentWindow() const;
48 Document* contentDocument() const;
50 void setContentFrame(Frame&);
51 void clearContentFrame();
53 virtual void disconnectContentFrame();
55 // Most subclasses use LayoutPart (either LayoutEmbeddedObject or LayoutIFrame)
56 // except for HTMLObjectElement and HTMLEmbedElement which may return any
57 // LayoutObject when using fallback content.
58 LayoutPart* layoutPart() const;
60 Document* getSVGDocument(ExceptionState&) const;
62 virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; }
64 virtual bool loadedNonEmptyDocument() const { return false; }
65 virtual void didLoadNonEmptyDocument() { }
67 void setWidget(PassRefPtrWillBeRawPtr<Widget>);
68 Widget* ownedWidget() const;
70 class UpdateSuspendScope {
71 STACK_ALLOCATED();
72 public:
73 UpdateSuspendScope();
74 ~UpdateSuspendScope();
76 private:
77 void performDeferredWidgetTreeOperations();
80 // FrameOwner overrides:
81 bool isLocal() const override { return true; }
82 void dispatchLoad() override;
83 SandboxFlags sandboxFlags() const override { return m_sandboxFlags; }
84 void renderFallbackContent() override { }
86 DECLARE_VIRTUAL_TRACE();
88 protected:
89 HTMLFrameOwnerElement(const QualifiedName& tagName, Document&);
90 void setSandboxFlags(SandboxFlags);
92 bool loadOrRedirectSubframe(const KURL&, const AtomicString& frameName, bool replaceCurrentItem);
94 private:
95 bool isKeyboardFocusable() const override;
96 bool isFrameOwnerElement() const final { return true; }
98 virtual ReferrerPolicy referrerPolicyAttribute() { return ReferrerPolicyDefault; }
100 RawPtrWillBeMember<Frame> m_contentFrame;
101 RefPtrWillBeMember<Widget> m_widget;
102 SandboxFlags m_sandboxFlags;
105 DEFINE_ELEMENT_TYPE_CASTS(HTMLFrameOwnerElement, isFrameOwnerElement());
107 class SubframeLoadingDisabler {
108 STACK_ALLOCATED();
109 public:
110 explicit SubframeLoadingDisabler(Node& root)
111 : m_root(root)
113 disabledSubtreeRoots().add(m_root);
116 ~SubframeLoadingDisabler()
118 disabledSubtreeRoots().remove(m_root);
121 static bool canLoadFrame(HTMLFrameOwnerElement& owner)
123 if (owner.document().unloadStarted())
124 return false;
125 for (Node* node = &owner; node; node = node->parentOrShadowHostNode()) {
126 if (disabledSubtreeRoots().contains(node))
127 return false;
129 return true;
132 private:
133 static WillBeHeapHashCountedSet<RawPtrWillBeMember<Node>>& disabledSubtreeRoots();
135 RawPtrWillBeMember<Node> m_root;
138 DEFINE_TYPE_CASTS(HTMLFrameOwnerElement, FrameOwner, owner, owner->isLocal(), owner.isLocal());
140 } // namespace blink
142 #endif // HTMLFrameOwnerElement_h