Hi Mike, On Tue, Sep 30, 2008 at 8:34 PM, Mike Belshe <[EMAIL PROTECTED]> wrote:
> Hi, Marshall, > I'm not quite sure what you are trying to do; a frame-independent script > object is generally something we'd try not to do. I admit, I'm not up to > speed with what Gears may have needed to do to support some of its > background workers, and maybe that is where you found this call. > > Are you trying to run in the renderer process or the browser process? Are > you writing a plugin? > > Sorry for the vague questions, I'm not sure how to answer the questions > without more context. > > Mike > Pardon the long description. Please bear with me :-). I'm adding the ability to get/set JavaScript Arrays of different types via CppVariant and CppBoundClass in chromium's webkit/glue. Currently, we have no capability to assign arrays to a CppVariant instance, meaning that we can't use a JavaScript array as the return value from a CppBoundClass callback. In order to return a JavaScript Array using CppVariant we need to create an NPObject that represents that array. Aaron Boodman recommended, based on his experience with gears, that I use NPN_Evaluate() to create the NPObject array representation. NPN_Evaluate() requires an NPObject argument of class type NPScriptObject. Therefore, in order to use this approach I need to create an NPObject of class type NPScriptObject from within CppVariant without violating dependency rules. This leads me to the following plan: Internally, CppBoundClass wraps NPObject within it's own structure of type CppNPObject. An instance of this structure is created in CppBoundClass::BindToJavascript(), which is itself called from WebViewDelegate:: WindowObjectCleared(). This CppNPObject structure has a member that points to the CppBoundClass instance that created it. Since I now know that global contexts are discouraged, I'm planning to add an additional member to CppNPObject that points to the WebFrame instance that was originally passed as an argument to CppBoundClass::BindToJavascript(). I can then retrieve the underlying WebCore::Frame object via a call to WebFrame::GetFrameImplementation() and use a method like the following to create the NPScriptObject: NPObject* CreateScriptObject(Frame* frame) { v8::HandleScope handleScope; v8::Handle<v8::Context> context = V8Proxy::GetContext(frame); if (context.IsEmpty()) return NULL; v8::Context::Scope scope(context); DOMWindow* window = frame->domWindow(); v8::Handle<v8::Value> global = V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, window); ASSERT(global->IsObject()); return NPN_CreateScriptObject(0, v8::Handle<v8::Object>::Cast(global), window); } However, using NPN_Evaluate() to create an array indirectly via its string representation doesn't strike me as an optimal approach. I would much prefer to create the NPObject array representation directly. Do you know if the capability currently exists to create an NPObject array representation directly from within webkit/glue without violating dependency restrictions? If not, would it be reasonable to add this capability to the V8 framework? A set of methods like the following would be ideal for my purposes: NPObject *V8Proxy::CreateSimpleArrayObject(Frame *frame, const std::vector<std::wstring>& array); NPObject *V8Proxy::CreateSimpleArrayObject(Frame *frame, const std::vector<double>& array); NPObject *V8Proxy::CreateSimpleArrayObject(Frame *frame, const std::vector<int32_t>& array); NPObject *V8Proxy::CreateSimpleArrayObject(Frame *frame, const std::vector<bool>& array); I'm assuming that webkit/glue is allowed access to V8Proxy -- I may be wrong about that. Also, a V8-dependent solution might be a hard sell to the webkit/glue maintainers unless we can come up with a reasonable KJS alternative as well. Regards, Marshall --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Chromium-dev" group. To post to this group, send email to chromium-dev@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/chromium-dev?hl=en -~----------~----~----~----~------~----~------~--~---