Title: [114782] trunk/Source
Revision
114782
Author
[email protected]
Date
2012-04-20 14:29:00 -0700 (Fri, 20 Apr 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=84490
PageGroupLoadDeferrer needs to take a ReasonForSuspension argument

Reviewed by Anders Carlsson.

Source/WebCore:

No new tests. (Refactor, no change in behavior)

- Make PageGroupLoadDeferrer take a ReasonForSuspension argument so it can pass it along.
* page/PageGroupLoadDeferrer.cpp:
(WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
* page/PageGroupLoadDeferrer.h:

- Change suspendScheduledTasks to take a ReasonForSuspension.
- As long as we're changing Document.h, add a m_suspendedScheduledTasks flag and some
  ASSERTs to catch what would be epically wrong behavior in the future.
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::suspendScheduledTasks):
(WebCore::Document::resumeScheduledTasks):
* dom/Document.h:

- Pass ActiveDOMObject::WillShowDialog along to all PageGroupLoadDeferrers, as it used
  to be the default behavior
* page/Chrome.cpp:
(WebCore::Chrome::runModal):
(WebCore::Chrome::runBeforeUnloadConfirmPanel):
(WebCore::Chrome::runJavaScriptAlert):
(WebCore::Chrome::runJavaScriptConfirm):
(WebCore::Chrome::runJavaScriptPrompt):
(WebCore::Chrome::shouldInterruptJavaScript):

Source/WebKit/blackberry:

* Api/WebPageGroupLoadDeferrer.cpp:
(BlackBerry::WebKit::WebPageGroupLoadDeferrer::WebPageGroupLoadDeferrer): Pass along ActiveDOMObject::WillShowDialog,
  which used to be the default

* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::ChromeClientBlackBerry::createWindow): Pass along ActiveDOMObject::WillShowDialog, which used to be the default.
(WebCore::ChromeClientBlackBerry::runOpenPanel): Ditto.

Source/WebKit/chromium:

* src/WebViewImpl.cpp:
(WebKit::WebView::willEnterModalLoop): Pass along ActiveDOMObject::WillShowDialog, which used
  to be the default.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114781 => 114782)


--- trunk/Source/WebCore/ChangeLog	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebCore/ChangeLog	2012-04-20 21:29:00 UTC (rev 114782)
@@ -1,3 +1,36 @@
+2012-04-20  Brady Eidson  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=84490
+        PageGroupLoadDeferrer needs to take a ReasonForSuspension argument
+
+        Reviewed by Anders Carlsson.
+
+        No new tests. (Refactor, no change in behavior)
+
+        - Make PageGroupLoadDeferrer take a ReasonForSuspension argument so it can pass it along.
+        * page/PageGroupLoadDeferrer.cpp:
+        (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
+        * page/PageGroupLoadDeferrer.h:
+
+        - Change suspendScheduledTasks to take a ReasonForSuspension.
+        - As long as we're changing Document.h, add a m_suspendedScheduledTasks flag and some
+          ASSERTs to catch what would be epically wrong behavior in the future.
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::suspendScheduledTasks):
+        (WebCore::Document::resumeScheduledTasks):
+        * dom/Document.h:
+
+        - Pass ActiveDOMObject::WillShowDialog along to all PageGroupLoadDeferrers, as it used
+          to be the default behavior
+        * page/Chrome.cpp:
+        (WebCore::Chrome::runModal):
+        (WebCore::Chrome::runBeforeUnloadConfirmPanel):
+        (WebCore::Chrome::runJavaScriptAlert):
+        (WebCore::Chrome::runJavaScriptConfirm):
+        (WebCore::Chrome::runJavaScriptPrompt):
+        (WebCore::Chrome::shouldInterruptJavaScript):
+
 2012-04-20  Anders Carlsson  <[email protected]>
 
         Scrolling after going to a find-in-page result jumps to the top of the page

Modified: trunk/Source/WebCore/dom/Document.cpp (114781 => 114782)


--- trunk/Source/WebCore/dom/Document.cpp	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-04-20 21:29:00 UTC (rev 114782)
@@ -478,6 +478,7 @@
     , m_wheelEventHandlerCount(0)
     , m_touchEventHandlerCount(0)
     , m_pendingTasksTimer(this, &Document::pendingTasksTimerFired)
+    , m_scheduledTasksAreSuspended(false)
 {
     m_document = this;
 
@@ -5076,18 +5077,24 @@
     }
 }
 
-void Document::suspendScheduledTasks()
+void Document::suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension reason)
 {
+    ASSERT(!m_scheduledTasksAreSuspended);
+
     suspendScriptedAnimationControllerCallbacks();
-    suspendActiveDOMObjects(ActiveDOMObject::WillShowDialog);
+    suspendActiveDOMObjects(reason);
     scriptRunner()->suspend();
     m_pendingTasksTimer.stop();
     if (m_parser)
         m_parser->suspendScheduledTasks();
+
+    m_scheduledTasksAreSuspended = true;
 }
 
 void Document::resumeScheduledTasks()
 {
+    ASSERT(m_scheduledTasksAreSuspended);
+
     if (m_parser)
         m_parser->resumeScheduledTasks();
     if (!m_pendingTasks.isEmpty())
@@ -5095,6 +5102,8 @@
     scriptRunner()->resume();
     resumeActiveDOMObjects();
     resumeScriptedAnimationControllerCallbacks();
+    
+    m_scheduledTasksAreSuspended = false;
 }
 
 void Document::suspendScriptedAnimationControllerCallbacks()

