Title: [88738] trunk/Source/WebKit/chromium
Revision
88738
Author
[email protected]
Date
2011-06-13 17:38:36 -0700 (Mon, 13 Jun 2011)

Log Message

[Chromium] WebNotification should check if ScriptExecutionContext is gone
before dispatching events.
https://bugs.webkit.org/show_bug.cgi?id=62592

Reviewed by David Levin.

* public/WebNotification.h:
* src/WebNotification.cpp:
(WebKit::WebNotification::dispatchDisplayEvent):
(WebKit::WebNotification::dispatchErrorEvent):
(WebKit::WebNotification::dispatchCloseEvent):
(WebKit::WebNotification::dispatchClickEvent):
(WebKit::WebNotification::dispatchEvent): Added a helper method to check
the context and dispatch an event.

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (88737 => 88738)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-06-14 00:22:50 UTC (rev 88737)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-06-14 00:38:36 UTC (rev 88738)
@@ -1,3 +1,20 @@
+2011-06-13  Jian Li  <[email protected]>
+
+        Reviewed by David Levin.
+
+        [Chromium] WebNotification should check if ScriptExecutionContext is gone
+        before dispatching events.
+        https://bugs.webkit.org/show_bug.cgi?id=62592
+
+        * public/WebNotification.h:
+        * src/WebNotification.cpp:
+        (WebKit::WebNotification::dispatchDisplayEvent):
+        (WebKit::WebNotification::dispatchErrorEvent):
+        (WebKit::WebNotification::dispatchCloseEvent):
+        (WebKit::WebNotification::dispatchClickEvent):
+        (WebKit::WebNotification::dispatchEvent): Added a helper method to check
+        the context and dispatch an event.
+
 2011-06-13  Dmitry Lomov  <[email protected]>
 
         Reviewed by Adam Barth.

Modified: trunk/Source/WebKit/chromium/public/WebNotification.h (88737 => 88738)


--- trunk/Source/WebKit/chromium/public/WebNotification.h	2011-06-14 00:22:50 UTC (rev 88737)
+++ trunk/Source/WebKit/chromium/public/WebNotification.h	2011-06-14 00:38:36 UTC (rev 88738)
@@ -39,6 +39,10 @@
 namespace WTF { template <typename T> class PassRefPtr; }
 #endif
 
+namespace WTF {
+class AtomicString;
+}
+
 namespace WebKit {
 
 class WebNotificationPrivate;
@@ -104,6 +108,7 @@
 
 private:
     void assign(WebNotificationPrivate*);
+    void dispatchEvent(const WTF::AtomicString& type);
     WebNotificationPrivate* m_private;
 };
 

Modified: trunk/Source/WebKit/chromium/src/WebNotification.cpp (88737 => 88738)


--- trunk/Source/WebKit/chromium/src/WebNotification.cpp	2011-06-14 00:22:50 UTC (rev 88737)
+++ trunk/Source/WebKit/chromium/src/WebNotification.cpp	2011-06-14 00:38:36 UTC (rev 88738)
@@ -116,29 +116,35 @@
 
 void WebNotification::dispatchDisplayEvent()
 {
-    RefPtr<Event> event = Event::create("display", false, true);
-    m_private->dispatchEvent(event.release());
+    dispatchEvent("display");
 }
 
 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */)
 {
     // FIXME: errorMessage not supported by WebCore yet
-    RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true);
-    m_private->dispatchEvent(event.release());
+    dispatchEvent(eventNames().errorEvent);
 }
 
 void WebNotification::dispatchCloseEvent(bool /* byUser */)
 {
     // FIXME: byUser flag not supported by WebCore yet
-    RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true);
-    m_private->dispatchEvent(event.release());
+    dispatchEvent(eventNames().closeEvent);
 }
 
 void WebNotification::dispatchClickEvent()
 {
     // Make sure clicks on notifications are treated as user gestures.
     UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
-    RefPtr<Event> event = Event::create(eventNames().clickEvent, false, true);
+    dispatchEvent(eventNames().clickEvent);
+}
+
+void WebNotification::dispatchEvent(const WTF::AtomicString& type)
+{
+    // Do not dispatch if the context is gone.
+    if (!m_private->scriptExecutionContext())
+        return;
+
+    RefPtr<Event> event = Event::create(type, false, true);
     m_private->dispatchEvent(event.release());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to