Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/WebKit/Source/core/dom/Fullscreen.h

Issue 2202493002: NOT FOR REVIEW: Fullscreen WIP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 13 matching lines...) Expand all
24 * along with this library; see the file COPYING.LIB. If not, write to 24 * along with this library; see the file COPYING.LIB. If not, write to
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 * Boston, MA 02110-1301, USA. 26 * Boston, MA 02110-1301, USA.
27 * 27 *
28 */ 28 */
29 29
30 #ifndef Fullscreen_h 30 #ifndef Fullscreen_h
31 #define Fullscreen_h 31 #define Fullscreen_h
32 32
33 #include "core/CoreExport.h" 33 #include "core/CoreExport.h"
34 #include "core/dom/ContextLifecycleObserver.h"
35 #include "core/dom/Document.h"
36 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
37 #include "platform/Supplementable.h"
38 #include "platform/Timer.h"
39 #include "platform/geometry/LayoutRect.h"
40 #include "wtf/Deque.h"
41 #include "wtf/RefPtr.h"
42 #include "wtf/Vector.h"
43 35
44 namespace blink { 36 namespace blink {
45 37
46 class LayoutFullScreen; 38 class Document;
47 class ComputedStyle;
48 39
49 class CORE_EXPORT Fullscreen final 40 class CORE_EXPORT Fullscreen {
50 : public GarbageCollectedFinalized<Fullscreen>,
51 public Supplement<Document>,
52 public ContextLifecycleObserver {
53 USING_GARBAGE_COLLECTED_MIXIN(Fullscreen);
54
55 public: 41 public:
56 virtual ~Fullscreen(); 42 static bool isFullscreenElement(const Element&);
57 static const char* supplementName();
58 static Fullscreen& from(Document&);
59 static Fullscreen* fromIfExists(Document&);
60 static Element* fullscreenElementFrom(Document&);
61 static Element* fullscreenElementForBindingFrom(TreeScope&);
62 static Element* currentFullScreenElementFrom(Document&);
63 static Element* currentFullScreenElementForBindingFrom(Document&);
64 static bool isCurrentFullScreenElement(const Element&);
65 43
66 enum RequestType { 44 enum RequestType {
67 // Element.requestFullscreen() 45 // Element.requestFullscreen()
68 UnprefixedRequest, 46 UnprefixedRequest,
69 // Element.webkitRequestFullscreen()/webkitRequestFullScreen() and 47 // Element.webkitRequestFullscreen()/webkitRequestFullScreen() and
70 // HTMLVideoElement.webkitEnterFullscreen()/webkitEnterFullScreen() 48 // HTMLVideoElement.webkitEnterFullscreen()/webkitEnterFullScreen()
71 PrefixedRequest, 49 PrefixedRequest,
72 }; 50 };
73 51
74 // |forCrossProcessDescendant| is used in OOPIF scenarios and is set to 52 static void requestFullscreen(Element&, RequestType);
75 // true when fullscreen is requested for an out-of-process descendant
76 // element.
77 static void requestFullscreen(Element&,
78 RequestType,
79 bool forCrossProcessDescendant = false);
80 53
81 static void fullyExitFullscreen(Document&); 54 static void fullyExitFullscreen(Document&);
82 static void exitFullscreen(Document&); 55 static void exitFullscreen(Document&);
83 56
84 static bool fullscreenEnabled(Document&); 57 static bool fullscreenEnabled(Document&);
85 // TODO(foolip): The fullscreen element stack is modified synchronously in 58 static Element* fullscreenElement(Document&);
86 // requestFullscreen(), which is not per spec and means that 59 static Element* fullscreenElementForBinding(TreeScope&);
87 // |fullscreenElement()| is not always the same as
88 // |currentFullScreenElement()|, see https://crbug.com/402421.
89 Element* fullscreenElement() const {
90 return !m_fullscreenElementStack.isEmpty()
91 ? m_fullscreenElementStack.last().first.get()
92 : nullptr;
93 }
94 60
95 void didEnterFullscreenForElement(Element*); 61 static void didEnterFullscreenForElement(Element&, RequestType);
96 void didExitFullscreen(); 62 static void animationFrameTaskAfterEnter(Element*, RequestType, bool error);
97 63
98 void setFullScreenLayoutObject(LayoutFullScreen*); 64 static void didExitFullscreen(Document&);
99 LayoutFullScreen* fullScreenLayoutObject() const { 65 static void animationFrameTaskAfterExit(Document*);
100 return m_fullScreenLayoutObject;
101 }
102 void fullScreenLayoutObjectDestroyed();
103 66
104 void elementRemoved(Element&); 67 static void didUpdateSize(Element&);
105 68
106 // Returns true if the current fullscreen element stack corresponds to a 69 static void elementRemoved(Element&);
107 // container for an actual fullscreen element in a descendant
108 // out-of-process iframe.
109 bool forCrossProcessDescendant() { return m_forCrossProcessDescendant; }
110
111 // Mozilla API
112 // TODO(foolip): |currentFullScreenElement()| is a remnant from before the
113 // fullscreen element stack. It is still maintained separately from the
114 // stack and is is what the :-webkit-full-screen pseudo-class depends on. It
115 // should be removed, see https://crbug.com/402421.
116 Element* currentFullScreenElement() const {
117 return m_currentFullScreenElement.get();
118 }
119
120 // ContextLifecycleObserver:
121 void contextDestroyed() override;
122
123 DECLARE_VIRTUAL_TRACE();
124
125 private:
126 static Fullscreen* fromIfExistsSlow(Document&);
127
128 explicit Fullscreen(Document&);
129
130 Document* document();
131
132 void clearFullscreenElementStack();
133 void popFullscreenElementStack();
134 void pushFullscreenElementStack(Element&, RequestType);
135
136 void enqueueChangeEvent(Document&, RequestType);
137 void enqueueErrorEvent(Element&, RequestType);
138 void eventQueueTimerFired(TimerBase*);
139
140 HeapVector<std::pair<Member<Element>, RequestType>> m_fullscreenElementStack;
141 Member<Element> m_currentFullScreenElement;
142 LayoutFullScreen* m_fullScreenLayoutObject;
143 Timer<Fullscreen> m_eventQueueTimer;
144 HeapDeque<Member<Event>> m_eventQueue;
145 LayoutRect m_savedPlaceholderFrameRect;
146 RefPtr<ComputedStyle> m_savedPlaceholderComputedStyle;
147
148 // TODO(alexmos, dcheng): Currently, this assumes that if fullscreen was
149 // entered for an element in an out-of-process iframe, then it's not
150 // possible to re-enter fullscreen for a different element in this
151 // document, since that requires a user gesture, which can't be obtained
152 // since nothing in this document is visible, and since user gestures can't
153 // be forwarded across processes. However, the latter assumption could
154 // change if https://crbug.com/161068 is fixed so that cross-process
155 // postMessage can carry user gestures. If that happens, this should be
156 // moved to be part of |m_fullscreenElementStack|.
157 bool m_forCrossProcessDescendant;
158 }; 70 };
159 71
160 inline Fullscreen* Fullscreen::fromIfExists(Document& document) { 72 inline bool Fullscreen::isFullscreenElement(const Element& element) {
161 if (!document.hasFullscreenSupplement()) 73 return fullscreenElement(element.document()) == &element;
162 return nullptr;
163 return fromIfExistsSlow(document);
164 }
165
166 inline bool Fullscreen::isCurrentFullScreenElement(const Element& element) {
167 if (Fullscreen* found = fromIfExists(element.document()))
168 return found->currentFullScreenElement() == &element;
169 return false;
170 } 74 }
171 75
172 } // namespace blink 76 } // namespace blink
173 77
174 #endif // Fullscreen_h 78 #endif // Fullscreen_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.cpp ('k') | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698