OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | |
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | |
9 * Copyright (C) 2013 Google Inc. All rights reserved. | |
10 * | |
11 * This library is free software; you can redistribute it and/or | |
12 * modify it under the terms of the GNU Library General Public | |
13 * License as published by the Free Software Foundation; either | |
14 * version 2 of the License, or (at your option) any later version. | |
15 * | |
16 * This library is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 * Library General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU Library General Public License | |
22 * along with this library; see the file COPYING.LIB. If not, write to | |
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
24 * Boston, MA 02110-1301, USA. | |
25 * | |
26 */ | |
27 | |
28 #ifndef FullscreenElementStack_h | |
29 #define FullscreenElementStack_h | |
30 | |
31 #include "core/dom/Document.h" | |
32 #include "core/dom/DocumentLifecycleObserver.h" | |
33 #include "core/dom/Element.h" | |
34 #include "platform/Supplementable.h" | |
35 #include "platform/Timer.h" | |
36 #include "platform/geometry/LayoutRect.h" | |
37 #include "wtf/Deque.h" | |
38 #include "wtf/RefPtr.h" | |
39 #include "wtf/Vector.h" | |
40 | |
41 namespace blink { | |
42 | |
43 class RenderFullScreen; | |
44 class RenderStyle; | |
45 | |
46 class FullscreenElementStack FINAL | |
47 : public NoBaseWillBeGarbageCollectedFinalized<FullscreenElementStack> | |
48 , public DocumentSupplement | |
49 , public DocumentLifecycleObserver { | |
50 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(FullscreenElementStack); | |
51 public: | |
52 virtual ~FullscreenElementStack(); | |
53 static const char* supplementName(); | |
54 static FullscreenElementStack& from(Document&); | |
55 static FullscreenElementStack* fromIfExists(Document&); | |
56 static Element* fullscreenElementFrom(Document&); | |
57 static Element* currentFullScreenElementFrom(Document&); | |
58 static bool isFullScreen(Document&); | |
59 static bool isActiveFullScreenElement(const Element&); | |
60 | |
61 enum RequestType { | |
62 UnprefixedRequest, // Element.requestFullscreen() | |
63 PrefixedRequest, // Element.webkitRequestFullscreen() | |
64 PrefixedMozillaRequest, // Element.webkitRequestFullScreen() | |
65 PrefixedMozillaAllowKeyboardInputRequest, // Element.webkitRequestFullSc
reen(Element.ALLOW_KEYBOARD_INPUT) | |
66 PrefixedVideoRequest, // HTMLVideoElement.webkitEnterFullscreen() and we
bkitEnterFullScreen() | |
67 }; | |
68 | |
69 void requestFullscreen(Element&, RequestType); | |
70 void fullyExitFullscreen(); | |
71 void exitFullscreen(); | |
72 | |
73 static bool fullscreenEnabled(Document&); | |
74 Element* fullscreenElement() const { return !m_fullScreenElementStack.isEmpt
y() ? m_fullScreenElementStack.last().first.get() : 0; } | |
75 | |
76 void willEnterFullScreenForElement(Element*); | |
77 void didEnterFullScreenForElement(Element*); | |
78 void willExitFullScreenForElement(Element*); | |
79 void didExitFullScreenForElement(Element*); | |
80 | |
81 void setFullScreenRenderer(RenderFullScreen*); | |
82 RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer;
} | |
83 void fullScreenRendererDestroyed(); | |
84 | |
85 void elementRemoved(Element&); | |
86 | |
87 // Mozilla API | |
88 bool webkitIsFullScreen() const { return m_fullScreenElement.get(); } | |
89 bool webkitFullScreenKeyboardInputAllowed() const { return m_fullScreenEleme
nt.get() && m_areKeysEnabledInFullScreen; } | |
90 Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement
.get(); } | |
91 | |
92 virtual void documentWasDetached() OVERRIDE; | |
93 #if !ENABLE(OILPAN) | |
94 virtual void documentWasDisposed() OVERRIDE; | |
95 #endif | |
96 | |
97 virtual void trace(Visitor*) OVERRIDE; | |
98 | |
99 private: | |
100 static FullscreenElementStack* fromIfExistsSlow(Document&); | |
101 | |
102 explicit FullscreenElementStack(Document&); | |
103 | |
104 Document* document(); | |
105 | |
106 static bool elementReady(Element&, RequestType); | |
107 | |
108 void clearFullscreenElementStack(); | |
109 void popFullscreenElementStack(); | |
110 void pushFullscreenElementStack(Element&, RequestType); | |
111 | |
112 void enqueueChangeEvent(Document&, RequestType); | |
113 void enqueueErrorEvent(Element&, RequestType); | |
114 void eventQueueTimerFired(Timer<FullscreenElementStack>*); | |
115 | |
116 bool m_areKeysEnabledInFullScreen; | |
117 RefPtrWillBeMember<Element> m_fullScreenElement; | |
118 WillBeHeapVector<std::pair<RefPtrWillBeMember<Element>, RequestType> > m_ful
lScreenElementStack; | |
119 RawPtrWillBeMember<RenderFullScreen> m_fullScreenRenderer; | |
120 Timer<FullscreenElementStack> m_eventQueueTimer; | |
121 WillBeHeapDeque<RefPtrWillBeMember<Event> > m_eventQueue; | |
122 LayoutRect m_savedPlaceholderFrameRect; | |
123 RefPtr<RenderStyle> m_savedPlaceholderRenderStyle; | |
124 }; | |
125 | |
126 inline bool FullscreenElementStack::isActiveFullScreenElement(const Element& ele
ment) | |
127 { | |
128 FullscreenElementStack* fullscreen = fromIfExists(element.document()); | |
129 if (!fullscreen) | |
130 return false; | |
131 return fullscreen->webkitCurrentFullScreenElement() == &element; | |
132 } | |
133 | |
134 inline FullscreenElementStack* FullscreenElementStack::fromIfExists(Document& do
cument) | |
135 { | |
136 if (!document.hasFullscreenElementStack()) | |
137 return 0; | |
138 return fromIfExistsSlow(document); | |
139 } | |
140 | |
141 } // namespace blink | |
142 | |
143 // Needed by the HeapVector<> element stack. | |
144 namespace WTF { | |
145 | |
146 template<>struct IsPod<blink::FullscreenElementStack::RequestType> { | |
147 static const bool value = true; | |
148 }; | |
149 | |
150 } // namespace WTF | |
151 | |
152 #endif // FullscreenElementStack_h | |
OLD | NEW |