⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kwqkhtmlpart.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	(d->m_doc && (htmlDocument().applets().length() != 0 ||                      d->m_doc->hasWindowEventListener(EventImpl::UNLOAD_EVENT) ||		      d->m_doc->hasPasswordField()))) {        return false;    }    return true;}void KWQKHTMLPart::saveWindowProperties(SavedProperties *windowProperties){    Window *window = Window::retrieveWindow(this);    if (window)        window->saveProperties(*windowProperties);}void KWQKHTMLPart::saveLocationProperties(SavedProperties *locationProperties){    Window *window = Window::retrieveWindow(this);    if (window) {        Interpreter::lock();        Location *location = window->location();        Interpreter::unlock();        location->saveProperties(*locationProperties);    }}void KWQKHTMLPart::restoreWindowProperties(SavedProperties *windowProperties){    Window *window = Window::retrieveWindow(this);    if (window)        window->restoreProperties(*windowProperties);}void KWQKHTMLPart::restoreLocationProperties(SavedProperties *locationProperties){    Window *window = Window::retrieveWindow(this);    if (window) {        Interpreter::lock();        Location *location = window->location();        Interpreter::unlock();        location->restoreProperties(*locationProperties);    }}void KWQKHTMLPart::saveInterpreterBuiltins(SavedBuiltins &interpreterBuiltins){    if (jScript() && jScript()->interpreter()) {	jScript()->interpreter()->saveBuiltins(interpreterBuiltins);    }}void KWQKHTMLPart::restoreInterpreterBuiltins(const SavedBuiltins &interpreterBuiltins){    if (jScript() && jScript()->interpreter()) {	jScript()->interpreter()->restoreBuiltins(interpreterBuiltins);    }}void KWQKHTMLPart::openURLFromPageCache(KWQPageState *state){    DocumentImpl *doc = state->document();    KURL *url = state->URL();    SavedProperties *windowProperties = state->windowProperties();    SavedProperties *locationProperties = state->locationProperties();    SavedBuiltins *interpreterBuiltins = state->interpreterBuiltins();    QMap<int, ScheduledAction*> *actions = state->pausedActions();        cancelRedirection();    // We still have to close the previous part page.    if (!d->m_restored){        closeURL();    }                d->m_bComplete = false;        // Don't re-emit the load event.    d->m_bLoadEventEmitted = true;        // delete old status bar msg's from kjs (if it _was_ activated on last URL)    if( d->m_bJScriptEnabled )    {        d->m_kjsStatusBarText = QString::null;        d->m_kjsDefaultStatusBarText = QString::null;    }    ASSERT (url);        m_url = *url;        // initializing m_url to the new url breaks relative links when opening such a link after this call and _before_ begin() is called (when the first    // data arrives) (Simon)    if(m_url.protocol().startsWith( "http" ) && !m_url.host().isEmpty() && m_url.path().isEmpty()) {        m_url.setPath("/");        emit d->m_extension->setLocationBarURL( m_url.prettyURL() );    }        // copy to m_workingURL after fixing m_url above    d->m_workingURL = m_url;            emit started( 0L );        // -----------begin-----------    clear();    doc->setInPageCache(false);    d->m_bCleared = false;    d->m_cacheId = 0;    d->m_bComplete = false;    d->m_bLoadEventEmitted = false;    d->m_referrer = m_url.url();        setView(doc->view());        d->m_doc = doc;    d->m_doc->ref();        Decoder *decoder = doc->decoder();    if (decoder) {        decoder->ref();    }    if (d->m_decoder) {        d->m_decoder->deref();    }    d->m_decoder = decoder;    updatePolicyBaseURL();            restoreWindowProperties (windowProperties);    restoreLocationProperties (locationProperties);    restoreInterpreterBuiltins (*interpreterBuiltins);    if (actions)        resumeActions (actions, state);        checkCompleted();}KWQKHTMLPart *KWQKHTMLPart::partForWidget(const QWidget *widget){    ASSERT_ARG(widget, widget);        NodeImpl *node = nodeForWidget(widget);    if (node) {	return partForNode(node);    }        // Assume all widgets are either form controls, or KHTMLViews.#if KWIQ    const KHTMLView *view = 0;    if (QOBJECT_IS_A(widget, KHTMLView)) view = static_cast<const KHTMLView*>(widget);#else    const KHTMLView *view = dynamic_cast<const KHTMLView *>(widget);#endif    ASSERT(view);    return KWQ(view->part());}WebCoreBridge *KWQKHTMLPart::bridgeForWidget(const QWidget *widget){    ASSERT_ARG(widget, widget);        DOM::NodeImpl *node = nodeForWidget(widget);    if (node) {	return partForNode(node)->bridge() ;    }        // Assume all widgets are either form controls, or KHTMLViews.#if KWIQ    const KHTMLView *view = 0;    if (QOBJECT_IS_A(widget, KHTMLView)) view = static_cast<const KHTMLView*>(widget);#else    const KHTMLView *view = dynamic_cast<const KHTMLView *>(widget);#endif    ASSERT(view);    return KWQ(view->part())->bridge();}KWQKHTMLPart *KWQKHTMLPart::partForNode(DOM::NodeImpl *node){    ASSERT_ARG(node, node);    return KWQ(node->getDocument()->part());}#if 0NSView *KWQKHTMLPart::documentViewForNode(DOM::NodeImpl *node){    WebCoreBridge *bridge = partForNode(node)->bridge();    return [bridge documentView];}#endifDOM::NodeImpl *KWQKHTMLPart::nodeForWidget(const QWidget *widget){    ASSERT_ARG(widget, widget);    const QObject *o = widget->eventFilterObject();    return o ? static_cast<const RenderWidget *>(o)->element() : 0;}void KWQKHTMLPart::setDocumentFocus(QWidget *widget){    DOM::NodeImpl *node = nodeForWidget(widget);    if (node) {        node->getDocument()->setFocusNode(node);    } else {        ERROR("unable to clear focus because widget had no corresponding node");    }}void KWQKHTMLPart::clearDocumentFocus(QWidget *widget){    DOM::NodeImpl *node = nodeForWidget(widget);    if (node) {    	node->getDocument()->setFocusNode(0);    } else {        ERROR("unable to clear focus because widget had no corresponding node");    }}void KWQKHTMLPart::saveDocumentState(){    // Do not save doc state if the page has a password field and a form that would be submitted    // via https    if (!(d->m_doc && d->m_doc->hasPasswordField() && d->m_doc->hasSecureForm())) {         _bridge->saveDocumentState();    }}void KWQKHTMLPart::restoreDocumentState(){    _bridge->restoreDocumentState();}QPtrList<KWQKHTMLPart> &KWQKHTMLPart::mutableInstances(){    static QPtrList<KWQKHTMLPart> instancesList;    return instancesList;}void KWQKHTMLPart::updatePolicyBaseURL(){    // FIXME: docImpl() returns null for everything other than HTML documents; is this causing problems? -dwh    if (parentPart() && parentPart()->docImpl()) {        setPolicyBaseURL(parentPart()->docImpl()->policyBaseURL());    } else {        setPolicyBaseURL(m_url.url());    }}void KWQKHTMLPart::setPolicyBaseURL(const DOMString &s){    // FIXME: XML documents will cause this to return null.  docImpl() is    // an HTMLdocument only. -dwh    if (docImpl())        docImpl()->setPolicyBaseURL(s);    ConstFrameIt end = d->m_frames.end();    for (ConstFrameIt it = d->m_frames.begin(); it != end; ++it) {        ReadOnlyPart *subpart = (*it).m_part;        static_cast<KWQKHTMLPart *>(subpart)->setPolicyBaseURL(s);    }}QString KWQKHTMLPart::requestedURLString() const{    return _bridge->requestedURLString();}QString KWQKHTMLPart::incomingReferrer() const{    return _bridge->incomingReferrer();}void KWQKHTMLPart::forceLayout(){    KHTMLView *v = d->m_view;    if (v) {        v->layout();        // We cannot unschedule a pending relayout, since the force can be called with        // a tiny rectangle from a drawRect update.  By unscheduling we in effect        // "validate" and stop the necessary full repaint from occurring.  Basically any basic        // append/remove DHTML is broken by this call.  For now, I have removed the optimization        // until we have a better invalidation stategy. -dwh        //v->unscheduleRelayout();    }}void KWQKHTMLPart::forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth){    // Dumping externalRepresentation(_part->renderer()).ascii() is a good trick to see    // the state of things before and after the layout    RenderCanvas *root = static_cast<RenderCanvas *>(xmlDocImpl()->renderer());    if (root) {        // This magic is basically copied from khtmlview::print        int pageW = (int)ceil(minPageWidth);        root->setWidth(pageW);        root->setNeedsLayoutAndMinMaxRecalc();        forceLayout();                // If we don't fit in the minimum page width, we'll lay out again. If we don't fit in the        // maximum page width, we will lay out to the maximum page width and clip extra content.        // FIXME: We are assuming a shrink-to-fit printing implementation.  A cropping        // implementation should not do this!        int rightmostPos = root->rightmostPosition();        if (rightmostPos > minPageWidth) {            pageW = kMin(rightmostPos, (int)ceil(maxPageWidth));            root->setWidth(pageW);            root->setNeedsLayoutAndMinMaxRecalc();            forceLayout();        }    }}void KWQKHTMLPart::sendResizeEvent(){    KHTMLView *v = d->m_view;    if (v) {        // Sending an event can result in the destruction of the view and part.        // We ref so that happens after we return from the KHTMLView function.        v->ref();	QResizeEvent e;	v->resizeEvent(&e);        v->deref();    }}void KWQKHTMLPart::sendScrollEvent(){    KHTMLView *v = d->m_view;    if (v) {        DocumentImpl *doc = xmlDocImpl();        if (!doc)            return;        doc->dispatchHTMLEvent(EventImpl::SCROLL_EVENT, true, false);    }}void KWQKHTMLPart::runJavaScriptAlert(const QString &message){    QString text = message;    text.replace('\\', backslashAsCurrencySymbol());    _bridge->runJavaScriptAlertPanelWithMessage(text.utf8());}bool KWQKHTMLPart::runJavaScriptConfirm(const QString &message){     QString text = message;     text.replace('\\', backslashAsCurrencySymbol());     return _bridge->runJavaScriptConfirmPanelWithMessage(text.utf8());}bool KWQKHTMLPart::runJavaScriptPrompt(const QString &prompt, const QString &defaultValue, QString &result){    QString promptText = prompt;    promptText.replace('\\', backslashAsCurrencySymbol());    QString defaultValueText = defaultValue;    defaultValueText.replace('\\', backslashAsCurrencySymbol());    gchar * returnedText = 0;         bool ok = _bridge->runJavaScriptTextInputPanelWithPrompt(prompt.utf8(),							     defaultValue.utf8(),							     &returnedText);    if (ok) {	result = QString::fromUtf8(returnedText);        result.replace(backslashAsCurrencySymbol(), '\\');    }    g_free(returnedText);    return ok;}void KWQKHTMLPart::addMessageToConsole(const QString &message, unsigned lineNumber, const QString &sourceURL){    _bridge->addMessageToConsole(message.utf8(), lineNumber, sourceURL.utf8());}void KWQKHTMLPart::createEmptyDocument(){    // Although it's not completely clear from the name of this function,    // it does nothing if we already have a document, and just creates an    // empty one if we have no document at all.    if (!d->m_doc) {        _bridge->loadEmptyDocumentSynchronously();	if (parentPart() && (parentPart()->childFrame(this)->m_type == ChildFrame::IFrame ||			     parentPart()->childFrame(this)->m_type == ChildFrame::Object)) {	    d->m_doc->setBaseURL(parentPart()->d->m_doc->baseURL());	}    }}void KWQKHTMLPart::addMetaData(const QString &key, const QString &value){    d->m_job->addMetaData(key, value);}bool KWQKHTMLPart::keyEvent(QKeyEvent *event){    ASSERT(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease);    // Check for cases where we are too early for events -- possible unmatched key up    // from pressing return in the location bar.    DocumentImpl *doc = xmlDocImpl();    if (!doc) {        return false;    }    DOM::NodeImpl *node = doc->focusNode();    if (!node && docImpl()) {	node = docImpl()->body();    }    if (!node) {        return false;    }        NSEvent *oldCurrentEvent = _currentEvent;    _currentEvent = (NSEvent*) event;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -