2011-05-25 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 May 2011 19:28:22 +0000 (19:28 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 May 2011 19:28:22 +0000 (19:28 +0000)
commit0f3fa07a0bbe6422bbcb9340fab3227484326be9
tree18eb778bb6a2a6ec72ba2771a0a28da050e32318
parent0b0fafa70d36f4b9a6800f13f6acfeae301039ab
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 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: https://svn.webkit.org/repository/webkit/trunk@87315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bridge/qt/qt_instance.cpp
Source/WebCore/bridge/qt/qt_instance.h
Source/WebCore/bridge/qt/qt_runtime.cpp
Source/WebKit/qt/Api/qwebframe.cpp
Source/WebKit/qt/Api/qwebframe_p.h
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp