| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 Fullscreen* Fullscreen::fromIfExistsSlow(Document& document) | 174 Fullscreen* Fullscreen::fromIfExistsSlow(Document& document) |
| 175 { | 175 { |
| 176 return static_cast<Fullscreen*>(Supplement<Document>::from(document, supplem
entName())); | 176 return static_cast<Fullscreen*>(Supplement<Document>::from(document, supplem
entName())); |
| 177 } | 177 } |
| 178 | 178 |
| 179 Element* Fullscreen::fullscreenElementFrom(Document& document) | 179 Element* Fullscreen::fullscreenElementFrom(Document& document) |
| 180 { | 180 { |
| 181 if (Fullscreen* found = fromIfExists(document)) | 181 if (Fullscreen* found = fromIfExists(document)) |
| 182 return found->fullscreenElement(); | 182 return found->fullscreenElement(); |
| 183 return 0; | 183 return nullptr; |
| 184 } | 184 } |
| 185 | 185 |
| 186 Element* Fullscreen::currentFullScreenElementFrom(Document& document) | 186 Element* Fullscreen::currentFullScreenElementFrom(Document& document) |
| 187 { | 187 { |
| 188 if (Fullscreen* found = fromIfExists(document)) | 188 if (Fullscreen* found = fromIfExists(document)) |
| 189 return found->webkitCurrentFullScreenElement(); | 189 return found->currentFullScreenElement(); |
| 190 return 0; | 190 return nullptr; |
| 191 } | |
| 192 | |
| 193 bool Fullscreen::isFullScreen(Document& document) | |
| 194 { | |
| 195 return currentFullScreenElementFrom(document); | |
| 196 } | 191 } |
| 197 | 192 |
| 198 Fullscreen::Fullscreen(Document& document) | 193 Fullscreen::Fullscreen(Document& document) |
| 199 : ContextLifecycleObserver(&document) | 194 : ContextLifecycleObserver(&document) |
| 200 , m_fullScreenLayoutObject(nullptr) | 195 , m_fullScreenLayoutObject(nullptr) |
| 201 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) | 196 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) |
| 202 , m_forCrossProcessDescendant(false) | 197 , m_forCrossProcessDescendant(false) |
| 203 { | 198 { |
| 204 document.setHasFullscreenSupplement(); | 199 document.setHasFullscreenSupplement(); |
| 205 } | 200 } |
| 206 | 201 |
| 207 Fullscreen::~Fullscreen() | 202 Fullscreen::~Fullscreen() |
| 208 { | 203 { |
| 209 } | 204 } |
| 210 | 205 |
| 211 inline Document* Fullscreen::document() | 206 inline Document* Fullscreen::document() |
| 212 { | 207 { |
| 213 return toDocument(lifecycleContext()); | 208 return toDocument(lifecycleContext()); |
| 214 } | 209 } |
| 215 | 210 |
| 216 void Fullscreen::contextDestroyed() | 211 void Fullscreen::contextDestroyed() |
| 217 { | 212 { |
| 218 m_eventQueue.clear(); | 213 m_eventQueue.clear(); |
| 219 | 214 |
| 220 if (m_fullScreenLayoutObject) | 215 if (m_fullScreenLayoutObject) |
| 221 m_fullScreenLayoutObject->destroy(); | 216 m_fullScreenLayoutObject->destroy(); |
| 222 | 217 |
| 223 m_fullScreenElement = nullptr; | 218 m_currentFullScreenElement = nullptr; |
| 224 m_fullScreenElementStack.clear(); | 219 m_fullscreenElementStack.clear(); |
| 225 | |
| 226 } | 220 } |
| 227 | 221 |
| 228 void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo
ol forCrossProcessDescendant) | 222 void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo
ol forCrossProcessDescendant) |
| 229 { | 223 { |
| 230 // Use counters only need to be incremented in the process of the actual | 224 // Use counters only need to be incremented in the process of the actual |
| 231 // fullscreen element. | 225 // fullscreen element. |
| 232 if (!forCrossProcessDescendant) { | 226 if (!forCrossProcessDescendant) { |
| 233 if (document()->isSecureContext()) { | 227 if (document()->isSecureContext()) { |
| 234 UseCounter::count(document(), UseCounter::FullscreenSecureOrigin); | 228 UseCounter::count(document(), UseCounter::FullscreenSecureOrigin); |
| 235 } else { | 229 } else { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // will be the top frame's document. With OOPIF, each renderer process for | 352 // will be the top frame's document. With OOPIF, each renderer process for |
| 359 // the current page will separately call fullyExitFullscreen to cover all | 353 // the current page will separately call fullyExitFullscreen to cover all |
| 360 // local frames in each process. | 354 // local frames in each process. |
| 361 Document& doc = topmostLocalAncestor(document); | 355 Document& doc = topmostLocalAncestor(document); |
| 362 | 356 |
| 363 // 2. If |doc|'s fullscreen element stack is empty, terminate these steps. | 357 // 2. If |doc|'s fullscreen element stack is empty, terminate these steps. |
| 364 if (!fullscreenElementFrom(doc)) | 358 if (!fullscreenElementFrom(doc)) |
| 365 return; | 359 return; |
| 366 | 360 |
| 367 // 3. Remove elements from |doc|'s fullscreen element stack until only the t
op element is left. | 361 // 3. Remove elements from |doc|'s fullscreen element stack until only the t
op element is left. |
| 368 size_t stackSize = from(doc).m_fullScreenElementStack.size(); | 362 size_t stackSize = from(doc).m_fullscreenElementStack.size(); |
| 369 from(doc).m_fullScreenElementStack.remove(0, stackSize - 1); | 363 from(doc).m_fullscreenElementStack.remove(0, stackSize - 1); |
| 370 DCHECK_EQ(from(doc).m_fullScreenElementStack.size(), 1u); | 364 DCHECK_EQ(from(doc).m_fullscreenElementStack.size(), 1u); |
| 371 | 365 |
| 372 // 4. Act as if the exitFullscreen() method was invoked on |doc|. | 366 // 4. Act as if the exitFullscreen() method was invoked on |doc|. |
| 373 from(doc).exitFullscreen(); | 367 from(doc).exitFullscreen(); |
| 374 } | 368 } |
| 375 | 369 |
| 376 void Fullscreen::exitFullscreen() | 370 void Fullscreen::exitFullscreen() |
| 377 { | 371 { |
| 378 // The exitFullscreen() method must run these steps: | 372 // The exitFullscreen() method must run these steps: |
| 379 | 373 |
| 380 // 1. Let doc be the context object. (i.e. "this") | 374 // 1. Let doc be the context object. (i.e. "this") |
| 381 Document* currentDoc = document(); | 375 Document* currentDoc = document(); |
| 382 if (!currentDoc->isActive()) | 376 if (!currentDoc->isActive()) |
| 383 return; | 377 return; |
| 384 | 378 |
| 385 // 2. If doc's fullscreen element stack is empty, terminate these steps. | 379 // 2. If doc's fullscreen element stack is empty, terminate these steps. |
| 386 if (m_fullScreenElementStack.isEmpty()) | 380 if (m_fullscreenElementStack.isEmpty()) |
| 387 return; | 381 return; |
| 388 | 382 |
| 389 // 3. Let descendants be all the doc's descendant browsing context's documen
ts with a non-empty fullscreen | 383 // 3. Let descendants be all the doc's descendant browsing context's documen
ts with a non-empty fullscreen |
| 390 // element stack (if any), ordered so that the child of the doc is last and
the document furthest | 384 // element stack (if any), ordered so that the child of the doc is last and
the document furthest |
| 391 // away from the doc is first. | 385 // away from the doc is first. |
| 392 HeapDeque<Member<Document>> descendants; | 386 HeapDeque<Member<Document>> descendants; |
| 393 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t
raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) { | 387 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t
raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) { |
| 394 if (!descendant->isLocalFrame()) | 388 if (!descendant->isLocalFrame()) |
| 395 continue; | 389 continue; |
| 396 DCHECK(toLocalFrame(descendant)->document()); | 390 DCHECK(toLocalFrame(descendant)->document()); |
| 397 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) | 391 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) |
| 398 descendants.prepend(toLocalFrame(descendant)->document()); | 392 descendants.prepend(toLocalFrame(descendant)->document()); |
| 399 } | 393 } |
| 400 | 394 |
| 401 // 4. For each descendant in descendants, empty descendant's fullscreen elem
ent stack, and queue a | 395 // 4. For each descendant in descendants, empty descendant's fullscreen elem
ent stack, and queue a |
| 402 // task to fire an event named fullscreenchange with its bubbles attribute s
et to true on descendant. | 396 // task to fire an event named fullscreenchange with its bubbles attribute s
et to true on descendant. |
| 403 for (auto& descendant : descendants) { | 397 for (auto& descendant : descendants) { |
| 404 DCHECK(descendant); | 398 DCHECK(descendant); |
| 405 RequestType requestType = from(*descendant).m_fullScreenElementStack.las
t().second; | 399 RequestType requestType = from(*descendant).m_fullscreenElementStack.las
t().second; |
| 406 from(*descendant).clearFullscreenElementStack(); | 400 from(*descendant).clearFullscreenElementStack(); |
| 407 enqueueChangeEvent(*descendant, requestType); | 401 enqueueChangeEvent(*descendant, requestType); |
| 408 } | 402 } |
| 409 | 403 |
| 410 // 5. While doc is not null, run these substeps: | 404 // 5. While doc is not null, run these substeps: |
| 411 Element* newTop = 0; | 405 Element* newTop = 0; |
| 412 while (currentDoc) { | 406 while (currentDoc) { |
| 413 RequestType requestType = from(*currentDoc).m_fullScreenElementStack.las
t().second; | 407 RequestType requestType = from(*currentDoc).m_fullscreenElementStack.las
t().second; |
| 414 | 408 |
| 415 // 1. Pop the top element of doc's fullscreen element stack. | 409 // 1. Pop the top element of doc's fullscreen element stack. |
| 416 from(*currentDoc).popFullscreenElementStack(); | 410 from(*currentDoc).popFullscreenElementStack(); |
| 417 | 411 |
| 418 // If doc's fullscreen element stack is non-empty and the element now
at the top is either | 412 // If doc's fullscreen element stack is non-empty and the element now
at the top is either |
| 419 // not in a document or its node document is not doc, repeat this sub
step. | 413 // not in a document or its node document is not doc, repeat this sub
step. |
| 420 newTop = fullscreenElementFrom(*currentDoc); | 414 newTop = fullscreenElementFrom(*currentDoc); |
| 421 if (newTop && (!newTop->isConnected() || newTop->document() != currentDo
c)) | 415 if (newTop && (!newTop->isConnected() || newTop->document() != currentDo
c)) |
| 422 continue; | 416 continue; |
| 423 | 417 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // Speculative fix for engaget.com/videos per crbug.com/336239. | 449 // Speculative fix for engaget.com/videos per crbug.com/336239. |
| 456 // FIXME: This check is wrong. We DCHECK(document->isActive()) above | 450 // FIXME: This check is wrong. We DCHECK(document->isActive()) above |
| 457 // so this should be redundant and should be removed! | 451 // so this should be redundant and should be removed! |
| 458 if (!host) | 452 if (!host) |
| 459 return; | 453 return; |
| 460 | 454 |
| 461 // Only exit out of full screen window mode if there are no remaining elemen
ts in the | 455 // Only exit out of full screen window mode if there are no remaining elemen
ts in the |
| 462 // full screen stack. | 456 // full screen stack. |
| 463 if (!newTop) { | 457 if (!newTop) { |
| 464 // FIXME: if the frame exiting fullscreen is not the frame that entered | 458 // FIXME: if the frame exiting fullscreen is not the frame that entered |
| 465 // fullscreen (but a parent frame for example), m_fullScreenElement | 459 // fullscreen (but a parent frame for example), |
| 466 // might be null. We want to pass an element that is part of the | 460 // m_currentFullScreenElement might be null. We want to pass an element |
| 467 // document so we will pass the documentElement in that case. | 461 // that is part of the document so we will pass the documentElement in |
| 468 // This should be fix by exiting fullscreen for a frame instead of an | 462 // that case. This should be fix by exiting fullscreen for a frame |
| 469 // element, see https://crbug.com/441259 | 463 // instead of an element, see https://crbug.com/441259 |
| 470 host->chromeClient().exitFullScreenForElement( | 464 host->chromeClient().exitFullScreenForElement( |
| 471 m_fullScreenElement ? m_fullScreenElement.get() : document()->docume
ntElement()); | 465 m_currentFullScreenElement ? m_currentFullScreenElement.get() : docu
ment()->documentElement()); |
| 472 return; | 466 return; |
| 473 } | 467 } |
| 474 | 468 |
| 475 // Otherwise, notify the chrome of the new full screen element. | 469 // Otherwise, notify the chrome of the new full screen element. |
| 476 host->chromeClient().enterFullScreenForElement(newTop); | 470 host->chromeClient().enterFullScreenForElement(newTop); |
| 477 } | 471 } |
| 478 | 472 |
| 479 bool Fullscreen::fullscreenEnabled(Document& document) | 473 bool Fullscreen::fullscreenEnabled(Document& document) |
| 480 { | 474 { |
| 481 // 4. The fullscreenEnabled attribute must return true if the context object
has its | 475 // 4. The fullscreenEnabled attribute must return true if the context object
has its |
| 482 // fullscreen enabled flag set and fullscreen is supported, and false oth
erwise. | 476 // fullscreen enabled flag set and fullscreen is supported, and false oth
erwise. |
| 483 | 477 |
| 484 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. | 478 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. |
| 485 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); | 479 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); |
| 486 } | 480 } |
| 487 | 481 |
| 488 void Fullscreen::didEnterFullscreenForElement(Element* element) | 482 void Fullscreen::didEnterFullscreenForElement(Element* element) |
| 489 { | 483 { |
| 490 DCHECK(element); | 484 DCHECK(element); |
| 491 if (!document()->isActive()) | 485 if (!document()->isActive()) |
| 492 return; | 486 return; |
| 493 | 487 |
| 494 if (m_fullScreenLayoutObject) | 488 if (m_fullScreenLayoutObject) |
| 495 m_fullScreenLayoutObject->unwrapLayoutObject(); | 489 m_fullScreenLayoutObject->unwrapLayoutObject(); |
| 496 | 490 |
| 497 m_fullScreenElement = element; | 491 m_currentFullScreenElement = element; |
| 498 | 492 |
| 499 // Create a placeholder block for a the full-screen element, to keep the pag
e from reflowing | 493 // Create a placeholder block for a the full-screen element, to keep the pag
e from reflowing |
| 500 // when the element is removed from the normal flow. Only do this for a Layo
utBox, as only | 494 // when the element is removed from the normal flow. Only do this for a Layo
utBox, as only |
| 501 // a box will have a frameRect. The placeholder will be created in setFullSc
reenLayoutObject() | 495 // a box will have a frameRect. The placeholder will be created in setFullSc
reenLayoutObject() |
| 502 // during layout. | 496 // during layout. |
| 503 LayoutObject* layoutObject = m_fullScreenElement->layoutObject(); | 497 LayoutObject* layoutObject = m_currentFullScreenElement->layoutObject(); |
| 504 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox(); | 498 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox(); |
| 505 if (shouldCreatePlaceholder) { | 499 if (shouldCreatePlaceholder) { |
| 506 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect(); | 500 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect(); |
| 507 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty
leRef()); | 501 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty
leRef()); |
| 508 } | 502 } |
| 509 | 503 |
| 510 // TODO(alexmos): When |m_forCrossProcessDescendant| is true, some of | 504 // TODO(alexmos): When |m_forCrossProcessDescendant| is true, some of |
| 511 // this layout work has already been done in another process, so it should | 505 // this layout work has already been done in another process, so it should |
| 512 // not be necessary to repeat it here. | 506 // not be necessary to repeat it here. |
| 513 if (m_fullScreenElement != document()->documentElement()) | 507 if (m_currentFullScreenElement != document()->documentElement()) |
| 514 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb
ject->parent() : 0, document()); | 508 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb
ject->parent() : 0, document()); |
| 515 | 509 |
| 516 // When |m_forCrossProcessDescendant| is true, m_fullScreenElement | 510 // When |m_forCrossProcessDescendant| is true, m_currentFullScreenElement |
| 517 // corresponds to the HTMLFrameOwnerElement for the out-of-process iframe | 511 // corresponds to the HTMLFrameOwnerElement for the out-of-process iframe |
| 518 // that contains the actual fullscreen element. Hence, it must also set | 512 // that contains the actual fullscreen element. Hence, it must also set |
| 519 // the ContainsFullScreenElement flag (so that it gains the | 513 // the ContainsFullScreenElement flag (so that it gains the |
| 520 // -webkit-full-screen-ancestor style). | 514 // -webkit-full-screen-ancestor style). |
| 521 if (m_forCrossProcessDescendant) { | 515 if (m_forCrossProcessDescendant) { |
| 522 DCHECK(m_fullScreenElement->isFrameOwnerElement()); | 516 DCHECK(m_currentFullScreenElement->isFrameOwnerElement()); |
| 523 DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isR
emoteFrame()); | 517 DCHECK(toHTMLFrameOwnerElement(m_currentFullScreenElement)->contentFrame
()->isRemoteFrame()); |
| 524 m_fullScreenElement->setContainsFullScreenElement(true); | 518 m_currentFullScreenElement->setContainsFullScreenElement(true); |
| 525 } | 519 } |
| 526 | 520 |
| 527 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(true); | 521 m_currentFullScreenElement->setContainsFullScreenElementOnAncestorsCrossingF
rameBoundaries(true); |
| 528 | 522 |
| 529 document()->styleEngine().ensureFullscreenUAStyle(); | 523 document()->styleEngine().ensureFullscreenUAStyle(); |
| 530 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); | 524 m_currentFullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen
); |
| 531 | 525 |
| 532 // FIXME: This should not call updateStyleAndLayoutTree. | 526 // FIXME: This should not call updateStyleAndLayoutTree. |
| 533 document()->updateStyleAndLayoutTree(); | 527 document()->updateStyleAndLayoutTree(); |
| 534 | 528 |
| 535 m_fullScreenElement->didBecomeFullscreenElement(); | 529 m_currentFullScreenElement->didBecomeFullscreenElement(); |
| 536 | 530 |
| 537 if (document()->frame()) | 531 if (document()->frame()) |
| 538 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 532 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
| 539 | 533 |
| 540 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); | 534 m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); |
| 541 } | 535 } |
| 542 | 536 |
| 543 void Fullscreen::didExitFullscreen() | 537 void Fullscreen::didExitFullscreen() |
| 544 { | 538 { |
| 545 if (!m_fullScreenElement) | 539 if (!m_currentFullScreenElement) |
| 546 return; | 540 return; |
| 547 | 541 |
| 548 if (!document()->isActive()) | 542 if (!document()->isActive()) |
| 549 return; | 543 return; |
| 550 | 544 |
| 551 m_fullScreenElement->willStopBeingFullscreenElement(); | 545 m_currentFullScreenElement->willStopBeingFullscreenElement(); |
| 552 | 546 |
| 553 if (m_forCrossProcessDescendant) | 547 if (m_forCrossProcessDescendant) |
| 554 m_fullScreenElement->setContainsFullScreenElement(false); | 548 m_currentFullScreenElement->setContainsFullScreenElement(false); |
| 555 | 549 |
| 556 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou
ndaries(false); | 550 m_currentFullScreenElement->setContainsFullScreenElementOnAncestorsCrossingF
rameBoundaries(false); |
| 557 | 551 |
| 558 if (m_fullScreenLayoutObject) | 552 if (m_fullScreenLayoutObject) |
| 559 LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject(); | 553 LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject(); |
| 560 | 554 |
| 561 document()->styleEngine().ensureFullscreenUAStyle(); | 555 document()->styleEngine().ensureFullscreenUAStyle(); |
| 562 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); | 556 m_currentFullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen
); |
| 563 m_fullScreenElement = nullptr; | 557 m_currentFullScreenElement = nullptr; |
| 564 | 558 |
| 565 if (document()->frame()) | 559 if (document()->frame()) |
| 566 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 560 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
| 567 | 561 |
| 568 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means | 562 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means |
| 569 // that the events will be queued there. So if we have no events here, start
the timer on the | 563 // that the events will be queued there. So if we have no events here, start
the timer on the |
| 570 // exiting document. | 564 // exiting document. |
| 571 Document* exitingDocument = document(); | 565 Document* exitingDocument = document(); |
| 572 if (m_eventQueue.isEmpty()) | 566 if (m_eventQueue.isEmpty()) |
| 573 exitingDocument = &topmostLocalAncestor(*document()); | 567 exitingDocument = &topmostLocalAncestor(*document()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 604 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) | 598 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
| 605 { | 599 { |
| 606 Event* event; | 600 Event* event; |
| 607 if (requestType == UnprefixedRequest) { | 601 if (requestType == UnprefixedRequest) { |
| 608 event = createEvent(EventTypeNames::fullscreenchange, document); | 602 event = createEvent(EventTypeNames::fullscreenchange, document); |
| 609 } else { | 603 } else { |
| 610 DCHECK(document.hasFullscreenSupplement()); | 604 DCHECK(document.hasFullscreenSupplement()); |
| 611 Fullscreen& fullscreen = from(document); | 605 Fullscreen& fullscreen = from(document); |
| 612 EventTarget* target = fullscreen.fullscreenElement(); | 606 EventTarget* target = fullscreen.fullscreenElement(); |
| 613 if (!target) | 607 if (!target) |
| 614 target = fullscreen.webkitCurrentFullScreenElement(); | 608 target = fullscreen.currentFullScreenElement(); |
| 615 if (!target) | 609 if (!target) |
| 616 target = &document; | 610 target = &document; |
| 617 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); | 611 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); |
| 618 } | 612 } |
| 619 m_eventQueue.append(event); | 613 m_eventQueue.append(event); |
| 620 // NOTE: The timer is started in didEnterFullscreenForElement/didExitFullscr
een. | 614 // NOTE: The timer is started in didEnterFullscreenForElement/didExitFullscr
een. |
| 621 } | 615 } |
| 622 | 616 |
| 623 void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType) | 617 void Fullscreen::enqueueErrorEvent(Element& element, RequestType requestType) |
| 624 { | 618 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // fullscreen element stack, run these steps: | 650 // fullscreen element stack, run these steps: |
| 657 | 651 |
| 658 // 1. If |oldNode| is at the top of its node document's fullscreen element s
tack, act as if the | 652 // 1. If |oldNode| is at the top of its node document's fullscreen element s
tack, act as if the |
| 659 // exitFullscreen() method was invoked on that document. | 653 // exitFullscreen() method was invoked on that document. |
| 660 if (fullscreenElement() == &oldNode) { | 654 if (fullscreenElement() == &oldNode) { |
| 661 exitFullscreen(); | 655 exitFullscreen(); |
| 662 return; | 656 return; |
| 663 } | 657 } |
| 664 | 658 |
| 665 // 2. Otherwise, remove |oldNode| from its node document's fullscreen elemen
t stack. | 659 // 2. Otherwise, remove |oldNode| from its node document's fullscreen elemen
t stack. |
| 666 for (size_t i = 0; i < m_fullScreenElementStack.size(); ++i) { | 660 for (size_t i = 0; i < m_fullscreenElementStack.size(); ++i) { |
| 667 if (m_fullScreenElementStack[i].first.get() == &oldNode) { | 661 if (m_fullscreenElementStack[i].first.get() == &oldNode) { |
| 668 m_fullScreenElementStack.remove(i); | 662 m_fullscreenElementStack.remove(i); |
| 669 return; | 663 return; |
| 670 } | 664 } |
| 671 } | 665 } |
| 672 | 666 |
| 673 // NOTE: |oldNode| was not in the fullscreen element stack. | 667 // NOTE: |oldNode| was not in the fullscreen element stack. |
| 674 } | 668 } |
| 675 | 669 |
| 676 void Fullscreen::clearFullscreenElementStack() | 670 void Fullscreen::clearFullscreenElementStack() |
| 677 { | 671 { |
| 678 m_fullScreenElementStack.clear(); | 672 m_fullscreenElementStack.clear(); |
| 679 } | 673 } |
| 680 | 674 |
| 681 void Fullscreen::popFullscreenElementStack() | 675 void Fullscreen::popFullscreenElementStack() |
| 682 { | 676 { |
| 683 if (m_fullScreenElementStack.isEmpty()) | 677 if (m_fullscreenElementStack.isEmpty()) |
| 684 return; | 678 return; |
| 685 | 679 |
| 686 m_fullScreenElementStack.removeLast(); | 680 m_fullscreenElementStack.removeLast(); |
| 687 } | 681 } |
| 688 | 682 |
| 689 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques
tType) | 683 void Fullscreen::pushFullscreenElementStack(Element& element, RequestType reques
tType) |
| 690 { | 684 { |
| 691 m_fullScreenElementStack.append(std::make_pair(&element, requestType)); | 685 m_fullscreenElementStack.append(std::make_pair(&element, requestType)); |
| 692 } | 686 } |
| 693 | 687 |
| 694 DEFINE_TRACE(Fullscreen) | 688 DEFINE_TRACE(Fullscreen) |
| 695 { | 689 { |
| 696 visitor->trace(m_fullScreenElement); | 690 visitor->trace(m_currentFullScreenElement); |
| 697 visitor->trace(m_fullScreenElementStack); | 691 visitor->trace(m_fullscreenElementStack); |
| 698 visitor->trace(m_eventQueue); | 692 visitor->trace(m_eventQueue); |
| 699 Supplement<Document>::trace(visitor); | 693 Supplement<Document>::trace(visitor); |
| 700 ContextLifecycleObserver::trace(visitor); | 694 ContextLifecycleObserver::trace(visitor); |
| 701 } | 695 } |
| 702 | 696 |
| 703 } // namespace blink | 697 } // namespace blink |
| OLD | NEW |