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

📄 render_frames.cpp

📁 将konqueror浏览器移植到ARM9 2410中
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    for(int c = 1; c < m_frameset->totalCols(); c++)    {      if(_x >= pos && _x <= pos+m_frameset->border())      {        if(m_vSplitVar && m_vSplitVar[c-1] == true) m_vSplit = c-1;#ifdef DEBUG_LAYOUT        kdDebug( 6031 ) << "vsplit!" << endl;#endif        res = true;        break;      }      pos += m_colWidth[c] + m_frameset->border();    }    pos = m_rowHeight[0];    for(int r = 1; r < m_frameset->totalRows(); r++)    {      if( _y >= pos && _y <= pos+m_frameset->border())      {        if(m_hSplitVar && m_hSplitVar[r-1] == true) m_hSplit = r-1;#ifdef DEBUG_LAYOUT        kdDebug( 6031 ) << "hsplitvar = " << m_hSplitVar << endl;        kdDebug( 6031 ) << "hsplit!" << endl;#endif        res = true;        break;      }      pos += m_rowHeight[r] + m_frameset->border();    }#ifdef DEBUG_LAYOUT    kdDebug( 6031 ) << m_hSplit << "/" << m_vSplit << endl;#endif    QCursor cursor;    if(m_hSplit != -1 && m_vSplit != -1)    {      cursor = Qt::sizeAllCursor;    }    else if( m_vSplit != -1 )    {      cursor = Qt::splitHCursor;    }    else if( m_hSplit != -1 )    {      cursor = Qt::splitVCursor;    }    if(evt->id() == EventImpl::MOUSEDOWN_EVENT)    {      m_resizing = true;      KApplication::setOverrideCursor(cursor);      m_vSplitPos = _x;      m_hSplitPos = _y;    }    else      static_cast<KHTMLView *>(m_view)->setCursor(cursor);  }  // ### need to draw a nice movin indicator for the resize.  // ### check the resize is not going out of bounds.  if(m_resizing && evt->id() == EventImpl::MOUSEUP_EVENT)  {    m_resizing = false;    KApplication::restoreOverrideCursor();    if(m_vSplit != -1 )    {#ifdef DEBUG_LAYOUT      kdDebug( 6031 ) << "split xpos=" << _x << endl;#endif      int delta = m_vSplitPos - _x;      m_colWidth[m_vSplit] -= delta;      m_colWidth[m_vSplit+1] += delta;    }    if(m_hSplit != -1 )    {#ifdef DEBUG_LAYOUT      kdDebug( 6031 ) << "split ypos=" << _y << endl;#endif      int delta = m_hSplitPos - _y;      m_rowHeight[m_hSplit] -= delta;      m_rowHeight[m_hSplit+1] += delta;    }    positionFrames( );  }  return res;}bool RenderFrameSet::canResize( int _x, int _y, DOM::NodeImpl::MouseEventType type ){   if(m_resizing || type == DOM::NodeImpl::MousePress)     return true;  if ( type != DOM::NodeImpl::MouseMove )    return false;  // check if we're over a horizontal or vertical boundary  int pos = m_colWidth[0];  for(int c = 1; c < m_frameset->totalCols(); c++)    if(_x >= pos && _x <= pos+m_frameset->border())      return true;  pos = m_rowHeight[0];  for(int r = 1; r < m_frameset->totalRows(); r++)    if( _y >= pos && _y <= pos+m_frameset->border())      return true;  return false;}/**************************************************************************************/RenderPart::RenderPart( QScrollView *view )    : RenderWidget( view ){    // init RenderObject attributes    setInline(false);    m_view = view;}void RenderPart::setWidget( QWidget *widget ){#ifdef DEBUG_LAYOUT    kdDebug(6031) << "RenderPart::setWidget()" << endl;#endif    setQWidget( widget );    if(widget->inherits("KHTMLView"))        connect( widget, SIGNAL( cleared() ), this, SLOT( slotViewCleared() ) );    setLayouted( false );    setMinMaxKnown( false );    updateSize();    // make sure the scrollbars are set correctly for restore    // ### find better fix    slotViewCleared();}void RenderPart::layout( ){    if ( m_widget )        m_widget->resize( QMIN( m_width, 2000 ), QMIN( m_height, 3860 ) );}void RenderPart::partLoadingErrorNotify(){}short RenderPart::intrinsicWidth() const{    return 300;}int RenderPart::intrinsicHeight() const{    return 200;}void RenderPart::slotViewCleared(){}/***************************************************************************************/RenderFrame::RenderFrame( QScrollView *view, DOM::HTMLFrameElementImpl *frame )    : RenderPart( view ), m_frame( frame ){    setInline( false );}void RenderFrame::slotViewCleared(){    if(m_widget->inherits("QScrollView")) {#ifdef DEBUG_LAYOUT        kdDebug(6031) << "frame is a scrollview!" << endl;#endif        QScrollView *view = static_cast<QScrollView *>(m_widget);        if(!m_frame->frameBorder || !((static_cast<HTMLFrameSetElementImpl *>(m_frame->_parent))->frameBorder()))            view->setFrameStyle(QFrame::NoFrame);        view->setVScrollBarMode(m_frame->scrolling);        view->setHScrollBarMode(m_frame->scrolling);        if(view->inherits("KHTMLView")) {#ifdef DEBUG_LAYOUT            kdDebug(6031) << "frame is a KHTMLview!" << endl;#endif            KHTMLView *htmlView = static_cast<KHTMLView *>(view);            if(m_frame->marginWidth != -1) htmlView->setMarginWidth(m_frame->marginWidth);            if(m_frame->marginHeight != -1) htmlView->setMarginHeight(m_frame->marginHeight);        }    }}/****************************************************************************************/RenderPartObject::RenderPartObject( QScrollView *view, DOM::HTMLElementImpl *o )    : RenderPart( view ){    // init RenderObject attributes    setInline(true);    m_obj = o;}void RenderPartObject::updateWidget(){  QString url;  QString serviceType;  if(m_obj->id() == ID_OBJECT) {      // check for embed child object     HTMLObjectElementImpl *o = static_cast<HTMLObjectElementImpl *>(m_obj);     HTMLEmbedElementImpl *embed = 0;     NodeImpl *child = o->firstChild();     while ( child ) {        if ( child->id() == ID_EMBED )           embed = static_cast<HTMLEmbedElementImpl *>( child );        child = child->nextSibling();     }     if ( !embed )     {        url = o->url;        serviceType = o->serviceType;    	if(serviceType.isEmpty() || serviceType.isNull()) {           if(!o->classId.isEmpty()) {              // We have a clsid, means this is activex (Niko)              serviceType = "application/x-activex-handler";              url = "dummy"; // Not needed, but KHTMLPart aborts the request if empty           }           if(o->classId.contains(QString::fromLatin1("D27CDB6E-AE6D-11cf-96B8-444553540000"))) {              // It is ActiveX, but the nsplugin system handling              // should also work, that's why we don't override the              // serviceType with application/x-activex-handler              // but let the KTrader in khtmlpart::createPart() detect              // the user's preference: launch with activex viewer or              // with nspluginviewer (Niko)              serviceType = "application/x-shockwave-flash";           }           else if(o->classId.contains(QString::fromLatin1("CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA")))              serviceType = "audio/x-pn-realaudio-plugin";           // TODO: add more plugins here        }        if((url.isEmpty() || url.isNull())) {           // look for a SRC attribute in the params           NodeImpl *child = o->firstChild();           while ( child ) {              if ( child->id() == ID_PARAM ) {                 HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>( child );                 if ( p->name().lower()==QString::fromLatin1("src") ||                      p->name().lower()==QString::fromLatin1("movie") ||                      p->name().lower()==QString::fromLatin1("code") )                 {                    url = p->value();                    break;                 }              }              child = child->nextSibling();           }        }        // add all <param>'s to the QStringList argument of the part        QStringList params;        NodeImpl *child = o->firstChild();        while ( child ) {           if ( child->id() == ID_PARAM ) {              HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>( child );              QString aStr = p->name();              aStr += QString::fromLatin1("=\"");              aStr += p->value();              aStr += QString::fromLatin1("\"");              params.append(aStr);           }           child = child->nextSibling();        }        if ( url.isEmpty() && serviceType.isEmpty() ) {#ifdef DEBUG_LAYOUT            kdDebug() << "RenderPartObject::close - empty url and serverType" << endl;#endif            return;        }        KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();        params.append( QString::fromLatin1("__KHTML__PLUGINEMBED=\"YES\"") );        params.append( QString::fromLatin1("__KHTML__PLUGINBASEURL=\"%1\"").arg( part->url().url() ) );        params.append( QString::fromLatin1("__KHTML__CLASSID=\"%1\"").arg( o->classId ) );        params.append( QString::fromLatin1("__KHTML__CODEBASE=\"%1\"").arg( static_cast<ElementImpl *>(o)->getAttribute(ATTR_CODEBASE).string() ) );        part->requestObject( this, url, serviceType, params );     }     else {        // render embed object        url = embed->url;        serviceType = embed->serviceType;        if ( url.isEmpty() && serviceType.isEmpty() ) {#ifdef DEBUG_LAYOUT            kdDebug() << "RenderPartObject::close - empty url and serverType" << endl;#endif            return;        }        KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();        embed->param.append( QString::fromLatin1("__KHTML__PLUGINEMBED=\"YES\"") );        embed->param.append( QString::fromLatin1("__KHTML__PLUGINBASEURL=\"%1\"").arg( part->url().url() ) );        embed->param.append( QString::fromLatin1("__KHTML__CLASSID=\"%1\"").arg( o->classId ) );        embed->param.append( QString::fromLatin1("__KHTML__CODEBASE=\"%1\"").arg( static_cast<ElementImpl *>(o)->getAttribute(ATTR_CODEBASE).string() ) );        // Check if serviceType can be handled by ie. nsplugin		// else default to the activexhandler if there is a classid        // and a codebase, where we may download the ocx if it's missing (Niko)        bool retval = part->requestObject( this, url, serviceType, embed->param );        if(!retval && !o->classId.isEmpty() && !( static_cast<ElementImpl *>(o)->getAttribute(ATTR_CODEBASE).string() ).isEmpty() )        {           serviceType = "application/x-activex-handler";           part->requestObject( this, url, serviceType, embed->param );        }     }  }  else if ( m_obj->id() == ID_EMBED ) {     HTMLEmbedElementImpl *o = static_cast<HTMLEmbedElementImpl *>(m_obj);     url = o->url;     serviceType = o->serviceType;     if ( url.isEmpty() && serviceType.isEmpty() ) {#ifdef DEBUG_LAYOUT         kdDebug() << "RenderPartObject::close - empty url and serverType" << endl;#endif         return;     }     KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();     o->param.append( QString::fromLatin1("__KHTML__PLUGINEMBED=\"YES\"") );     o->param.append( QString::fromLatin1("__KHTML__PLUGINBASEURL=\"%1\"").arg( part->url().url() ) );     part->requestObject( this, url, serviceType, o->param );  } else {      assert(m_obj->id() == ID_IFRAME);      HTMLIFrameElementImpl *o = static_cast<HTMLIFrameElementImpl *>(m_obj);      url = o->url.string();      if( url.isEmpty()) return;      KHTMLView *v = static_cast<KHTMLView *>(m_view);      v->part()->requestFrame( this, url, o->name.string(), QStringList(), true );  }  setLayouted(false);}// ugly..void RenderPartObject::close(){    if (m_obj->id() == ID_OBJECT)        updateWidget();    RenderPart::close();}void RenderPartObject::partLoadingErrorNotify(){    HTMLEmbedElementImpl *embed = 0;    if( m_obj->id()==ID_OBJECT ) {        // check for embed child object        HTMLObjectElementImpl *o = static_cast<HTMLObjectElementImpl *>(m_obj);        NodeImpl *child = o->firstChild();        while ( child ) {            if ( child->id() == ID_EMBED )                embed = static_cast<HTMLEmbedElementImpl *>( child );            child = child->nextSibling();        }    } else if( m_obj->id()==ID_EMBED )        embed = static_cast<HTMLEmbedElementImpl *>(m_obj);    // Display vender download page    if( embed && !embed->pluginPage.isEmpty() ) {        KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();        KParts::BrowserExtension *ext = part->browserExtension();        if ( ext ) ext->createNewWindow( KURL(embed->pluginPage) );    }}void RenderPartObject::layout( ){    if ( layouted() ) return;    // minimum height    m_height = 0;    calcWidth();    calcHeight();    if ( !style()->width().isPercent() )        setLayouted();    RenderPart::layout();}void RenderPartObject::slotViewCleared(){  if(m_widget->inherits("QScrollView") ) {#ifdef DEBUG_LAYOUT      kdDebug(6031) << "iframe is a scrollview!" << endl;#endif      QScrollView *view = static_cast<QScrollView *>(m_widget);      int frameStyle = QFrame::NoFrame;      QScrollView::ScrollBarMode scroll = QScrollView::Auto;      int marginw = 0;      int marginh = 0;      if ( m_obj->id() == ID_IFRAME) {	  HTMLIFrameElementImpl *m_frame = static_cast<HTMLIFrameElementImpl *>(m_obj);	  if(m_frame->frameBorder)	      frameStyle = QFrame::Box;	  scroll = m_frame->scrolling;	  marginw = m_frame->marginWidth;	  marginh = m_frame->marginHeight;      }      view->setFrameStyle(frameStyle);      view->setVScrollBarMode(scroll);      view->setHScrollBarMode(scroll);      if(view->inherits("KHTMLView")) {#ifdef DEBUG_LAYOUT          kdDebug(6031) << "frame is a KHTMLview!" << endl;#endif          KHTMLView *htmlView = static_cast<KHTMLView *>(view);          if(marginw != -1) htmlView->setMarginWidth(marginw);          if(marginh != -1) htmlView->setMarginHeight(marginh);        }  }}#include "render_frames.moc"

⌨️ 快捷键说明

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