| OLD | NEW |
| 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 r
ights reserved. | 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/) | 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) | 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 9 * Copyright (C) 2013 Google Inc. All rights reserved. | 9 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 10 * | 10 * |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 , public Supplement<Document> | 49 , public Supplement<Document> |
| 50 , public ContextLifecycleObserver { | 50 , public ContextLifecycleObserver { |
| 51 USING_GARBAGE_COLLECTED_MIXIN(Fullscreen); | 51 USING_GARBAGE_COLLECTED_MIXIN(Fullscreen); |
| 52 public: | 52 public: |
| 53 virtual ~Fullscreen(); | 53 virtual ~Fullscreen(); |
| 54 static const char* supplementName(); | 54 static const char* supplementName(); |
| 55 static Fullscreen& from(Document&); | 55 static Fullscreen& from(Document&); |
| 56 static Fullscreen* fromIfExists(Document&); | 56 static Fullscreen* fromIfExists(Document&); |
| 57 static Element* fullscreenElementFrom(Document&); | 57 static Element* fullscreenElementFrom(Document&); |
| 58 static Element* currentFullScreenElementFrom(Document&); | 58 static Element* currentFullScreenElementFrom(Document&); |
| 59 static bool isFullScreen(Document&); | 59 static bool isCurrentFullScreenElement(const Element&); |
| 60 static bool isActiveFullScreenElement(const Element&); | |
| 61 | 60 |
| 62 enum RequestType { | 61 enum RequestType { |
| 63 // Element.requestFullscreen() | 62 // Element.requestFullscreen() |
| 64 UnprefixedRequest, | 63 UnprefixedRequest, |
| 65 // Element.webkitRequestFullscreen()/webkitRequestFullScreen() and | 64 // Element.webkitRequestFullscreen()/webkitRequestFullScreen() and |
| 66 // HTMLVideoElement.webkitEnterFullscreen()/webkitEnterFullScreen() | 65 // HTMLVideoElement.webkitEnterFullscreen()/webkitEnterFullScreen() |
| 67 PrefixedRequest, | 66 PrefixedRequest, |
| 68 }; | 67 }; |
| 69 | 68 |
| 70 // |forCrossProcessDescendant| is used in OOPIF scenarios and is set to | 69 // |forCrossProcessDescendant| is used in OOPIF scenarios and is set to |
| 71 // true when fullscreen is requested for an out-of-process descendant | 70 // true when fullscreen is requested for an out-of-process descendant |
| 72 // element. | 71 // element. |
| 73 void requestFullscreen(Element&, RequestType, bool forCrossProcessDescendant
= false); | 72 void requestFullscreen(Element&, RequestType, bool forCrossProcessDescendant
= false); |
| 74 | 73 |
| 75 static void fullyExitFullscreen(Document&); | 74 static void fullyExitFullscreen(Document&); |
| 76 void exitFullscreen(); | 75 void exitFullscreen(); |
| 77 | 76 |
| 78 static bool fullscreenEnabled(Document&); | 77 static bool fullscreenEnabled(Document&); |
| 79 Element* fullscreenElement() const { return !m_fullScreenElementStack.isEmpt
y() ? m_fullScreenElementStack.last().first.get() : 0; } | 78 // TODO(foolip): The fullscreen element stack is modified synchronously in |
| 79 // requestFullscreen(), which is not per spec and means that |
| 80 // |fullscreenElement()| is not always the same as |
| 81 // |currentFullScreenElement()|, see https://crbug.com/402421. |
| 82 Element* fullscreenElement() const { return !m_fullscreenElementStack.isEmpt
y() ? m_fullscreenElementStack.last().first.get() : nullptr; } |
| 80 | 83 |
| 81 void didEnterFullscreenForElement(Element*); | 84 void didEnterFullscreenForElement(Element*); |
| 82 void didExitFullscreen(); | 85 void didExitFullscreen(); |
| 83 | 86 |
| 84 void setFullScreenLayoutObject(LayoutFullScreen*); | 87 void setFullScreenLayoutObject(LayoutFullScreen*); |
| 85 LayoutFullScreen* fullScreenLayoutObject() const { return m_fullScreenLayout
Object; } | 88 LayoutFullScreen* fullScreenLayoutObject() const { return m_fullScreenLayout
Object; } |
| 86 void fullScreenLayoutObjectDestroyed(); | 89 void fullScreenLayoutObjectDestroyed(); |
| 87 | 90 |
| 88 void elementRemoved(Element&); | 91 void elementRemoved(Element&); |
| 89 | 92 |
| 90 // Returns true if the current fullscreen element stack corresponds to a | 93 // Returns true if the current fullscreen element stack corresponds to a |
| 91 // container for an actual fullscreen element in a descendant | 94 // container for an actual fullscreen element in a descendant |
| 92 // out-of-process iframe. | 95 // out-of-process iframe. |
| 93 bool forCrossProcessDescendant() { return m_forCrossProcessDescendant; } | 96 bool forCrossProcessDescendant() { return m_forCrossProcessDescendant; } |
| 94 | 97 |
| 95 // Mozilla API | 98 // Mozilla API |
| 96 Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement
.get(); } | 99 // TODO(foolip): |currentFullScreenElement()| is a remnant from before the |
| 100 // fullscreen element stack. It is still maintained separately from the |
| 101 // stack and is is what the :-webkit-full-screen pseudo-class depends on. It |
| 102 // should be removed, see https://crbug.com/402421. |
| 103 Element* currentFullScreenElement() const { return m_currentFullScreenElemen
t.get(); } |
| 97 | 104 |
| 98 // ContextLifecycleObserver: | 105 // ContextLifecycleObserver: |
| 99 void contextDestroyed() override; | 106 void contextDestroyed() override; |
| 100 | 107 |
| 101 DECLARE_VIRTUAL_TRACE(); | 108 DECLARE_VIRTUAL_TRACE(); |
| 102 | 109 |
| 103 private: | 110 private: |
| 104 static Fullscreen* fromIfExistsSlow(Document&); | 111 static Fullscreen* fromIfExistsSlow(Document&); |
| 105 | 112 |
| 106 explicit Fullscreen(Document&); | 113 explicit Fullscreen(Document&); |
| 107 | 114 |
| 108 Document* document(); | 115 Document* document(); |
| 109 | 116 |
| 110 void clearFullscreenElementStack(); | 117 void clearFullscreenElementStack(); |
| 111 void popFullscreenElementStack(); | 118 void popFullscreenElementStack(); |
| 112 void pushFullscreenElementStack(Element&, RequestType); | 119 void pushFullscreenElementStack(Element&, RequestType); |
| 113 | 120 |
| 114 void enqueueChangeEvent(Document&, RequestType); | 121 void enqueueChangeEvent(Document&, RequestType); |
| 115 void enqueueErrorEvent(Element&, RequestType); | 122 void enqueueErrorEvent(Element&, RequestType); |
| 116 void eventQueueTimerFired(TimerBase*); | 123 void eventQueueTimerFired(TimerBase*); |
| 117 | 124 |
| 118 Member<Element> m_fullScreenElement; | 125 HeapVector<std::pair<Member<Element>, RequestType>> m_fullscreenElementStack
; |
| 119 HeapVector<std::pair<Member<Element>, RequestType>> m_fullScreenElementStack
; | 126 Member<Element> m_currentFullScreenElement; |
| 120 LayoutFullScreen* m_fullScreenLayoutObject; | 127 LayoutFullScreen* m_fullScreenLayoutObject; |
| 121 Timer<Fullscreen> m_eventQueueTimer; | 128 Timer<Fullscreen> m_eventQueueTimer; |
| 122 HeapDeque<Member<Event>> m_eventQueue; | 129 HeapDeque<Member<Event>> m_eventQueue; |
| 123 LayoutRect m_savedPlaceholderFrameRect; | 130 LayoutRect m_savedPlaceholderFrameRect; |
| 124 RefPtr<ComputedStyle> m_savedPlaceholderComputedStyle; | 131 RefPtr<ComputedStyle> m_savedPlaceholderComputedStyle; |
| 125 | 132 |
| 126 // TODO(alexmos, dcheng): Currently, this assumes that if fullscreen was | 133 // TODO(alexmos, dcheng): Currently, this assumes that if fullscreen was |
| 127 // entered for an element in an out-of-process iframe, then it's not | 134 // entered for an element in an out-of-process iframe, then it's not |
| 128 // possible to re-enter fullscreen for a different element in this | 135 // possible to re-enter fullscreen for a different element in this |
| 129 // document, since that requires a user gesture, which can't be obtained | 136 // document, since that requires a user gesture, which can't be obtained |
| 130 // since nothing in this document is visible, and since user gestures can't | 137 // since nothing in this document is visible, and since user gestures can't |
| 131 // be forwarded across processes. However, the latter assumption could | 138 // be forwarded across processes. However, the latter assumption could |
| 132 // change if https://crbug.com/161068 is fixed so that cross-process | 139 // change if https://crbug.com/161068 is fixed so that cross-process |
| 133 // postMessage can carry user gestures. If that happens, this should be | 140 // postMessage can carry user gestures. If that happens, this should be |
| 134 // moved to be part of |m_fullScreenElementStack|. | 141 // moved to be part of |m_fullScreenElementStack|. |
| 135 bool m_forCrossProcessDescendant; | 142 bool m_forCrossProcessDescendant; |
| 136 }; | 143 }; |
| 137 | 144 |
| 138 inline bool Fullscreen::isActiveFullScreenElement(const Element& element) | |
| 139 { | |
| 140 Fullscreen* fullscreen = fromIfExists(element.document()); | |
| 141 if (!fullscreen) | |
| 142 return false; | |
| 143 return fullscreen->webkitCurrentFullScreenElement() == &element; | |
| 144 } | |
| 145 | |
| 146 inline Fullscreen* Fullscreen::fromIfExists(Document& document) | 145 inline Fullscreen* Fullscreen::fromIfExists(Document& document) |
| 147 { | 146 { |
| 148 if (!document.hasFullscreenSupplement()) | 147 if (!document.hasFullscreenSupplement()) |
| 149 return 0; | 148 return nullptr; |
| 150 return fromIfExistsSlow(document); | 149 return fromIfExistsSlow(document); |
| 151 } | 150 } |
| 152 | 151 |
| 152 inline bool Fullscreen::isCurrentFullScreenElement(const Element& element) |
| 153 { |
| 154 if (Fullscreen* found = fromIfExists(element.document())) |
| 155 return found->currentFullScreenElement() == &element; |
| 156 return false; |
| 157 } |
| 158 |
| 153 } // namespace blink | 159 } // namespace blink |
| 154 | 160 |
| 155 #endif // Fullscreen_h | 161 #endif // Fullscreen_h |
| OLD | NEW |