File: Fullscreen.cpp

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (614 lines) | stat: -rw-r--r-- 23,248 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
/*
 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
 *           (C) 2001 Dirk Mueller (mueller@kde.org)
 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
 * Copyright (C) 2013 Google Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#include "config.h"
#include "core/dom/Fullscreen.h"

#include "core/HTMLNames.h"
#include "core/dom/Document.h"
#include "core/events/Event.h"
#include "core/frame/FrameHost.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLIFrameElement.h"
#include "core/html/HTMLMediaElement.h"
#include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "core/page/EventHandler.h"
#include "core/rendering/RenderFullScreen.h"
#include "platform/UserGestureIndicator.h"

namespace blink {

using namespace HTMLNames;

static bool fullscreenIsAllowedForAllOwners(const Document& document)
{
    for (const Element* owner = document.ownerElement(); owner; owner = owner->document().ownerElement()) {
        if (!isHTMLIFrameElement(owner))
            return false;
        if (!owner->hasAttribute(allowfullscreenAttr))
            return false;
    }
    return true;
}

static bool fullscreenIsSupported(const Document& document)
{
    // Fullscreen is supported if there is no previously-established user preference,
    // security risk, or platform limitation.
    return !document.settings() || document.settings()->fullscreenSupported();
}

static bool fullscreenElementReady(const Element& element, Fullscreen::RequestType requestType)
{
    // A fullscreen element ready check for an element |element| returns true if all of the
    // following are true, and false otherwise:

    // |element| is in a document.
    if (!element.inDocument())
        return false;

    // |element|'s node document's fullscreen enabled flag is set.
    if (!fullscreenIsAllowedForAllOwners(element.document())) {
        if (requestType == Fullscreen::PrefixedVideoRequest)
            UseCounter::count(element.document(), UseCounter::VideoFullscreenAllowedExemption);
        else
            return false;
    }

    // |element|'s node document's fullscreen element stack is either empty or its top element is an
    // inclusive ancestor of |element|.
    if (const Element* topElement = Fullscreen::fullscreenElementFrom(element.document())) {
        if (!topElement->contains(&element))
            return false;
    }

    // |element| has no ancestor element whose local name is iframe and namespace is the HTML
    // namespace.
    if (Traversal<HTMLIFrameElement>::firstAncestor(element))
        return false;

    // |element|'s node document's browsing context either has a browsing context container and the
    // fullscreen element ready check returns true for |element|'s node document's browsing
    // context's browsing context container, or it has no browsing context container.
    if (const Element* owner = element.document().ownerElement()) {
        if (!fullscreenElementReady(*owner, requestType))
            return false;
    }

    return true;
}

static bool isPrefixed(const AtomicString& type)
{
    return type == EventTypeNames::webkitfullscreenchange || type == EventTypeNames::webkitfullscreenerror;
}

static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, EventTarget& target)
{
    EventInit initializer;
    initializer.bubbles = isPrefixed(type);
    RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer);
    event->setTarget(&target);
    return event;
}

const char* Fullscreen::supplementName()
{
    return "Fullscreen";
}

Fullscreen& Fullscreen::from(Document& document)
{
    Fullscreen* fullscreen = fromIfExists(document);
    if (!fullscreen) {
        fullscreen = new Fullscreen(document);
        DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBeNoop(fullscreen));
    }

    return *fullscreen;
}

Fullscreen* Fullscreen::fromIfExistsSlow(Document& document)
{
    return static_cast<Fullscreen*>(DocumentSupplement::from(document, supplementName()));
}

Element* Fullscreen::fullscreenElementFrom(Document& document)
{
    if (Fullscreen* found = fromIfExists(document))
        return found->fullscreenElement();
    return 0;
}

Element* Fullscreen::currentFullScreenElementFrom(Document& document)
{
    if (Fullscreen* found = fromIfExists(document))
        return found->webkitCurrentFullScreenElement();
    return 0;
}

bool Fullscreen::isFullScreen(Document& document)
{
    return currentFullScreenElementFrom(document);
}

Fullscreen::Fullscreen(Document& document)
    : DocumentLifecycleObserver(&document)
    , m_fullScreenRenderer(nullptr)
    , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired)
{
    document.setHasFullscreenSupplement();
}

Fullscreen::~Fullscreen()
{
}

inline Document* Fullscreen::document()
{
    return lifecycleContext();
}

void Fullscreen::documentWasDetached()
{
    m_eventQueue.clear();

    if (m_fullScreenRenderer)
        m_fullScreenRenderer->destroy();

#if ENABLE(OILPAN)
    m_fullScreenElement = nullptr;
    m_fullScreenElementStack.clear();
#endif

}

#if !ENABLE(OILPAN)
void Fullscreen::documentWasDisposed()
{
    // NOTE: the context dispose phase is not supported in oilpan. Please
    // consider using the detach phase instead.
    m_fullScreenElement = nullptr;
    m_fullScreenElementStack.clear();
}
#endif

void Fullscreen::requestFullscreen(Element& element, RequestType requestType)
{
    // Ignore this request if the document is not in a live frame.
    if (!document()->isActive())
        return;

    // If |element| is on top of |doc|'s fullscreen element stack, terminate these substeps.
    if (&element == fullscreenElement())
        return;

    do {
        // 1. If any of the following conditions are true, terminate these steps and queue a task to fire
        // an event named fullscreenerror with its bubbles attribute set to true on the context object's
        // node document:

        // The fullscreen element ready check returns false.
        if (!fullscreenElementReady(element, requestType))
            break;

        // This algorithm is not allowed to show a pop-up:
        //   An algorithm is allowed to show a pop-up if, in the task in which the algorithm is running, either:
        //   - an activation behavior is currently being processed whose click event was trusted, or
        //   - the event listener for a trusted click event is being handled.
        if (!UserGestureIndicator::processingUserGesture()) {
            String message = ExceptionMessages::failedToExecute("requestFullScreen",
                "Element", "API can only be initiated by a user gesture.");
            document()->executionContext()->addConsoleMessage(
                ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
            break;
        }

        // Fullscreen is not supported.
        if (!fullscreenIsSupported(element.document()))
            break;

        // 2. Let doc be element's node document. (i.e. "this")
        Document* currentDoc = document();

        // 3. Let docs be all doc's ancestor browsing context's documents (if any) and doc.
        Deque<Document*> docs;

        do {
            docs.prepend(currentDoc);
            currentDoc = currentDoc->ownerElement() ? &currentDoc->ownerElement()->document() : 0;
        } while (currentDoc);

        // 4. For each document in docs, run these substeps:
        Deque<Document*>::iterator current = docs.begin(), following = docs.begin();

        do {
            ++following;

            // 1. Let following document be the document after document in docs, or null if there is no
            // such document.
            Document* currentDoc = *current;
            Document* followingDoc = following != docs.end() ? *following : 0;

            // 2. If following document is null, push context object on document's fullscreen element
            // stack, and queue a task to fire an event named fullscreenchange with its bubbles attribute
            // set to true on the document.
            if (!followingDoc) {
                from(*currentDoc).pushFullscreenElementStack(element, requestType);
                enqueueChangeEvent(*currentDoc, requestType);
                continue;
            }

            // 3. Otherwise, if document's fullscreen element stack is either empty or its top element
            // is not following document's browsing context container,
            Element* topElement = fullscreenElementFrom(*currentDoc);
            if (!topElement || topElement != followingDoc->ownerElement()) {
                // ...push following document's browsing context container on document's fullscreen element
                // stack, and queue a task to fire an event named fullscreenchange with its bubbles attribute
                // set to true on document.
                from(*currentDoc).pushFullscreenElementStack(*followingDoc->ownerElement(), requestType);
                enqueueChangeEvent(*currentDoc, requestType);
                continue;
            }

            // 4. Otherwise, do nothing for this document. It stays the same.
        } while (++current != docs.end());

        // 5. Return, and run the remaining steps asynchronously.
        // 6. Optionally, perform some animation.
        document()->frameHost()->chrome().client().enterFullScreenForElement(&element);

        // 7. Optionally, display a message indicating how the user can exit displaying the context object fullscreen.
        return;
    } while (0);

    enqueueErrorEvent(element, requestType);
}

void Fullscreen::fullyExitFullscreen(Document& document)
{
    // To fully exit fullscreen, run these steps:

    // 1. Let |doc| be the top-level browsing context's document.
    Document& doc = document.topDocument();

    // 2. If |doc|'s fullscreen element stack is empty, terminate these steps.
    if (!fullscreenElementFrom(doc))
        return;

    // 3. Remove elements from |doc|'s fullscreen element stack until only the top element is left.
    size_t stackSize = from(doc).m_fullScreenElementStack.size();
    from(doc).m_fullScreenElementStack.remove(0, stackSize - 1);
    ASSERT(from(doc).m_fullScreenElementStack.size() == 1);

    // 4. Act as if the exitFullscreen() method was invoked on |doc|.
    from(doc).exitFullscreen();
}

void Fullscreen::exitFullscreen()
{
    // The exitFullscreen() method must run these steps:

    // 1. Let doc be the context object. (i.e. "this")
    Document* currentDoc = document();
    if (!currentDoc->isActive())
        return;

    // 2. If doc's fullscreen element stack is empty, terminate these steps.
    if (m_fullScreenElementStack.isEmpty())
        return;

    // 3. Let descendants be all the doc's descendant browsing context's documents with a non-empty fullscreen
    // element stack (if any), ordered so that the child of the doc is last and the document furthest
    // away from the doc is first.
    WillBeHeapDeque<RefPtrWillBeMember<Document> > descendants;
    for (Frame* descendant = document()->frame() ? document()->frame()->tree().traverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) {
        if (!descendant->isLocalFrame())
            continue;
        ASSERT(toLocalFrame(descendant)->document());
        if (fullscreenElementFrom(*toLocalFrame(descendant)->document()))
            descendants.prepend(toLocalFrame(descendant)->document());
    }

    // 4. For each descendant in descendants, empty descendant's fullscreen element stack, and queue a
    // task to fire an event named fullscreenchange with its bubbles attribute set to true on descendant.
    for (WillBeHeapDeque<RefPtrWillBeMember<Document> >::iterator i = descendants.begin(); i != descendants.end(); ++i) {
        ASSERT(*i);
        RequestType requestType = from(**i).m_fullScreenElementStack.last().second;
        from(**i).clearFullscreenElementStack();
        enqueueChangeEvent(**i, requestType);
    }

    // 5. While doc is not null, run these substeps:
    Element* newTop = 0;
    while (currentDoc) {
        RequestType requestType = from(*currentDoc).m_fullScreenElementStack.last().second;

        // 1. Pop the top element of doc's fullscreen element stack.
        from(*currentDoc).popFullscreenElementStack();

        //    If doc's fullscreen element stack is non-empty and the element now at the top is either
        //    not in a document or its node document is not doc, repeat this substep.
        newTop = fullscreenElementFrom(*currentDoc);
        if (newTop && (!newTop->inDocument() || newTop->document() != currentDoc))
            continue;

        // 2. Queue a task to fire an event named fullscreenchange with its bubbles attribute set to true
        // on doc.
        enqueueChangeEvent(*currentDoc, requestType);

        // 3. If doc's fullscreen element stack is empty and doc's browsing context has a browsing context
        // container, set doc to that browsing context container's node document.
        if (!newTop && currentDoc->ownerElement()) {
            currentDoc = &currentDoc->ownerElement()->document();
            continue;
        }

        // 4. Otherwise, set doc to null.
        currentDoc = 0;
    }

    // 6. Return, and run the remaining steps asynchronously.
    // 7. Optionally, perform some animation.

    FrameHost* host = document()->frameHost();

    // Speculative fix for engaget.com/videos per crbug.com/336239.
    // FIXME: This check is wrong. We ASSERT(document->isActive()) above
    // so this should be redundant and should be removed!
    if (!host)
        return;

    // Only exit out of full screen window mode if there are no remaining elements in the
    // full screen stack.
    if (!newTop) {
        // FIXME: if the frame exiting fullscreen is not the frame that entered
        // fullscreen (but a parent frame for example), m_fullScreenElement
        // might be null. We want to pass an element that is part of the
        // document so we will pass the documentElement in that case.
        // This should be fix by exiting fullscreen for a frame instead of an
        // element, see https://crbug.com/441259
        host->chrome().client().exitFullScreenForElement(
            m_fullScreenElement ? m_fullScreenElement.get() : document()->documentElement());
        return;
    }

    // Otherwise, notify the chrome of the new full screen element.
    host->chrome().client().enterFullScreenForElement(newTop);
}

bool Fullscreen::fullscreenEnabled(Document& document)
{
    // 4. The fullscreenEnabled attribute must return true if the context object has its
    //    fullscreen enabled flag set and fullscreen is supported, and false otherwise.

    // Top-level browsing contexts are implied to have their allowFullScreen attribute set.
    return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(document);
}

void Fullscreen::didEnterFullScreenForElement(Element* element)
{
    ASSERT(element);
    if (!document()->isActive())
        return;

    if (m_fullScreenRenderer)
        m_fullScreenRenderer->unwrapRenderer();

    m_fullScreenElement = element;

    // Create a placeholder block for a the full-screen element, to keep the page from reflowing
    // when the element is removed from the normal flow. Only do this for a RenderBox, as only
    // a box will have a frameRect. The placeholder will be created in setFullScreenRenderer()
    // during layout.
    RenderObject* renderer = m_fullScreenElement->renderer();
    bool shouldCreatePlaceholder = renderer && renderer->isBox();
    if (shouldCreatePlaceholder) {
        m_savedPlaceholderFrameRect = toRenderBox(renderer)->frameRect();
        m_savedPlaceholderRenderStyle = RenderStyle::clone(renderer->style());
    }

    if (m_fullScreenElement != document()->documentElement())
        RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() : 0, document());

    m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);

    // FIXME: This should not call updateStyleIfNeeded.
    document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::FullScreen));
    document()->updateRenderTreeIfNeeded();

    m_fullScreenElement->didBecomeFullscreenElement();

    if (document()->frame())
        document()->frame()->eventHandler().scheduleHoverStateUpdate();

    m_eventQueueTimer.startOneShot(0, FROM_HERE);
}

void Fullscreen::didExitFullScreenForElement(Element*)
{
    if (!m_fullScreenElement)
        return;

    if (!document()->isActive())
        return;

    m_fullScreenElement->willStopBeingFullscreenElement();

    m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);

    if (m_fullScreenRenderer)
        m_fullScreenRenderer->unwrapRenderer();

    m_fullScreenElement = nullptr;
    document()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::FullScreen));

    if (document()->frame())
        document()->frame()->eventHandler().scheduleHoverStateUpdate();

    // When fullyExitFullscreen is called, we call exitFullscreen on the topDocument(). That means
    // that the events will be queued there. So if we have no events here, start the timer on the
    // exiting document.
    Document* exitingDocument = document();
    if (m_eventQueue.isEmpty())
        exitingDocument = &document()->topDocument();
    ASSERT(exitingDocument);
    from(*exitingDocument).m_eventQueueTimer.startOneShot(0, FROM_HERE);
}

void Fullscreen::setFullScreenRenderer(RenderFullScreen* renderer)
{
    if (renderer == m_fullScreenRenderer)
        return;

    if (renderer && m_savedPlaceholderRenderStyle) {
        renderer->createPlaceholder(m_savedPlaceholderRenderStyle.release(), m_savedPlaceholderFrameRect);
    } else if (renderer && m_fullScreenRenderer && m_fullScreenRenderer->placeholder()) {
        RenderBlock* placeholder = m_fullScreenRenderer->placeholder();
        renderer->createPlaceholder(RenderStyle::clone(placeholder->style()), placeholder->frameRect());
    }

    if (m_fullScreenRenderer)
        m_fullScreenRenderer->unwrapRenderer();
    ASSERT(!m_fullScreenRenderer);

    m_fullScreenRenderer = renderer;
}

void Fullscreen::fullScreenRendererDestroyed()
{
    m_fullScreenRenderer = nullptr;
}

void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType)
{
    RefPtrWillBeRawPtr<Event> event;
    if (requestType == UnprefixedRequest) {
        event = createEvent(EventTypeNames::fullscreenchange, document);
    } else {
        ASSERT(document.hasFullscreenSupplement());
        Fullscreen& fullscreen = from(document);
        EventTarget* target = fullscreen.fullscreenElement();
        if (!target)
            target = fullscreen.webkitCurrentFullScreenElement();
        if (!target)
            target = &document;
        event = createEvent(EventTypeNames::webkitfullscreenchange, *target);
    }
    m_eventQueue.append(event);
    // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScreenForElement.
}

void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType)
{
    RefPtrWillBeRawPtr<Event> event;
    if (requestType == UnprefixedRequest)
        event = createEvent(EventTypeNames::fullscreenerror, element.document());
    else
        event = createEvent(EventTypeNames::webkitfullscreenerror, element);
    m_eventQueue.append(event);
    m_eventQueueTimer.startOneShot(0, FROM_HERE);
}

void Fullscreen::eventQueueTimerFired(Timer<Fullscreen>*)
{
    // Since we dispatch events in this function, it's possible that the
    // document will be detached and GC'd. We protect it here to make sure we
    // can finish the function successfully.
    RefPtrWillBeRawPtr<Document> protectDocument(document());
    WillBeHeapDeque<RefPtrWillBeMember<Event> > eventQueue;
    m_eventQueue.swap(eventQueue);

    while (!eventQueue.isEmpty()) {
        RefPtrWillBeRawPtr<Event> event = eventQueue.takeFirst();
        Node* target = event->target()->toNode();

        // If the element was removed from our tree, also message the documentElement.
        if (!target->inDocument() && document()->documentElement()) {
            ASSERT(isPrefixed(event->type()));
            eventQueue.append(createEvent(event->type(), *document()->documentElement()));
        }

        target->dispatchEvent(event);
    }
}

void Fullscreen::elementRemoved(Element& oldNode)
{
    // Whenever the removing steps run with an |oldNode| and |oldNode| is in its node document's
    // fullscreen element stack, run these steps:

    // 1. If |oldNode| is at the top of its node document's fullscreen element stack, act as if the
    //    exitFullscreen() method was invoked on that document.
    if (fullscreenElement() == &oldNode) {
        exitFullscreen();
        return;
    }

    // 2. Otherwise, remove |oldNode| from its node document's fullscreen element stack.
    for (size_t i = 0; i < m_fullScreenElementStack.size(); ++i) {
        if (m_fullScreenElementStack[i].first.get() == &oldNode) {
            m_fullScreenElementStack.remove(i);
            return;
        }
    }

    // NOTE: |oldNode| was not in the fullscreen element stack.
}

void Fullscreen::clearFullscreenElementStack()
{
    m_fullScreenElementStack.clear();
}

void Fullscreen::popFullscreenElementStack()
{
    if (m_fullScreenElementStack.isEmpty())
        return;

    m_fullScreenElementStack.removeLast();
}

void Fullscreen::pushFullscreenElementStack(Element& element, RequestType requestType)
{
    m_fullScreenElementStack.append(std::make_pair(&element, requestType));
}

void Fullscreen::trace(Visitor* visitor)
{
    visitor->trace(m_fullScreenElement);
    visitor->trace(m_fullScreenElementStack);
    visitor->trace(m_fullScreenRenderer);
    visitor->trace(m_eventQueue);
    DocumentSupplement::trace(visitor);
    DocumentLifecycleObserver::trace(visitor);
}

} // namespace blink