Disconnecting DOMWindow properties is fragile and overly complicated
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jan 2012 08:46:38 +0000 (08:46 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Jan 2012 08:46:38 +0000 (08:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75699

Reviewed by Alexey Proskuryakov.

Previously, we had to carefully check every object tree hanging off of
DOMWindow to make sure that every property correctly disconnected
itself and all its subobjects from the Frame when the DOMWindow
disconnected from the Frame.

This patch introduces DOMWindowProperty, which is a base class that
handles this work automagically, ensuring that we won't have any
dangling Frame pointers and removing a bunch of boilerplate code.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* css/StyleMedia.cpp:
(WebCore::StyleMedia::StyleMedia):
* css/StyleMedia.h:
(WebCore::StyleMedia::create):
* loader/appcache/DOMApplicationCache.cpp:
(WebCore::DOMApplicationCache::DOMApplicationCache):
(WebCore::DOMApplicationCache::disconnectFrame):
* loader/appcache/DOMApplicationCache.h:
* page/BarInfo.cpp:
(WebCore::BarInfo::BarInfo):
* page/BarInfo.h:
* page/Console.cpp:
(WebCore::Console::Console):
(WebCore::Console::memory):
* page/Console.h:
* page/DOMSelection.cpp:
(WebCore::DOMSelection::DOMSelection):
* page/DOMSelection.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::registerProperty):
(WebCore::DOMWindow::unregisterProperty):
(WebCore::DOMWindow::clear):
* page/DOMWindow.h:
* page/Geolocation.cpp:
(WebCore::Geolocation::Geolocation):
(WebCore::Geolocation::disconnectFrame):
* page/Geolocation.h:
* page/History.cpp:
(WebCore::History::History):
* page/History.h:
* page/Location.cpp:
(WebCore::Location::Location):
* page/Location.h:
* page/Navigator.cpp:
(WebCore::Navigator::Navigator):
(WebCore::Navigator::~Navigator):
* page/Navigator.h:
* page/Performance.cpp:
(WebCore::Performance::Performance):
(WebCore::Performance::memory):
* page/Performance.h:
* page/PerformanceNavigation.cpp:
(WebCore::PerformanceNavigation::PerformanceNavigation):
* page/PerformanceNavigation.h:
* page/PerformanceTiming.cpp:
(WebCore::PerformanceTiming::PerformanceTiming):
* page/PerformanceTiming.h:
* page/Screen.cpp:
(WebCore::Screen::Screen):
* page/Screen.h:
* plugins/DOMMimeTypeArray.cpp:
(WebCore::DOMMimeTypeArray::DOMMimeTypeArray):
* plugins/DOMMimeTypeArray.h:
* plugins/DOMPluginArray.cpp:
(WebCore::DOMPluginArray::DOMPluginArray):
* plugins/DOMPluginArray.h:
* storage/Storage.cpp:
(WebCore::Storage::Storage):
* storage/Storage.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104380 268f45cc-cd09-0410-ab3c-d52691b4dbfc

43 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/StyleMedia.cpp
Source/WebCore/css/StyleMedia.h
Source/WebCore/loader/appcache/DOMApplicationCache.cpp
Source/WebCore/loader/appcache/DOMApplicationCache.h
Source/WebCore/page/BarInfo.cpp
Source/WebCore/page/BarInfo.h
Source/WebCore/page/Console.cpp
Source/WebCore/page/Console.h
Source/WebCore/page/DOMSelection.cpp
Source/WebCore/page/DOMSelection.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/DOMWindowProperty.cpp [new file with mode: 0644]
Source/WebCore/page/DOMWindowProperty.h [new file with mode: 0644]
Source/WebCore/page/Geolocation.cpp
Source/WebCore/page/Geolocation.h
Source/WebCore/page/History.cpp
Source/WebCore/page/History.h
Source/WebCore/page/Location.cpp
Source/WebCore/page/Location.h
Source/WebCore/page/Navigator.cpp
Source/WebCore/page/Navigator.h
Source/WebCore/page/Performance.cpp
Source/WebCore/page/Performance.h
Source/WebCore/page/PerformanceNavigation.cpp
Source/WebCore/page/PerformanceNavigation.h
Source/WebCore/page/PerformanceTiming.cpp
Source/WebCore/page/PerformanceTiming.h
Source/WebCore/page/Screen.cpp
Source/WebCore/page/Screen.h
Source/WebCore/plugins/DOMMimeTypeArray.cpp
Source/WebCore/plugins/DOMMimeTypeArray.h
Source/WebCore/plugins/DOMPluginArray.cpp
Source/WebCore/plugins/DOMPluginArray.h
Source/WebCore/storage/Storage.cpp
Source/WebCore/storage/Storage.h

index 6d63385..498dfad 100644 (file)
@@ -989,6 +989,7 @@ SET(WebCore_SOURCES
     page/DOMSelection.cpp
     page/DOMTimer.cpp
     page/DOMWindow.cpp
+    page/DOMWindowProperty.cpp
     page/DragController.cpp
     page/EventHandler.cpp
     page/EventSource.cpp
index bec0756..833f03e 100644 (file)
@@ -1,3 +1,84 @@
+2012-01-07  Adam Barth  <abarth@webkit.org>
+
+        Disconnecting DOMWindow properties is fragile and overly complicated
+        https://bugs.webkit.org/show_bug.cgi?id=75699
+
+        Reviewed by Alexey Proskuryakov.
+
+        Previously, we had to carefully check every object tree hanging off of
+        DOMWindow to make sure that every property correctly disconnected
+        itself and all its subobjects from the Frame when the DOMWindow
+        disconnected from the Frame.
+
+        This patch introduces DOMWindowProperty, which is a base class that
+        handles this work automagically, ensuring that we won't have any
+        dangling Frame pointers and removing a bunch of boilerplate code.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * css/StyleMedia.cpp:
+        (WebCore::StyleMedia::StyleMedia):
+        * css/StyleMedia.h:
+        (WebCore::StyleMedia::create):
+        * loader/appcache/DOMApplicationCache.cpp:
+        (WebCore::DOMApplicationCache::DOMApplicationCache):
+        (WebCore::DOMApplicationCache::disconnectFrame):
+        * loader/appcache/DOMApplicationCache.h:
+        * page/BarInfo.cpp:
+        (WebCore::BarInfo::BarInfo):
+        * page/BarInfo.h:
+        * page/Console.cpp:
+        (WebCore::Console::Console):
+        (WebCore::Console::memory):
+        * page/Console.h:
+        * page/DOMSelection.cpp:
+        (WebCore::DOMSelection::DOMSelection):
+        * page/DOMSelection.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::registerProperty):
+        (WebCore::DOMWindow::unregisterProperty):
+        (WebCore::DOMWindow::clear):
+        * page/DOMWindow.h:
+        * page/Geolocation.cpp:
+        (WebCore::Geolocation::Geolocation):
+        (WebCore::Geolocation::disconnectFrame):
+        * page/Geolocation.h:
+        * page/History.cpp:
+        (WebCore::History::History):
+        * page/History.h:
+        * page/Location.cpp:
+        (WebCore::Location::Location):
+        * page/Location.h:
+        * page/Navigator.cpp:
+        (WebCore::Navigator::Navigator):
+        (WebCore::Navigator::~Navigator):
+        * page/Navigator.h:
+        * page/Performance.cpp:
+        (WebCore::Performance::Performance):
+        (WebCore::Performance::memory):
+        * page/Performance.h:
+        * page/PerformanceNavigation.cpp:
+        (WebCore::PerformanceNavigation::PerformanceNavigation):
+        * page/PerformanceNavigation.h:
+        * page/PerformanceTiming.cpp:
+        (WebCore::PerformanceTiming::PerformanceTiming):
+        * page/PerformanceTiming.h:
+        * page/Screen.cpp:
+        (WebCore::Screen::Screen):
+        * page/Screen.h:
+        * plugins/DOMMimeTypeArray.cpp:
+        (WebCore::DOMMimeTypeArray::DOMMimeTypeArray):
+        * plugins/DOMMimeTypeArray.h:
+        * plugins/DOMPluginArray.cpp:
+        (WebCore::DOMPluginArray::DOMPluginArray):
+        * plugins/DOMPluginArray.h:
+        * storage/Storage.cpp:
+        (WebCore::Storage::Storage):
+        * storage/Storage.h:
+
 2012-01-06  Mark Rowe  <mrowe@apple.com>
 
         REGRESSION (r83075): Save as PDF does not generate any links for webkit.org and others
index ec6d5fe..98a078d 100644 (file)
@@ -2646,6 +2646,8 @@ webcore_sources += \
        Source/WebCore/page/DOMTimer.h \
        Source/WebCore/page/DOMWindow.cpp \
        Source/WebCore/page/DOMWindow.h \
+       Source/WebCore/page/DOMWindowProperty.cpp \
+       Source/WebCore/page/DOMWindowProperty.h \
        Source/WebCore/page/DragActions.h \
        Source/WebCore/page/DragClient.h \
        Source/WebCore/page/DragController.cpp \
index ea0e4ea..d34ff38 100644 (file)
@@ -967,6 +967,7 @@ SOURCES += \
     page/DOMSelection.cpp \
     page/DOMTimer.cpp \
     page/DOMWindow.cpp \
+    page/DOMWindowProperty.cpp \
     page/DragController.cpp \
     page/EventHandler.cpp \
     page/EventSource.cpp \
index 80a23ef..14dad03 100644 (file)
             'page/DOMTimer.cpp',
             'page/DOMTimer.h',
             'page/DOMWindow.cpp',
+            'page/DOMWindowProperty.cpp',
+            'page/DOMWindowProperty.h',
             'page/DragController.cpp',
             'page/EventHandler.cpp',
             'page/EventSource.cpp',
index ac34366..0a07d67 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\page\DOMWindowProperty.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\page\DOMWindowProperty.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\page\DragActions.h"
                                >
                        </File>
index 6710424..c466ec6 100644 (file)
                97C078501165D5BE003A32EF /* SuffixTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 97C0784F1165D5BE003A32EF /* SuffixTree.h */; };
                97C471DB12F925BD0086354B /* ContentSecurityPolicy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97C471D912F925BC0086354B /* ContentSecurityPolicy.cpp */; };
                97C471DC12F925BD0086354B /* ContentSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 97C471DA12F925BD0086354B /* ContentSecurityPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               97D2AD0314B823A60093DF32 /* DOMWindowProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97D2AD0114B823A60093DF32 /* DOMWindowProperty.cpp */; };
