Skip to content
Permalink
Browse files
Extract Supplementable base class from Page and Navigator
https://bugs.webkit.org/show_bug.cgi?id=79624

Reviewed by Hajime Morita.

We'll use this pattern again soon for ScriptExecutionContext.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/gamepad/NavigatorGamepad.cpp:
(WebCore::NavigatorGamepad::from):
* Modules/gamepad/NavigatorGamepad.h:
* Modules/geolocation/NavigatorGeolocation.cpp:
(WebCore::NavigatorGeolocation::from):
* Modules/geolocation/NavigatorGeolocation.h:
* Modules/mediastream/NavigatorMediaStream.cpp:
(WebCore::NavigatorMediaStream::webkitGetUserMedia):
* Modules/mediastream/UserMediaController.cpp:
(WebCore::provideUserMediaTo):
* Modules/mediastream/UserMediaController.h:
(WebCore::UserMediaController::from):
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DeviceMotionController.cpp:
(WebCore::provideDeviceMotionTo):
* dom/DeviceMotionController.h:
(WebCore::DeviceMotionController::from):
* dom/DeviceOrientationController.cpp:
(WebCore::provideDeviceOrientationTo):
* dom/DeviceOrientationController.h:
(WebCore):
(WebCore::DeviceOrientationController::from):
* notifications/NotificationController.cpp:
(WebCore::provideNotification):
* notifications/NotificationController.h:
(WebCore):
(WebCore::NotificationController::from):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::page):
(WebCore):
(WebCore::DOMWindow::addEventListener):
(WebCore::DOMWindow::removeEventListener):
(WebCore::DOMWindow::removeAllEventListeners):
* page/DOMWindow.h:
(WebCore):
(DOMWindow):
* page/Navigator.cpp:
(WebCore):
* page/Navigator.h:
(Navigator):
* page/NavigatorSupplement.cpp: Removed.
* page/NavigatorSupplement.h: Removed.
* page/Page.cpp:
(WebCore):
* page/Page.h:
(Page):
* page/PageSupplement.cpp: Removed.
* page/PageSupplement.h: Removed.
* page/SpeechInput.cpp:
(WebCore::provideSpeechInputTo):
* page/SpeechInput.h:
(WebCore::SpeechInput::from):
* platform/Supplementable.h: Added.
(WebCore):
(Supplement):
(WebCore::Supplement::~Supplement):
(WebCore::Supplement::provideTo):
(WebCore::Supplement::from):
(Supplementable):
(WebCore::Supplementable::provideSupplement):
(WebCore::Supplementable::requireSupplement):


