Changeset 47492 in webkit


Ignore:
Timestamp:
Aug 18, 2009 10:50:36 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-08-18 John Gregg <johnnyg@google.com>

Reviewed by Dimitri Glazkov.

V8 Bindings for Desktop Notifications feature.
https://bugs.webkit.org/show_bug.cgi?id=28271

  • WebCore.gypi: added notification files to build (all still behind a flag that's not on)
  • bindings/scripts/CodeGeneratorV8.pm: added special case in DOMWindow/AppCache style for named event handlers
  • bindings/v8/DOMObjectsInclude.h:
  • bindings/v8/DerivedSourcesAllInOne.cpp:
  • bindings/v8/V8DOMWrapper.cpp: (WebCore::V8DOMWrapper::getTemplate): (WebCore::V8DOMWrapper::convertEventTargetToV8Object):
  • bindings/v8/V8Index.cpp:
  • bindings/v8/V8Index.h:
  • bindings/v8/V8Proxy.h:
  • bindings/v8/WorkerContextExecutionProxy.cpp: (WebCore::WorkerContextExecutionProxy::convertToV8Object):
  • bindings/v8/custom/V8CustomBinding.h:
  • bindings/v8/custom/V8NotificationCenterCustom.cpp: Added.
  • notifications/Notification.h: made event handler routines public (as they are in DOMWindow, eg) for binding access.
  • notifications/NotificationCenter.idl: needed to make methods V8Custom to support different behaviors in worker/page context in chromium.
  • workers/WorkerThread.h: (WebCore::WorkerThread::getNotificationPresenter): (WebCore::WorkerThread::setNotificationPresenter): needed to make these methods public as well so chromium can inject the notification presenter into the worker thread.
Location:
trunk/WebCore
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r47489 r47492  
     12009-08-18  John Gregg  <johnnyg@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        V8 Bindings for Desktop Notifications feature.
     6        https://bugs.webkit.org/show_bug.cgi?id=28271
     7
     8        * WebCore.gypi:
     9        added notification files to build (all still behind a flag that's not on)
     10        * bindings/scripts/CodeGeneratorV8.pm:
     11        added special case in DOMWindow/AppCache style for named event handlers
     12        * bindings/v8/DOMObjectsInclude.h:
     13        * bindings/v8/DerivedSourcesAllInOne.cpp:
     14        * bindings/v8/V8DOMWrapper.cpp:
     15        (WebCore::V8DOMWrapper::getTemplate):
     16        (WebCore::V8DOMWrapper::convertEventTargetToV8Object):
     17        * bindings/v8/V8Index.cpp:
     18        * bindings/v8/V8Index.h:
     19        * bindings/v8/V8Proxy.h:
     20        * bindings/v8/WorkerContextExecutionProxy.cpp:
     21        (WebCore::WorkerContextExecutionProxy::convertToV8Object):
     22        * bindings/v8/custom/V8CustomBinding.h:
     23        * bindings/v8/custom/V8NotificationCenterCustom.cpp: Added.
     24        * notifications/Notification.h:
     25        made event handler routines public (as they are in DOMWindow, eg) for
     26        binding access.
     27        * notifications/NotificationCenter.idl:
     28        needed to make methods V8Custom to support different behaviors in
     29        worker/page context in chromium.
     30        * workers/WorkerThread.h:
     31        (WebCore::WorkerThread::getNotificationPresenter):
     32        (WebCore::WorkerThread::setNotificationPresenter):
     33        needed to make these methods public as well so chromium can inject
     34        the notification presenter into the worker thread.
     35
    1362009-08-13  Maciej Stachowiak  <mjs@apple.com>
    237
  • trunk/WebCore/WebCore.gypi

    r47481 r47492  
    162162            'inspector/JavaScriptCallFrame.idl',
    163163            'loader/appcache/DOMApplicationCache.idl',
     164            'notifications/Notification.idl',
     165            'notifications/NotificationCenter.idl',
    164166            'page/AbstractView.idl',
    165167            'page/BarInfo.idl',
     
    660662            'bindings/v8/custom/V8NodeIteratorCustom.cpp',
    661663            'bindings/v8/custom/V8NodeListCustom.cpp',
     664            'bindings/v8/custom/V8NotificationCenterCustom.cpp',
    662665            'bindings/v8/custom/V8StorageCustom.cpp',
    663666            'bindings/v8/custom/V8SQLResultSetRowListCustom.cpp',
     
    15631566            'loader/loader.cpp',
    15641567            'loader/loader.h',
     1568            'notifications/Notification.cpp',
     1569            'notifications/Notification.h',
     1570            'notifications/NotificationCenter.cpp',
     1571            'notifications/NotificationCenter.h',
     1572            'notifications/NotificationPresenter.h',
     1573            'notifications/NotificationContents.h',
    15651574            'page/animation/AnimationBase.cpp',
    15661575            'page/animation/AnimationBase.h',
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r47249 r47492  
    967967                $getter = "V8Custom::v8DOMApplicationCacheEventHandlerAccessorGetter";
    968968                $setter = "V8Custom::v8DOMApplicationCacheEventHandlerAccessorSetter";
     969            } elsif ($interfaceName eq "Notification") {
     970                $getter = "V8Custom::v8NotificationEventHandlerAccessorGetter";
     971                $setter = "V8Custom::v8NotificationEventHandlerAccessorSetter";
    969972            } else {
    970973                $getter = "V8Custom::v8${customAccessor}AccessorGetter";
     
    20422045    }
    20432046
    2044     if ($type eq "WorkerLocation" or $type eq "WorkerNavigator") {
     2047    if ($type eq "WorkerLocation" or $type eq "WorkerNavigator" or $type eq "NotificationCenter") {
    20452048        $implIncludes{"WorkerContextExecutionProxy.h"} = 1;
    20462049        my $classIndex = uc($type);
  • trunk/WebCore/bindings/v8/DOMObjectsInclude.h

    r46917 r47492  
    215215#endif // WORKERS
    216216
     217#if ENABLE(NOTIFICATIONS)
     218#include "Notification.h"
     219#include "NotificationCenter.h"
     220#endif // NOTIFICATIONS
     221
    217222#if ENABLE(XPATH)
    218223#include "XPathEvaluator.h"
  • trunk/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp

    r46917 r47492  
    176176#include "bindings/V8NodeList.cpp"
    177177#include "bindings/V8Notation.cpp"
     178#include "bindings/V8Notification.cpp"
     179#include "bindings/V8NotificationCenter.cpp"
    178180#include "bindings/V8OverflowEvent.cpp"
    179181#include "bindings/V8Plugin.cpp"
  • trunk/WebCore/bindings/v8/V8DOMWrapper.cpp

    r47001 r47492  
    379379        break;
    380380    }
     381
     382#if ENABLE(NOTIFICATIONS)
     383    case V8ClassIndex::NOTIFICATION: {
     384        // Reserve one more internal field for keeping event listeners.
     385        v8::Local<v8::ObjectTemplate> instanceTemplate = descriptor->InstanceTemplate();
     386        instanceTemplate->SetInternalFieldCount(V8Custom::kNotificationInternalFieldCount);
     387        break;
     388    }
     389#endif // NOTIFICATIONS
    381390
    382391#if ENABLE(WORKERS)
     
    12501259#endif // WORKERS
    12511260
     1261#if ENABLE(NOTIFICATIONS)
     1262    Notification* notification = target->toNotification();
     1263    if (notification)
     1264        return convertToV8Object(V8ClassIndex::NOTIFICATION, notification);
     1265#endif
     1266
    12521267    Node* node = target->toNode();
    12531268    if (node)
  • trunk/WebCore/bindings/v8/V8Index.cpp

    r46917 r47492  
    386386#endif
    387387
     388#if ENABLE(NOTIFICATIONS)
     389#include "V8Notification.h"
     390#include "V8NotificationCenter.h"
     391#endif
     392
    388393#if ENABLE(SHARED_WORKERS)
    389394#include "V8SharedWorker.h"
  • trunk/WebCore/bindings/v8/V8Index.h

    r46917 r47492  
    8787#else
    8888#define APPLICATIONCACHE_NONNODE_WRAPPER_TYPES(V)
     89#endif
     90
     91#if ENABLE(NOTIFICATIONS)
     92#define NOTIFICATIONS_NONNODE_WRAPPER_TYPES(V)                          \
     93    V(NOTIFICATION, Notification)                                       \
     94    V(NOTIFICATIONCENTER, NotificationCenter)
     95#else
     96#define NOTIFICATIONS_NONNODE_WRAPPER_TYPES(V)
    8997#endif
    9098
     
    398406    DATAGRID_NONNODE_TYPES(V)                                           \
    399407    VIDEO_NONNODE_TYPES(V)                                              \
     408    NOTIFICATIONS_NONNODE_WRAPPER_TYPES(V)                              \
    400409    SHARED_WORKER_NONNODE_WRAPPER_TYPES(V)                              \
    401410    WORKER_NONNODE_WRAPPER_TYPES(V)
  • trunk/WebCore/bindings/v8/V8Proxy.h

    r46849 r47492  
    8787    class NodeFilter;
    8888    class NodeList;
     89#if ENABLE(NOTIFICATIONS)
     90    class Notification;
     91    class NotificationCenter;
     92#endif
    8993    class Plugin;
    9094    class PluginArray;
  • trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp

    r46919 r47492  
    3939#include "DedicatedWorkerContext.h"
    4040#include "Event.h"
     41#include "Notification.h"
     42#include "NotificationCenter.h"
    4143#include "EventException.h"
    4244#include "MessagePort.h"
     
    220222                static_cast<WorkerNavigator*>(impl)->ref();
    221223                break;
     224#if ENABLE(NOTIFICATIONS)
     225            case V8ClassIndex::NOTIFICATIONCENTER:
     226                static_cast<NotificationCenter*>(impl)->ref();
     227                break;
     228            case V8ClassIndex::NOTIFICATION:
     229                static_cast<Notification*>(impl)->ref();
     230                break;
     231#endif
    222232            case V8ClassIndex::DOMCOREEXCEPTION:
    223233                static_cast<DOMCoreException*>(impl)->ref();
  • trunk/WebCore/bindings/v8/custom/V8CustomBinding.h

    r47363 r47492  
    136136#endif
    137137
     138#if ENABLE(NOTIFICATIONS)
     139        static const int kNotificationRequestCacheIndex = kDefaultWrapperInternalFieldCount + 0;
     140        static const int kNotificationInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;
     141#endif
     142
    138143        static const int kDOMWindowConsoleIndex = kDefaultWrapperInternalFieldCount + 0;
    139144        static const int kDOMWindowHistoryIndex = kDefaultWrapperInternalFieldCount + 1;
     
    517522        DECLARE_CALLBACK(WorkerContextAddEventListener);
    518523        DECLARE_CALLBACK(WorkerContextRemoveEventListener);
    519 #endif
     524#endif // ENABLE(WORKERS)
     525
     526#if ENABLE(NOTIFICATIONS)
     527        DECLARE_CALLBACK(NotificationCenterRequestPermission);
     528        DECLARE_CALLBACK(NotificationCenterCreateNotification);
     529        DECLARE_CALLBACK(NotificationCenterCreateHTMLNotification);
     530
     531        DECLARE_CALLBACK(NotificationAddEventListener);
     532        DECLARE_CALLBACK(NotificationRemoveEventListener);
     533        DECLARE_PROPERTY_ACCESSOR(NotificationEventHandler);
     534#endif // ENABLE(NOTIFICATIONS)
    520535
    521536#if ENABLE(OFFLINE_WEB_APPLICATIONS)
  • trunk/WebCore/notifications/Notification.h

    r47056 r47492  
    8787        virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&);
    8888        virtual Notification* toNotification() { return this; }
    89      
     89
     90        // These methods are for onEvent style listeners.
     91        EventListener* getAttributeEventListener(const AtomicString&) const;
     92        void setAttributeEventListener(const AtomicString&, PassRefPtr<EventListener>);
     93        void clearAttributeEventListener(const AtomicString&);
     94
    9095    private:
    9196        Notification(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider);
     
    97102 
    98103        void handleEvent(PassRefPtr<Event> event, bool useCapture);
    99         EventListener* getAttributeEventListener(const AtomicString&) const;
    100         void setAttributeEventListener(const AtomicString&, PassRefPtr<EventListener>);
    101         void clearAttributeEventListener(const AtomicString&);
    102104
    103105        bool m_isHTML;
  • trunk/WebCore/notifications/NotificationCenter.idl

    r47056 r47492  
    3434        Conditional=NOTIFICATIONS
    3535    ] NotificationCenter {
    36        Notification createHTMLNotification(in DOMString url) raises(Exception);
    37        Notification createNotification(in DOMString iconUrl, in DOMString title, in DOMString body) raises(Exception);
     36       [V8Custom] Notification createHTMLNotification(in DOMString url) raises(Exception);
     37       [V8Custom] Notification createNotification(in DOMString iconUrl, in DOMString title, in DOMString body) raises(Exception);
    3838
    3939       int checkPermission();
  • trunk/WebCore/workers/WorkerThread.h

    r47429 r47492  
    6060        static unsigned workerThreadCount();
    6161
     62#if ENABLE(NOTIFICATIONS)
     63        NotificationPresenter* getNotificationPresenter() { return m_notificationPresenter; }
     64        void setNotificationPresenter(NotificationPresenter* presenter) { m_notificationPresenter = presenter; }
     65#endif
     66
    6267    protected:
    6368        WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&);
     
    7075
    7176        WorkerContext* workerContext() { return m_workerContext.get(); }
    72 
    73 #if ENABLE(NOTIFICATIONS)
    74         NotificationPresenter* getNotificationPresenter() { return m_notificationPresenter; }
    75         void setNotificationPresenter(NotificationPresenter* presenter) { m_notificationPresenter = presenter; }
    76 #endif
    7777
    7878    private:
Note: See TracChangeset for help on using the changeset viewer.