Title: [154572] trunk/Source/WebCore
Revision
154572
Author
[email protected]
Date
2013-08-25 02:51:42 -0700 (Sun, 25 Aug 2013)

Log Message

No need for dispatchVisibilityStateChangeEvent function
https://bugs.webkit.org/show_bug.cgi?id=120261

Reviewed by Andreas Kling.

* dom/Document.cpp: Removed dispatchVisibilityStateChangeEvent.
* dom/Document.h: Ditto.
* page/Frame.cpp: Ditto.
* page/Frame.h: Ditto.

* page/Page.cpp:
(WebCore::Page::setVisibilityState): Put all the logic for dispatching the
visibility state change event. Nothing here requires any special information
about the internals of Frame or Document.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154571 => 154572)


--- trunk/Source/WebCore/ChangeLog	2013-08-25 09:33:29 UTC (rev 154571)
+++ trunk/Source/WebCore/ChangeLog	2013-08-25 09:51:42 UTC (rev 154572)
@@ -1,5 +1,22 @@
 2013-08-25  Darin Adler  <[email protected]>
 
+        No need for dispatchVisibilityStateChangeEvent function
+        https://bugs.webkit.org/show_bug.cgi?id=120261
+
+        Reviewed by Andreas Kling.
+
+        * dom/Document.cpp: Removed dispatchVisibilityStateChangeEvent.
+        * dom/Document.h: Ditto.
+        * page/Frame.cpp: Ditto.
+        * page/Frame.h: Ditto.
+
+        * page/Page.cpp:
+        (WebCore::Page::setVisibilityState): Put all the logic for dispatching the
+        visibility state change event. Nothing here requires any special information
+        about the internals of Frame or Document.
+
+2013-08-25  Darin Adler  <[email protected]>
+
         No need for clearTimers function in Frame
         https://bugs.webkit.org/show_bug.cgi?id=120265
 

Modified: trunk/Source/WebCore/dom/Document.cpp (154571 => 154572)


--- trunk/Source/WebCore/dom/Document.cpp	2013-08-25 09:33:29 UTC (rev 154571)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-08-25 09:51:42 UTC (rev 154572)
@@ -1591,11 +1591,6 @@
 {
     return pageVisibilityState() != PageVisibilityStateVisible;
 }
-
-void Document::dispatchVisibilityStateChangeEvent()
-{
-    dispatchEvent(Event::create(eventNames().visibilitychangeEvent, false, false));
-}
 #endif
 
 #if ENABLE(CSP_NEXT)

Modified: trunk/Source/WebCore/dom/Document.h (154571 => 154572)


--- trunk/Source/WebCore/dom/Document.h	2013-08-25 09:33:29 UTC (rev 154571)
+++ trunk/Source/WebCore/dom/Document.h	2013-08-25 09:51:42 UTC (rev 154572)
@@ -406,7 +406,6 @@
 #if ENABLE(PAGE_VISIBILITY_API)
     String visibilityState() const;
     bool hidden() const;
-    void dispatchVisibilityStateChangeEvent();
 #endif
 
 #if ENABLE(CSP_NEXT)

Modified: trunk/Source/WebCore/page/Frame.cpp (154571 => 154572)


--- trunk/Source/WebCore/page/Frame.cpp	2013-08-25 09:33:29 UTC (rev 154571)
+++ trunk/Source/WebCore/page/Frame.cpp	2013-08-25 09:51:42 UTC (rev 154572)
@@ -614,21 +614,6 @@
     return &toFrameView(widget)->frame();
 }
 
-#if ENABLE(PAGE_VISIBILITY_API)
-void Frame::dispatchVisibilityStateChangeEvent()
-{
-    if (m_doc)
-        m_doc->dispatchVisibilityStateChangeEvent();
-
-    Vector<RefPtr<Frame> > childFrames;
-    for (Frame* child = tree().firstChild(); child; child = child->tree().nextSibling())
-        childFrames.append(child);
-
-    for (size_t i = 0; i < childFrames.size(); ++i)
-        childFrames[i]->dispatchVisibilityStateChangeEvent();
-}
-#endif
-
 void Frame::willDetachPage()
 {
     if (Frame* parent = tree().parent())

Modified: trunk/Source/WebCore/page/Frame.h (154571 => 154572)


--- trunk/Source/WebCore/page/Frame.h	2013-08-25 09:33:29 UTC (rev 154571)
+++ trunk/Source/WebCore/page/Frame.h	2013-08-25 09:51:42 UTC (rev 154572)
@@ -124,10 +124,6 @@
         RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame.
         RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
 
-#if ENABLE(PAGE_VISIBILITY_API)
-        void dispatchVisibilityStateChangeEvent();
-#endif
-
     // ======== All public functions below this point are candidates to move out of Frame into another class. ========
 
         void injectUserScripts(UserScriptInjectionTime);

Modified: trunk/Source/WebCore/page/Page.cpp (154571 => 154572)


--- trunk/Source/WebCore/page/Page.cpp	2013-08-25 09:33:29 UTC (rev 154571)
+++ trunk/Source/WebCore/page/Page.cpp	2013-08-25 09:51:42 UTC (rev 154572)
@@ -1275,15 +1275,23 @@
 #if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitialState)
 {
-    // FIXME: the visibility state needs to be stored on the top-level document
+#if !ENABLE(PAGE_VISIBILITY_API)
+    UNUSED_PARAM(isInitialState);
+#else
+    // FIXME: The visibility state should be stored on the top-level document.
     // https://bugs.webkit.org/show_bug.cgi?id=116769
-#if ENABLE(PAGE_VISIBILITY_API)
+
     if (m_visibilityState == visibilityState)
         return;
     m_visibilityState = visibilityState;
 
-    if (!isInitialState && m_mainFrame)
-        m_mainFrame->dispatchVisibilityStateChangeEvent();
+    if (!isInitialState) {
+        Vector<RefPtr<Document>> documents;
+        for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
+            documents.append(frame->document());
+        for (size_t i = 0, size = documents.size(); i < size; ++i)
+            documents[i]->dispatchEvent(Event::create(eventNames().visibilitychangeEvent, false, false));
+    }
 #endif
 
     if (visibilityState == WebCore::PageVisibilityStateHidden) {
@@ -1296,9 +1304,6 @@
         if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
             mainFrame()->animation().resumeAnimations();
     }
-#if !ENABLE(PAGE_VISIBILITY_API)
-    UNUSED_PARAM(isInitialState);
-#endif
 }
 #endif // ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to