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

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

Issue 2411553003: Notify WebMediaPlayer when its ancestor enters/exists fullscreen. (Closed)
Patch Set: Rebased. Add FullscreenObserver. Created 4 years, 2 months 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
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 #include "core/dom/ContextLifecycleObserver.h" 34 #include "core/dom/ContextLifecycleObserver.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/Element.h" 36 #include "core/dom/Element.h"
37 #include "platform/Supplementable.h" 37 #include "platform/Supplementable.h"
38 #include "platform/Timer.h" 38 #include "platform/Timer.h"
39 #include "platform/geometry/LayoutRect.h" 39 #include "platform/geometry/LayoutRect.h"
40 #include "wtf/Deque.h" 40 #include "wtf/Deque.h"
41 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
42 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
43 43
44 #include <set>
45
44 namespace blink { 46 namespace blink {
45 47
46 class LayoutFullScreen; 48 class LayoutFullScreen;
47 class ComputedStyle; 49 class ComputedStyle;
48 50
49 class CORE_EXPORT Fullscreen final 51 class CORE_EXPORT Fullscreen final
50 : public GarbageCollectedFinalized<Fullscreen>, 52 : public GarbageCollectedFinalized<Fullscreen>,
51 public Supplement<Document>, 53 public Supplement<Document>,
52 public ContextLifecycleObserver { 54 public ContextLifecycleObserver {
53 USING_GARBAGE_COLLECTED_MIXIN(Fullscreen); 55 USING_GARBAGE_COLLECTED_MIXIN(Fullscreen);
54 56
55 public: 57 public:
56 virtual ~Fullscreen(); 58 virtual ~Fullscreen();
57 static const char* supplementName(); 59 static const char* supplementName();
58 static Fullscreen& from(Document&); 60 static Fullscreen& from(Document&);
59 static Fullscreen* fromIfExists(Document&); 61 static Fullscreen* fromIfExists(Document&);
60 static Element* fullscreenElementFrom(Document&); 62 static Element* fullscreenElementFrom(Document&);
61 static Element* currentFullScreenElementFrom(Document&); 63 static Element* currentFullScreenElementFrom(Document&);
62 static bool isCurrentFullScreenElement(const Element&); 64 static bool isCurrentFullScreenElement(const Element&);
63 65
66 class FullscreenObserver {
67 public:
68 FullscreenObserver() {}
69 virtual ~FullscreenObserver() {}
70 virtual void onEnteredFullscreen() = 0;
71 virtual void onExitedFullscreen() = 0;
72 };
73
64 enum RequestType { 74 enum RequestType {
65 // Element.requestFullscreen() 75 // Element.requestFullscreen()
66 UnprefixedRequest, 76 UnprefixedRequest,
67 // Element.webkitRequestFullscreen()/webkitRequestFullScreen() and 77 // Element.webkitRequestFullscreen()/webkitRequestFullScreen() and
68 // HTMLVideoElement.webkitEnterFullscreen()/webkitEnterFullScreen() 78 // HTMLVideoElement.webkitEnterFullscreen()/webkitEnterFullScreen()
69 PrefixedRequest, 79 PrefixedRequest,
70 }; 80 };
71 81
72 // |forCrossProcessDescendant| is used in OOPIF scenarios and is set to 82 // |forCrossProcessDescendant| is used in OOPIF scenarios and is set to
73 // true when fullscreen is requested for an out-of-process descendant 83 // true when fullscreen is requested for an out-of-process descendant
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // fullscreen element stack. It is still maintained separately from the 121 // fullscreen element stack. It is still maintained separately from the
112 // stack and is is what the :-webkit-full-screen pseudo-class depends on. It 122 // stack and is is what the :-webkit-full-screen pseudo-class depends on. It
113 // should be removed, see https://crbug.com/402421. 123 // should be removed, see https://crbug.com/402421.
114 Element* currentFullScreenElement() const { 124 Element* currentFullScreenElement() const {
115 return m_currentFullScreenElement.get(); 125 return m_currentFullScreenElement.get();
116 } 126 }
117 127
118 // ContextLifecycleObserver: 128 // ContextLifecycleObserver:
119 void contextDestroyed() override; 129 void contextDestroyed() override;
120 130
131 void registerObserver(FullscreenObserver*);
132 void removeObserver(FullscreenObserver*);
133
121 DECLARE_VIRTUAL_TRACE(); 134 DECLARE_VIRTUAL_TRACE();
122 135
123 private: 136 private:
124 static Fullscreen* fromIfExistsSlow(Document&); 137 static Fullscreen* fromIfExistsSlow(Document&);
125 138
126 explicit Fullscreen(Document&); 139 explicit Fullscreen(Document&);
127 140
128 Document* document(); 141 Document* document();
129 142
130 void clearFullscreenElementStack(); 143 void clearFullscreenElementStack();
(...skipping 15 matching lines...) Expand all
146 // TODO(alexmos, dcheng): Currently, this assumes that if fullscreen was 159 // TODO(alexmos, dcheng): Currently, this assumes that if fullscreen was
147 // entered for an element in an out-of-process iframe, then it's not 160 // entered for an element in an out-of-process iframe, then it's not
148 // possible to re-enter fullscreen for a different element in this 161 // possible to re-enter fullscreen for a different element in this
149 // document, since that requires a user gesture, which can't be obtained 162 // document, since that requires a user gesture, which can't be obtained
150 // since nothing in this document is visible, and since user gestures can't 163 // since nothing in this document is visible, and since user gestures can't
151 // be forwarded across processes. However, the latter assumption could 164 // be forwarded across processes. However, the latter assumption could
152 // change if https://crbug.com/161068 is fixed so that cross-process 165 // change if https://crbug.com/161068 is fixed so that cross-process
153 // postMessage can carry user gestures. If that happens, this should be 166 // postMessage can carry user gestures. If that happens, this should be
154 // moved to be part of |m_fullscreenElementStack|. 167 // moved to be part of |m_fullscreenElementStack|.
155 bool m_forCrossProcessDescendant; 168 bool m_forCrossProcessDescendant;
169
170 std::set<FullscreenObserver*> m_observers;
156 }; 171 };
157 172
158 inline Fullscreen* Fullscreen::fromIfExists(Document& document) { 173 inline Fullscreen* Fullscreen::fromIfExists(Document& document) {
159 if (!document.hasFullscreenSupplement()) 174 if (!document.hasFullscreenSupplement())
160 return nullptr; 175 return nullptr;
161 return fromIfExistsSlow(document); 176 return fromIfExistsSlow(document);
162 } 177 }
163 178
164 inline bool Fullscreen::isCurrentFullScreenElement(const Element& element) { 179 inline bool Fullscreen::isCurrentFullScreenElement(const Element& element) {
165 if (Fullscreen* found = fromIfExists(element.document())) 180 if (Fullscreen* found = fromIfExists(element.document()))
166 return found->currentFullScreenElement() == &element; 181 return found->currentFullScreenElement() == &element;
167 return false; 182 return false;
168 } 183 }
169 184
170 } // namespace blink 185 } // namespace blink
171 186
172 #endif // Fullscreen_h 187 #endif // Fullscreen_h
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | third_party/WebKit/Source/core/dom/Fullscreen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698