diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-09-26 16:20:26 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-09-26 16:20:26 -0400 |
commit | 9fd915fb41f40a9e09f748c6963a07e2be5e6239 (patch) | |
tree | 07c7bfe357b940f48ec6a4b1f68901583db9b5a7 /binary/src | |
parent | c0833dae2966190bfaa7001d5e4d1277e0bb7a8e (diff) | |
download | pentadactyl-9fd915fb41f40a9e09f748c6963a07e2be5e6239.tar.gz |
Add dactylIUtils.createContents. Closes issue #581.
Diffstat (limited to 'binary/src')
-rw-r--r-- | binary/src/dactylIUtils.idl | 3 | ||||
-rw-r--r-- | binary/src/dactylUtils.cpp | 25 |
2 files changed, 28 insertions, 0 deletions
diff --git a/binary/src/dactylIUtils.idl b/binary/src/dactylIUtils.idl index 84f941af..0a1aa9ae 100644 --- a/binary/src/dactylIUtils.idl +++ b/binary/src/dactylIUtils.idl @@ -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); diff --git a/binary/src/dactylUtils.cpp b/binary/src/dactylUtils.cpp index 958b267d..86a4d46a 100644 --- a/binary/src/dactylUtils.cpp +++ b/binary/src/dactylUtils.cpp @@ -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" @@ -272,6 +275,28 @@ dactylUtils::EvalInContext(const nsAString &aSource, } 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, jsval *rval) |