Canonical link: https://commits.webkit.org/96728@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Adam Barth committed Feb 27, 2012
1 parent fa12def commit 4f1352578b89579f396467c6173d83e758cdb6c0
Showing 35 changed files with 207 additions and 335 deletions.
@@ -1037,13 +1037,11 @@ SET(WebCore_SOURCES
page/Navigator.cpp
page/NavigatorBase.cpp
page/NavigatorRegisterProtocolHandler.cpp
page/NavigatorSupplement.cpp
page/OriginAccessEntry.cpp
page/Page.cpp
page/PageGroup.cpp
page/PageGroupLoadDeferrer.cpp
page/PageSerializer.cpp
page/PageSupplement.cpp
page/PageVisibilityState.cpp
page/Performance.cpp
page/PerformanceNavigation.cpp
@@ -1,3 +1,79 @@
2012-02-26 Adam Barth <abarth@webkit.org>

Extract Supplementable base class from Page and Navigator
https://bugs.webkit.org/show_bug.cgi?id=79624

Reviewed by Hajime Morita.

We'll use this pattern again soon for ScriptExecutionContext.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/gamepad/NavigatorGamepad.cpp:
(WebCore::NavigatorGamepad::from):
* Modules/gamepad/NavigatorGamepad.h:
* Modules/geolocation/NavigatorGeolocation.cpp:
(WebCore::NavigatorGeolocation::from):
* Modules/geolocation/NavigatorGeolocation.h:
* Modules/mediastream/NavigatorMediaStream.cpp:
(WebCore::NavigatorMediaStream::webkitGetUserMedia):
* Modules/mediastream/UserMediaController.cpp:
(WebCore::provideUserMediaTo):
* Modules/mediastream/UserMediaController.h:
(WebCore::UserMediaController::from):
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DeviceMotionController.cpp:
(WebCore::provideDeviceMotionTo):
* dom/DeviceMotionController.h:
(WebCore::DeviceMotionController::from):
* dom/DeviceOrientationController.cpp:
(WebCore::provideDeviceOrientationTo):
* dom/DeviceOrientationController.h:
(WebCore):
(WebCore::DeviceOrientationController::from):
* notifications/NotificationController.cpp:
(WebCore::provideNotification):
* notifications/NotificationController.h:
(WebCore):
(WebCore::NotificationController::from):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::page):
(WebCore):
(WebCore::DOMWindow::addEventListener):
(WebCore::DOMWindow::removeEventListener):
(WebCore::DOMWindow::removeAllEventListeners):
* page/DOMWindow.h:
(WebCore):
(DOMWindow):
* page/Navigator.cpp:
(WebCore):
* page/Navigator.h:
(Navigator):
* page/NavigatorSupplement.cpp: Removed.
* page/NavigatorSupplement.h: Removed.
* page/Page.cpp:
(WebCore):
* page/Page.h:
(Page):
* page/PageSupplement.cpp: Removed.
* page/PageSupplement.h: Removed.
* page/SpeechInput.cpp:
(WebCore::provideSpeechInputTo):
* page/SpeechInput.h:
(WebCore::SpeechInput::from):
* platform/Supplementable.h: Added.
(WebCore):
(Supplement):
(WebCore::Supplement::~Supplement):
(WebCore::Supplement::provideTo):
(WebCore::Supplement::from):
(Supplementable):
(WebCore::Supplementable::provideSupplement):
(WebCore::Supplementable::requireSupplement):

2012-02-26 Hajime Morrita <morrita@chromium.org>

