Пример #1
0
static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event)
{
    HTMLDocumentNode *doc = NSEVENTLIST_THIS(iface)->This->doc;
    HTMLDocumentObj *doc_obj;
    nsIDOMHTMLElement *nsbody = NULL;

    TRACE("(%p)\n", doc);

    if(!doc || !doc->basedoc.window)
        return NS_ERROR_FAILURE;
    doc_obj = doc->basedoc.doc_obj;

    connect_scripts(doc->basedoc.window);

    if(doc_obj->nscontainer->editor_controller) {
        nsIController_Release(doc_obj->nscontainer->editor_controller);
        doc_obj->nscontainer->editor_controller = NULL;
    }

    if(doc_obj->usermode == EDITMODE)
        handle_edit_load(&doc_obj->basedoc);

    if(doc == doc_obj->basedoc.doc_node)
        handle_docobj_load(doc_obj);

    set_ready_state(doc->basedoc.window, READYSTATE_COMPLETE);

    if(doc == doc_obj->basedoc.doc_node) {
        if(doc_obj->view_sink)
            IAdviseSink_OnViewChange(doc_obj->view_sink, DVASPECT_CONTENT, -1);

        if(doc_obj->frame) {
            static const WCHAR wszDone[] = {'D','o','n','e',0};
            IOleInPlaceFrame_SetStatusText(doc_obj->frame, wszDone);
        }

        update_title(doc_obj);
    }

    if(!doc->nsdoc) {
        ERR("NULL nsdoc\n");
        return NS_ERROR_FAILURE;
    }

    nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
    if(nsbody) {
        fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event);
        nsIDOMHTMLElement_Release(nsbody);
    }

    return NS_OK;
}
Пример #2
0
static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event)
{
    NSContainer *This = NSEVENTLIST_THIS(iface)->This;
    nsIDOMHTMLDocument *nshtmldoc;
    nsIDOMHTMLElement *nsbody = NULL;
    nsIDOMDocument *nsdoc;
    task_t *task;

    TRACE("(%p)\n", This);

    if(!This->doc)
        return NS_OK;

    connect_scripts(This->doc);
    setup_nswindow(This->doc->window);

    if(This->editor_controller) {
        nsIController_Release(This->editor_controller);
        This->editor_controller = NULL;
    }

    if(This->doc->usermode == EDITMODE)
        handle_edit_load(This->doc);

    task = heap_alloc(sizeof(task_t));

    task->doc = This->doc;
    task->task_id = TASK_PARSECOMPLETE;
    task->next = NULL;

    /*
     * This should be done in the worker thread that parses HTML,
     * but we don't have such thread (Gecko parses HTML for us).
     */
    push_task(task);


    nsIWebNavigation_GetDocument(This->navigation, &nsdoc);
    nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
    nsIDOMDocument_Release(nsdoc);

    nsIDOMHTMLDocument_GetBody(nshtmldoc, &nsbody);
    nsIDOMHTMLDocument_Release(nshtmldoc);

    if(nsbody) {
        fire_event(This->doc, EVENTID_LOAD, (nsIDOMNode*)nsbody);
        nsIDOMHTMLElement_Release(nsbody);
    }

    return NS_OK;
}
Пример #3
0
static void handle_docobj_load(HTMLDocumentObj *doc)
{
    HRESULT hres;

    if(doc->nscontainer->editor_controller) {
        nsIController_Release(doc->nscontainer->editor_controller);
        doc->nscontainer->editor_controller = NULL;
    }

    if(doc->usermode == EDITMODE)
        handle_edit_load(&doc->basedoc);

    if(doc->client) {
        IOleCommandTarget *olecmd = NULL;

        hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
        if(SUCCEEDED(hres)) {
            if(doc->download_state) {
                VARIANT state, progress;

                V_VT(&progress) = VT_I4;
                V_I4(&progress) = 0;
                IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS,
                        OLECMDEXECOPT_DONTPROMPTUSER, &progress, NULL);

                V_VT(&state) = VT_I4;
                V_I4(&state) = 0;
                IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE,
                        OLECMDEXECOPT_DONTPROMPTUSER, &state, NULL);
            }

            IOleCommandTarget_Exec(olecmd, &CGID_ShellDocView, 103, 0, NULL, NULL);
            IOleCommandTarget_Exec(olecmd, &CGID_MSHTML, IDM_PARSECOMPLETE, 0, NULL, NULL);
            IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_HTTPEQUIV_DONE, 0, NULL, NULL);

            IOleCommandTarget_Release(olecmd);
        }
    }

    doc->download_state = 0;
}