Chromium Code Reviews| Index: Source/core/dom/FullscreenElementStack.cpp |
| diff --git a/Source/core/dom/FullscreenElementStack.cpp b/Source/core/dom/FullscreenElementStack.cpp |
| index 85f472d75043a36ad16d6f6c98ad334cfa966a02..ea919c056e03ba2b9db46580899adc696cec359a 100644 |
| --- a/Source/core/dom/FullscreenElementStack.cpp |
| +++ b/Source/core/dom/FullscreenElementStack.cpp |
| @@ -57,7 +57,10 @@ static bool fullscreenIsAllowedForAllOwners(const Document& document) |
| static PassRefPtrWillBeRawPtr<Event> createEvent(const AtomicString& type, EventTarget& target) |
| { |
| - RefPtrWillBeRawPtr<Event> event = Event::createBubble(type); |
| + EventInit initializer; |
| + // The prefixed events bubble, the unprefixed ones do not. |
|
falken
2014/07/17 03:45:02
I'm probably missing something... why the behavior
|
| + initializer.bubbles = type == EventTypeNames::webkitfullscreenchange || type == EventTypeNames::webkitfullscreenerror; |
| + RefPtrWillBeRawPtr<Event> event = Event::create(type, initializer); |
| event->setTarget(&target); |
| return event; |
| } |
| @@ -235,8 +238,8 @@ void FullscreenElementStack::requestFullScreenForElement(Element& element, Reque |
| // 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); |
| - enqueueChangeEvent(*currentDoc); |
| + from(*currentDoc).pushFullscreenElementStack(element, requestType); |
| + enqueueChangeEvent(*currentDoc, requestType); |
| continue; |
| } |
| @@ -247,8 +250,8 @@ void FullscreenElementStack::requestFullScreenForElement(Element& element, Reque |
| // ...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()); |
| - enqueueChangeEvent(*currentDoc); |
| + from(*currentDoc).pushFullscreenElementStack(*followingDoc->ownerElement(), requestType); |
| + enqueueChangeEvent(*currentDoc, requestType); |
| continue; |
| } |
| @@ -264,7 +267,7 @@ void FullscreenElementStack::requestFullScreenForElement(Element& element, Reque |
| return; |
| } while (0); |
| - enqueueErrorEvent(element); |
| + enqueueErrorEvent(element, requestType); |
| } |
| void FullscreenElementStack::fullyExitFullscreen() |
| @@ -276,9 +279,9 @@ void FullscreenElementStack::fullyExitFullscreen() |
| // To achieve that aim, remove all the elements from the top document's stack except for the first before |
| // calling exitFullscreen(): |
| - WillBeHeapVector<RefPtrWillBeMember<Element> > replacementFullscreenElementStack; |
| - replacementFullscreenElementStack.append(fullscreenElementFrom(document()->topDocument())); |
| + WillBeHeapVector<std::pair<RefPtrWillBeMember<Element>, RequestType> > replacementFullscreenElementStack; |
| FullscreenElementStack& topFullscreenElementStack = from(document()->topDocument()); |
| + replacementFullscreenElementStack.append(topFullscreenElementStack.m_fullScreenElementStack.last()); |
| topFullscreenElementStack.m_fullScreenElementStack.swap(replacementFullscreenElementStack); |
| topFullscreenElementStack.exitFullscreen(); |
| } |
| @@ -312,13 +315,16 @@ void FullscreenElementStack::exitFullscreen() |
| // 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); |
| + 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(); |
| @@ -330,7 +336,7 @@ void FullscreenElementStack::exitFullscreen() |
| // 2. Queue a task to fire an event named fullscreenchange with its bubbles attribute set to true |
| // on doc. |
| - enqueueChangeEvent(*currentDoc); |
| + 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. |
| @@ -482,23 +488,33 @@ void FullscreenElementStack::fullScreenRendererDestroyed() |
| m_fullScreenRenderer = 0; |
| } |
| -void FullscreenElementStack::enqueueChangeEvent(Document& document) |
| -{ |
| - ASSERT(document.hasFullscreenElementStack()); |
| - FullscreenElementStack& fullscreen = from(document); |
| - |
| - EventTarget* target = fullscreen.fullscreenElement(); |
| - if (!target) |
| - target = fullscreen.webkitCurrentFullScreenElement(); |
| - if (!target) |
| - target = &document; |
| - m_eventQueue.append(createEvent(EventTypeNames::webkitfullscreenchange, *target)); |
| +void FullscreenElementStack::enqueueChangeEvent(Document& document, RequestType requestType) |
| +{ |
| + RefPtrWillBeRawPtr<Event> event; |
| + if (requestType == UnprefixedRequest) { |
| + event = createEvent(EventTypeNames::fullscreenchange, document); |
|
falken
2014/07/17 03:45:02
Why is the target different between unprefixed and
|
| + } else { |
| + ASSERT(document.hasFullscreenElementStack()); |
| + FullscreenElementStack& 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 FullscreenElementStack::enqueueErrorEvent(Element& element) |
| +void FullscreenElementStack::enqueueErrorEvent(Element& element, RequestType requestType) |
| { |
| - m_eventQueue.append(createEvent(EventTypeNames::webkitfullscreenerror, element)); |
| + 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); |
| } |
| @@ -516,8 +532,10 @@ void FullscreenElementStack::eventQueueTimerFired(Timer<FullscreenElementStack>* |
| Node* target = event->target()->toNode(); |
| // If the element was removed from our tree, also message the documentElement. |
| - if (!target->inDocument() && document()->documentElement()) |
| + if (!target->inDocument() && document()->documentElement()) { |
| + ASSERT(event->type() == EventTypeNames::webkitfullscreenchange || event->type() == EventTypeNames::webkitfullscreenerror); |
| eventQueue.append(createEvent(event->type(), *document()->documentElement())); |
| + } |
| target->dispatchEvent(event); |
| } |
| @@ -561,9 +579,9 @@ void FullscreenElementStack::popFullscreenElementStack() |
| m_fullScreenElementStack.removeLast(); |
| } |
| -void FullscreenElementStack::pushFullscreenElementStack(Element& element) |
| +void FullscreenElementStack::pushFullscreenElementStack(Element& element, RequestType requestType) |
| { |
| - m_fullScreenElementStack.append(&element); |
| + m_fullScreenElementStack.append(std::make_pair(&element, requestType)); |
| } |
| void FullscreenElementStack::trace(Visitor* visitor) |