• caio.oliveira@openbossa.org's avatar
    2011-05-25 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> · 32c83b25
    caio.oliveira@openbossa.org authored
            Reviewed by Andreas Kling.
    
            [Qt] JSC bridge: implement __qt_sender__ without using Scope Chain
            https://bugs.webkit.org/show_bug.cgi?id=61343
    
            Create a stack to keep track of the sender objects. This is simpler than
            the similar mechanism in QObject (C++ API), that keeps a stack per-object.
    
            Since we do not support multiple threads, one static stack will be enough for
            handling the behavior.
    
            This behavior is covered by the tst_QWebFrame::connectAndDisconnect() auto test.
    
            * bridge/qt/qt_instance.cpp:
            (JSC::Bindings::QtInstance::qtSenderStack):
            We have one static stack of QObject*. The top of the stack contains the
            last object that emitted signal that called a JavaScript function.
    
            * bridge/qt/qt_instance.h:
            (JSC::Bindings::QtInstance::QtSenderStack::top):
            (JSC::Bindings::QtInstance::QtSenderStack::push):
            (JSC::Bindings::QtInstance::QtSenderStack::pop):
            Minimal functionality to manipulate the sender stack.
    
            * bridge/qt/qt_runtime.cpp:
            (JSC::Bindings::QtConnectionObject::execute):
            Remove the previous code that modified the scope chain. Push the sender object
            to the stack before calling the JavaScript function (the "slot" in Qt-speak) and
            pop it afterwards.
    2011-05-25  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
    
            Reviewed by Andreas Kling.
    
            [Qt] JSC bridge: implement __qt_sender__ without using Scope Chain
            https://bugs.webkit.org/show_bug.cgi?id=61343
    
            Create a '__qt_sender__' property in the global object, that returns the top of
            the qtSenderStack. This is an alternative implementation for the feature of
            providing a way for a function (acting as a Qt 'slot') discover which object
            emitted the signal that caused it to be executed.
    
            This reduces the coupling of the Qt bridge and JSC internal implementation. The
            patch tries to use as much JSC public API as possible.
    
            This behavior is covered by the tst_QWebFrame::connectAndDisconnect() auto test.
    
            * WebCoreSupport/FrameLoaderClientQt.cpp:
            (WebCore::FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld):
            Instead of emitting the QWebPage::javaScriptWindowObjectCleared() directly, calls
            a QWebPagePrivate function to do it.
    
            * Api/qwebframe_p.h:
            * Api/qwebframe.cpp:
            (QWebFramePrivate::didClearedWindowObject):
            Before emitting the signal mentioned, adds the '__qt_sender__' to the fresh
            global object.
    
            (qtSenderCallback):
            Returns the JSObjectRef corresponding to the top of qtSenderStack.
    
            (QWebFramePrivate::addQtSenderToGlobalObject):
            Create a property with a qtSenderCallback as getter function in the global object.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    32c83b25
qt_runtime.cpp 70.2 KB