Move ChromeClient::showContextMenu() to ContextMenuClient
@@ -2782,8 +2782,6 @@ webcore_sources += \
Source/WebCore/page/NavigatorBase.h \
Source/WebCore/page/NavigatorRegisterProtocolHandler.cpp \
Source/WebCore/page/NavigatorRegisterProtocolHandler.h \
Source/WebCore/page/NavigatorSupplement.cpp \
Source/WebCore/page/NavigatorSupplement.h \
Source/WebCore/page/OriginAccessEntry.cpp \
Source/WebCore/page/OriginAccessEntry.h \
Source/WebCore/page/Page.cpp \
@@ -2794,8 +2792,6 @@ webcore_sources += \
Source/WebCore/page/PageGroupLoadDeferrer.h \
Source/WebCore/page/PageSerializer.cpp \
Source/WebCore/page/PageSerializer.h \
Source/WebCore/page/PageSupplement.cpp \
Source/WebCore/page/PageSupplement.h \
Source/WebCore/page/PageVisibilityState.cpp \
Source/WebCore/page/PageVisibilityState.h \
Source/WebCore/page/Performance.cpp \
@@ -3350,6 +3346,7 @@ webcore_sources += \
Source/WebCore/platform/sql/SQLValue.h \
Source/WebCore/platform/SSLKeyGenerator.h \
Source/WebCore/platform/SuddenTermination.h \
Source/WebCore/platform/Supplementable.h \
Source/WebCore/platform/SystemTime.h \
Source/WebCore/platform/text/Base64.cpp \
Source/WebCore/platform/text/Base64.h \
@@ -46,7 +46,7 @@ NavigatorGamepad::~NavigatorGamepad()
NavigatorGamepad* NavigatorGamepad::from(Navigator* navigator)
{
DEFINE_STATIC_LOCAL(AtomicString, name, ("NavigatorGamepad"));
NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(NavigatorSupplement::from(navigator, name));
NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(Supplement<Navigator>::from(navigator, name));
if (!supplement) {
supplement = new NavigatorGamepad();
provideTo(navigator, name, adoptPtr(supplement));
@@ -28,14 +28,14 @@

#if ENABLE(GAMEPAD)

#include "NavigatorSupplement.h"
#include "Supplementable.h"

namespace WebCore {

class GamepadList;
class Navigator;

class NavigatorGamepad : public NavigatorSupplement {
class NavigatorGamepad : public Supplement<Navigator> {
public:
virtual ~NavigatorGamepad();
static NavigatorGamepad* from(Navigator*);
@@ -54,7 +54,7 @@ void NavigatorGeolocation::willDetachPage()
NavigatorGeolocation* NavigatorGeolocation::from(Navigator* navigator)
{
DEFINE_STATIC_LOCAL(AtomicString, name, ("NavigatorGeolocation"));
NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(NavigatorSupplement::from(navigator, name));
NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from(navigator, name));
if (!supplement) {
supplement = new NavigatorGeolocation(navigator->frame());
provideTo(navigator, name, adoptPtr(supplement));
@@ -27,15 +27,15 @@
#define NavigatorGeolocation_h

#include "DOMWindowProperty.h"
#include "NavigatorSupplement.h"
#include "Supplementable.h"

namespace WebCore {

class Frame;
class Geolocation;
class Navigator;

class NavigatorGeolocation : public NavigatorSupplement, public DOMWindowProperty {
class NavigatorGeolocation : public Supplement<Navigator>, public DOMWindowProperty {
public:
virtual ~NavigatorGeolocation();
static NavigatorGeolocation* from(Navigator*);
@@ -53,7 +53,7 @@ void NavigatorMediaStream::webkitGetUserMedia(Navigator* navigator, const String
if (!successCallback)
return;

UserMediaController* userMedia = UserMediaController::from(navigator->frame());
UserMediaController* userMedia = UserMediaController::from(navigator->frame() ? navigator->frame()->page() : 0);
if (!userMedia) {
ec = NOT_SUPPORTED_ERR;
return;
@@ -52,7 +52,7 @@ PassOwnPtr<UserMediaController> UserMediaController::create(UserMediaClient* cli

void provideUserMediaTo(Page* page, UserMediaClient* client)
{
PageSupplement::provideTo(page, UserMediaController::supplementName(), UserMediaController::create(client));
UserMediaController::provideTo(page, UserMediaController::supplementName(), UserMediaController::create(client));
}

} // namespace WebCore
@@ -27,16 +27,13 @@

#if ENABLE(MEDIA_STREAM)

#include "PageSupplement.h"
#include "Page.h"
#include "UserMediaClient.h"
#include <wtf/PassOwnPtr.h>

namespace WebCore {

class Frame;
class Page;

class UserMediaController : public PageSupplement {
class UserMediaController : public Supplement<Page> {
public:
~UserMediaController();

@@ -46,8 +43,7 @@ class UserMediaController : public PageSupplement {

static PassOwnPtr<UserMediaController> create(UserMediaClient*);
static const AtomicString& supplementName();
static UserMediaController* from(Frame* frame) { return static_cast<UserMediaController*>(PageSupplement::from(frame, supplementName())); }
static UserMediaController* from(Page* page) { return static_cast<UserMediaController*>(PageSupplement::from(page, supplementName())); }
static UserMediaController* from(Page* page) { return static_cast<UserMediaController*>(Supplement<Page>::from(page, supplementName())); }

protected:
UserMediaController(UserMediaClient*);
@@ -124,7 +124,7 @@ void Vibration::timerStopFired(Timer<Vibration>* timer)

const AtomicString& Vibration::supplementName()
{
DEFINE_STATIC_LOCAL(AtomicString, name, ("vibration"));
DEFINE_STATIC_LOCAL(AtomicString, name, ("Vibration"));
return name;
}

@@ -135,7 +135,7 @@ bool Vibration::isActive(Page* page)

void provideVibrationTo(Page* page, VibrationClient* client)
{
PageSupplement::provideTo(page, Vibration::supplementName(), Vibration::create(client));
Vibration::provideTo(page, Vibration::supplementName(), Vibration::create(client));
}

} // namespace WebCore
@@ -22,7 +22,7 @@

#if ENABLE(VIBRATION)

#include "PageSupplement.h"
#include "Page.h"
#include "Timer.h"
#include <wtf/PassOwnPtr.h>

@@ -32,7 +32,7 @@ class Navigator;
class Page;
class VibrationClient;

class Vibration : public PageSupplement {
class Vibration : public Supplement<Page> {
public:
typedef Vector<unsigned long> VibrationPattern;

@@ -52,7 +52,7 @@ class Vibration : public PageSupplement {
void timerStopFired(Timer<Vibration>*);

static const AtomicString& supplementName();
static Vibration* from(Page* page) { return static_cast<Vibration*>(PageSupplement::from(page, supplementName())); }
static Vibration* from(Page* page) { return static_cast<Vibration*>(Supplement<Page>::from(page, supplementName())); }
static bool isActive(Page*);

private:
@@ -1006,12 +1006,10 @@ SOURCES += \
page/Navigator.cpp \
page/NavigatorBase.cpp \
page/NavigatorRegisterProtocolHandler.cpp \
page/NavigatorSupplement.cpp \
page/OriginAccessEntry.cpp \
page/Page.cpp \
page/PageGroup.cpp \
page/PageGroupLoadDeferrer.cpp \
page/PageSupplement.cpp \
page/PageVisibilityState.cpp \
page/Performance.cpp \
page/PerformanceNavigation.cpp \
@@ -223,7 +223,6 @@
'page/Page.h',
'page/PageGroup.h',
'page/PageSerializer.h',
'page/PageSupplement.h',
'page/PageVisibilityState.h',
'page/PrintContext.h',
'page/SecurityOrigin.h',
@@ -295,6 +294,7 @@
'platform/SearchPopupMenu.h',
'platform/SharedBuffer.h',
'platform/SharedBufferChunkReader.h',
'platform/Supplementable.h',
'platform/SystemTime.h',
'platform/Theme.h',
'platform/ThemeTypes.h',
@@ -2682,16 +2682,13 @@
'page/NavigatorBase.h',
'page/NavigatorRegisterProtocolHandler.cpp',
'page/NavigatorRegisterProtocolHandler.h',
'page/NavigatorSupplement.cpp',
'page/NavigatorSupplement.h',
'page/OriginAccessEntry.cpp',
'page/OriginAccessEntry.h',
'page/Page.cpp',
'page/PageGroup.cpp',
'page/PageGroupLoadDeferrer.cpp',
'page/PageGroupLoadDeferrer.h',
'page/PageSerializer.cpp',
'page/PageSupplement.cpp',
'page/PageVisibilityState.cpp',
'page/Performance.cpp',
'page/Performance.h',
@@ -25709,14 +25709,6 @@
RelativePath="..\page\NavigatorRegisterProtocolHandler.h"
>
</File>
<File
RelativePath="..\page\NavigatorSupplement.cpp"
>
</File>
<File
RelativePath="..\page\NavigatorSupplement.h"
>
</File>
<File
RelativePath="..\page\OriginAccessEntry.cpp"
>
@@ -25753,14 +25745,6 @@
RelativePath="..\page\PageSerializer.h"
>
</File>
<File
RelativePath="..\page\PageSupplement.cpp"
>
</File>
<File
RelativePath="..\page\PageSupplement.h"
>
</File>
<File
RelativePath="..\page\PageVisibilityState.cpp"
>

0 comments on commit 4f13525

Please sign in to comment.