2011-05-21  Jeremy Noble  <jer.noble@apple.com>

        Reviewed by Eric Carlson.

        WebKit2: fix failing fullscreen/full-screen-remove* tests.
        https://bugs.webkit.org/show_bug.cgi?id=61027

        * platform/mac-wk2/Skipped: Unskip most fullscreen/ tests.
2011-05-21  Jeremy Noble  <jer.noble@apple.com>

        Reviewed by Eric Carlson.

        WebKit2: fix failing fullscreen/full-screen-remove* tests.
        https://bugs.webkit.org/show_bug.cgi?id=61027

        * dom/Document.cpp:
        (WebCore::Document::fullScreenChangeDelayTimerFired): dispatchEvent can be
            synchronous, so make sure to check whether the current element is
            in the DOM before dispatching.
2011-05-21  Jeremy Noble  <jer.noble@apple.com>

        Reviewed by Eric Carlson.

        WebKit2: fix failing fullscreen/full-screen-remove* tests.
        https://bugs.webkit.org/show_bug.cgi?id=61027

        * WebProcess/InjectedBundle/InjectedBundlePageFullScreenClient.cpp:
        (WebKit::InjectedBundlePageFullScreenClient::exitFullScreenForElement): Call the
            exit functions (was calling the enter functions).

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87022 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 8b73ceb..3d2b6dd 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -4986,12 +4986,12 @@
         RefPtr<Element> element = m_fullScreenChangeEventTargetQueue.takeFirst();
         if (!element)
             element = documentElement();
-        
-        element->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
 
         // If the element was removed from our tree, also message the documentElement.
         if (!contains(element.get()))
             m_fullScreenChangeEventTargetQueue.append(documentElement());
+        
+        element->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
     }
 }