Change adoptPtr(new ...) to ...::create in Page.cpp

https://bugs.webkit.org/show_bug.cgi?id=74457

Patch by Greg Billock <gbillock@google.com> on 2011-12-20
Reviewed by Darin Adler.

* dom/DeviceMotionController.cpp:
(WebCore::DeviceMotionController::create):
* dom/DeviceMotionController.h:
* dom/DeviceOrientationController.cpp:
(WebCore::DeviceOrientationController::create):
* dom/DeviceOrientationController.h:
* editing/FrameSelection.cpp:
(WebCore::DragCaretController::create):
* editing/FrameSelection.h:
* history/BackForwardController.cpp:
(WebCore::BackForwardController::create):
* history/BackForwardController.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::create):
* inspector/InspectorController.h:
* loader/ProgressTracker.cpp:
(WebCore::ProgressTracker::create):
* loader/ProgressTracker.h:
* notifications/NotificationController.cpp:
(WebCore::NotificationController::create):
* notifications/NotificationController.h:
* page/Chrome.cpp:
(WebCore::Chrome::create):
* page/Chrome.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::create):
* page/ContextMenuController.h:
* page/DragController.cpp:
(WebCore::DragController::create):
* page/DragController.h:
* page/FocusController.cpp:
(WebCore::FocusController::create):
* page/FocusController.h:
* page/GeolocationController.cpp:
(WebCore::GeolocationController::create):
* page/GeolocationController.h:
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::initGroup):
(WebCore::Page::speechInput):
* page/PageGroup.cpp:
(WebCore::PageGroup::create):
* page/PageGroup.h:
* page/Settings.cpp:
(WebCore::Settings::create):
* page/Settings.h:
* page/SpeechInput.cpp:
(WebCore::SpeechInput::create):
* page/SpeechInput.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@103365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 36a5132c
2011-12-20 Greg Billock <gbillock@google.com>
Change adoptPtr(new ...) to ...::create in Page.cpp
https://bugs.webkit.org/show_bug.cgi?id=74457
Reviewed by Darin Adler.
* dom/DeviceMotionController.cpp:
(WebCore::DeviceMotionController::create):
* dom/DeviceMotionController.h:
* dom/DeviceOrientationController.cpp:
(WebCore::DeviceOrientationController::create):
* dom/DeviceOrientationController.h:
* editing/FrameSelection.cpp:
(WebCore::DragCaretController::create):
* editing/FrameSelection.h:
* history/BackForwardController.cpp:
(WebCore::BackForwardController::create):
* history/BackForwardController.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::create):
* inspector/InspectorController.h:
* loader/ProgressTracker.cpp:
(WebCore::ProgressTracker::create):
* loader/ProgressTracker.h:
* notifications/NotificationController.cpp:
(WebCore::NotificationController::create):
* notifications/NotificationController.h:
* page/Chrome.cpp:
(WebCore::Chrome::create):
* page/Chrome.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::create):
* page/ContextMenuController.h:
* page/DragController.cpp:
(WebCore::DragController::create):
* page/DragController.h:
* page/FocusController.cpp:
(WebCore::FocusController::create):
* page/FocusController.h:
* page/GeolocationController.cpp:
(WebCore::GeolocationController::create):
* page/GeolocationController.h:
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::initGroup):
(WebCore::Page::speechInput):
* page/PageGroup.cpp:
(WebCore::PageGroup::create):
* page/PageGroup.h:
* page/Settings.cpp:
(WebCore::Settings::create):
* page/Settings.h:
* page/SpeechInput.cpp:
(WebCore::SpeechInput::create):
* page/SpeechInput.h:
2011-12-20 Ryosuke Niwa <rniwa@webkit.org>
Mac build fix after r103354.
......@@ -45,6 +45,11 @@ DeviceMotionController::~DeviceMotionController()
m_client->deviceMotionControllerDestroyed();
}
PassOwnPtr<DeviceMotionController> DeviceMotionController::create(DeviceMotionClient* client)
{
return adoptPtr(new DeviceMotionController(client));
}
void DeviceMotionController::timerFired(Timer<DeviceMotionController>* timer)
{
ASSERT_UNUSED(timer, timer == &m_timer);
......
......@@ -37,9 +37,10 @@ class DeviceMotionClient;
class DeviceMotionController {
public:
DeviceMotionController(DeviceMotionClient*);
~DeviceMotionController();
static PassOwnPtr<DeviceMotionController> create(DeviceMotionClient*);
void addListener(DOMWindow*);
void removeListener(DOMWindow*);
void removeAllListeners(DOMWindow*);
......@@ -52,6 +53,8 @@ public:
bool isActive() { return !m_listeners.isEmpty(); }
private:
DeviceMotionController(DeviceMotionClient*);
void timerFired(Timer<DeviceMotionController>*);
DeviceMotionClient* m_client;
......
......@@ -46,6 +46,11 @@ DeviceOrientationController::~DeviceOrientationController()
m_client->deviceOrientationControllerDestroyed();
}
PassOwnPtr<DeviceOrientationController> DeviceOrientationController::create(Page* page, DeviceOrientationClient* client)
{
return adoptPtr(new DeviceOrientationController(page, client));
}
void DeviceOrientationController::timerFired(Timer<DeviceOrientationController>* timer)
{
ASSERT_UNUSED(timer, timer == &m_timer);
......
......@@ -39,9 +39,10 @@ class Page;
class DeviceOrientationController {
public:
DeviceOrientationController(Page*, DeviceOrientationClient*);
~DeviceOrientationController();
static PassOwnPtr<DeviceOrientationController> create(Page*, DeviceOrientationClient*);
void addListener(DOMWindow*);
void removeListener(DOMWindow*);
void removeAllListeners(DOMWindow*);
......@@ -56,6 +57,8 @@ public:
DeviceOrientationClient* client() const { return m_client; }
private:
DeviceOrientationController(Page*, DeviceOrientationClient*);
void timerFired(Timer<DeviceOrientationController>*);
Page* m_page;
......
......@@ -90,6 +90,11 @@ DragCaretController::DragCaretController()
{
}
PassOwnPtr<DragCaretController> DragCaretController::create()
{
return adoptPtr(new DragCaretController);
}
bool DragCaretController::isContentRichlyEditable() const
{
return isRichlyEditablePosition(m_position.deepEquivalent());
......
......@@ -84,7 +84,7 @@ class DragCaretController : private CaretBase {
WTF_MAKE_NONCOPYABLE(DragCaretController);
WTF_MAKE_FAST_ALLOCATED;
public:
DragCaretController();
static PassOwnPtr<DragCaretController> create();
RenderObject* caretRenderer() const;
void paintDragCaret(Frame*, GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect) const;
......@@ -100,6 +100,8 @@ public:
void nodeWillBeRemoved(Node*);
private:
DragCaretController();
VisiblePosition m_position;
};
......@@ -331,4 +333,3 @@ void showTree(const WebCore::FrameSelection*);
#endif
#endif // FrameSelection_h
......@@ -44,6 +44,11 @@ BackForwardController::~BackForwardController()
{
}
PassOwnPtr<BackForwardController> BackForwardController::create(Page* page, PassRefPtr<BackForwardList> client)
{
return adoptPtr(new BackForwardController(page, client));
}
bool BackForwardController::canGoBackOrForward(int distance) const
{
return m_page->canGoBackOrForward(distance);
......
......@@ -39,9 +39,10 @@ class Page;
class BackForwardController {
WTF_MAKE_NONCOPYABLE(BackForwardController); WTF_MAKE_FAST_ALLOCATED;
public:
BackForwardController(Page*, PassRefPtr<BackForwardList>);
~BackForwardController();
static PassOwnPtr<BackForwardController> create(Page*, PassRefPtr<BackForwardList>);
BackForwardList* client() const { return m_client.get(); }
bool canGoBackOrForward(int distance) const;
......@@ -70,6 +71,8 @@ public:
void markPagesForFullStyleRecalc();
private:
BackForwardController(Page*, PassRefPtr<BackForwardList>);
Page* m_page;
RefPtr<BackForwardList> m_client;
};
......
......@@ -160,6 +160,11 @@ InspectorController::~InspectorController()
ASSERT(!m_inspectorClient);
}
PassOwnPtr<InspectorController> InspectorController::create(Page* page, InspectorClient* client)
{
return adoptPtr(new InspectorController(page, client));
}
void InspectorController::inspectedPageDestroyed()
{
disconnectFrontend();
......
......@@ -63,8 +63,10 @@ class InspectorController {
WTF_MAKE_NONCOPYABLE(InspectorController);
WTF_MAKE_FAST_ALLOCATED;
public:
InspectorController(Page*, InspectorClient*);
~InspectorController();
static PassOwnPtr<InspectorController> create(Page*, InspectorClient*);
void inspectedPageDestroyed();
bool enabled() const;
......@@ -104,6 +106,8 @@ public:
void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
private:
InspectorController(Page*, InspectorClient*);
friend class PostWorkerNotificationToFrontendTask;
friend InstrumentingAgents* instrumentationForPage(Page*);
......
......@@ -81,6 +81,11 @@ ProgressTracker::~ProgressTracker()
deleteAllValues(m_progressItems);
}
PassOwnPtr<ProgressTracker> ProgressTracker::create()
{
return adoptPtr(new ProgressTracker);
}
double ProgressTracker::estimatedProgress() const
{
return m_progressValue;
......
......@@ -26,6 +26,7 @@
#ifndef ProgressTracker_h
#define ProgressTracker_h
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
......@@ -39,9 +40,9 @@ struct ProgressItem;
class ProgressTracker {
WTF_MAKE_NONCOPYABLE(ProgressTracker); WTF_MAKE_FAST_ALLOCATED;
public:
ProgressTracker();
~ProgressTracker();
static PassOwnPtr<ProgressTracker> create();
static unsigned long createUniqueIdentifier();
double estimatedProgress() const;
......@@ -57,6 +58,8 @@ public:
long long totalBytesReceived() const { return m_totalBytesReceived; }
private:
ProgressTracker();
void reset();
void finalProgressComplete();
......
......@@ -29,6 +29,7 @@
#if ENABLE(NOTIFICATIONS)
#include "NotificationPresenter.h"
#include <wtf/PassOwnPtr.h>
namespace WebCore {
......@@ -42,6 +43,11 @@ NotificationController::~NotificationController()
{
}
PassOwnPtr<NotificationController> NotificationController::create(Page* page, NotificationPresenter* client)
{
return adoptPtr(new NotificationController(page, client));
}
} // namespace WebCore
#endif // ENABLE(NOTIFICATIONS)
......@@ -28,6 +28,7 @@
#if ENABLE(NOTIFICATIONS)
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
......@@ -38,12 +39,15 @@ class Page;
class NotificationController {
WTF_MAKE_NONCOPYABLE(NotificationController);
public:
NotificationController(Page*, NotificationPresenter*);
~NotificationController();
static PassOwnPtr<NotificationController> create(Page*, NotificationPresenter*);
NotificationPresenter* client() { return m_client; }
private:
NotificationController(Page*, NotificationPresenter*);
Page* m_page;
NotificationPresenter* m_client;
};
......
......@@ -71,6 +71,11 @@ Chrome::~Chrome()
m_client->chromeDestroyed();
}
PassOwnPtr<Chrome> Chrome::create(Page* page, ChromeClient* client)
{
return adoptPtr(new Chrome(page, client));
}
void Chrome::invalidateRootView(const IntRect& updateRect, bool immediate)
{
m_client->invalidateRootView(updateRect, immediate);
......
......@@ -60,9 +60,10 @@ namespace WebCore {
class Chrome : public HostWindow {
public:
Chrome(Page*, ChromeClient*);
~Chrome();
static PassOwnPtr<Chrome> create(Page*, ChromeClient*);
ChromeClient* client() { return m_client; }
// HostWindow methods.
......@@ -182,6 +183,8 @@ namespace WebCore {
#endif
private:
Chrome(Page*, ChromeClient*);
Page* m_page;
ChromeClient* m_client;
};
......
......@@ -87,6 +87,11 @@ ContextMenuController::~ContextMenuController()
m_client->contextMenuDestroyed();
}
PassOwnPtr<ContextMenuController> ContextMenuController::create(Page* page, ContextMenuClient* client)
{
return adoptPtr(new ContextMenuController(page, client));
}
void ContextMenuController::clearContextMenu()
{
m_contextMenu.clear();
......
......@@ -44,9 +44,10 @@ namespace WebCore {
class ContextMenuController {
WTF_MAKE_NONCOPYABLE(ContextMenuController); WTF_MAKE_FAST_ALLOCATED;
public:
ContextMenuController(Page*, ContextMenuClient*);
~ContextMenuController();
static PassOwnPtr<ContextMenuController> create(Page*, ContextMenuClient*);
ContextMenuClient* client() const { return m_client; }
ContextMenu* contextMenu() const { return m_contextMenu.get(); }
......@@ -65,6 +66,8 @@ namespace WebCore {
const HitTestResult& hitTestResult() { return m_hitTestResult; }
private:
ContextMenuController(Page*, ContextMenuClient*);
PassOwnPtr<ContextMenu> createContextMenu(Event*);
void showContextMenu(Event*);
......
......@@ -102,6 +102,11 @@ DragController::~DragController()
m_client->dragControllerDestroyed();
}
PassOwnPtr<DragController> DragController::create(Page* page, DragClient* client)
{
return adoptPtr(new DragController(page, client));
}
static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, Frame* frame, RefPtr<Range> context,
bool allowPlainText, bool& chosePlainText)
{
......
......@@ -53,8 +53,10 @@ namespace WebCore {
class DragController {
WTF_MAKE_NONCOPYABLE(DragController); WTF_MAKE_FAST_ALLOCATED;
public:
DragController(Page*, DragClient*);
~DragController();
static PassOwnPtr<DragController> create(Page*, DragClient*);
DragClient* client() const { return m_client; }
DragSession dragEntered(DragData*);
......@@ -93,6 +95,8 @@ namespace WebCore {
static const float DragImageAlpha;
private:
DragController(Page*, DragClient*);
bool dispatchTextInputEventFor(Frame*, DragData*);
bool canProcessDrag(DragData*);
bool concludeEditDrag(DragData*);
......
......@@ -91,6 +91,11 @@ FocusController::FocusController(Page* page)
{
}
PassOwnPtr<FocusController> FocusController::create(Page* page)
{
return adoptPtr(new FocusController(page));
}
void FocusController::setFocusedFrame(PassRefPtr<Frame> frame)
{
ASSERT(!frame || frame->page() == m_page);
......
......@@ -46,7 +46,7 @@ class TreeScope;
class FocusController {
WTF_MAKE_NONCOPYABLE(FocusController); WTF_MAKE_FAST_ALLOCATED;
public:
FocusController(Page*);
static PassOwnPtr<FocusController> create(Page*);
void setFocusedFrame(PassRefPtr<Frame>);
Frame* focusedFrame() const { return m_focusedFrame.get(); }
......@@ -66,6 +66,8 @@ public:
bool transferFocusToElementInShadowRoot(Element* shadowHost, bool restorePreviousSelection);
private:
FocusController(Page*);
bool advanceFocusDirectionally(FocusDirection, KeyboardEvent*);
bool advanceFocusInDocumentOrder(FocusDirection, KeyboardEvent*, bool initialFocus);
......
......@@ -47,6 +47,11 @@ GeolocationController::~GeolocationController()
m_client->geolocationDestroyed();
}
PassOwnPtr<GeolocationController> GeolocationController::create(Page* page, GeolocationClient* client)
{
return adoptPtr(new GeolocationController(page, client));
}
void GeolocationController::addObserver(Geolocation* observer, bool enableHighAccuracy)
{
// This may be called multiple times with the same observer, though removeObserver()
......
......@@ -43,9 +43,10 @@ class Page;
class GeolocationController {
WTF_MAKE_NONCOPYABLE(GeolocationController);
public:
GeolocationController(Page*, GeolocationClient*);
~GeolocationController();
static PassOwnPtr<GeolocationController> create(Page*, GeolocationClient*);
void addObserver(Geolocation*, bool enableHighAccuracy);
void removeObserver(Geolocation*);
......@@ -60,6 +61,8 @@ public:
GeolocationClient* client() { return m_client; }
private:
GeolocationController(Page*, GeolocationClient*);
Page* m_page;
GeolocationClient* m_client;
......
......@@ -124,27 +124,27 @@ float deviceScaleFactor(Frame* frame)
}
Page::Page(PageClients& pageClients)
: m_chrome(adoptPtr(new Chrome(this, pageClients.chromeClient)))
, m_dragCaretController(adoptPtr(new DragCaretController))
: m_chrome(Chrome::create(this, pageClients.chromeClient))
, m_dragCaretController(DragCaretController::create())
#if ENABLE(DRAG_SUPPORT)
, m_dragController(adoptPtr(new DragController(this, pageClients.dragClient)))
, m_dragController(DragController::create(this, pageClients.dragClient))
#endif
, m_focusController(adoptPtr(new FocusController(this)))
, m_focusController(FocusController::create(this))
#if ENABLE(CONTEXT_MENUS)
, m_contextMenuController(adoptPtr(new ContextMenuController(this, pageClients.contextMenuClient)))
, m_contextMenuController(ContextMenuController::create(this, pageClients.contextMenuClient))
#endif
#if ENABLE(INSPECTOR)
, m_inspectorController(adoptPtr(new InspectorController(this, pageClients.inspectorClient)))
, m_inspectorController(InspectorController::create(this, pageClients.inspectorClient))
#endif
#if ENABLE(CLIENT_BASED_GEOLOCATION)
, m_geolocationController(adoptPtr(new GeolocationController(this, pageClients.geolocationClient)))
, m_geolocationController(GeolocationController::create(this, pageClients.geolocationClient))
#endif
#if ENABLE(DEVICE_ORIENTATION)
, m_deviceMotionController(RuntimeEnabledFeatures::deviceMotionEnabled() ? adoptPtr(new DeviceMotionController(pageClients.deviceMotionClient)) : nullptr)
, m_deviceOrientationController(RuntimeEnabledFeatures::deviceOrientationEnabled() ? adoptPtr(new DeviceOrientationController(this, pageClients.deviceOrientationClient)) : nullptr)
, m_deviceMotionController(RuntimeEnabledFeatures::deviceMotionEnabled() ? DeviceMotionController::create(pageClients.deviceMotionClient) : nullptr)
, m_deviceOrientationController(RuntimeEnabledFeatures::deviceOrientationEnabled() ? DeviceOrientationController::create(this, pageClients.deviceOrientationClient) : nullptr)
#endif
#if ENABLE(NOTIFICATIONS)
, m_notificationController(adoptPtr(new NotificationController(this, pageClients.notificationClient)))
, m_notificationController(NotificationController::create(this, pageClients.notificationClient))
#endif
#if ENABLE(INPUT_SPEECH)
, m_speechInputClient(pageClients.speechInputClient)
......@@ -152,9 +152,9 @@ Page::Page(PageClients& pageClients)
#if ENABLE(MEDIA_STREAM)
, m_userMediaClient(pageClients.userMediaClient)
#endif
, m_settings(adoptPtr(new Settings(this)))
, m_progress(adoptPtr(new ProgressTracker))
, m_backForwardController(adoptPtr(new BackForwardController(this, pageClients.backForwardClient)))
, m_settings(Settings::create(this))
, m_progress(ProgressTracker::create())
, m_backForwardController(BackForwardController::create(this, pageClients.backForwardClient))
, m_theme(RenderTheme::themeForPage(this))
, m_editorClient(pageClients.editorClient)
, m_frameCount(0)
......@@ -405,7 +405,7 @@ void Page::initGroup()
{
ASSERT(!m_singlePageGroup);
ASSERT(!m_group);
m_singlePageGroup = adoptPtr(new PageGroup(this));
m_singlePageGroup = PageGroup::create(this);
m_group = m_singlePageGroup.get();
}
......@@ -984,7 +984,7 @@ SpeechInput* Page::speechInput()
{
ASSERT(m_speechInputClient);
if (!m_speechInput.get())
m_speechInput = adoptPtr(new SpeechInput(m_speechInputClient));
m_speechInput = SpeechInput::create(m_speechInputClient);
return m_speechInput.get();
}
#endif
......
......@@ -76,6 +76,11 @@ PageGroup::~PageGroup()
removeAllUserContent();
}
PassOwnPtr<PageGroup> PageGroup::create(Page* page)
{
return adoptPtr(new PageGroup(page));
}
typedef HashMap<String, PageGroup*> PageGroupMap;
static PageGroupMap* pageGroups = 0;
......
......@@ -46,9 +46,9 @@ namespace WebCore {
WTF_MAKE_NONCOPYABLE(PageGroup); WTF_MAKE_FAST_ALLOCATED;
public:
PageGroup(const String& name);
PageGroup(Page*);
~PageGroup();
static PassOwnPtr<PageGroup> create(Page*);
static PageGroup* pageGroup(const String& groupName);
static void closeLocalStorage();
......@@ -108,6 +108,8 @@ namespace WebCore {
GroupSettings* groupSettings() const { return m_groupSettings.get(); }
private:
PageGroup(Page*);
void addVisitedLink(LinkHash stringHash);
void resetUserStyleCacheInAllFrames();
......
......@@ -244,6 +244,11 @@ Settings::Settings(Page* page)
AtomicString::init();
}
PassOwnPtr<Settings> Settings::create(Page* page)
{
return adoptPtr(new Settings(page));
}
const AtomicString& Settings::standardFontFamily(UScriptCode script) const
{
return getGenericFontFamilyForScript(m_standardFontFamilyMap, script);
......
......@@ -68,7 +68,7 @@ namespace WebCore {
class Settings {
WTF_MAKE_NONCOPYABLE(Settings); WTF_MAKE_FAST_ALLOCATED;
public:
Settings(Page*);
static PassOwnPtr<Settings> create(Page*);
void setStandardFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
const AtomicString& standardFontFamily(UScriptCode = USCRIPT_COMMON) const;
......@@ -515,6 +515,8 @@ namespace WebCore {
#endif
private:
Settings(Page*);
Page* m_page;
String m_defaultTextEncodingName;
......
......@@ -36,6 +36,7 @@
#include "SecurityOrigin.h"
#include "SpeechInputClient.h"
#include "SpeechInputListener.h"
#include <wtf/PassOwnPtr.h>
namespace WebCore {
......@@ -51,6 +52,11 @@ SpeechInput::~SpeechInput()
m_client->setListener(0);
}
PassOwnPtr<SpeechInput> SpeechInput::create(SpeechInputClient* client)