Changeset 53785 in webkit


Ignore:
Timestamp:
Jan 24, 2010 2:54:18 PM (14 years ago)
Author:
oliver@apple.com
Message:

2010-01-24 Oliver Hunt <oliver@apple.com>

Reviewed by Darin Adler.

Object Serialization assumes deserialization will always occur in the context of a webpage
https://bugs.webkit.org/show_bug.cgi?id=34056
rdar://7573833

Added ClassInfo to JSDOMGlobalObject and make the window and worker class info
inherit from it. With this in place we're able to determine whether a given
global object is a DOMGlobalObject, and then use that information to avoid
attempting to deserialize types that require the presence of the DOM.

No test as all global objects in webkit inherit from JSDOMGlobalObject.

  • bindings/js/JSDOMGlobalObject.cpp: (WebCore::):
  • bindings/js/JSDOMGlobalObject.h: (WebCore::JSDOMGlobalObject::classInfo):
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::):
  • bindings/js/JSWorkerContextBase.cpp: (WebCore::):
  • bindings/js/SerializedScriptValue.cpp: (WebCore::DeserializingTreeWalker::DeserializingTreeWalker): (WebCore::DeserializingTreeWalker::convertIfTerminal):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53780 r53785  
     12010-01-24  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Object Serialization assumes deserialization will always occur in the context of a webpage
     6        https://bugs.webkit.org/show_bug.cgi?id=34056
     7        rdar://7573833
     8
     9        Added ClassInfo to JSDOMGlobalObject and make the window and worker class info
     10        inherit from it.  With this in place we're able to determine whether a given
     11        global object is a DOMGlobalObject, and then use that information to avoid
     12        attempting to deserialize types that require the presence of the DOM.
     13
     14        No test as all global objects in webkit inherit from JSDOMGlobalObject.
     15
     16        * bindings/js/JSDOMGlobalObject.cpp:
     17        (WebCore::):
     18        * bindings/js/JSDOMGlobalObject.h:
     19        (WebCore::JSDOMGlobalObject::classInfo):
     20        * bindings/js/JSDOMWindowBase.cpp:
     21        (WebCore::):
     22        * bindings/js/JSWorkerContextBase.cpp:
     23        (WebCore::):
     24        * bindings/js/SerializedScriptValue.cpp:
     25        (WebCore::DeserializingTreeWalker::DeserializingTreeWalker):
     26        (WebCore::DeserializingTreeWalker::convertIfTerminal):
     27
    1282010-01-24  Eric Carlson  <eric.carlson@apple.com>
    229
  • trunk/WebCore/bindings/js/JSDOMGlobalObject.cpp

    r53430 r53785  
    4040
    4141namespace WebCore {
     42
     43const ClassInfo JSDOMGlobalObject::s_info = { "DOMGlobalObject", 0, 0, 0 };
    4244
    4345JSDOMGlobalObject::JSDOMGlobalObject(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject::JSDOMGlobalObjectData* data, JSObject* thisValue)
  • trunk/WebCore/bindings/js/JSDOMGlobalObject.h

    r53430 r53785  
    6868        DOMWrapperWorld* world() { return d()->m_world.get(); }
    6969
     70        virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
     71        static const JSC::ClassInfo s_info;
     72
    7073    protected:
    7174        struct JSDOMGlobalObjectData : public JSC::JSGlobalObject::JSGlobalObjectData {
  • trunk/WebCore/bindings/js/JSDOMWindowBase.cpp

    r53587 r53785  
    4242namespace WebCore {
    4343
    44 const ClassInfo JSDOMWindowBase::s_info = { "Window", 0, 0, 0 };
     44const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, 0 };
    4545
    4646JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData(PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell)
  • trunk/WebCore/bindings/js/JSWorkerContextBase.cpp

    r51330 r53785  
    4343ASSERT_CLASS_FITS_IN_CELL(JSWorkerContextBase);
    4444
    45 const ClassInfo JSWorkerContextBase::s_info = { "WorkerContext", 0, 0, 0 };
     45const ClassInfo JSWorkerContextBase::s_info = { "WorkerContext", &JSDOMGlobalObject::s_info, 0, 0 };
    4646
    4747JSWorkerContextBase::JSWorkerContextBase(NonNullPassRefPtr<JSC::Structure> structure, PassRefPtr<WorkerContext> impl)
  • trunk/WebCore/bindings/js/SerializedScriptValue.cpp

    r53774 r53785  
    615615    DeserializingTreeWalker(ExecState* exec, bool mustCopy)
    616616        : BaseWalker(exec)
     617        , m_globalObject(exec->lexicalGlobalObject())
     618        , m_isDOMGlobalObject(m_globalObject->inherits(&JSDOMGlobalObject::s_info))
    617619        , m_mustCopy(mustCopy)
    618620    {
     
    695697                return new (m_exec) DateInstance(m_exec, value.asDouble());
    696698            case SerializedScriptValueData::FileType:
     699                if (!m_isDOMGlobalObject)
     700                    return jsNull();
    697701                return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()), File::create(value.asString().crossThreadString()));
    698702            case SerializedScriptValueData::FileListType: {
     703                if (!m_isDOMGlobalObject)
     704                    return jsNull();
    699705                RefPtr<FileList> result = FileList::create();
    700706                SerializedFileList* serializedFileList = value.asFileList();
     
    747753
    748754private:
     755    JSGlobalObject* m_globalObject;
     756    bool m_isDOMGlobalObject;
    749757    bool m_mustCopy;
    750758};
Note: See TracChangeset for help on using the changeset viewer.