| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // 1. Let |doc| be the top-level browsing context's document. | 304 // 1. Let |doc| be the top-level browsing context's document. |
| 305 Document& doc = document.topDocument(); | 305 Document& doc = document.topDocument(); |
| 306 | 306 |
| 307 // 2. If |doc|'s fullscreen element stack is empty, terminate these steps. | 307 // 2. If |doc|'s fullscreen element stack is empty, terminate these steps. |
| 308 if (!fullscreenElementFrom(doc)) | 308 if (!fullscreenElementFrom(doc)) |
| 309 return; | 309 return; |
| 310 | 310 |
| 311 // 3. Remove elements from |doc|'s fullscreen element stack until only the t
op element is left. | 311 // 3. Remove elements from |doc|'s fullscreen element stack until only the t
op element is left. |
| 312 size_t stackSize = from(doc).m_fullScreenElementStack.size(); | 312 size_t stackSize = from(doc).m_fullScreenElementStack.size(); |
| 313 from(doc).m_fullScreenElementStack.remove(0, stackSize - 1); | 313 from(doc).m_fullScreenElementStack.remove(0, stackSize - 1); |
| 314 ASSERT(from(doc).m_fullScreenElementStack.size() == 1); | 314 DCHECK_EQ(from(doc).m_fullScreenElementStack.size(), 1u); |
| 315 | 315 |
| 316 // 4. Act as if the exitFullscreen() method was invoked on |doc|. | 316 // 4. Act as if the exitFullscreen() method was invoked on |doc|. |
| 317 from(doc).exitFullscreen(); | 317 from(doc).exitFullscreen(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void Fullscreen::exitFullscreen() | 320 void Fullscreen::exitFullscreen() |
| 321 { | 321 { |
| 322 // The exitFullscreen() method must run these steps: | 322 // The exitFullscreen() method must run these steps: |
| 323 | 323 |
| 324 // 1. Let doc be the context object. (i.e. "this") | 324 // 1. Let doc be the context object. (i.e. "this") |
| 325 Document* currentDoc = document(); | 325 Document* currentDoc = document(); |
| 326 if (!currentDoc->isActive()) | 326 if (!currentDoc->isActive()) |
| 327 return; | 327 return; |
| 328 | 328 |
| 329 // 2. If doc's fullscreen element stack is empty, terminate these steps. | 329 // 2. If doc's fullscreen element stack is empty, terminate these steps. |
| 330 if (m_fullScreenElementStack.isEmpty()) | 330 if (m_fullScreenElementStack.isEmpty()) |
| 331 return; | 331 return; |
| 332 | 332 |
| 333 // 3. Let descendants be all the doc's descendant browsing context's documen
ts with a non-empty fullscreen | 333 // 3. Let descendants be all the doc's descendant browsing context's documen
ts with a non-empty fullscreen |
| 334 // element stack (if any), ordered so that the child of the doc is last and
the document furthest | 334 // element stack (if any), ordered so that the child of the doc is last and
the document furthest |
| 335 // away from the doc is first. | 335 // away from the doc is first. |
| 336 HeapDeque<Member<Document>> descendants; | 336 HeapDeque<Member<Document>> descendants; |
| 337 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t
raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) { | 337 for (Frame* descendant = document()->frame() ? document()->frame()->tree().t
raverseNext() : 0; descendant; descendant = descendant->tree().traverseNext()) { |
| 338 if (!descendant->isLocalFrame()) | 338 if (!descendant->isLocalFrame()) |
| 339 continue; | 339 continue; |
| 340 ASSERT(toLocalFrame(descendant)->document()); | 340 DCHECK(toLocalFrame(descendant)->document()); |
| 341 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) | 341 if (fullscreenElementFrom(*toLocalFrame(descendant)->document())) |
| 342 descendants.prepend(toLocalFrame(descendant)->document()); | 342 descendants.prepend(toLocalFrame(descendant)->document()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 // 4. For each descendant in descendants, empty descendant's fullscreen elem
ent stack, and queue a | 345 // 4. For each descendant in descendants, empty descendant's fullscreen elem
ent stack, and queue a |
| 346 // task to fire an event named fullscreenchange with its bubbles attribute s
et to true on descendant. | 346 // task to fire an event named fullscreenchange with its bubbles attribute s
et to true on descendant. |
| 347 for (auto& descendant : descendants) { | 347 for (auto& descendant : descendants) { |
| 348 ASSERT(descendant); | 348 DCHECK(descendant); |
| 349 RequestType requestType = from(*descendant).m_fullScreenElementStack.las
t().second; | 349 RequestType requestType = from(*descendant).m_fullScreenElementStack.las
t().second; |
| 350 from(*descendant).clearFullscreenElementStack(); | 350 from(*descendant).clearFullscreenElementStack(); |
| 351 enqueueChangeEvent(*descendant, requestType); | 351 enqueueChangeEvent(*descendant, requestType); |
| 352 } | 352 } |
| 353 | 353 |
| 354 // 5. While doc is not null, run these substeps: | 354 // 5. While doc is not null, run these substeps: |
| 355 Element* newTop = 0; | 355 Element* newTop = 0; |
| 356 while (currentDoc) { | 356 while (currentDoc) { |
| 357 RequestType requestType = from(*currentDoc).m_fullScreenElementStack.las
t().second; | 357 RequestType requestType = from(*currentDoc).m_fullScreenElementStack.las
t().second; |
| 358 | 358 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 379 // 4. Otherwise, set doc to null. | 379 // 4. Otherwise, set doc to null. |
| 380 currentDoc = 0; | 380 currentDoc = 0; |
| 381 } | 381 } |
| 382 | 382 |
| 383 // 6. Return, and run the remaining steps asynchronously. | 383 // 6. Return, and run the remaining steps asynchronously. |
| 384 // 7. Optionally, perform some animation. | 384 // 7. Optionally, perform some animation. |
| 385 | 385 |
| 386 FrameHost* host = document()->frameHost(); | 386 FrameHost* host = document()->frameHost(); |
| 387 | 387 |
| 388 // Speculative fix for engaget.com/videos per crbug.com/336239. | 388 // Speculative fix for engaget.com/videos per crbug.com/336239. |
| 389 // FIXME: This check is wrong. We ASSERT(document->isActive()) above | 389 // FIXME: This check is wrong. We DCHECK(document->isActive()) above |
| 390 // so this should be redundant and should be removed! | 390 // so this should be redundant and should be removed! |
| 391 if (!host) | 391 if (!host) |
| 392 return; | 392 return; |
| 393 | 393 |
| 394 // Only exit out of full screen window mode if there are no remaining elemen
ts in the | 394 // Only exit out of full screen window mode if there are no remaining elemen
ts in the |
| 395 // full screen stack. | 395 // full screen stack. |
| 396 if (!newTop) { | 396 if (!newTop) { |
| 397 // FIXME: if the frame exiting fullscreen is not the frame that entered | 397 // FIXME: if the frame exiting fullscreen is not the frame that entered |
| 398 // fullscreen (but a parent frame for example), m_fullScreenElement | 398 // fullscreen (but a parent frame for example), m_fullScreenElement |
| 399 // might be null. We want to pass an element that is part of the | 399 // might be null. We want to pass an element that is part of the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 413 { | 413 { |
| 414 // 4. The fullscreenEnabled attribute must return true if the context object
has its | 414 // 4. The fullscreenEnabled attribute must return true if the context object
has its |
| 415 // fullscreen enabled flag set and fullscreen is supported, and false oth
erwise. | 415 // fullscreen enabled flag set and fullscreen is supported, and false oth
erwise. |
| 416 | 416 |
| 417 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. | 417 // Top-level browsing contexts are implied to have their allowFullScreen att
ribute set. |
| 418 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); | 418 return fullscreenIsAllowedForAllOwners(document) && fullscreenIsSupported(do
cument); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void Fullscreen::didEnterFullScreenForElement(Element* element) | 421 void Fullscreen::didEnterFullScreenForElement(Element* element) |
| 422 { | 422 { |
| 423 ASSERT(element); | 423 DCHECK(element); |
| 424 if (!document()->isActive()) | 424 if (!document()->isActive()) |
| 425 return; | 425 return; |
| 426 | 426 |
| 427 if (m_fullScreenLayoutObject) | 427 if (m_fullScreenLayoutObject) |
| 428 m_fullScreenLayoutObject->unwrapLayoutObject(); | 428 m_fullScreenLayoutObject->unwrapLayoutObject(); |
| 429 | 429 |
| 430 m_fullScreenElement = element; | 430 m_fullScreenElement = element; |
| 431 | 431 |
| 432 // Create a placeholder block for a the full-screen element, to keep the pag
e from reflowing | 432 // Create a placeholder block for a the full-screen element, to keep the pag
e from reflowing |
| 433 // when the element is removed from the normal flow. Only do this for a Layo
utBox, as only | 433 // when the element is removed from the normal flow. Only do this for a Layo
utBox, as only |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 479 |
| 480 if (document()->frame()) | 480 if (document()->frame()) |
| 481 document()->frame()->eventHandler().scheduleHoverStateUpdate(); | 481 document()->frame()->eventHandler().scheduleHoverStateUpdate(); |
| 482 | 482 |
| 483 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means | 483 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu
ment(). That means |
| 484 // that the events will be queued there. So if we have no events here, start
the timer on the | 484 // that the events will be queued there. So if we have no events here, start
the timer on the |
| 485 // exiting document. | 485 // exiting document. |
| 486 Document* exitingDocument = document(); | 486 Document* exitingDocument = document(); |
| 487 if (m_eventQueue.isEmpty()) | 487 if (m_eventQueue.isEmpty()) |
| 488 exitingDocument = &document()->topDocument(); | 488 exitingDocument = &document()->topDocument(); |
| 489 ASSERT(exitingDocument); | 489 DCHECK(exitingDocument); |
| 490 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); | 490 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); |
| 491 } | 491 } |
| 492 | 492 |
| 493 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject) | 493 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject) |
| 494 { | 494 { |
| 495 if (layoutObject == m_fullScreenLayoutObject) | 495 if (layoutObject == m_fullScreenLayoutObject) |
| 496 return; | 496 return; |
| 497 | 497 |
| 498 if (layoutObject && m_savedPlaceholderComputedStyle) { | 498 if (layoutObject && m_savedPlaceholderComputedStyle) { |
| 499 layoutObject->createPlaceholder(m_savedPlaceholderComputedStyle.release(
), m_savedPlaceholderFrameRect); | 499 layoutObject->createPlaceholder(m_savedPlaceholderComputedStyle.release(
), m_savedPlaceholderFrameRect); |
| 500 } else if (layoutObject && m_fullScreenLayoutObject && m_fullScreenLayoutObj
ect->placeholder()) { | 500 } else if (layoutObject && m_fullScreenLayoutObject && m_fullScreenLayoutObj
ect->placeholder()) { |
| 501 LayoutBlock* placeholder = m_fullScreenLayoutObject->placeholder(); | 501 LayoutBlock* placeholder = m_fullScreenLayoutObject->placeholder(); |
| 502 layoutObject->createPlaceholder(ComputedStyle::clone(placeholder->styleR
ef()), placeholder->frameRect()); | 502 layoutObject->createPlaceholder(ComputedStyle::clone(placeholder->styleR
ef()), placeholder->frameRect()); |
| 503 } | 503 } |
| 504 | 504 |
| 505 if (m_fullScreenLayoutObject) | 505 if (m_fullScreenLayoutObject) |
| 506 m_fullScreenLayoutObject->unwrapLayoutObject(); | 506 m_fullScreenLayoutObject->unwrapLayoutObject(); |
| 507 ASSERT(!m_fullScreenLayoutObject); | 507 DCHECK(!m_fullScreenLayoutObject); |
| 508 | 508 |
| 509 m_fullScreenLayoutObject = layoutObject; | 509 m_fullScreenLayoutObject = layoutObject; |
| 510 } | 510 } |
| 511 | 511 |
| 512 void Fullscreen::fullScreenLayoutObjectDestroyed() | 512 void Fullscreen::fullScreenLayoutObjectDestroyed() |
| 513 { | 513 { |
| 514 m_fullScreenLayoutObject = nullptr; | 514 m_fullScreenLayoutObject = nullptr; |
| 515 } | 515 } |
| 516 | 516 |
| 517 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) | 517 void Fullscreen::enqueueChangeEvent(Document& document, RequestType requestType) |
| 518 { | 518 { |
| 519 RawPtr<Event> event; | 519 RawPtr<Event> event; |
| 520 if (requestType == UnprefixedRequest) { | 520 if (requestType == UnprefixedRequest) { |
| 521 event = createEvent(EventTypeNames::fullscreenchange, document); | 521 event = createEvent(EventTypeNames::fullscreenchange, document); |
| 522 } else { | 522 } else { |
| 523 ASSERT(document.hasFullscreenSupplement()); | 523 DCHECK(document.hasFullscreenSupplement()); |
| 524 Fullscreen& fullscreen = from(document); | 524 Fullscreen& fullscreen = from(document); |
| 525 EventTarget* target = fullscreen.fullscreenElement(); | 525 EventTarget* target = fullscreen.fullscreenElement(); |
| 526 if (!target) | 526 if (!target) |
| 527 target = fullscreen.webkitCurrentFullScreenElement(); | 527 target = fullscreen.webkitCurrentFullScreenElement(); |
| 528 if (!target) | 528 if (!target) |
| 529 target = &document; | 529 target = &document; |
| 530 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); | 530 event = createEvent(EventTypeNames::webkitfullscreenchange, *target); |
| 531 } | 531 } |
| 532 m_eventQueue.append(event); | 532 m_eventQueue.append(event); |
| 533 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr
eenForElement. | 533 // NOTE: The timer is started in didEnterFullScreenForElement/didExitFullScr
eenForElement. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 552 RawPtr<Document> protectDocument(document()); | 552 RawPtr<Document> protectDocument(document()); |
| 553 HeapDeque<Member<Event>> eventQueue; | 553 HeapDeque<Member<Event>> eventQueue; |
| 554 m_eventQueue.swap(eventQueue); | 554 m_eventQueue.swap(eventQueue); |
| 555 | 555 |
| 556 while (!eventQueue.isEmpty()) { | 556 while (!eventQueue.isEmpty()) { |
| 557 RawPtr<Event> event = eventQueue.takeFirst(); | 557 RawPtr<Event> event = eventQueue.takeFirst(); |
| 558 Node* target = event->target()->toNode(); | 558 Node* target = event->target()->toNode(); |
| 559 | 559 |
| 560 // If the element was removed from our tree, also message the documentEl
ement. | 560 // If the element was removed from our tree, also message the documentEl
ement. |
| 561 if (!target->inShadowIncludingDocument() && document()->documentElement(
)) { | 561 if (!target->inShadowIncludingDocument() && document()->documentElement(
)) { |
| 562 ASSERT(isPrefixed(event->type())); | 562 DCHECK(isPrefixed(event->type())); |
| 563 eventQueue.append(createEvent(event->type(), *document()->documentEl
ement())); | 563 eventQueue.append(createEvent(event->type(), *document()->documentEl
ement())); |
| 564 } | 564 } |
| 565 | 565 |
| 566 target->dispatchEvent(event); | 566 target->dispatchEvent(event); |
| 567 } | 567 } |
| 568 } | 568 } |
| 569 | 569 |
| 570 void Fullscreen::elementRemoved(Element& oldNode) | 570 void Fullscreen::elementRemoved(Element& oldNode) |
| 571 { | 571 { |
| 572 // Whenever the removing steps run with an |oldNode| and |oldNode| is in its
node document's | 572 // Whenever the removing steps run with an |oldNode| and |oldNode| is in its
node document's |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 DEFINE_TRACE(Fullscreen) | 611 DEFINE_TRACE(Fullscreen) |
| 612 { | 612 { |
| 613 visitor->trace(m_fullScreenElement); | 613 visitor->trace(m_fullScreenElement); |
| 614 visitor->trace(m_fullScreenElementStack); | 614 visitor->trace(m_fullScreenElementStack); |
| 615 visitor->trace(m_eventQueue); | 615 visitor->trace(m_eventQueue); |
| 616 Supplement<Document>::trace(visitor); | 616 Supplement<Document>::trace(visitor); |
| 617 DocumentLifecycleObserver::trace(visitor); | 617 DocumentLifecycleObserver::trace(visitor); |
| 618 } | 618 } |
| 619 | 619 |
| 620 } // namespace blink | 620 } // namespace blink |
| OLD | NEW |