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 30 matching lines...) Expand all Loading... |
41 #include "core/page/ChromeClient.h" | 41 #include "core/page/ChromeClient.h" |
42 #include "core/rendering/RenderFullScreen.h" | 42 #include "core/rendering/RenderFullScreen.h" |
43 #include "platform/UserGestureIndicator.h" | 43 #include "platform/UserGestureIndicator.h" |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 using namespace HTMLNames; | 47 using namespace HTMLNames; |
48 | 48 |
49 static bool fullscreenIsAllowedForAllOwners(const Document& document) | 49 static bool fullscreenIsAllowedForAllOwners(const Document& document) |
50 { | 50 { |
51 for (const HTMLFrameOwnerElement* owner = document.ownerElement(); owner; ow
ner = owner->document().ownerElement()) { | 51 for (const Element* owner = document.ownerElement(); owner; owner = owner->d
ocument().ownerElement()) { |
52 if (!isHTMLIFrameElement(owner)) | 52 if (!isHTMLIFrameElement(owner)) |
53 return false; | 53 return false; |
54 if (!owner->hasAttribute(allowfullscreenAttr)) | 54 if (!owner->hasAttribute(allowfullscreenAttr)) |
55 return false; | 55 return false; |
56 } | 56 } |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
60 static bool fullscreenIsSupported(const Document& document) | 60 static bool fullscreenIsSupported(const Document& document) |
61 { | 61 { |
62 // Fullscreen is supported if there is no previously-established user prefer
ence, | 62 // Fullscreen is supported if there is no previously-established user prefer
ence, |
63 // security risk, or platform limitation. | 63 // security risk, or platform limitation. |
64 return !document.settings() || document.settings()->fullscreenSupported(); | 64 return !document.settings() || document.settings()->fullscreenSupported(); |
65 } | 65 } |
66 | 66 |
67 static bool fullscreenIsSupported(const Document& document, const Element& eleme
nt) | 67 static bool fullscreenIsSupported(const Document& document, const Element& eleme
nt) |
68 { | 68 { |
69 if (!document.settings() || (document.settings()->disallowFullscreenForNonMe
diaElements() && !isHTMLMediaElement(element))) | 69 if (!document.settings() || (document.settings()->disallowFullscreenForNonMe
diaElements() && !isHTMLMediaElement(element))) |
70 return false; | 70 return false; |
71 return fullscreenIsSupported(document); | 71 return fullscreenIsSupported(document); |
72 } | 72 } |
73 | 73 |
| 74 static bool fullscreenElementReady(const Element& element, Fullscreen::RequestTy
pe requestType) |
| 75 { |
| 76 // A fullscreen element ready check for an element |element| returns true if
all of the |
| 77 // following are true, and false otherwise: |
| 78 |
| 79 // |element| is in a document. |
| 80 if (!element.inDocument()) |
| 81 return false; |
| 82 |
| 83 // |element|'s node document's fullscreen enabled flag is set. |
| 84 if (!fullscreenIsAllowedForAllOwners(element.document())) { |
| 85 if (requestType == Fullscreen::PrefixedVideoRequest) |
| 86 UseCounter::count(element.document(), UseCounter::VideoFullscreenAll
owedExemption); |
| 87 else |
| 88 return false; |
| 89 } |
| 90 |
| 91 // |element|'s node document's fullscreen element stack is either empty or i
ts top element is an |
| 92 // inclusive ancestor of |element|. |
| 93 if (const Element* topElement = Fullscreen::fullscreenElementFrom(element.do
cument())) { |
| 94 if (!topElement->contains(&element)) |
| 95 return false; |
| 96 } |
| 97 |
| 98 // |element| has no ancestor element whose local name is iframe and namespac
e is the HTML |
| 99 // namespace. |
| 100 if (Traversal<HTMLIFrameElement>::firstAncestor(element)) |
| 101 return false; |
| 102 |
| 103 // |element|'s node document's browsing context either has a browsing contex
t container and the |
| 104 // fullscreen element ready check returns true for |element|'s node document
's browsing |
| 105 // context's browsing context container, or it has no browsing context conta
iner. |
| 106 if (const Element* owner = element.document().ownerElement()) { |
| 107 if (!fullscreenElementReady(*owner, requestType)) |
| 108 return false; |
| 109 } |
| 110 |
| 111 return true; |
| 112 } |
| 113 |
74 static bool isPrefixed(const AtomicString& type) | 114 static bool isPrefixed(const AtomicString& type) |
75 { | 115 { |
76 return type == EventTypeNames::webkitfullscreenchange || type == EventTypeNa
mes::webkitfullscreenerror; | 116 return type == EventTypeNames::webkitfullscreenchange || type == EventTypeNa
mes::webkitfullscreenerror; |
77 } | 117 } |
78 | 118 |
79 static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, Event
Target& target) | 119 static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, Event
Target& target) |
80 { | 120 { |
81 EventInit initializer; | 121 EventInit initializer; |
82 initializer.bubbles = isPrefixed(type); | 122 initializer.bubbles = isPrefixed(type); |
83 RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer); | 123 RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 #if !ENABLE(OILPAN) | 200 #if !ENABLE(OILPAN) |
161 void Fullscreen::documentWasDisposed() | 201 void Fullscreen::documentWasDisposed() |
162 { | 202 { |
163 // NOTE: the context dispose phase is not supported in oilpan. Please | 203 // NOTE: the context dispose phase is not supported in oilpan. Please |
164 // consider using the detach phase instead. | 204 // consider using the detach phase instead. |
165 m_fullScreenElement = nullptr; | 205 m_fullScreenElement = nullptr; |
166 m_fullScreenElementStack.clear(); | 206 m_fullScreenElementStack.clear(); |
167 } | 207 } |
168 #endif | 208 #endif |
169 | 209 |
170 bool Fullscreen::elementReady(Element& element, RequestType requestType) | |
171 { | |
172 // A fullscreen element ready check for an element |element| returns true if
all of the | |
173 // following are true, and false otherwise: | |
174 | |
175 // |element| is in a document. | |
176 if (!element.inDocument()) | |
177 return false; | |
178 | |
179 // |element|'s node document's fullscreen enabled flag is set. | |
180 if (!fullscreenIsAllowedForAllOwners(element.document())) { | |
181 if (requestType == PrefixedVideoRequest) | |
182 UseCounter::count(element.document(), UseCounter::VideoFullscreenAll
owedExemption); | |
183 else | |
184 return false; | |
185 } | |
186 | |
187 // |element|'s node document's fullscreen element stack is either empty or i
ts top element is an | |
188 // inclusive ancestor of |element|. | |
189 if (Element* topElement = fullscreenElementFrom(element.document())) { | |
190 if (!topElement->contains(&element)) | |
191 return false; | |
192 } | |
193 | |
194 // |element| has no ancestor element whose local name is iframe and namespac
e is the HTML | |
195 // namespace. | |
196 if (Traversal<HTMLIFrameElement>::firstAncestor(element)) | |
197 return false; | |
198 | |
199 // |element|'s node document's browsing context either has a browsing contex
t container and the | |
200 // fullscreen element ready check returns true for |element|'s node document
's browsing | |
201 // context's browsing context container, or it has no browsing context conta
iner. | |
202 if (HTMLFrameOwnerElement* container = element.document().ownerElement()) { | |
203 if (!elementReady(*container, requestType)) | |
204 return false; | |
205 } | |
206 | |
207 return true; | |
208 } | |
209 | |
210 void Fullscreen::requestFullscreen(Element& element, RequestType requestType) | 210 void Fullscreen::requestFullscreen(Element& element, RequestType requestType) |
211 { | 211 { |
212 // Ignore this request if the document is not in a live frame. | 212 // Ignore this request if the document is not in a live frame. |
213 if (!document()->isActive()) | 213 if (!document()->isActive()) |
214 return; | 214 return; |
215 | 215 |
216 // If |element| is on top of |doc|'s fullscreen element stack, terminate the
se substeps. | 216 // If |element| is on top of |doc|'s fullscreen element stack, terminate the
se substeps. |
217 if (&element == fullscreenElement()) | 217 if (&element == fullscreenElement()) |
218 return; | 218 return; |
219 | 219 |
220 do { | 220 do { |
221 // 1. If any of the following conditions are true, terminate these steps
and queue a task to fire | 221 // 1. If any of the following conditions are true, terminate these steps
and queue a task to fire |
222 // an event named fullscreenerror with its bubbles attribute set to true
on the context object's | 222 // an event named fullscreenerror with its bubbles attribute set to true
on the context object's |
223 // node document: | 223 // node document: |
224 | 224 |
225 // The fullscreen element ready check returns false. | 225 // The fullscreen element ready check returns false. |
226 if (!elementReady(element, requestType)) | 226 if (!fullscreenElementReady(element, requestType)) |
227 break; | 227 break; |
228 | 228 |
229 // This algorithm is not allowed to show a pop-up: | 229 // This algorithm is not allowed to show a pop-up: |
230 // An algorithm is allowed to show a pop-up if, in the task in which t
he algorithm is running, either: | 230 // An algorithm is allowed to show a pop-up if, in the task in which t
he algorithm is running, either: |
231 // - an activation behavior is currently being processed whose click e
vent was trusted, or | 231 // - an activation behavior is currently being processed whose click e
vent was trusted, or |
232 // - the event listener for a trusted click event is being handled. | 232 // - the event listener for a trusted click event is being handled. |
233 if (!UserGestureIndicator::processingUserGesture()) | 233 if (!UserGestureIndicator::processingUserGesture()) |
234 break; | 234 break; |
235 | 235 |
236 // Fullscreen is not supported. | 236 // Fullscreen is not supported. |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 void Fullscreen::trace(Visitor* visitor) | 614 void Fullscreen::trace(Visitor* visitor) |
615 { | 615 { |
616 visitor->trace(m_fullScreenElement); | 616 visitor->trace(m_fullScreenElement); |
617 visitor->trace(m_fullScreenElementStack); | 617 visitor->trace(m_fullScreenElementStack); |
618 visitor->trace(m_fullScreenRenderer); | 618 visitor->trace(m_fullScreenRenderer); |
619 visitor->trace(m_eventQueue); | 619 visitor->trace(m_eventQueue); |
620 DocumentSupplement::trace(visitor); | 620 DocumentSupplement::trace(visitor); |
621 } | 621 } |
622 | 622 |
623 } // namespace blink | 623 } // namespace blink |
OLD | NEW |