Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: third_party/WebKit/Source/core/dom/Fullscreen.cpp

Issue 2147803002: Clean up some OOPIF-related naming and comments in Fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve conflicts Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 bool Fullscreen::isFullScreen(Document& document) 192 bool Fullscreen::isFullScreen(Document& document)
193 { 193 {
194 return currentFullScreenElementFrom(document); 194 return currentFullScreenElementFrom(document);
195 } 195 }
196 196
197 Fullscreen::Fullscreen(Document& document) 197 Fullscreen::Fullscreen(Document& document)
198 : ContextLifecycleObserver(&document) 198 : ContextLifecycleObserver(&document)
199 , m_fullScreenLayoutObject(nullptr) 199 , m_fullScreenLayoutObject(nullptr)
200 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired) 200 , m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired)
201 , m_forCrossProcessAncestor(false) 201 , m_forCrossProcessDescendant(false)
202 { 202 {
203 document.setHasFullscreenSupplement(); 203 document.setHasFullscreenSupplement();
204 } 204 }
205 205
206 Fullscreen::~Fullscreen() 206 Fullscreen::~Fullscreen()
207 { 207 {
208 } 208 }
209 209
210 inline Document* Fullscreen::document() 210 inline Document* Fullscreen::document()
211 { 211 {
212 return toDocument(lifecycleContext()); 212 return toDocument(lifecycleContext());
213 } 213 }
214 214
215 void Fullscreen::contextDestroyed() 215 void Fullscreen::contextDestroyed()
216 { 216 {
217 m_eventQueue.clear(); 217 m_eventQueue.clear();
218 218
219 if (m_fullScreenLayoutObject) 219 if (m_fullScreenLayoutObject)
220 m_fullScreenLayoutObject->destroy(); 220 m_fullScreenLayoutObject->destroy();
221 221
222 m_fullScreenElement = nullptr; 222 m_fullScreenElement = nullptr;
223 m_fullScreenElementStack.clear(); 223 m_fullScreenElementStack.clear();
224 224
225 } 225 }
226 226
227 void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo ol forCrossProcessAncestor) 227 void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo ol forCrossProcessDescendant)
228 { 228 {
229 // Use counters only need to be incremented in the process of the actual 229 // Use counters only need to be incremented in the process of the actual
230 // fullscreen element. 230 // fullscreen element.
231 if (!forCrossProcessAncestor) { 231 if (!forCrossProcessDescendant) {
232 if (document()->isSecureContext()) { 232 if (document()->isSecureContext()) {
233 UseCounter::count(document(), UseCounter::FullscreenSecureOrigin); 233 UseCounter::count(document(), UseCounter::FullscreenSecureOrigin);
234 } else { 234 } else {
235 UseCounter::count(document(), UseCounter::FullscreenInsecureOrigin); 235 UseCounter::count(document(), UseCounter::FullscreenInsecureOrigin);
236 HostsUsingFeatures::countAnyWorld(*document(), HostsUsingFeatures::F eature::FullscreenInsecureHost); 236 HostsUsingFeatures::countAnyWorld(*document(), HostsUsingFeatures::F eature::FullscreenInsecureHost);
237 } 237 }
238 } 238 }
239 239
240 // Ignore this request if the document is not in a live frame. 240 // Ignore this request if the document is not in a live frame.
241 if (!document()->isActive()) 241 if (!document()->isActive())
(...skipping 10 matching lines...) Expand all
252 252
253 // The fullscreen element ready check returns false. 253 // The fullscreen element ready check returns false.
254 if (!fullscreenElementReady(element)) 254 if (!fullscreenElementReady(element))
255 break; 255 break;
256 256
257 // This algorithm is not allowed to show a pop-up: 257 // This algorithm is not allowed to show a pop-up:
258 // An algorithm is allowed to show a pop-up if, in the task in which t he algorithm is running, either: 258 // An algorithm is allowed to show a pop-up if, in the task in which t he algorithm is running, either:
259 // - an activation behavior is currently being processed whose click e vent was trusted, or 259 // - an activation behavior is currently being processed whose click e vent was trusted, or
260 // - the event listener for a trusted click event is being handled. 260 // - the event listener for a trusted click event is being handled.
261 // 261 //
262 // If |forCrossProcessAncestor| is true, requestFullscreen was already 262 // If |forCrossProcessDescendant| is true, requestFullscreen
263 // called on an element in another process, and getting here means that 263 // was already called on a descendant element in another process, and
264 // it already passed the user gesture check. 264 // getting here means that it already passed the user gesture check.
265 if (!UserGestureIndicator::utilizeUserGesture() && !forCrossProcessAnces tor) { 265 if (!UserGestureIndicator::utilizeUserGesture() && !forCrossProcessDesce ndant) {
266 String message = ExceptionMessages::failedToExecute("requestFullScre en", 266 String message = ExceptionMessages::failedToExecute("requestFullScre en",
267 "Element", "API can only be initiated by a user gesture."); 267 "Element", "API can only be initiated by a user gesture.");
268 document()->addConsoleMessage( 268 document()->addConsoleMessage(
269 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, mes sage)); 269 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, mes sage));
270 break; 270 break;
271 } 271 }
272 272
273 // Fullscreen is not supported. 273 // Fullscreen is not supported.
274 if (!fullscreenIsSupported(element.document())) 274 if (!fullscreenIsSupported(element.document()))
275 break; 275 break;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // stack, and queue a task to fire an event named fullscreenchan ge with its bubbles attribute 324 // stack, and queue a task to fire an event named fullscreenchan ge with its bubbles attribute
325 // set to true on document. 325 // set to true on document.
326 from(*currentDoc).pushFullscreenElementStack(*followingOwner, re questType); 326 from(*currentDoc).pushFullscreenElementStack(*followingOwner, re questType);
327 enqueueChangeEvent(*currentDoc, requestType); 327 enqueueChangeEvent(*currentDoc, requestType);
328 continue; 328 continue;
329 } 329 }
330 330
331 // 4. Otherwise, do nothing for this document. It stays the same. 331 // 4. Otherwise, do nothing for this document. It stays the same.
332 } while (++current != docs.end()); 332 } while (++current != docs.end());
333 333
334 m_forCrossProcessAncestor = forCrossProcessAncestor; 334 m_forCrossProcessDescendant = forCrossProcessDescendant;
335 335
336 // 5. Return, and run the remaining steps asynchronously. 336 // 5. Return, and run the remaining steps asynchronously.
337 // 6. Optionally, perform some animation. 337 // 6. Optionally, perform some animation.
338 document()->frameHost()->chromeClient().enterFullScreenForElement(&eleme nt); 338 document()->frameHost()->chromeClient().enterFullScreenForElement(&eleme nt);
339 339
340 // 7. Optionally, display a message indicating how the user can exit dis playing the context object fullscreen. 340 // 7. Optionally, display a message indicating how the user can exit dis playing the context object fullscreen.
341 return; 341 return;
342 } while (false); 342 } while (false);
343 343
344 enqueueErrorEvent(element, requestType); 344 enqueueErrorEvent(element, requestType);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // when the element is removed from the normal flow. Only do this for a Layo utBox, as only 498 // when the element is removed from the normal flow. Only do this for a Layo utBox, as only
499 // a box will have a frameRect. The placeholder will be created in setFullSc reenLayoutObject() 499 // a box will have a frameRect. The placeholder will be created in setFullSc reenLayoutObject()
500 // during layout. 500 // during layout.
501 LayoutObject* layoutObject = m_fullScreenElement->layoutObject(); 501 LayoutObject* layoutObject = m_fullScreenElement->layoutObject();
502 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox(); 502 bool shouldCreatePlaceholder = layoutObject && layoutObject->isBox();
503 if (shouldCreatePlaceholder) { 503 if (shouldCreatePlaceholder) {
504 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect(); 504 m_savedPlaceholderFrameRect = toLayoutBox(layoutObject)->frameRect();
505 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty leRef()); 505 m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->sty leRef());
506 } 506 }
507 507
508 // TODO(alexmos): When |m_forCrossProcessAncestor| is true, some of 508 // TODO(alexmos): When |m_forCrossProcessDescendant| is true, some of
509 // this layout work has already been done in another process, so it should 509 // this layout work has already been done in another process, so it should
510 // not be necessary to repeat it here. 510 // not be necessary to repeat it here.
511 if (m_fullScreenElement != document()->documentElement()) 511 if (m_fullScreenElement != document()->documentElement())
512 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb ject->parent() : 0, document()); 512 LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutOb ject->parent() : 0, document());
513 513
514 if (m_forCrossProcessAncestor) { 514 // When |m_forCrossProcessDescendant| is true, m_fullScreenElement
515 // corresponds to the HTMLFrameOwnerElement for the out-of-process iframe
516 // that contains the actual fullscreen element. Hence, it must also set
517 // the ContainsFullScreenElement flag (so that it gains the
518 // -webkit-full-screen-ancestor style).
519 if (m_forCrossProcessDescendant) {
515 DCHECK(m_fullScreenElement->isFrameOwnerElement()); 520 DCHECK(m_fullScreenElement->isFrameOwnerElement());
516 DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isR emoteFrame()); 521 DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isR emoteFrame());
517 m_fullScreenElement->setContainsFullScreenElement(true); 522 m_fullScreenElement->setContainsFullScreenElement(true);
518 } 523 }
519 524
520 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true); 525 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(true);
521 526
522 document()->styleEngine().ensureFullscreenUAStyle(); 527 document()->styleEngine().ensureFullscreenUAStyle();
523 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); 528 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen);
524 529
(...skipping 11 matching lines...) Expand all
536 void Fullscreen::didExitFullscreen() 541 void Fullscreen::didExitFullscreen()
537 { 542 {
538 if (!m_fullScreenElement) 543 if (!m_fullScreenElement)
539 return; 544 return;
540 545
541 if (!document()->isActive()) 546 if (!document()->isActive())
542 return; 547 return;
543 548
544 m_fullScreenElement->willStopBeingFullscreenElement(); 549 m_fullScreenElement->willStopBeingFullscreenElement();
545 550
546 if (m_forCrossProcessAncestor) 551 if (m_forCrossProcessDescendant)
547 m_fullScreenElement->setContainsFullScreenElement(false); 552 m_fullScreenElement->setContainsFullScreenElement(false);
548 553
549 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false); 554 m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBou ndaries(false);
550 555
551 if (m_fullScreenLayoutObject) 556 if (m_fullScreenLayoutObject)
552 LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject(); 557 LayoutFullScreenItem(m_fullScreenLayoutObject).unwrapLayoutObject();
553 558
554 document()->styleEngine().ensureFullscreenUAStyle(); 559 document()->styleEngine().ensureFullscreenUAStyle();
555 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen); 560 m_fullScreenElement->pseudoStateChanged(CSSSelector::PseudoFullScreen);
556 m_fullScreenElement = nullptr; 561 m_fullScreenElement = nullptr;
557 562
558 if (document()->frame()) 563 if (document()->frame())
559 document()->frame()->eventHandler().scheduleHoverStateUpdate(); 564 document()->frame()->eventHandler().scheduleHoverStateUpdate();
560 565
561 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means 566 // When fullyExitFullscreen is called, we call exitFullscreen on the topDocu ment(). That means
562 // that the events will be queued there. So if we have no events here, start the timer on the 567 // that the events will be queued there. So if we have no events here, start the timer on the
563 // exiting document. 568 // exiting document.
564 Document* exitingDocument = document(); 569 Document* exitingDocument = document();
565 if (m_eventQueue.isEmpty()) 570 if (m_eventQueue.isEmpty())
566 exitingDocument = &topmostLocalAncestor(*document()); 571 exitingDocument = &topmostLocalAncestor(*document());
567 DCHECK(exitingDocument); 572 DCHECK(exitingDocument);
568 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE); 573 from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE);
569 574
570 m_forCrossProcessAncestor = false; 575 m_forCrossProcessDescendant = false;
571 } 576 }
572 577
573 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject) 578 void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject)
574 { 579 {
575 if (layoutObject == m_fullScreenLayoutObject) 580 if (layoutObject == m_fullScreenLayoutObject)
576 return; 581 return;
577 582
578 if (layoutObject && m_savedPlaceholderComputedStyle) { 583 if (layoutObject && m_savedPlaceholderComputedStyle) {
579 layoutObject->createPlaceholder(m_savedPlaceholderComputedStyle.release( ), m_savedPlaceholderFrameRect); 584 layoutObject->createPlaceholder(m_savedPlaceholderComputedStyle.release( ), m_savedPlaceholderFrameRect);
580 } else if (layoutObject && m_fullScreenLayoutObject && m_fullScreenLayoutObj ect->placeholder()) { 585 } else if (layoutObject && m_fullScreenLayoutObject && m_fullScreenLayoutObj ect->placeholder()) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 DEFINE_TRACE(Fullscreen) 692 DEFINE_TRACE(Fullscreen)
688 { 693 {
689 visitor->trace(m_fullScreenElement); 694 visitor->trace(m_fullScreenElement);
690 visitor->trace(m_fullScreenElementStack); 695 visitor->trace(m_fullScreenElementStack);
691 visitor->trace(m_eventQueue); 696 visitor->trace(m_eventQueue);
692 Supplement<Document>::trace(visitor); 697 Supplement<Document>::trace(visitor);
693 ContextLifecycleObserver::trace(visitor); 698 ContextLifecycleObserver::trace(visitor);
694 } 699 }
695 700
696 } // namespace blink 701 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Fullscreen.h ('k') | third_party/WebKit/Source/web/FullscreenController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698