Commit 84fe60e1 authored by abarth@webkit.org's avatar 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:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 42bd431b
......@@ -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
......
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
......@@ -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 \
......
......@@ -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 \
......
......@@ -2991,6 +2991,8 @@
'page/DOMTimer.cpp',
'page/DOMTimer.h',
'page/DOMWindow.cpp',
'page/DOMWindowProperty.cpp',
'page/DOMWindowProperty.h',
'page/DragController.cpp',
'page/EventHandler.cpp',
'page/EventSource.cpp',
......
......@@ -25185,6 +25185,14 @@
RelativePath="..\page\DOMWindow.h"
>
</File>
<File
RelativePath="..\page\DOMWindowProperty.cpp"
>
</File>
<File
RelativePath="..\page\DOMWindowProperty.h"
>
</File>
<File
RelativePath="..\page\DragActions.h"
>
......@@ -3369,6 +3369,8 @@
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 */; };
......@@ -10629,6 +10631,8 @@
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>"; };
......@@ -15653,6 +15657,8 @@
1403B99609EB13AF00797C7F /* DOMWindow.cpp */,
1403B99509EB13AF00797C7F /* DOMWindow.h */,
1403B90C09EB124500797C7F /* DOMWindow.idl */,
97D2AD0114B823A60093DF32 /* DOMWindowProperty.cpp */,
97D2AD0214B823A60093DF32 /* DOMWindowProperty.h */,
A718760D0B2A120100A16ECE /* DragActions.h */,
A7CA59620B27C1F200FA021D /* DragClient.h */,
A7CA595C0B27BD9E00FA021D /* DragController.cpp */,
......@@ -24883,6 +24889,7 @@
977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
FD537353137B651800008DCE /* ZeroPole.h in Headers */,
974A862314B7ADBB003FDC76 /* FrameDestructionObserver.h in Headers */,
97D2AD0414B823A60093DF32 /* DOMWindowProperty.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -27787,6 +27794,7 @@
977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
974A862214B7ADBB003FDC76 /* FrameDestructionObserver.cpp in Sources */,
97D2AD0314B823A60093DF32 /* DOMWindowProperty.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -36,7 +36,7 @@
namespace WebCore {
StyleMedia::StyleMedia(Frame* frame)
: m_frame(frame)
: DOMWindowProperty(frame)
{
}
......
......@@ -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
......
......@@ -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
......
......@@ -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;
};
......
......@@ -36,21 +36,11 @@
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;
......
......@@ -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;
};
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
/*
* 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;
}
}
/*
* Copyright (C) 2011 Google, Inc. All Rights Reserved.