+2013-03-05 Anders Carlsson <andersca@apple.com>
+
+ Split up the storage event dispatch functions further
+ https://bugs.webkit.org/show_bug.cgi?id=111482
+
+ Reviewed by Beth Dakin.
+
+ Add new functions for dispatching storage events to a set of frames.
+
+ * storage/StorageAreaImpl.cpp:
+ (WebCore::StorageAreaImpl::dispatchStorageEvent):
+ * storage/StorageEventDispatcher.cpp:
+ (WebCore::StorageEventDispatcher::dispatchSessionStorageEvents):
+ (WebCore::StorageEventDispatcher::dispatchLocalStorageEvents):
+ (WebCore):
+ (WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames):
+ (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames):
+ * storage/StorageEventDispatcher.h:
+ (WebCore):
+ (StorageEventDispatcher):
+
2013-03-05 Stephen Chenney <schenney@chromium.org>
Crash when ImageLoader deletes Element inside SVGImageElement
void StorageAreaImpl::dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame)
{
if (m_storageType == LocalStorage)
- StorageEventDispatcher::dispatchLocalStorageEvent(key, oldValue, newValue, m_securityOrigin.get(), sourceFrame);
+ StorageEventDispatcher::dispatchLocalStorageEvents(key, oldValue, newValue, m_securityOrigin.get(), sourceFrame);
else
- StorageEventDispatcher::dispatchSessionStorageEvent(key, oldValue, newValue, m_securityOrigin.get(), sourceFrame);
+ StorageEventDispatcher::dispatchSessionStorageEvents(key, oldValue, newValue, m_securityOrigin.get(), sourceFrame);
}
} // namespace WebCore
namespace WebCore {
-void StorageEventDispatcher::dispatchSessionStorageEvent(const String& key, const String& oldValue, const String& newValue, SecurityOrigin* securityOrigin, Frame* sourceFrame)
+void StorageEventDispatcher::dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, SecurityOrigin* securityOrigin, Frame* sourceFrame)
{
Page* page = sourceFrame->page();
if (!page)
frames.append(frame);
}
- InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, SessionStorage, securityOrigin, page);
-
- for (unsigned i = 0; i < frames.size(); ++i) {
- ExceptionCode ec = 0;
- Storage* storage = frames[i]->document()->domWindow()->sessionStorage(ec);
- if (!ec)
- frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
- }
+ dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, sourceFrame->document()->url(), securityOrigin);
}
-void StorageEventDispatcher::dispatchLocalStorageEvent(const String& key, const String& oldValue, const String& newValue, SecurityOrigin* securityOrigin, Frame* sourceFrame)
+void StorageEventDispatcher::dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, SecurityOrigin* securityOrigin, Frame* sourceFrame)
{
Page* page = sourceFrame->page();
if (!page)
// Send events to every page.
const HashSet<Page*>& pages = page->group().pages();
- HashSet<Page*>::const_iterator end = pages.end();
- for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
+ for (HashSet<Page*>::const_iterator it = pages.begin(), end = pages.end(); it != end; ++it) {
for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin))
frames.append(frame);
}
- InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStorage, securityOrigin, *it);
}
+ dispatchLocalStorageEventsToFrames(page->group(), frames, key, oldValue, newValue, sourceFrame->document()->url(), securityOrigin);
+}
+
+void StorageEventDispatcher::dispatchSessionStorageEventsToFrames(Page& page, const Vector<RefPtr<Frame> >& frames, const String& key, const String& oldValue, const String& newValue, const String& url, SecurityOrigin* securityOrigin)
+{
+ InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, SessionStorage, securityOrigin, &page);
+
+ for (unsigned i = 0; i < frames.size(); ++i) {
+ ExceptionCode ec = 0;
+ Storage* storage = frames[i]->document()->domWindow()->sessionStorage(ec);
+ if (!ec)
+ frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+ }
+}
+
+void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageGroup, const Vector<RefPtr<Frame> >& frames, const String& key, const String& oldValue, const String& newValue, const String& url, SecurityOrigin* securityOrigin)
+{
+ const HashSet<Page*>& pages = pageGroup.pages();
+ for (HashSet<Page*>::const_iterator it = pages.begin(), end = pages.end(); it != end; ++it)
+ InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStorage, securityOrigin, *it);
+
for (unsigned i = 0; i < frames.size(); ++i) {
ExceptionCode ec = 0;
Storage* storage = frames[i]->document()->domWindow()->localStorage(ec);
if (!ec)
- frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(), storage));
+ frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
}
}
#ifndef StorageEventDispatcher_h
#define StorageEventDispatcher_h
-#include "StorageArea.h"
#include <wtf/Forward.h>
+#include <wtf/Vector.h>
namespace WebCore {
+class Frame;
+class Page;
+class PageGroup;
+class SecurityOrigin;
+
class StorageEventDispatcher {
public:
- static void dispatchSessionStorageEvent(const String& key, const String& oldValue, const String& newValue, SecurityOrigin*, Frame* sourceFrame);
- static void dispatchLocalStorageEvent(const String& key, const String& oldValue, const String& newValue, SecurityOrigin*, Frame* sourceFrame);
+ static void dispatchSessionStorageEvents(const String& key, const String& oldValue, const String& newValue, SecurityOrigin*, Frame* sourceFrame);
+ static void dispatchLocalStorageEvents(const String& key, const String& oldValue, const String& newValue, SecurityOrigin*, Frame* sourceFrame);
+ static void dispatchSessionStorageEventsToFrames(Page&, const Vector<RefPtr<Frame> >& frames, const String& key, const String& oldValue, const String& newValue, const String& url, SecurityOrigin*);
+ static void dispatchLocalStorageEventsToFrames(PageGroup&, const Vector<RefPtr<Frame> >& frames, const String& key, const String& oldValue, const String& newValue, const String& url, SecurityOrigin*);
private:
// Do not instantiate.
StorageEventDispatcher();