Commit 965cf1c3 authored by andersca@apple.com's avatar andersca@apple.com

Reviewed by Darin.

        Change all refcounted classes in page/ to start with a refcount of 1.

        * page/BarInfo.cpp:
        (WebCore::BarInfo::BarInfo):
        * page/BarInfo.h:
        (WebCore::BarInfo::create):
        * page/Console.cpp:
        (WebCore::Console::Console):
        * page/Console.h:
        (WebCore::Console::create):
        * page/DOMSelection.cpp:
        (WebCore::DOMSelection::DOMSelection):
        * page/DOMSelection.h:
        (WebCore::DOMSelection::create):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::DOMWindow):
        (WebCore::DOMWindow::screen):
        (WebCore::DOMWindow::history):
        (WebCore::DOMWindow::locationbar):
        (WebCore::DOMWindow::menubar):
        (WebCore::DOMWindow::personalbar):
        (WebCore::DOMWindow::scrollbars):
        (WebCore::DOMWindow::statusbar):
        (WebCore::DOMWindow::toolbar):
        (WebCore::DOMWindow::console):
        (WebCore::DOMWindow::getSelection):
        * page/DOMWindow.h:
        (WebCore::DOMWindow::create):
        * page/Frame.cpp:
        (WebCore::Frame::domWindow):
        * page/History.cpp:
        (WebCore::History::History):
        * page/History.h:
        (WebCore::History::create):
        * page/InspectorController.cpp:
        (WebCore::InspectorResource::create):
        (WebCore::InspectorResource::InspectorResource):
        (WebCore::InspectorDatabaseResource::create):
        (WebCore::InspectorDatabaseResource::InspectorDatabaseResource):
        (WebCore::InspectorController::didLoadResourceFromMemoryCache):
        (WebCore::InspectorController::identifierForInitialRequest):
        (WebCore::InspectorController::didOpenDatabase):
        * page/Plugin.h:
        (WebCore::Plugin::create):
        (WebCore::Plugin::Plugin):
        * page/Screen.cpp:
        (WebCore::Screen::Screen):
        * page/Screen.h:
        (WebCore::Screen::create):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30434 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 04346b10
