Commit e8a038c2 authored by alexmos's avatar alexmos Committed by Commit bot

Clean up some OOPIF-related naming and comments in Fullscreen.

m_forCrossProcessAncestor was intended to mean that fullscreen was
entered for an iframe container which is an ancestor of the actual
fullscreen element, which also mirrors the
:-webkit-full-screen-ancestor style that the container will gain.  But
on the flipside, this naming can also be confusing: if an ancestor of
a cross-process iframe goes fullscreen, that iframe doesn't need to
know about this at all, and instead it only needs to know when an
element in a descendant frame goes fullscreen.  It might make more
sense to name this flag to reflect where the actual fullscreen element
is, rather than how m_fullscreenElement relates to it, so this CL
renames the flag to m_forCrossProcessDescendant and updates comments.

BUG=550497

Review-Url: https://codereview.chromium.org/2147803002
Cr-Commit-Position: refs/heads/master@{#405287}
parent 627da0d7
......@@ -198,7 +198,7 @@ Fullscreen::Fullscreen(Document& document)
: ContextLifecycleObserver(&document)
, m_fullScreenLayoutObject(nullptr)
, m_eventQueueTimer(this, &Fullscreen::eventQueueTimerFired)
, m_forCrossProcessAncestor(false)
, m_forCrossProcessDescendant(false)
{
document.setHasFullscreenSupplement();
}
......@@ -224,11 +224,11 @@ void Fullscreen::contextDestroyed()
}
void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bool forCrossProcessAncestor)
void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bool forCrossProcessDescendant)
{
// Use counters only need to be incremented in the process of the actual
// fullscreen element.
if (!forCrossProcessAncestor) {
if (!forCrossProcessDescendant) {
if (document()->isSecureContext()) {
UseCounter::count(document(), UseCounter::FullscreenSecureOrigin);
} else {
......@@ -259,10 +259,10 @@ void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo
// - 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 |forCrossProcessAncestor| is true, requestFullscreen was already
// called on an element in another process, and getting here means that
// it already passed the user gesture check.
if (!UserGestureIndicator::utilizeUserGesture() && !forCrossProcessAncestor) {
// If |forCrossProcessDescendant| is true, requestFullscreen
// was already called on a descendant element in another process, and
// getting here means that it already passed the user gesture check.
if (!UserGestureIndicator::utilizeUserGesture() && !forCrossProcessDescendant) {
String message = ExceptionMessages::failedToExecute("requestFullScreen",
"Element", "API can only be initiated by a user gesture.");
document()->addConsoleMessage(
......@@ -331,7 +331,7 @@ void Fullscreen::requestFullscreen(Element& element, RequestType requestType, bo
// 4. Otherwise, do nothing for this document. It stays the same.
} while (++current != docs.end());
m_forCrossProcessAncestor = forCrossProcessAncestor;
m_forCrossProcessDescendant = forCrossProcessDescendant;
// 5. Return, and run the remaining steps asynchronously.
// 6. Optionally, perform some animation.
......@@ -505,13 +505,18 @@ void Fullscreen::didEnterFullscreenForElement(Element* element)
m_savedPlaceholderComputedStyle = ComputedStyle::clone(layoutObject->styleRef());
}
// TODO(alexmos): When |m_forCrossProcessAncestor| is true, some of
// TODO(alexmos): When |m_forCrossProcessDescendant| is true, some of
// this layout work has already been done in another process, so it should
// not be necessary to repeat it here.
if (m_fullScreenElement != document()->documentElement())
LayoutFullScreen::wrapLayoutObject(layoutObject, layoutObject ? layoutObject->parent() : 0, document());
if (m_forCrossProcessAncestor) {
// When |m_forCrossProcessDescendant| is true, m_fullScreenElement
// corresponds to the HTMLFrameOwnerElement for the out-of-process iframe
// that contains the actual fullscreen element. Hence, it must also set
// the ContainsFullScreenElement flag (so that it gains the
// -webkit-full-screen-ancestor style).
if (m_forCrossProcessDescendant) {
DCHECK(m_fullScreenElement->isFrameOwnerElement());
DCHECK(toHTMLFrameOwnerElement(m_fullScreenElement)->contentFrame()->isRemoteFrame());
m_fullScreenElement->setContainsFullScreenElement(true);
......@@ -543,7 +548,7 @@ void Fullscreen::didExitFullscreen()
m_fullScreenElement->willStopBeingFullscreenElement();
if (m_forCrossProcessAncestor)
if (m_forCrossProcessDescendant)
m_fullScreenElement->setContainsFullScreenElement(false);
m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(false);
......@@ -567,7 +572,7 @@ void Fullscreen::didExitFullscreen()
DCHECK(exitingDocument);
from(*exitingDocument).m_eventQueueTimer.startOneShot(0, BLINK_FROM_HERE);
m_forCrossProcessAncestor = false;
m_forCrossProcessDescendant = false;
}
void Fullscreen::setFullScreenLayoutObject(LayoutFullScreen* layoutObject)
......
......@@ -67,9 +67,10 @@ public:
PrefixedRequest,
};
// |forCrossProcessAncestor| is used in OOPIF scenarios and is set to true
// when fullscreen is requested for an out-of-process descendant element.
void requestFullscreen(Element&, RequestType, bool forCrossProcessAncestor = false);
// |forCrossProcessDescendant| is used in OOPIF scenarios and is set to
// true when fullscreen is requested for an out-of-process descendant
// element.
void requestFullscreen(Element&, RequestType, bool forCrossProcessDescendant = false);
static void fullyExitFullscreen(Document&);
void exitFullscreen();
......@@ -77,12 +78,6 @@ public:
static bool fullscreenEnabled(Document&);
Element* fullscreenElement() const { return !m_fullScreenElementStack.isEmpty() ? m_fullScreenElementStack.last().first.get() : 0; }
// |isAncestorOfFullscreenElement| is used in OOPIF scenarios and is set to
// true when these functions are called to enter/exit fullscreen for an
// out-of-process descendant element. In this case, we enter fullscreen
// for its (local) iframe container and make sure to also set the
// ContainsFullScreenElement flag on it (so that it gains the
// -webkit-full-screen-ancestor style).
void didEnterFullscreenForElement(Element*);
void didExitFullscreen();
......@@ -93,8 +88,9 @@ public:
void elementRemoved(Element&);
// Returns true if the current fullscreen element stack corresponds to a
// container for an actual fullscreen element in an out-of-process iframe.
bool forCrossProcessAncestor() { return m_forCrossProcessAncestor; }
// container for an actual fullscreen element in a descendant
// out-of-process iframe.
bool forCrossProcessDescendant() { return m_forCrossProcessDescendant; }
// Mozilla API
Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement.get(); }
......@@ -136,7 +132,7 @@ private:
// change if https://crbug.com/161068 is fixed so that cross-process
// postMessage can carry user gestures. If that happens, this should be
// moved to be part of |m_fullScreenElementStack|.
bool m_forCrossProcessAncestor;
bool m_forCrossProcessDescendant;
};
inline bool Fullscreen::isActiveFullScreenElement(const Element& element)
......
......@@ -156,7 +156,7 @@ void FullscreenController::enterFullScreenForElement(Element* element)
// We need to transition to fullscreen mode.
WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(element->document().frame());
if (frame && frame->client()) {
if (!Fullscreen::from(element->document()).forCrossProcessAncestor())
if (!Fullscreen::from(element->document()).forCrossProcessDescendant())
frame->client()->enterFullscreen();
m_provisionalFullScreenElement = element;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment