Changeset 64803 in webkit


Ignore:
Timestamp:
Aug 5, 2010 5:31:51 PM (14 years ago)
Author:
weinig@apple.com
Message:

Add ability to get a JSValueRef for a node handle and a world
https://bugs.webkit.org/show_bug.cgi?id=43591

Reviewed by Anders Carlsson.

WebCore:

  • WebCore.exp.in: Add exports.

WebKit2:

  • Add API to get a JSValueRef for a world, node and frame (the frame is currently necessary to pick the right globalObject for the node wrapper).
  • Add API to a JSGlobalContextRef for a world and a frame.
  • WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:

(WKBundleFrameGetJavaScriptContextForWorld):
(WKBundleFrameGetJavaScriptWrapperForNodeForWorld):

  • WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
  • WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h:
  • WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:

(WebKit::InjectedBundleNodeHandle::coreNode):

  • WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
  • WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:

(WebKit::InjectedBundleScriptWorld::coreWorld):

  • WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:
  • WebProcess/WebPage/WebFrame.cpp:

(WebKit::WebFrame::jsContext):
(WebKit::WebFrame::jsContextForWorld):
(WebKit::WebFrame::jsWrapperForWorld):

  • WebProcess/WebPage/WebFrame.h:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64801 r64803  
     12010-08-05  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Add ability to get a JSValueRef for a node handle and a world
     6        https://bugs.webkit.org/show_bug.cgi?id=43591
     7
     8        * WebCore.exp.in: Add exports.
     9
    1102010-08-05  Gavin Barraclough  <barraclough@apple.com>
    211
  • trunk/WebCore/WebCore.exp.in

    r64797 r64803  
    290290__ZN7WebCore13KeyboardEventC1ERKNS_12AtomicStringEbbPNS_9DOMWindowERKNS_6StringEjbbbbb
    291291__ZN7WebCore13TypingCommand39insertParagraphSeparatorInQuotedContentEPNS_8DocumentE
     292__ZN7WebCore13createWrapperEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_4NodeE
    292293__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
    293294__ZN7WebCore13toJSDOMWindowEN3JSC7JSValueE
     
    411412__ZN7WebCore17nameForCursorTypeENS_6Cursor4TypeE
    412413__ZN7WebCore17openTemporaryFileEPKcRi
     414__ZN7WebCore18SearchPopupMenuMacC1EPNS_15PopupMenuClientE
    413415__ZN7WebCore18deprecatedParseURLERKNS_6StringE
    414416__ZN7WebCore18isStartOfParagraphERKNS_15VisiblePositionE
    415417__ZN7WebCore18pluginScriptObjectEPN3JSC9ExecStateEPNS_13JSHTMLElementE
    416 __ZN7WebCore18SearchPopupMenuMacC1EPNS_15PopupMenuClientE
    417418__ZN7WebCore19AnimationController16resumeAnimationsEPNS_8DocumentE
    418419__ZN7WebCore19AnimationController17suspendAnimationsEPNS_8DocumentE
     
    672673__ZN7WebCore8Document16isPageBoxVisibleEi
    673674__ZN7WebCore8Document17getFocusableNodesERN3WTF6VectorINS1_6RefPtrINS_4NodeEEELm0EEE
     675__ZN7WebCore8Document18createWrapperCacheEPNS_15DOMWrapperWorldE
    674676__ZN7WebCore8Document19accessSVGExtensionsEv
    675677__ZN7WebCore8Document22createDocumentFragmentEv
  • trunk/WebKit2/ChangeLog

    r64801 r64803  
     12010-08-05  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Add ability to get a JSValueRef for a node handle and a world
     6        https://bugs.webkit.org/show_bug.cgi?id=43591
     7
     8        - Add API to get a JSValueRef for a world, node and frame (the
     9          frame is currently necessary to pick the right globalObject for
     10          the node wrapper).
     11        - Add API to a JSGlobalContextRef for a world and a frame.
     12
     13        * WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
     14        (WKBundleFrameGetJavaScriptContextForWorld):
     15        (WKBundleFrameGetJavaScriptWrapperForNodeForWorld):
     16        * WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
     17        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h:
     18        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
     19        (WebKit::InjectedBundleNodeHandle::coreNode):
     20        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
     21        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
     22        (WebKit::InjectedBundleScriptWorld::coreWorld):
     23        * WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:
     24        * WebProcess/WebPage/WebFrame.cpp:
     25        (WebKit::WebFrame::jsContext):
     26        (WebKit::WebFrame::jsContextForWorld):
     27        (WebKit::WebFrame::jsWrapperForWorld):
     28        * WebProcess/WebPage/WebFrame.h:
     29
    1302010-08-05  Gavin Barraclough  <barraclough@apple.com>
    231
  • trunk/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp

    r64426 r64803  
    7070}
    7171
     72JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frameRef, WKBundleScriptWorldRef worldRef)
     73{
     74    return toWK(frameRef)->jsContextForWorld(toWK(worldRef));
     75}
     76
     77JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frameRef, WKBundleNodeHandleRef nodeHandleRef, WKBundleScriptWorldRef worldRef)
     78{
     79    return toWK(frameRef)->jsWrapperForWorld(toWK(nodeHandleRef), toWK(worldRef));
     80}
     81
    7282WKStringRef WKBundleFrameCopyName(WKBundleFrameRef frameRef)
    7383{
  • trunk/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleFrame.h

    r64253 r64803  
    4444
    4545WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContext(WKBundleFrameRef frame);
     46WK_EXPORT JSGlobalContextRef WKBundleFrameGetJavaScriptContextForWorld(WKBundleFrameRef frame, WKBundleScriptWorldRef world);
     47
     48WK_EXPORT JSValueRef WKBundleFrameGetJavaScriptWrapperForNodeForWorld(WKBundleFrameRef frame, WKBundleNodeHandleRef nodeHandle, WKBundleScriptWorldRef world);
    4649
    4750#ifdef __cplusplus
  • trunk/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h

    r64778 r64803  
    2727#define WKBundleNodeHandle_h
    2828
     29#include <JavaScriptCore/JavaScript.h>
    2930#include <WebKit2/WKBase.h>
    3031#include <WebKit2/WKBundleBase.h>
  • trunk/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp

    r64788 r64803  
    2626#include "InjectedBundleNodeHandle.h"
    2727
     28#include "InjectedBundleScriptWorld.h"
    2829#include <WebCore/Node.h>
    2930#include <wtf/HashMap.h>
     
    6768}
    6869
     70Node* InjectedBundleNodeHandle::coreNode() const
     71{
     72    return m_node.get();
     73}
     74
    6975} // namespace WebKit
  • trunk/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h

    r64778 r64803  
    2525
    2626#include "APIObject.h"
     27#include <JavaScriptCore/JSBase.h>
     28#include <wtf/PassRefPtr.h>
    2729#include <wtf/RefPtr.h>
    28 #include <wtf/PassRefPtr.h>
    2930
    3031namespace WebCore {
     
    3435namespace WebKit {
    3536
     37class InjectedBundleScriptWorld;
     38
    3639class InjectedBundleNodeHandle : public APIObject {
    3740public:
     
    4043    static PassRefPtr<InjectedBundleNodeHandle> getOrCreate(WebCore::Node*);
    4144    ~InjectedBundleNodeHandle();
     45
     46    WebCore::Node* coreNode() const;
    4247
    4348private:
  • trunk/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp

    r64788 r64803  
    7777}
    7878
     79DOMWrapperWorld* InjectedBundleScriptWorld::coreWorld() const
     80{
     81    return m_world.get();
     82}
     83
    7984} // namespace WebKit
  • trunk/WebKit2/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h

    r64788 r64803  
    4747    ~InjectedBundleScriptWorld();
    4848
     49    WebCore::DOMWrapperWorld* coreWorld() const;
     50
    4951private:
    5052    InjectedBundleScriptWorld(PassRefPtr<WebCore::DOMWrapperWorld>);
  • trunk/WebKit2/WebProcess/WebPage/WebFrame.cpp

    r64504 r64803  
    2626#include "WebFrame.h"
    2727
     28#include "InjectedBundleNodeHandle.h"
     29#include "InjectedBundleScriptWorld.h"
    2830#include "WebPage.h"
    2931#include <JavaScriptCore/APICast.h>
     
    250252JSGlobalContextRef WebFrame::jsContext()
    251253{
    252     // FIXME: Is there a way to get this and know that it's a JSGlobalContextRef?
    253     // The const_cast here is a bit ugly.
    254     return const_cast<JSGlobalContextRef>(toRef(m_coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec()));
     254    return toGlobalRef(m_coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec());
     255}
     256
     257JSGlobalContextRef WebFrame::jsContextForWorld(InjectedBundleScriptWorld* world)
     258{
     259    return toGlobalRef(m_coreFrame->script()->globalObject(world->coreWorld())->globalExec());
     260}
     261
     262JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, InjectedBundleScriptWorld* world)
     263{
     264    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld());
     265    ExecState* exec = globalObject->globalExec();
     266
     267    JSLock lock(SilenceAssertionsOnly);
     268    return toRef(exec, toJS(exec, globalObject, nodeHandle->coreNode()));
    255269}
    256270
  • trunk/WebKit2/WebProcess/WebPage/WebFrame.h

    r64801 r64803  
    4545namespace WebKit {
    4646
     47class InjectedBundleNodeHandle;
     48class InjectedBundleScriptWorld;
    4749class WebPage;
    4850
     
    7577    JSValueRef computedStyleIncludingVisitedInfo(JSObjectRef element);
    7678    JSGlobalContextRef jsContext();
     79    JSGlobalContextRef jsContextForWorld(InjectedBundleScriptWorld*);
     80
     81    JSValueRef jsWrapperForWorld(InjectedBundleNodeHandle*, InjectedBundleScriptWorld*);
     82
    7783    static WebCore::String counterValue(JSObjectRef element);
    7884    static WebCore::String markerText(JSObjectRef element);
Note: See TracChangeset for help on using the changeset viewer.