2008-02-20 Anders Carlsson <andersca@apple.com>
Reviewed by Darin.
Change all refcounted classes in page/ to start with a refcount of 1.
* page/BarInfo.cpp:
(WebCore::BarInfo::BarInfo):
* page/BarInfo.h:
(WebCore::BarInfo::create):
* page/Console.cpp:
(WebCore::Console::Console):
* page/Console.h:
(WebCore::Console::create):
* page/DOMSelection.cpp:
(WebCore::DOMSelection::DOMSelection):
* page/DOMSelection.h:
(WebCore::DOMSelection::create):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::DOMWindow):
(WebCore::DOMWindow::screen):
(WebCore::DOMWindow::history):
(WebCore::DOMWindow::locationbar):
(WebCore::DOMWindow::menubar):
(WebCore::DOMWindow::personalbar):
(WebCore::DOMWindow::scrollbars):
(WebCore::DOMWindow::statusbar):
(WebCore::DOMWindow::toolbar):
(WebCore::DOMWindow::console):
(WebCore::DOMWindow::getSelection):
* page/DOMWindow.h:
(WebCore::DOMWindow::create):
* page/Frame.cpp:
(WebCore::Frame::domWindow):
* page/History.cpp:
(WebCore::History::History):
* page/History.h:
(WebCore::History::create):
* page/InspectorController.cpp:
(WebCore::InspectorResource::create):
(WebCore::InspectorResource::InspectorResource):
(WebCore::InspectorDatabaseResource::create):
(WebCore::InspectorDatabaseResource::InspectorDatabaseResource):
(WebCore::InspectorController::didLoadResourceFromMemoryCache):
(WebCore::InspectorController::identifierForInitialRequest):
(WebCore::InspectorController::didOpenDatabase):
* page/Plugin.h:
(WebCore::Plugin::create):
(WebCore::Plugin::Plugin):
* page/Screen.cpp:
(WebCore::Screen::Screen):
* page/Screen.h:
(WebCore::Screen::create):
2008-02-20 Sam Weinig <sam@webkit.org>
Reviewed by Darin and Geoff.
......@@ -36,8 +36,7 @@
namespace WebCore {
BarInfo::BarInfo(Frame* frame, Type type)
: RefCounted<BarInfo>(0)
, m_frame(frame)
: m_frame(frame)
, m_type(type)
{
}
......
......@@ -29,6 +29,7 @@
#ifndef BarInfo_h
#define BarInfo_h
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
......@@ -38,13 +39,15 @@ namespace WebCore {
class BarInfo : public RefCounted<BarInfo> {
public:
enum Type { Locationbar, Menubar, Personalbar, Scrollbars, Statusbar, Toolbar };
BarInfo(Frame*, Type);
static PassRefPtr<BarInfo> create(Frame* frame, Type type) { return adoptRef(new BarInfo(frame, type)); }
void disconnectFrame();
bool visible() const;
private:
BarInfo(Frame*, Type);
Frame* m_frame;
Type m_type;
};
......
......@@ -38,8 +38,7 @@
namespace WebCore {
Console::Console(Frame* frame)
: RefCounted<Console>(0)
, m_frame(frame)
: m_frame(frame)
{
}
......
......@@ -38,7 +38,8 @@ namespace WebCore {
class Console : public RefCounted<Console> {
public:
Console(Frame*);
static PassRefPtr<Console> create(Frame* frame) { return adoptRef(new Console(frame)); }
void disconnectFrame();
void error(const String& message);
......@@ -47,6 +48,8 @@ namespace WebCore {
void warn(const String& message);
private:
Console(Frame*);
Frame* m_frame;
};
......
......@@ -42,8 +42,7 @@
namespace WebCore {
DOMSelection::DOMSelection(Frame* frame)
: RefCounted<DOMSelection>(0)
, m_frame(frame)
: m_frame(frame)
{
}
......
......@@ -45,7 +45,7 @@ namespace WebCore {
class DOMSelection : public RefCounted<DOMSelection> {
public:
DOMSelection(Frame*);
static PassRefPtr<DOMSelection> create(Frame* frame) { return adoptRef(new DOMSelection(frame)); }
Frame* frame() const;
void disconnectFrame();
......@@ -92,6 +92,8 @@ namespace WebCore {
//TextRange *createRange();
private:
DOMSelection(Frame*);
Frame* m_frame;
};
......
......@@ -99,8 +99,7 @@ void DOMWindow::adjustWindowRect(const FloatRect& screen, FloatRect& window, con
}
DOMWindow::DOMWindow(Frame* frame)
: RefCounted<DOMWindow>(0)
, m_frame(frame)
: m_frame(frame)
{
}
......@@ -160,63 +159,63 @@ void DOMWindow::clear()
Screen* DOMWindow::screen() const
{
if (!m_screen)
m_screen = new Screen(m_frame);
m_screen = Screen::create(m_frame);
return m_screen.get();
}
History* DOMWindow::history() const
{
if (!m_history)
m_history = new History(m_frame);
m_history = History::create(m_frame);
return m_history.get();
}
BarInfo* DOMWindow::locationbar() const
{
if (!m_locationbar)
m_locationbar = new BarInfo(m_frame, BarInfo::Locationbar);
m_locationbar = BarInfo::create(m_frame, BarInfo::Locationbar);
return m_locationbar.get();
}
BarInfo* DOMWindow::menubar() const
{
if (!m_menubar)
m_menubar = new BarInfo(m_frame, BarInfo::Menubar);
m_menubar = BarInfo::create(m_frame, BarInfo::Menubar);
return m_menubar.get();
}
BarInfo* DOMWindow::personalbar() const
{
if (!m_personalbar)
m_personalbar = new BarInfo(m_frame, BarInfo::Personalbar);
m_personalbar = BarInfo::create(m_frame, BarInfo::Personalbar);
return m_personalbar.get();
}
BarInfo* DOMWindow::scrollbars() const
{
if (!m_scrollbars)
m_scrollbars = new BarInfo(m_frame, BarInfo::Scrollbars);
m_scrollbars = BarInfo::create(m_frame, BarInfo::Scrollbars);
return m_scrollbars.get();
}
BarInfo* DOMWindow::statusbar() const
{
if (!m_statusbar)
m_statusbar = new BarInfo(m_frame, BarInfo::Statusbar);
m_statusbar = BarInfo::create(m_frame, BarInfo::Statusbar);
return m_statusbar.get();
}
BarInfo* DOMWindow::toolbar() const
{
if (!m_toolbar)
m_toolbar = new BarInfo(m_frame, BarInfo::Toolbar);
m_toolbar = BarInfo::create(m_frame, BarInfo::Toolbar);
return m_toolbar.get();
}
Console* DOMWindow::console() const
{
if (!m_console)
m_console = new Console(m_frame);
m_console = Console::create(m_frame);
return m_console.get();
}
......@@ -231,7 +230,7 @@ void DOMWindow::postMessage(const String& message, const String& domain, const S
DOMSelection* DOMWindow::getSelection()
{
if (!m_selection)
m_selection = new DOMSelection(m_frame);
m_selection = DOMSelection::create(m_frame);
return m_selection.get();
}
......
......@@ -50,7 +50,7 @@ namespace WebCore {
class DOMWindow : public RefCounted<DOMWindow> {
public:
DOMWindow(Frame*);
static PassRefPtr<DOMWindow> create(Frame* frame) { return adoptRef(new DOMWindow(frame)); }
virtual ~DOMWindow();
Frame* frame() { return m_frame; }
......@@ -157,6 +157,8 @@ namespace WebCore {
void resizeTo(float width, float height) const;
private:
DOMWindow(Frame*);
Frame* m_frame;
mutable RefPtr<Screen> m_screen;
mutable RefPtr<DOMSelection> m_selection;
......
......@@ -1644,7 +1644,7 @@ FrameTree* Frame::tree() const
DOMWindow* Frame::domWindow() const
{
if (!d->m_domWindow)
d->m_domWindow = new DOMWindow(const_cast<Frame*>(this));
d->m_domWindow = DOMWindow::create(const_cast<Frame*>(this));
return d->m_domWindow.get();
}
......
......@@ -32,8 +32,7 @@
namespace WebCore {
History::History(Frame* frame)
: RefCounted<History>(0)
, m_frame(frame)
: m_frame(frame)
{
}
......
......@@ -26,6 +26,7 @@
#ifndef History_h
#define History_h
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
......@@ -34,8 +35,8 @@ namespace WebCore {
class History : public RefCounted<History> {
public:
History(Frame*);
static PassRefPtr<History> create(Frame* frame) { return adoptRef(new History(frame)); }
Frame* frame() const;
void disconnectFrame();
......@@ -45,6 +46,8 @@ namespace WebCore {
void go(int distance);
private:
History(Frame*);
Frame* m_frame;
};
......
......@@ -115,25 +115,11 @@ struct InspectorResource : public RefCounted<InspectorResource> {
Other
};
InspectorResource(long long identifier, DocumentLoader* documentLoader, Frame* frame)
: RefCounted<InspectorResource>(0)
, identifier(identifier)
, loader(documentLoader)
, frame(frame)
, scriptContext(0)
, scriptObject(0)
, expectedContentLength(0)
, cached(false)
, finished(false)
, failed(false)
, length(0)
, responseStatusCode(0)
, startTime(-1.0)
, responseReceivedTime(-1.0)
, endTime(-1.0)
static PassRefPtr<InspectorResource> create(long long identifier, DocumentLoader* documentLoader, Frame* frame)
{
return adoptRef(new InspectorResource(identifier, documentLoader, frame));
}
~InspectorResource()
{
setScriptObject(0, 0);
......@@ -200,6 +186,25 @@ struct InspectorResource : public RefCounted<InspectorResource> {
double startTime;
double responseReceivedTime;
double endTime;
private:
InspectorResource(long long identifier, DocumentLoader* documentLoader, Frame* frame)
: identifier(identifier)
, loader(documentLoader)
, frame(frame)
, scriptContext(0)
, scriptObject(0)
, expectedContentLength(0)
, cached(false)
, finished(false)
, failed(false)
, length(0)
, responseStatusCode(0)
, startTime(-1.0)
, responseReceivedTime(-1.0)
, endTime(-1.0)
{
}
};
#pragma mark -
......@@ -207,21 +212,9 @@ struct InspectorResource : public RefCounted<InspectorResource> {
#if ENABLE(DATABASE)
struct InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> {
InspectorDatabaseResource(Database* database, String domain, String name, String version)
: RefCounted<InspectorDatabaseResource>(0)
, database(database)
, domain(domain)
, name(name)
, version(version)
, scriptContext(0)
, scriptObject(0)
static PassRefPtr<InspectorDatabaseResource> create(Database* database, const String& domain, const String& name, const String& version)
{
}
InspectorDatabaseResource()
: RefCounted<InspectorDatabaseResource>(0)
{
setScriptObject(0, 0);
return adoptRef(new InspectorDatabaseResource(database, domain, name, version));
}
void setScriptObject(JSContextRef context, JSObjectRef newScriptObject)
......@@ -243,6 +236,17 @@ struct InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource>
String version;
JSContextRef scriptContext;
JSObjectRef scriptObject;
private:
InspectorDatabaseResource(Database* database, const String& domain, const String& name, const String& version)
: database(database)
, domain(domain)
, name(name)
, version(version)
, scriptContext(0)
, scriptObject(0)
{
}
};
#endif
......@@ -1424,11 +1428,11 @@ void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader,
if (!enabled())
return;
InspectorResource* resource = new InspectorResource(m_nextIdentifier--, loader, loader->frame());
RefPtr<InspectorResource> resource = InspectorResource::create(m_nextIdentifier--, loader, loader->frame());
resource->finished = true;
updateResourceRequest(resource, request);
updateResourceResponse(resource, response);
updateResourceRequest(resource.get(), request);
updateResourceResponse(resource.get(), response);
resource->length = length;
resource->cached = true;
......@@ -1439,10 +1443,10 @@ void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader,
if (loader->frame() == m_inspectedPage->mainFrame() && request.url() == loader->requestURL())
m_mainResource = resource;
addResource(resource);
addResource(resource.get());
if (windowVisible())
addAndUpdateScriptResource(resource);
addAndUpdateScriptResource(resource.get());
}
void InspectorController::identifierForInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
......@@ -1450,17 +1454,17 @@ void InspectorController::identifierForInitialRequest(unsigned long identifier,
if (!enabled())
return;
InspectorResource* resource = new InspectorResource(identifier, loader, loader->frame());
RefPtr<InspectorResource> resource = InspectorResource::create(identifier, loader, loader->frame());
updateResourceRequest(resource, request);
updateResourceRequest(resource.get(), request);
if (loader->frame() == m_inspectedPage->mainFrame() && request.url() == loader->requestURL())
m_mainResource = resource;
addResource(resource);
addResource(resource.get());
if (windowVisible() && loader->isLoadingFromCachedPage() && resource == m_mainResource)
addAndUpdateScriptResource(resource);
addAndUpdateScriptResource(resource.get());
}
void InspectorController::willSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
......@@ -1577,12 +1581,12 @@ void InspectorController::didOpenDatabase(Database* database, const String& doma
if (!enabled())
return;
InspectorDatabaseResource* resource = new InspectorDatabaseResource(database, domain, name, version);
RefPtr<InspectorDatabaseResource> resource = InspectorDatabaseResource::create(database, domain, name, version);
m_databaseResources.add(resource);
if (windowVisible())
addDatabaseScriptResource(resource);
addDatabaseScriptResource(resource.get());
}
#endif
......
......@@ -29,10 +29,11 @@ namespace WebCore {
class Plugin : public RefCounted<Plugin> {
public:
Plugin(Widget* view) : RefCounted<Plugin>(0), m_view(view) { }
static PassRefPtr<Plugin> create(Widget* view) { return adoptRef(new Plugin(view)); }
Widget* view() const { return m_view; }
private:
Plugin(Widget* view) : m_view(view) { }
Widget* m_view;
};
......
......@@ -39,8 +39,7 @@
namespace WebCore {
Screen::Screen(Frame* frame)
: RefCounted<Screen>(0)
, m_frame(frame)
: m_frame(frame)
{
}
......
......@@ -30,6 +30,7 @@
#ifndef Screen_h
#define Screen_h
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
......@@ -38,7 +39,7 @@ namespace WebCore {
class Screen : public RefCounted<Screen> {
public:
Screen(Frame*);
static PassRefPtr<Screen> create(Frame *frame) { return adoptRef(new Screen(frame)); }
void disconnectFrame();
unsigned height() const;
......@@ -51,6 +52,8 @@ namespace WebCore {
unsigned availWidth() const;
private:
Screen(Frame*);
Frame* m_frame;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment