The project I'm working on is using Gecko without a UI. The core of
the app
does the following:
NS_InitXPCOM3(nsnull, nsnull, dirProvider, sCombined,
combinedCount);
...
nsCOMPtr<nsIDocShell> mDocShell;
mDocShell = do_CreateInstance("@mozilla.org/webshell;1");
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
...
nsIThread *thread = NS_GetCurrentThread();
while (true) {
PRBool processedEvent;
rv = thread->ProcessNextEvent(PR_TRUE, &processedEvent);
}
There's also a javascript component that listens for commands over a
socket
channel. It uses @mozilla.org/webshell;1 to control loading of pages
and accessing
the dom.
For simple things it works fine: I can fetch a document given a URL,
search for elements by id, name, xpath, and enter text into text and
textarea
nodes. Since it avoids loading of images, css, and skips layout and
rendering,
it's pretty fast. So far so good.
However, when I call element.click() on an input node of type submit,
nothing
happens. From debugging I find that it's not working because there's
no
psIPrefContext and no psPrefShell. I.e. HTMLInputElement has the
following:
NS_IMETHODIMP
nsHTMLInputElement::Click()
{
...
nsIPresShell *shell = doc->GetPrimaryShell();
if (shell) {
nsCOMPtr<nsPresContext> context = shell->GetPresContext();
if (context) {
...
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this),
context,
&event, nsnull, &status);
...
}
}
}
Since shell is null, the event is not dispatched.
What's a good way to resolve this?
Thank's in advance
Andrej
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding