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

📄 khtmlview.cpp.orig

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 ORIG
📖 第 1 页 / 共 5 页
字号:
       _width = visibleWidth();    killTimer(d->layoutTimerId);    d->layoutTimerId = 0;    d->layoutSchedulingEnabled=true;}void KHTMLView::closeChildDialogs(){    QObjectList *dlgs = queryList("QDialog");    for (QObject *dlg = dlgs->first(); dlg; dlg = dlgs->next())    {        KDialogBase* dlgbase = dynamic_cast<KDialogBase *>( dlg );        if ( dlgbase ) {            if ( dlgbase->testWFlags( WShowModal ) ) {                kdDebug(6000) << "closeChildDialogs: closing dialog " << dlgbase << endl;                // close() ends up calling QButton::animateClick, which isn't immediate                // we need something the exits the event loop immediately (#49068)                dlgbase->cancel();            }        }        else        {            kdWarning() << "closeChildDialogs: not a KDialogBase! Don't use QDialogs in KDE! " << static_cast<QWidget*>(dlg) << endl;            static_cast<QWidget*>(dlg)->hide();        }    }    delete dlgs;    d->m_dialogsAllowed = false;}bool KHTMLView::dialogsAllowed() {    bool allowed = d->m_dialogsAllowed;    KHTMLPart* p = m_part->parentPart();    if (p && p->view())        allowed &= p->view()->dialogsAllowed();    return allowed;}void KHTMLView::closeEvent( QCloseEvent* ev ){    closeChildDialogs();    QScrollView::closeEvent( ev );}//// Event Handling///////////////////void KHTMLView::viewportMousePressEvent( QMouseEvent *_mouse ){    if (!m_part->xmlDocImpl()) return;    if (d->possibleTripleClick && ( _mouse->button() & MouseButtonMask ) == LeftButton)    {        viewportMouseDoubleClickEvent( _mouse ); // it handles triple clicks too        return;    }    int xm, ym;    viewportToContents(_mouse->x(), _mouse->y(), xm, ym);    //kdDebug( 6000 ) << "mousePressEvent: viewport=("<<_mouse->x()<<"/"<<_mouse->y()<<"), contents=(" << xm << "/" << ym << ")\n";    d->isDoubleClick = false;    DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MousePress );    m_part->xmlDocImpl()->prepareMouseEvent( false, xm, ym, &mev );    //kdDebug(6000) << "innerNode="<<mev.innerNode.nodeName().string()<<endl;    if ( (_mouse->button() == MidButton) &&          !m_part->d->m_bOpenMiddleClick && !d->m_mouseScrollTimer &&          mev.url.isNull() && (mev.innerNode.elementId() != ID_INPUT) ) {        QPoint point = mapFromGlobal( _mouse->globalPos() );        d->m_mouseScroll_byX = 0;        d->m_mouseScroll_byY = 0;        d->m_mouseScrollTimer = new QTimer( this );        connect( d->m_mouseScrollTimer, SIGNAL(timeout()), this, SLOT(slotMouseScrollTimer()) );        if ( !d->m_mouseScrollIndicator ) {            QPixmap pixmap, icon;            pixmap.resize( 48, 48 );            pixmap.fill( QColor( qRgba( 127, 127, 127, 127 ) ) );            QPainter p( &pixmap );            icon = KGlobal::iconLoader()->loadIcon( "1uparrow", KIcon::Small );            p.drawPixmap( 16, 0, icon );            icon = KGlobal::iconLoader()->loadIcon( "1leftarrow", KIcon::Small );            p.drawPixmap( 0, 16, icon );            icon = KGlobal::iconLoader()->loadIcon( "1downarrow", KIcon::Small );            p.drawPixmap( 16, 32,icon  );            icon = KGlobal::iconLoader()->loadIcon( "1rightarrow", KIcon::Small );            p.drawPixmap( 32, 16, icon );            p.drawEllipse( 23, 23, 2, 2 );            d->m_mouseScrollIndicator = new QWidget( this, 0 );            d->m_mouseScrollIndicator->setFixedSize( 48, 48 );            d->m_mouseScrollIndicator->setPaletteBackgroundPixmap( pixmap );        }        d->m_mouseScrollIndicator->move( point.x()-24, point.y()-24 );        bool hasHorBar = visibleWidth() < contentsWidth();        bool hasVerBar = visibleHeight() < contentsHeight();        KConfig *config = KGlobal::config();        KConfigGroupSaver saver( config, "HTML Settings" );        if ( config->readBoolEntry( "ShowMouseScrollIndicator", true ) ) {            d->m_mouseScrollIndicator->show();            d->m_mouseScrollIndicator->unsetCursor();            QBitmap mask = d->m_mouseScrollIndicator->paletteBackgroundPixmap()->createHeuristicMask( true );	    if ( hasHorBar && !hasVerBar ) {                QBitmap bm( 16, 16, true );                bitBlt( &mask, 16,  0, &bm, 0, 0, -1, -1 );                bitBlt( &mask, 16, 32, &bm, 0, 0, -1, -1 );                d->m_mouseScrollIndicator->setCursor( KCursor::SizeHorCursor );            }            else if ( !hasHorBar && hasVerBar ) {                QBitmap bm( 16, 16, true );                bitBlt( &mask,  0, 16, &bm, 0, 0, -1, -1 );                bitBlt( &mask, 32, 16, &bm, 0, 0, -1, -1 );                d->m_mouseScrollIndicator->setCursor( KCursor::SizeVerCursor );            }            else                d->m_mouseScrollIndicator->setCursor( KCursor::SizeAllCursor );            d->m_mouseScrollIndicator->setMask( mask );        }        else {            if ( hasHorBar && !hasVerBar )                viewport()->setCursor( KCursor::SizeHorCursor );            else if ( !hasHorBar && hasVerBar )                viewport()->setCursor( KCursor::SizeVerCursor );            else                viewport()->setCursor( KCursor::SizeAllCursor );        }        return;    }    else if ( d->m_mouseScrollTimer ) {        delete d->m_mouseScrollTimer;        d->m_mouseScrollTimer = 0;        if ( d->m_mouseScrollIndicator )            d->m_mouseScrollIndicator->hide();    }	d->clickCount = 1;	d->clickX = xm;	d->clickY = ym;    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEDOWN_EVENT,mev.innerNode.handle(),mev.innerNonSharedNode.handle(),true,                                           d->clickCount,_mouse,true,DOM::NodeImpl::MousePress);    khtml::RenderObject* r = mev.innerNode.handle() ? mev.innerNode.handle()->renderer() : 0;    if (r && r->isWidget())	_mouse->ignore();    if (!swallowEvent) {	emit m_part->nodeActivated(mev.innerNode);	khtml::MousePressEvent event( _mouse, xm, ym, mev.url, mev.target, mev.innerNode );        QApplication::sendEvent( m_part, &event );        // we might be deleted after this    }}void KHTMLView::viewportMouseDoubleClickEvent( QMouseEvent *_mouse ){    if(!m_part->xmlDocImpl()) return;    int xm, ym;    viewportToContents(_mouse->x(), _mouse->y(), xm, ym);    kdDebug( 6000 ) << "mouseDblClickEvent: x=" << xm << ", y=" << ym << endl;    d->isDoubleClick = true;    DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MouseDblClick );    m_part->xmlDocImpl()->prepareMouseEvent( false, xm, ym, &mev );    // We do the same thing as viewportMousePressEvent() here, since the DOM does not treat    // single and double-click events as separate (only the detail, i.e. number of clicks differs)    if (d->clickCount > 0 &&        QPoint(d->clickX-xm,d->clickY-ym).manhattanLength() <= QApplication::startDragDistance())	d->clickCount++;    else { // shouldn't happen, if Qt has the same criterias for double clicks.	d->clickCount = 1;	d->clickX = xm;	d->clickY = ym;    }    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEDOWN_EVENT,mev.innerNode.handle(),mev.innerNonSharedNode.handle(),true,                                           d->clickCount,_mouse,true,DOM::NodeImpl::MouseDblClick);    khtml::RenderObject* r = mev.innerNode.handle() ? mev.innerNode.handle()->renderer() : 0;    if (r && r->isWidget())	_mouse->ignore();    if (!swallowEvent) {	khtml::MouseDoubleClickEvent event( _mouse, xm, ym, mev.url, mev.target, mev.innerNode, d->clickCount );	QApplication::sendEvent( m_part, &event );    }    d->possibleTripleClick=true;    QTimer::singleShot(QApplication::doubleClickInterval(),this,SLOT(tripleClickTimeout()));}void KHTMLView::tripleClickTimeout(){    d->possibleTripleClick = false;    d->clickCount = 0;}static inline void forwardPeripheralEvent(khtml::RenderWidget* r, QMouseEvent* me, int x, int y){    int absx = 0;    int absy = 0;    r->absolutePosition(absx, absy);    QPoint p(x-absx, y-absy);    QMouseEvent fw(me->type(), p, me->button(), me->state());    QWidget* w = r->widget();    if(w)        static_cast<khtml::RenderWidget::EventPropagator*>(w)->sendEvent(&fw);}void KHTMLView::viewportMouseMoveEvent( QMouseEvent * _mouse ){    if ( d->m_mouseScrollTimer ) {        QPoint point = mapFromGlobal( _mouse->globalPos() );        int deltaX = point.x() - d->m_mouseScrollIndicator->x() - 24;        int deltaY = point.y() - d->m_mouseScrollIndicator->y() - 24;        (deltaX > 0) ? d->m_mouseScroll_byX = 1 : d->m_mouseScroll_byX = -1;        (deltaY > 0) ? d->m_mouseScroll_byY = 1 : d->m_mouseScroll_byY = -1;        int adX = abs( deltaX );        int adY = abs( deltaY );        if (adX > 100) d->m_mouseScroll_byX *= 7;        else if (adX > 75) d->m_mouseScroll_byX *= 4;        else if (adX > 50) d->m_mouseScroll_byX *= 2;        else if (adX > 25) d->m_mouseScroll_byX *= 1;        else d->m_mouseScroll_byX = 0;        if (adY > 100) d->m_mouseScroll_byY *= 7;        else if (adY > 75) d->m_mouseScroll_byY *= 4;        else if (adY > 50) d->m_mouseScroll_byY *= 2;        else if (adY > 25) d->m_mouseScroll_byY *= 1;        else d->m_mouseScroll_byY = 0;        if (d->m_mouseScroll_byX == 0 && d->m_mouseScroll_byY == 0) {            d->m_mouseScrollTimer->stop();        }        else if (!d->m_mouseScrollTimer->isActive()) {            d->m_mouseScrollTimer->changeInterval( 20 );        }    }    if(!m_part->xmlDocImpl()) return;    int xm, ym;    viewportToContents(_mouse->x(), _mouse->y(), xm, ym);    DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MouseMove );    // Do not modify :hover/:active state while mouse is pressed.    m_part->xmlDocImpl()->prepareMouseEvent( _mouse->state() & Qt::MouseButtonMask /*readonly ?*/, xm, ym, &mev );//     kdDebug(6000) << "mouse move: " << _mouse->pos()// 		  << " button " << _mouse->button()// 		  << " state " << _mouse->state() << endl;    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEMOVE_EVENT,mev.innerNode.handle(),mev.innerNonSharedNode.handle(),false,                                           0,_mouse,true,DOM::NodeImpl::MouseMove);    if (d->clickCount > 0 &&        QPoint(d->clickX-xm,d->clickY-ym).manhattanLength() > QApplication::startDragDistance()) {	d->clickCount = 0;  // moving the mouse outside the threshold invalidates the click    }    // execute the scheduled script. This is to make sure the mouseover events come after the mouseout events    m_part->executeScheduledScript();    DOM::NodeImpl* fn = m_part->xmlDocImpl()->focusNode();    if (fn && fn != mev.innerNode.handle() &&        fn->renderer() && fn->renderer()->isWidget()) {        forwardPeripheralEvent(static_cast<khtml::RenderWidget*>(fn->renderer()), _mouse, xm, ym);    }    khtml::RenderObject* r = mev.innerNode.handle() ? mev.innerNode.handle()->renderer() : 0;    khtml::RenderStyle* style = (r && r->style()) ? r->style() : 0;    QCursor c;    bool mailtoCursor = false;    switch ( style ? style->cursor() : CURSOR_AUTO) {    case CURSOR_AUTO:        if ( r && r->isText() )            c = KCursor::ibeamCursor();        if ( mev.url.length() && m_part->settings()->changeCursor() ) {            c = m_part->urlCursor();	    if (mev.url.string().startsWith("mailto:") && mev.url.string().find('@')>0)                mailtoCursor = true;        }        if (r && r->isFrameSet() && !static_cast<RenderFrameSet*>(r)->noResize())            c = QCursor(static_cast<RenderFrameSet*>(r)->cursorShape());        break;    case CURSOR_CROSS:        c = KCursor::crossCursor();        break;    case CURSOR_POINTER:        c = m_part->urlCursor();	if (mev.url.string().startsWith("mailto:") && mev.url.string().find('@')>0)            mailtoCursor = true;        break;    case CURSOR_PROGRESS:        c = KCursor::workingCursor();        break;    case CURSOR_MOVE:        c = KCursor::sizeAllCursor();        break;    case CURSOR_E_RESIZE:    case CURSOR_W_RESIZE:        c = KCursor::sizeHorCursor();        break;    case CURSOR_N_RESIZE:    case CURSOR_S_RESIZE:        c = KCursor::sizeVerCursor();        break;    case CURSOR_NE_RESIZE:    case CURSOR_SW_RESIZE:        c = KCursor::sizeBDiagCursor();        break;    case CURSOR_NW_RESIZE:    case CURSOR_SE_RESIZE:        c = KCursor::sizeFDiagCursor();        break;    case CURSOR_TEXT:        c = KCursor::ibeamCursor();        break;    case CURSOR_WAIT:        c = KCursor::waitCursor();        break;    case CURSOR_HELP:        c = KCursor::whatsThisCursor();        break;    case CURSOR_DEFAULT:        break;    }    if ( viewport()->cursor().handle() != c.handle() ) {        if( c.handle() == KCursor::arrowCursor().handle()) {            for (KHTMLPart* p = m_part; p; p = p->parentPart())                p->view()->viewport()->unsetCursor();        }        else {            viewport()->setCursor( c );        }    }    if ( mailtoCursor && isVisible() && hasFocus() ) {#ifdef Q_WS_X11        if( !d->cursor_icon_widget ) {            QPixmap icon_pixmap = KGlobal::iconLoader()->loadIcon( "mail_generic", KIcon::Small, 0, KIcon::DefaultState, 0, true );            d->cursor_icon_widget = new QWidget( NULL, NULL, WX11BypassWM );            XSetWindowAttributes attr;            attr.save_under = True;            XChangeWindowAttributes( qt_xdisplay(), d->cursor_icon_widget->winId(), CWSaveUnder, &attr );            d->cursor_icon_widget->resize( icon_pixmap.width(), icon_pixmap.height());            if( icon_pixmap.mask() )                d->cursor_icon_widget->setMask( *icon_pixmap.mask());            else                d->cursor_icon_widget->clearMask();            d->cursor_icon_widget->setBackgroundPixmap( icon_pixmap );            d->cursor_icon_widget->erase();        }        QPoint c_pos = QCursor::pos();        d->cursor_icon_widget->move( c_pos.x() + 15, c_pos.y() + 15 );        XRaiseWindow( qt_xdisplay(), d->cursor_icon_widget->winId());        QApplication::flushX();        d->cursor_icon_widget->show();#endif    }    else if ( d->cursor_icon_widget )        d->cursor_icon_widget->hide();    if (r && r->isWidget()) {	_mouse->ignore();    }    d->prevMouseX = xm;    d->prevMouseY = ym;    if (!swallowEvent) {        khtml::MouseMoveEvent event( _mouse, xm, ym, mev.url, mev.target, mev.innerNode );        QApplication::sendEvent( m_part, &event );    }}void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse ){    bool swallowEvent = false;    int xm, ym;    viewportToContents(_mouse->x(), _mouse->y(), xm, ym);    DOM::NodeImpl::MouseEvent mev( _mouse->stateAfter(), DOM::NodeImpl::MouseRelease );    if ( m_part->xmlDocImpl() )

⌨️ 快捷键说明

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