| Summary: | Нужна реализация HTMLWindow2_execScript | ||
|---|---|---|---|
| Product: | Wine School | Reporter: | Синицын Иван <ivan> |
| Component: | Общее | Assignee: | BUGS@Etersoft <bugs> |
| Status: | DEFERRED --- | QA Contact: | |
| Severity: | minor | ||
| Priority: | P4 | CC: | kondratyuk, lav |
| Version: | 0.9 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | |||
| Заявки RT: | Связано с: | ||
| Дата напоминания: | |||
| Bug Depends on: | |||
| Bug Blocks: | 2585, 1527 | ||
|
Description
Синицын Иван
2008-07-01 09:31:29 MSD
В сети встречен такой вот код, про реализацию Exec_script от mozilla
virtual /* [id] */ HRESULT STDMETHODCALLTYPE execScript(
/* [in] */ BSTR code,
/* [in][defaultvalue] */ BSTR language,
/* [out][retval] */ VARIANT __RPC_FAR *pvarRet)
{
nsresult rv;
nsCOMPtr<nsIDOMWindow> domWindow;
NPN_GetValue(mData->pPluginInstance, NPNVDOMWindow,
NS_STATIC_CAST(nsIDOMWindow **, getter_AddRefs(domWindow)));
if (!domWindow)
{
return E_UNEXPECTED;
}
// Now get the DOM Document. Accessing the document will create one
// if necessary. So, basically, this call ensures that a document gets
// created -- if necessary.
nsCOMPtr<nsIDOMDocument> domDocument;
rv = domWindow->GetDocument(getter_AddRefs(domDocument));
NS_ASSERTION(domDocument, "No DOMDocument!");
if (NS_FAILED(rv)) {
return E_UNEXPECTED;
}
nsCOMPtr<nsIScriptGlobalObject> globalObject(do_QueryInterface(domWindow));
if (!globalObject)
return E_UNEXPECTED;
nsCOMPtr<nsIScriptContext> scriptContext = globalObject->GetContext();
if (!scriptContext)
return E_UNEXPECTED;
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDocument));
if (!doc)
return E_UNEXPECTED;
nsIPrincipal *principal = doc->GetPrincipal();
if (!principal)
return E_UNEXPECTED;
// Execute the script.
//
// Note: The script context takes care of the JS stack and of ensuring
// nothing is executed when JS is disabled.
//
nsAutoString scriptString(code);
NS_NAMED_LITERAL_CSTRING(url, "javascript:axplugin");
rv = scriptContext->EvaluateString(scriptString,
nsnull, // obj
principal,
url.get(), // url
1, // line no
nsnull,
nsnull,
nsnull);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
return S_OK;
}
Распространяется под лицензиями MPL 1.1/GPL 2.0/LGPL 2.1
Если лицензии позволяют, можно попробывать адаптировать его для wine.
Откладываем, bugs@ в ближайшее время делать ничего не будет. |