mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-25 19:52:27 +01:00
Add dactylIUtils.createContents. Closes issue #581.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* Public Domain */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIDOMElement.idl"
|
||||
|
||||
%{C++
|
||||
#include "jsapi.h"
|
||||
@@ -19,6 +20,8 @@ interface dactylIUtils : nsISupports
|
||||
[optional] in ACString filename,
|
||||
[optional] in PRInt32 lineNumber);
|
||||
|
||||
void createContents(in nsIDOMElement element);
|
||||
|
||||
[implicit_jscontext]
|
||||
jsval getGlobalForObject(in jsval object);
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsobj.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIXULTemplateBuilder.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIXPCScriptable.h"
|
||||
@@ -271,6 +274,28 @@ dactylUtils::EvalInContext(const nsAString &aSource,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
dactylUtils::CreateContents(nsIDOMElement *aElement)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
||||
|
||||
for (nsIContent *element = content;
|
||||
element;
|
||||
element = element->GetParent()) {
|
||||
|
||||
nsCOMPtr<nsIDOMXULElement> xulelem = do_QueryInterface(element);
|
||||
if (xulelem) {
|
||||
nsCOMPtr<nsIXULTemplateBuilder> builder;
|
||||
xulelem->GetBuilder(getter_AddRefs(builder));
|
||||
if (builder) {
|
||||
builder->CreateContents(content, PR_TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
dactylUtils::GetGlobalForObject(const jsval &aObject,
|
||||
JSContext *cx,
|
||||
|
||||
Reference in New Issue
Block a user