Modified: trunk/Source/WebCore/dom/Document.h (114781 => 114782)


--- trunk/Source/WebCore/dom/Document.h	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebCore/dom/Document.h	2012-04-20 21:29:00 UTC (rev 114782)
@@ -1141,7 +1141,7 @@
     
     bool isInDocumentWrite() { return m_writeRecursionDepth > 0; }
 
-    void suspendScheduledTasks();
+    void suspendScheduledTasks(ActiveDOMObject::ReasonForSuspension);
     void resumeScheduledTasks();
 
     IntSize viewportSize() const;
@@ -1482,7 +1482,8 @@
 #endif
 
     Timer<Document> m_pendingTasksTimer;
-    Vector<OwnPtr<Task> > m_pendingTasks;    
+    Vector<OwnPtr<Task> > m_pendingTasks;
+    bool m_scheduledTasksAreSuspended;
 };
 
 // Put these methods here, because they require the Document definition, but we really want to inline them.

Modified: trunk/Source/WebCore/page/Chrome.cpp (114781 => 114782)


--- trunk/Source/WebCore/page/Chrome.cpp	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebCore/page/Chrome.cpp	2012-04-20 21:29:00 UTC (rev 114782)
@@ -227,7 +227,7 @@
 {
     // Defer callbacks in all the other pages in this group, so we don't try to run _javascript_
     // in a way that could interact with this view.
-    PageGroupLoadDeferrer deferrer(m_page, false);
+    PageGroupLoadDeferrer deferrer(m_page, false, ActiveDOMObject::WillShowDialog);
 
     TimerBase::fireTimersInNestedEventLoop();
     m_client->runModal();
@@ -287,7 +287,7 @@
 {
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing _javascript_.
-    PageGroupLoadDeferrer deferrer(m_page, true);
+    PageGroupLoadDeferrer deferrer(m_page, true, ActiveDOMObject::WillShowDialog);
 
     return m_client->runBeforeUnloadConfirmPanel(message, frame);
 }
@@ -304,7 +304,7 @@
 
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing _javascript_.
-    PageGroupLoadDeferrer deferrer(m_page, true);
+    PageGroupLoadDeferrer deferrer(m_page, true, ActiveDOMObject::WillShowDialog);
 
     ASSERT(frame);
     m_client->runJavaScriptAlert(frame, frame->displayStringModifiedByEncoding(message));
@@ -317,7 +317,7 @@
 
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing _javascript_.
-    PageGroupLoadDeferrer deferrer(m_page, true);
+    PageGroupLoadDeferrer deferrer(m_page, true, ActiveDOMObject::WillShowDialog);
 
     ASSERT(frame);
     return m_client->runJavaScriptConfirm(frame, frame->displayStringModifiedByEncoding(message));
@@ -330,7 +330,7 @@
 
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing _javascript_.
-    PageGroupLoadDeferrer deferrer(m_page, true);
+    PageGroupLoadDeferrer deferrer(m_page, true, ActiveDOMObject::WillShowDialog);
 
     ASSERT(frame);
     bool ok = m_client->runJavaScriptPrompt(frame, frame->displayStringModifiedByEncoding(prompt), frame->displayStringModifiedByEncoding(defaultValue), result);
@@ -351,7 +351,7 @@
 {
     // Defer loads in case the client method runs a new event loop that would
     // otherwise cause the load to continue while we're in the middle of executing _javascript_.
-    PageGroupLoadDeferrer deferrer(m_page, true);
+    PageGroupLoadDeferrer deferrer(m_page, true, ActiveDOMObject::WillShowDialog);
 
     return m_client->shouldInterruptJavaScript();
 }

Modified: trunk/Source/WebCore/page/PageGroupLoadDeferrer.cpp (114781 => 114782)


--- trunk/Source/WebCore/page/PageGroupLoadDeferrer.cpp	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebCore/page/PageGroupLoadDeferrer.cpp	2012-04-20 21:29:00 UTC (rev 114782)
@@ -33,7 +33,7 @@
 
 using namespace std;
 
-PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
+PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf, ActiveDOMObject::ReasonForSuspension reason)
 {
     const HashSet<Page*>& pages = page->group().pages();
 
@@ -46,10 +46,8 @@
 
                 // This code is not logically part of load deferring, but we do not want JS code executed beneath modal
                 // windows or sheets, which is exactly when PageGroupLoadDeferrer is used.
-                // NOTE: if PageGroupLoadDeferrer is ever used for tasks other than showing a modal window or sheet,
-                // the constructor will need to take a ActiveDOMObject::ReasonForSuspension.
                 for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext())
-                    frame->document()->suspendScheduledTasks();
+                    frame->document()->suspendScheduledTasks(reason);
             }
         }
     }