+               97D2AD0414B823A60093DF32 /* DOMWindowProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 97D2AD0214B823A60093DF32 /* DOMWindowProperty.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97DCE20110807C750057D394 /* HistoryController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97DCE1FF10807C750057D394 /* HistoryController.cpp */; };
                97DCE20210807C750057D394 /* HistoryController.h in Headers */ = {isa = PBXBuildFile; fileRef = 97DCE20010807C750057D394 /* HistoryController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97E4028F13A696ED00913D67 /* IconController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97E4028D13A696ED00913D67 /* IconController.cpp */; };
                97C1F552122855CB00EDE616 /* HTMLToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLToken.h; path = parser/HTMLToken.h; sourceTree = "<group>"; };
                97C471D912F925BC0086354B /* ContentSecurityPolicy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentSecurityPolicy.cpp; sourceTree = "<group>"; };
                97C471DA12F925BD0086354B /* ContentSecurityPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentSecurityPolicy.h; sourceTree = "<group>"; };
+               97D2AD0114B823A60093DF32 /* DOMWindowProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowProperty.cpp; sourceTree = "<group>"; };
+               97D2AD0214B823A60093DF32 /* DOMWindowProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindowProperty.h; sourceTree = "<group>"; };
                97DCE1FF10807C750057D394 /* HistoryController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HistoryController.cpp; sourceTree = "<group>"; };
                97DCE20010807C750057D394 /* HistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HistoryController.h; sourceTree = "<group>"; };
                97E4028D13A696ED00913D67 /* IconController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IconController.cpp; sourceTree = "<group>"; };
                                1403B99609EB13AF00797C7F /* DOMWindow.cpp */,
                                1403B99509EB13AF00797C7F /* DOMWindow.h */,
                                1403B90C09EB124500797C7F /* DOMWindow.idl */,