Modified: trunk/Source/WebCore/page/PageGroupLoadDeferrer.h (114781 => 114782)


--- trunk/Source/WebCore/page/PageGroupLoadDeferrer.h	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebCore/page/PageGroupLoadDeferrer.h	2012-04-20 21:29:00 UTC (rev 114782)
@@ -20,6 +20,7 @@
 #ifndef PageGroupLoadDeferrer_h
 #define PageGroupLoadDeferrer_h
 
+#include "ActiveDOMObject.h"
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
@@ -31,7 +32,7 @@
     class PageGroupLoadDeferrer {
         WTF_MAKE_NONCOPYABLE(PageGroupLoadDeferrer);
     public:
-        PageGroupLoadDeferrer(Page*, bool deferSelf);
+        PageGroupLoadDeferrer(Page*, bool deferSelf, ActiveDOMObject::ReasonForSuspension);
         ~PageGroupLoadDeferrer();
 
     private:

Modified: trunk/Source/WebKit/blackberry/Api/WebPageGroupLoadDeferrer.cpp (114781 => 114782)


--- trunk/Source/WebKit/blackberry/Api/WebPageGroupLoadDeferrer.cpp	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebKit/blackberry/Api/WebPageGroupLoadDeferrer.cpp	2012-04-20 21:29:00 UTC (rev 114782)
@@ -29,7 +29,7 @@
 WebPageGroupLoadDeferrer::WebPageGroupLoadDeferrer(WebPage* webPage)
 {
     WebCore::TimerBase::fireTimersInNestedEventLoop();
-    m_pageGroupLoadDeferrer = new WebCore::PageGroupLoadDeferrer(webPage->d->m_page, true /* defer the page itself */);
+    m_pageGroupLoadDeferrer = new WebCore::PageGroupLoadDeferrer(webPage->d->m_page, true /* defer the page itself */, WebCore::ActiveDOMObject::WillShowDialog);
 }
 
 WebPageGroupLoadDeferrer::~WebPageGroupLoadDeferrer()

Modified: trunk/Source/WebKit/blackberry/ChangeLog (114781 => 114782)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-04-20 21:29:00 UTC (rev 114782)
@@ -1,3 +1,18 @@
+2012-04-20  Brady Eidson  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=84490
+        PageGroupLoadDeferrer needs to take a ReasonForSuspension argument
+
+        Reviewed by Anders Carlsson.
+
+        * Api/WebPageGroupLoadDeferrer.cpp:
+        (BlackBerry::WebKit::WebPageGroupLoadDeferrer::WebPageGroupLoadDeferrer): Pass along ActiveDOMObject::WillShowDialog,
+          which used to be the default
+
+        * WebCoreSupport/ChromeClientBlackBerry.cpp:
+        (WebCore::ChromeClientBlackBerry::createWindow): Pass along ActiveDOMObject::WillShowDialog, which used to be the default.
+        (WebCore::ChromeClientBlackBerry::runOpenPanel): Ditto.
+
 2012-04-20  Mike Lattanzio  <[email protected]>
 
         [BlackBerry] Expose WebViewportArguments to WebPageClient

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp (114781 => 114782)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp	2012-04-20 21:29:00 UTC (rev 114782)
@@ -216,7 +216,7 @@
         return 0;
 #endif
 
-    PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true);
+    PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true, ActiveDOMObject::WillShowDialog);
     TimerBase::fireTimersInNestedEventLoop();
 
     int x = features.xSet ? features.x : 0;
@@ -490,7 +490,7 @@
     unsigned int chosenFileSize;
 
     {
-        PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true);
+        PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true, ActiveDOMObject::WillShowDialog);
         TimerBase::fireTimersInNestedEventLoop();
 
         // FIXME: Use chooser->settings().acceptMIMETypes instead of WebString() for the second parameter.

Modified: trunk/Source/WebKit/chromium/ChangeLog (114781 => 114782)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-20 21:29:00 UTC (rev 114782)
@@ -1,3 +1,14 @@
+2012-04-20  Brady Eidson  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=84490
+        PageGroupLoadDeferrer needs to take a ReasonForSuspension argument
+
+        Reviewed by Anders Carlsson.
+
+        * src/WebViewImpl.cpp:
+        (WebKit::WebView::willEnterModalLoop): Pass along ActiveDOMObject::WillShowDialog, which used
+          to be the default.
+
 2012-04-20  James Robinson  <[email protected]>
 
         Avoid synchronously recalculating the nonFastScrollableRegion when the ScrollableArea set changes

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (114781 => 114782)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-04-20 21:25:27 UTC (rev 114781)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2012-04-20 21:29:00 UTC (rev 114782)
@@ -279,7 +279,7 @@
         pageGroupLoadDeferrerStack().append(static_cast<PageGroupLoadDeferrer*>(0));
     else {
         // Pick any page in the page group since we are deferring all pages.
-        pageGroupLoadDeferrerStack().append(new PageGroupLoadDeferrer(*pageGroup->pages().begin(), true));
+        pageGroupLoadDeferrerStack().append(new PageGroupLoadDeferrer(*pageGroup->pages().begin(), true, ActiveDOMObject::WillShowDialog));
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to