+                               97D2AD0114B823A60093DF32 /* DOMWindowProperty.cpp */,
+                               97D2AD0214B823A60093DF32 /* DOMWindowProperty.h */,
                                A718760D0B2A120100A16ECE /* DragActions.h */,
                                A7CA59620B27C1F200FA021D /* DragClient.h */,
                                A7CA595C0B27BD9E00FA021D /* DragController.cpp */,
                                977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
                                FD537353137B651800008DCE /* ZeroPole.h in Headers */,
                                974A862314B7ADBB003FDC76 /* FrameDestructionObserver.h in Headers */,
+                               97D2AD0414B823A60093DF32 /* DOMWindowProperty.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
                                FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
                                974A862214B7ADBB003FDC76 /* FrameDestructionObserver.cpp in Sources */,
+                               97D2AD0314B823A60093DF32 /* DOMWindowProperty.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 90b5740..5db8a6f 100644 (file)
@@ -36,7 +36,7 @@
 namespace WebCore {
 
 StyleMedia::StyleMedia(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
index 7605242..032929e 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef StyleMedia_h
 #define StyleMedia_h
 
+#include "DOMWindowProperty.h"
 #include "PlatformString.h"
 #include <wtf/RefCounted.h>
 
@@ -34,24 +35,15 @@ namespace WebCore {
 
 class Frame;
 
-class StyleMedia : public RefCounted<StyleMedia> {
+class StyleMedia : public RefCounted<StyleMedia>, public DOMWindowProperty {
 public:
-    static PassRefPtr<StyleMedia> create(Frame* frame)
-    {
-        return adoptRef(new StyleMedia(frame));
-    }
-
-    Frame* frame() { return m_frame; }
-    void disconnectFrame() { m_frame = 0; }
+    static PassRefPtr<StyleMedia> create(Frame* frame) { return adoptRef(new StyleMedia(frame));}
 
     String type() const;
-
     bool matchMedium(const String&) const;
 
 private:
-    StyleMedia(Frame*);
-
-    Frame* m_frame;
+    explicit StyleMedia(Frame*);
 };
 
 } // namespace
index 72c9fc9..042eb39 100644 (file)
@@ -40,7 +40,7 @@
 namespace WebCore {
 
 DOMApplicationCache::DOMApplicationCache(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
     ApplicationCacheHost* cacheHost = applicationCacheHost();
     if (cacheHost)
@@ -52,7 +52,7 @@ void DOMApplicationCache::disconnectFrame()
     ApplicationCacheHost* cacheHost = applicationCacheHost();
     if (cacheHost)
         cacheHost->setDOMApplicationCache(0);
-    m_frame = 0;
+    DOMWindowProperty::disconnectFrame();
 }
 
 ApplicationCacheHost* DOMApplicationCache::applicationCacheHost() const
index 022841c..2ca44c1 100644 (file)
@@ -27,6 +27,7 @@
 #define DOMApplicationCache_h
 
 #include "ApplicationCacheHost.h"
+#include "DOMWindowProperty.h"
 #include "EventNames.h"
 #include "EventTarget.h"
 #include <wtf/Forward.h>
@@ -41,13 +42,12 @@ namespace WebCore {
 class Frame;
 class KURL;
 
-class DOMApplicationCache : public RefCounted<DOMApplicationCache>, public EventTarget {
+class DOMApplicationCache : public RefCounted<DOMApplicationCache>, public EventTarget, public DOMWindowProperty {
 public:
     static PassRefPtr<DOMApplicationCache> create(Frame* frame) { return adoptRef(new DOMApplicationCache(frame)); }
     ~DOMApplicationCache() { ASSERT(!m_frame); }
 
-    Frame* frame() const { return m_frame; }
-    void disconnectFrame();
+    virtual void disconnectFrame() OVERRIDE;
 
     unsigned short status() const;
     void update(ExceptionCode&);
@@ -75,7 +75,7 @@ public:
     static const AtomicString& toEventType(ApplicationCacheHost::EventID id);
 
 private:
-    DOMApplicationCache(Frame*);
+    explicit DOMApplicationCache(Frame*);
 
     virtual void refEventTarget() { ref(); }
     virtual void derefEventTarget() { deref(); }
@@ -84,7 +84,6 @@ private:
 
     ApplicationCacheHost* applicationCacheHost() const;
 
-    Frame* m_frame;
     EventTargetData m_eventTargetData;
 };
 
index b6ab686..36b2ad6 100644 (file)
 namespace WebCore {
 
 BarInfo::BarInfo(Frame* frame, Type type)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
     , m_type(type)
 {
 }
 
-Frame* BarInfo::frame() const
-{
-    return m_frame;
-}
-
-void BarInfo::disconnectFrame()
-{
-    m_frame = 0;
-}
-
 BarInfo::Type BarInfo::type() const
 {
     return m_type;
index 376b8fc..b369b6e 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef BarInfo_h
 #define BarInfo_h
 
+#include "DOMWindowProperty.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -36,22 +37,17 @@ namespace WebCore {
 
     class Frame;
 
-    class BarInfo : public RefCounted<BarInfo> {
+    class BarInfo : public RefCounted<BarInfo>, public DOMWindowProperty {
     public:
         enum Type { Locationbar, Menubar, Personalbar, Scrollbars, Statusbar, Toolbar };
 
         static PassRefPtr<BarInfo> create(Frame* frame, Type type) { return adoptRef(new BarInfo(frame, type)); }
 
-        Frame* frame() const;
-        void disconnectFrame();
-
         Type type() const;
-
         bool visible() const;
 
     private:
         BarInfo(Frame*, Type);
-        Frame* m_frame;
         Type m_type;
     };
 
index 011cd6c..3cc4c2e 100644 (file)
@@ -56,7 +56,7 @@
 namespace WebCore {
 
 Console::Console(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
@@ -64,18 +64,6 @@ Console::~Console()
 {
 }
 
-Frame* Console::frame() const
-{
-    return m_frame;
-}
-
-void Console::disconnectFrame()
-{
-    if (m_memory)
-        m_memory = 0;
-    m_frame = 0;
-}
-
 static void printSourceURLAndLine(const String& sourceURL, unsigned lineNumber)
 {
     if (!sourceURL.isEmpty()) {
@@ -348,10 +336,11 @@ void Console::warn(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallS
     addMessage(LogMessageType, WarningMessageLevel, arguments, callStack);
 }
 
-MemoryInfo* Console::memory() const
+PassRefPtr<MemoryInfo> Console::memory() const
 {
-    m_memory = MemoryInfo::create(m_frame);
-    return m_memory.get();
+    // FIXME: Because we create a new object here each time,
+    // console.memory !== console.memory, which seems wrong.
+    return MemoryInfo::create(m_frame);
 }
 
 static bool printExceptions = false;
index 87fe407..5a10004 100644 (file)
@@ -30,6 +30,7 @@
 #define Console_h
 
 #include "ConsoleTypes.h"
+#include "DOMWindowProperty.h"
 #include "ScriptProfile.h"
 #include "ScriptState.h"
 #include <wtf/Forward.h>
@@ -48,14 +49,11 @@ class ScriptCallStack;
 typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
 #endif
 
-class Console : public RefCounted<Console> {
+class Console : public RefCounted<Console>, public DOMWindowProperty {
 public:
     static PassRefPtr<Console> create(Frame* frame) { return adoptRef(new Console(frame)); }
     virtual ~Console();
 
-    Frame* frame() const;
-    void disconnectFrame();
-
     void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
     void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack);
 
@@ -85,19 +83,17 @@ public:
     static bool shouldPrintExceptions();
     static void setShouldPrintExceptions(bool);
 
-    MemoryInfo* memory() const;
+    PassRefPtr<MemoryInfo> memory() const;
 
 private:
     inline Page* page() const;
     void addMessage(MessageType, MessageLevel, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>, bool acceptNoArguments = false);
 
-    Console(Frame*);
+    explicit Console(Frame*);
 
-    Frame* m_frame;
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     ProfilesArray m_profiles;
 #endif
-    mutable RefPtr<MemoryInfo> m_memory;
 };
 
 } // namespace WebCore
index 2d41a8d..97a438d 100644 (file)
@@ -54,20 +54,10 @@ static Node* selectionShadowAncestor(Frame* frame)
 }
 
 DOMSelection::DOMSelection(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-Frame* DOMSelection::frame() const
-{
-    return m_frame;
-}
-
-void DOMSelection::disconnectFrame()
-{
-    m_frame = 0;
-}
-
 const VisibleSelection& DOMSelection::visibleSelection() const
 {
     ASSERT(m_frame);
index b5fd197..9803acc 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef DOMSelection_h
 #define DOMSelection_h
 
+#include "DOMWindowProperty.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -43,13 +44,10 @@ namespace WebCore {
 
     typedef int ExceptionCode;
 
-    class DOMSelection : public RefCounted<DOMSelection> {
+    class DOMSelection : public RefCounted<DOMSelection>, public DOMWindowProperty {
     public:
         static PassRefPtr<DOMSelection> create(Frame* frame) { return adoptRef(new DOMSelection(frame)); }
 
-        Frame* frame() const;
-        void disconnectFrame();
-
         // Safari Selection Object API
         // These methods return the valid equivalents of internal editing positions.
         Node* baseNode() const;
@@ -90,13 +88,12 @@ namespace WebCore {
         void empty();
 
     private:
-        DOMSelection(Frame*);
+        explicit DOMSelection(Frame*);
 
         // Convenience method for accessors, does not NULL check m_frame.
         const VisibleSelection& visibleSelection() const;
 
         bool isValidForPosition(Node*) const;
-        Frame* m_frame;
     };
 
 } // namespace WebCore
index b36011e..5b7b952 100644 (file)
@@ -476,92 +476,54 @@ void DOMWindow::frameDestroyed()
     clear();
 }
 
+void DOMWindow::registerProperty(DOMWindowProperty* property)
+{
+    m_properties.add(property);
+}
+
+void DOMWindow::unregisterProperty(DOMWindowProperty* property)
+{
+    m_properties.remove(property);
+}
+
 void DOMWindow::clear()
 {
-    if (m_screen)
-        m_screen->disconnectFrame();
-    m_screen = 0;
+    HashSet<DOMWindowProperty*>::iterator stop = m_properties.end();
+    for (HashSet<DOMWindowProperty*>::iterator it = m_properties.begin(); it != stop; ++it)
+        (*it)->disconnectFrame();
+    m_properties.clear();
 
-    if (m_selection)
-        m_selection->disconnectFrame();
+    m_screen = 0;
     m_selection = 0;
-
-    if (m_history)
-        m_history->disconnectFrame();
     m_history = 0;
-
     m_crypto = 0;
-
-    if (m_locationbar)
-        m_locationbar->disconnectFrame();
     m_locationbar = 0;
-
-    if (m_menubar)
-        m_menubar->disconnectFrame();
     m_menubar = 0;
-
-    if (m_personalbar)
-        m_personalbar->disconnectFrame();
     m_personalbar = 0;
-
-    if (m_scrollbars)
-        m_scrollbars->disconnectFrame();
     m_scrollbars = 0;
-
-    if (m_statusbar)
-        m_statusbar->disconnectFrame();
     m_statusbar = 0;
-
-    if (m_toolbar)
-        m_toolbar->disconnectFrame();
     m_toolbar = 0;
-
-    if (m_console)
-        m_console->disconnectFrame();
     m_console = 0;
-
-    if (m_navigator)
-        m_navigator->disconnectFrame();
     m_navigator = 0;
-
 #if ENABLE(WEB_TIMING)
-    if (m_performance)
-        m_performance->disconnectFrame();
     m_performance = 0;
 #endif
-
-    if (m_location)
-        m_location->disconnectFrame();
     m_location = 0;
-
-    if (m_media)
-        m_media->disconnectFrame();
     m_media = 0;
-
-    if (m_sessionStorage)
-        m_sessionStorage->disconnectFrame();
     m_sessionStorage = 0;
-
-    if (m_localStorage)
-        m_localStorage->disconnectFrame();
     m_localStorage = 0;
-
-    if (m_applicationCache)
-        m_applicationCache->disconnectFrame();
     m_applicationCache = 0;
-
 #if ENABLE(NOTIFICATIONS)
+    // FIXME: Notifications shouldn't have different disconnection logic than
+    // the rest of the DOMWindowProperties.
     resetNotifications();
 #endif
-
 #if ENABLE(INDEXED_DATABASE)
     m_idbFactory = 0;
 #endif
-
 #if ENABLE(BLOB)
     m_domURL = 0;
 #endif
-
 #if ENABLE(QUOTA)
     m_storageInfo = 0;
 #endif
index 4c86f80..6bd2b70 100644 (file)
@@ -41,6 +41,7 @@ namespace WebCore {
     class DOMApplicationCache;
     class DOMSelection;
     class DOMURL;
+    class DOMWindowProperty;
     class Database;
     class DatabaseCallback;
     class Document;
@@ -93,6 +94,9 @@ namespace WebCore {
 
         virtual void frameDestroyed() OVERRIDE;
 
+        void registerProperty(DOMWindowProperty*);
+        void unregisterProperty(DOMWindowProperty*);
+
         void clear();
 
         PassRefPtr<MediaQueryList> matchMedia(const String&);
@@ -437,6 +441,9 @@ namespace WebCore {
         KURL m_url;
 
         bool m_shouldPrintWhenFinishedLoading;
+
+        HashSet<DOMWindowProperty*> m_properties;
+
         mutable RefPtr<Screen> m_screen;
         mutable RefPtr<DOMSelection> m_selection;
         mutable RefPtr<History> m_history;
diff --git a/Source/WebCore/page/DOMWindowProperty.cpp b/Source/WebCore/page/DOMWindowProperty.cpp
new file mode 100644 (file)
index 0000000..b6a9aba
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Google, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DOMWindowProperty.h"
+
+#include "DOMWindow.h"
+#include "Frame.h"
+
+namespace WebCore {
+
+DOMWindowProperty::DOMWindowProperty(Frame* frame)
+    : m_frame(frame)
+{
+    if (m_frame)
+        m_frame->domWindow()->registerProperty(this);
+}
+
+DOMWindowProperty::~DOMWindowProperty()
+{
+    if (m_frame)
+        m_frame->domWindow()->unregisterProperty(this);
+}
+
+void DOMWindowProperty::disconnectFrame()
+{
+    m_frame = 0;
+}
+
+}
diff --git a/Source/WebCore/page/DOMWindowProperty.h b/Source/WebCore/page/DOMWindowProperty.h
new file mode 100644 (file)
index 0000000..41baf43
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 Google, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DOMWindowProperty_h
+#define DOMWindowProperty_h
+
+namespace WebCore {
+
+class Frame;
+
+class DOMWindowProperty {
+public:
+    explicit DOMWindowProperty(Frame*);
+    virtual void disconnectFrame();
+
+    Frame* frame() const { return m_frame; }
+
+protected:
+    virtual ~DOMWindowProperty();
+
+    Frame* m_frame;
+};
+
+}
+
+#endif
index 1daea74..bb285c5 100644 (file)
@@ -225,7 +225,7 @@ void Geolocation::Watchers::getNotifiersVector(GeoNotifierVector& copy) const
 }
 
 Geolocation::Geolocation(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 #if !ENABLE(CLIENT_BASED_GEOLOCATION)
     , m_service(GeolocationService::create(this))
 #endif
@@ -273,7 +273,7 @@ void Geolocation::disconnectFrame()
     reset();
     if (m_frame && m_frame->document())
         m_frame->document()->setUsingGeolocation(false);
-    m_frame = 0;
+    DOMWindowProperty::disconnectFrame();
 }
 
 Geoposition* Geolocation::lastPosition()
index b27d80b..ea55cbf 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef Geolocation_h
 #define Geolocation_h
 
+#include "DOMWindowProperty.h"
 #include "Geoposition.h"
 #include "PositionCallback.h"
 #include "PositionError.h"
@@ -47,25 +48,23 @@ class GeolocationError;
 #endif
 class Page;
 
-class Geolocation : public RefCounted<Geolocation>
+class Geolocation : public RefCounted<Geolocation>, public DOMWindowProperty
 #if !ENABLE(CLIENT_BASED_GEOLOCATION) && ENABLE(GEOLOCATION)
     , public GeolocationServiceClient
 #endif
 {
 public:
     static PassRefPtr<Geolocation> create(Frame* frame) { return adoptRef(new Geolocation(frame)); }
-
     ~Geolocation();
 
+    virtual void disconnectFrame() OVERRIDE;
     void reset();
-    void disconnectFrame();
-    
+
     void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
     int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
     void clearWatch(int watchId);
 
     void setIsAllowed(bool);
-    Frame* frame() const { return m_frame; }
 
 #if ENABLE(CLIENT_BASED_GEOLOCATION)
     void positionChanged();
@@ -79,8 +78,8 @@ private:
 
     bool isAllowed() const { return m_allowGeolocation == Yes; }
     bool isDenied() const { return m_allowGeolocation == No; }
-    
-    Geolocation(Frame*);
+
+    explicit Geolocation(Frame*);
 
     Page* page() const;
 
@@ -172,7 +171,6 @@ private:
 
     GeoNotifierSet m_oneShots;
     Watchers m_watchers;
-    Frame* m_frame;
 #if !ENABLE(CLIENT_BASED_GEOLOCATION)
     OwnPtr<GeolocationService> m_service;
 #endif
index cbfc2bb..1f5a39f 100644 (file)
 namespace WebCore {
 
 History::History(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-Frame* History::frame() const
-{
-    return m_frame;
-}
-
-void History::disconnectFrame()
-{
-    m_frame = 0;
-}
-
 unsigned History::length() const
 {
     if (!m_frame)
index 9ec1914..bd50fcc 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef History_h
 #define History_h
 
+#include "DOMWindowProperty.h"
 #include "KURL.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
@@ -38,12 +39,9 @@ class ScriptExecutionContext;
 class SerializedScriptValue;
 typedef int ExceptionCode;
 
-class History : public RefCounted<History> {
+class History : public RefCounted<History>, public DOMWindowProperty {
 public:
     static PassRefPtr<History> create(Frame* frame) { return adoptRef(new History(frame)); }
-    
-    Frame* frame() const;
-    void disconnectFrame();
 
     unsigned length() const;
     void back();
@@ -61,11 +59,9 @@ public:
     void stateObjectAdded(PassRefPtr<SerializedScriptValue>, const String& title, const String& url, StateObjectType, ExceptionCode&);
 
 private:
-    History(Frame*);
+    explicit History(Frame*);
 
     KURL urlForState(const String& url);
-
-    Frame* m_frame;
 };
 
 } // namespace WebCore
index ca6f998..1a2d2db 100644 (file)
 namespace WebCore {
 
 Location::Location(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-void Location::disconnectFrame()
-{
-    m_frame = 0;
-}
-
 inline const KURL& Location::url() const
 {
     ASSERT(m_frame);
index 3a1047a..b882671 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef Location_h
 #define Location_h
 
+#include "DOMWindowProperty.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
@@ -41,13 +42,10 @@ class KURL;
 
 typedef int ExceptionCode;
 
-class Location : public RefCounted<Location> {
+class Location : public RefCounted<Location>, public DOMWindowProperty {
 public:
     static PassRefPtr<Location> create(Frame* frame) { return adoptRef(new Location(frame)); }
 
-    Frame* frame() const { return m_frame; }
-    void disconnectFrame();
-
     void setHref(const String&, DOMWindow* activeWindow, DOMWindow* firstWindow);
     String href() const;
 
@@ -74,11 +72,9 @@ public:
     String toString() const { return href(); }
 
 private:
-    Location(Frame*);
+    explicit Location(Frame*);
 
     const KURL& url() const;
-
-    Frame* m_frame;
 };
 
 } // namespace WebCore
index 4926632..c35e994 100644 (file)
 namespace WebCore {
 
 Navigator::Navigator(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
 Navigator::~Navigator()
 {
-    disconnectFrame();
 }
 
 void Navigator::resetGeolocation()
@@ -74,23 +73,6 @@ void Navigator::resetGeolocation()
         m_geolocation->reset();
 }
 
-void Navigator::disconnectFrame()
-{
-    if (m_plugins) {
-        m_plugins->disconnectFrame();
-        m_plugins = 0;
-    }
-    if (m_mimeTypes) {
-        m_mimeTypes->disconnectFrame();
-        m_mimeTypes = 0;
-    }
-    if (m_geolocation) {
-        m_geolocation->disconnectFrame();
-        m_geolocation = 0;
-    }
-    m_frame = 0;
-}
-
 // If this function returns true, we need to hide the substring "4." that would otherwise
 // appear in the appVersion string. This is to avoid problems with old versions of a
 // library called OpenCube QuickMenu, which as of this writing is still being used on
index 84f30bd..07c9d2b 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef Navigator_h
 #define Navigator_h
 
+#include "DOMWindowProperty.h"
 #include "NavigatorBase.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
@@ -40,14 +41,12 @@ class PluginData;
 
 typedef int ExceptionCode;
 
-class Navigator : public NavigatorBase, public RefCounted<Navigator> {
+class Navigator : public NavigatorBase, public RefCounted<Navigator>, public DOMWindowProperty {
 public:
     static PassRefPtr<Navigator> create(Frame* frame) { return adoptRef(new Navigator(frame)); }
     virtual ~Navigator();
 
     void resetGeolocation();
-    void disconnectFrame();
-    Frame* frame() const { return m_frame; }
 
     String appVersion() const;
     String language() const;
@@ -81,8 +80,8 @@ public:
 #endif
 
 private:
-    Navigator(Frame*);
-    Frame* m_frame;
+    explicit Navigator(Frame*);
+
     mutable RefPtr<DOMPluginArray> m_plugins;
     mutable RefPtr<DOMMimeTypeArray> m_mimeTypes;
     mutable RefPtr<Geolocation> m_geolocation;
index 4e130ea..36ddcd2 100644 (file)
 namespace WebCore {
 
 Performance::Performance(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-Frame* Performance::frame() const
+PassRefPtr<MemoryInfo> Performance::memory() const
 {
-    return m_frame;
-}
-
-void Performance::disconnectFrame()
-{
-    if (m_memory)
-        m_memory = 0;
-    if (m_navigation) {
-        m_navigation->disconnectFrame();
-        m_navigation = 0;
-    }
-    if (m_timing) {
-        m_timing->disconnectFrame();
-        m_timing = 0;
-    }
-    m_frame = 0;
-}
-
-MemoryInfo* Performance::memory() const
-{
-    m_memory = MemoryInfo::create(m_frame);
-    return m_memory.get();
+    return MemoryInfo::create(m_frame);
 }
 
 PerformanceNavigation* Performance::navigation() const
index be9e124..7826360 100644 (file)
@@ -33,6 +33,7 @@
 
 #if ENABLE(WEB_TIMING)
 
+#include "DOMWindowProperty.h"
 #include "MemoryInfo.h"
 #include "PerformanceNavigation.h"
 #include "PerformanceTiming.h"
 
 namespace WebCore {
 
-class Performance : public RefCounted<Performance> {
+class Performance : public RefCounted<Performance>, public DOMWindowProperty {
 public:
     static PassRefPtr<Performance> create(Frame* frame) { return adoptRef(new Performance(frame)); }
 
-    Frame* frame() const;
-    void disconnectFrame();
-
-    MemoryInfo* memory() const;
+    PassRefPtr<MemoryInfo> memory() const;
     PerformanceNavigation* navigation() const;
     PerformanceTiming* timing() const;
 
 private:
-    Performance(Frame*);
+    explicit Performance(Frame*);
 
-    mutable RefPtr<MemoryInfo> m_memory;
     mutable RefPtr<PerformanceNavigation> m_navigation;
     mutable RefPtr<PerformanceTiming> m_timing;
-    Frame* m_frame;
 };
 
 }
 
-#endif // !ENABLE(WEB_TIMING)
-#endif // !defined(Performance_h)
+#endif // ENABLE(WEB_TIMING)
+
+#endif // Performance_h
index 663e942..d764b62 100644 (file)
 namespace WebCore {
 
 PerformanceNavigation::PerformanceNavigation(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-Frame* PerformanceNavigation::frame() const
-{
-    return m_frame;
-}
-
-void PerformanceNavigation::disconnectFrame()
-{
-    m_frame = 0;
-}
-
 unsigned short PerformanceNavigation::type() const
 {
     if (!m_frame)
index bdf6eaa..f397923 100644 (file)
@@ -33,6 +33,7 @@
 
 #if ENABLE(WEB_TIMING)
 
+#include "DOMWindowProperty.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -40,13 +41,10 @@ namespace WebCore {
 
 class Frame;
 
-class PerformanceNavigation : public RefCounted<PerformanceNavigation> {
+class PerformanceNavigation : public RefCounted<PerformanceNavigation>, public DOMWindowProperty {
 public:
     static PassRefPtr<PerformanceNavigation> create(Frame* frame) { return adoptRef(new PerformanceNavigation(frame)); }
 
-    Frame* frame() const;
-    void disconnectFrame();
-
     enum PerformanceNavigationType {
         TYPE_NAVIGATE,
         TYPE_RELOAD,
@@ -58,9 +56,7 @@ public:
     unsigned short redirectCount() const;
 
 private:
-    PerformanceNavigation(Frame*);
-
-    Frame* m_frame;
+    explicit PerformanceNavigation(Frame*);
 };
 
 }
index bdce07e..6a4524b 100644 (file)
@@ -51,20 +51,10 @@ static unsigned long long toIntegerMilliseconds(double seconds)
 }
 
 PerformanceTiming::PerformanceTiming(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-Frame* PerformanceTiming::frame() const
-{
-    return m_frame;
-}
-
-void PerformanceTiming::disconnectFrame()
-{
-    m_frame = 0;
-}
-
 unsigned long long PerformanceTiming::navigationStart() const
 {
     DocumentLoadTiming* timing = documentLoadTiming();
index 52abd55..30b80b9 100644 (file)
@@ -33,6 +33,7 @@
 
 #if ENABLE(WEB_TIMING)
 
+#include "DOMWindowProperty.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -44,13 +45,10 @@ struct DocumentTiming;
 class Frame;
 class ResourceLoadTiming;
 
-class PerformanceTiming : public RefCounted<PerformanceTiming> {
+class PerformanceTiming : public RefCounted<PerformanceTiming>, public DOMWindowProperty {
 public:
     static PassRefPtr<PerformanceTiming> create(Frame* frame) { return adoptRef(new PerformanceTiming(frame)); }
 
-    Frame* frame() const;
-    void disconnectFrame();
-
     unsigned long long navigationStart() const;
     unsigned long long unloadEventStart() const;
     unsigned long long unloadEventEnd() const;
@@ -74,7 +72,7 @@ public:
     unsigned long long loadEventEnd() const;
 
 private:
-    PerformanceTiming(Frame*);
+    explicit PerformanceTiming(Frame*);
 
     const DocumentTiming* documentTiming() const;
     DocumentLoader* documentLoader() const;
@@ -82,8 +80,6 @@ private:
     ResourceLoadTiming* resourceLoadTiming() const;
     unsigned long long resourceLoadTimeRelativeToAbsolute(int) const;
     unsigned long long monotonicTimeToIntegerMilliseconds(double) const;
-
-    Frame* m_frame;
 };
 
 }
index df88fa4..b021e5f 100644 (file)
 namespace WebCore {
 
 Screen::Screen(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
-Frame* Screen::frame() const
-{
-    return m_frame;
-}
-
-void Screen::disconnectFrame()
-{
-    m_frame = 0;
-}
-
 unsigned Screen::horizontalDPI() const
 {
     if (!m_frame)
index d084db7..2624f1a 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef Screen_h
 #define Screen_h
 
+#include "DOMWindowProperty.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -37,13 +38,10 @@ namespace WebCore {
 
     class Frame;
 
-    class Screen : public RefCounted<Screen> {
+    class Screen : public RefCounted<Screen>, public DOMWindowProperty {
     public:
         static PassRefPtr<Screen> create(Frame *frame) { return adoptRef(new Screen(frame)); }
 
-        Frame* frame() const;
-        void disconnectFrame();
-
         unsigned horizontalDPI() const;
         unsigned verticalDPI() const;
         unsigned height() const;
@@ -56,9 +54,7 @@ namespace WebCore {
         unsigned availWidth() const;
 
     private:
-        Screen(Frame*);
-        
-        Frame* m_frame;
+        explicit Screen(Frame*);
     };
 
 } // namespace WebCore
index 82d4006..d39e9f1 100644 (file)
@@ -29,7 +29,7 @@
 namespace WebCore {
 
 DOMMimeTypeArray::DOMMimeTypeArray(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
index 54fff7b..25c276d 100644 (file)
@@ -22,6 +22,7 @@
 #define DOMMimeTypeArray_h
 
 #include "DOMMimeType.h"
+#include "DOMWindowProperty.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -32,24 +33,19 @@ namespace WebCore {
 class Frame;
 class PluginData;
 
-class DOMMimeTypeArray : public RefCounted<DOMMimeTypeArray> {
+class DOMMimeTypeArray : public RefCounted<DOMMimeTypeArray>, public DOMWindowProperty {
 public:
     static PassRefPtr<DOMMimeTypeArray> create(Frame* frame) { return adoptRef(new DOMMimeTypeArray(frame)); }
     ~DOMMimeTypeArray();
 
-    Frame* frame() { return m_frame; }
-    void disconnectFrame() { m_frame = 0; }
-
     unsigned length() const;
     PassRefPtr<DOMMimeType> item(unsigned index);
     bool canGetItemsForName(const AtomicString& propertyName);
     PassRefPtr<DOMMimeType> namedItem(const AtomicString& propertyName);
 
 private:
-    DOMMimeTypeArray(Frame*);
+    explicit DOMMimeTypeArray(Frame*);
     PluginData* getPluginData() const;
-
-    Frame* m_frame;
 };
 
 } // namespace WebCore
index 766c3eb..c8a53a5 100644 (file)
@@ -29,7 +29,7 @@
 namespace WebCore {
 
 DOMPluginArray::DOMPluginArray(Frame* frame)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
 {
 }
 
index 0b1f2ba..6c35457 100644 (file)
@@ -22,6 +22,7 @@
 #define DOMPluginArray_h
 
 #include "DOMPlugin.h"
+#include "DOMWindowProperty.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -32,14 +33,11 @@ namespace WebCore {
 class Frame;
 class PluginData;
 
-class DOMPluginArray : public RefCounted<DOMPluginArray> {
+class DOMPluginArray : public RefCounted<DOMPluginArray>, public DOMWindowProperty {
 public:
     static PassRefPtr<DOMPluginArray> create(Frame* frame) { return adoptRef(new DOMPluginArray(frame)); }
     ~DOMPluginArray();
 
-    Frame* frame() { return m_frame; }
-    void disconnectFrame() { m_frame = 0; }
-
     unsigned length() const;
     PassRefPtr<DOMPlugin> item(unsigned index);
     bool canGetItemsForName(const AtomicString& propertyName);
@@ -48,10 +46,8 @@ public:
     void refresh(bool reload);
 
 private:
-    DOMPluginArray(Frame*);
+    explicit DOMPluginArray(Frame*);
     PluginData* pluginData() const;
-
-    Frame* m_frame;
 };
 
 } // namespace WebCore
index 5ba4602..260ef4f 100644 (file)
@@ -41,7 +41,7 @@ PassRefPtr<Storage> Storage::create(Frame* frame, PassRefPtr<StorageArea> storag
 }
 
 Storage::Storage(Frame* frame, PassRefPtr<StorageArea> storageArea)
-    : m_frame(frame)
+    : DOMWindowProperty(frame)
     , m_storageArea(storageArea)
 {
     ASSERT(m_frame);
index 219bc55..98f041e 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef Storage_h
 #define Storage_h
 
+#include "DOMWindowProperty.h"
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -36,7 +37,7 @@ namespace WebCore {
     class StorageArea;
     typedef int ExceptionCode;
 
-    class Storage : public RefCounted<Storage> {
+    class Storage : public RefCounted<Storage>, public DOMWindowProperty {
     public:
         static PassRefPtr<Storage> create(Frame*, PassRefPtr<StorageArea>);
         ~Storage();
@@ -50,13 +51,9 @@ namespace WebCore {
 
         bool contains(const String& key) const;
 
-        Frame* frame() { return m_frame; }
-        void disconnectFrame() { m_frame = 0; }
-
     private:
         Storage(Frame*, PassRefPtr<StorageArea>);
 
-        Frame* m_frame;
         RefPtr<StorageArea> m_storageArea;
     };