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

📄 dom_docimpl.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    case ID_SCRIPT:        n = new HTMLScriptElementImpl(docPtr());        break;// tables    case ID_TABLE:        n = new HTMLTableElementImpl(docPtr());        break;    case ID_CAPTION:        n = new HTMLTableCaptionElementImpl(docPtr());        break;    case ID_COLGROUP:    case ID_COL:        n = new HTMLTableColElementImpl(docPtr(), id);        break;    case ID_TR:        n = new HTMLTableRowElementImpl(docPtr());        break;    case ID_TD:    case ID_TH:        n = new HTMLTableCellElementImpl(docPtr(), id);        break;    case ID_THEAD:    case ID_TBODY:    case ID_TFOOT:        n = new HTMLTableSectionElementImpl(docPtr(), id, false);        break;// inline elements    case ID_BR:        n = new HTMLBRElementImpl(docPtr());        break;    case ID_Q:        n = new HTMLGenericElementImpl(docPtr(), id);        break;// elements with no special representation in the DOM// block:    case ID_ADDRESS:    case ID_CENTER:        n = new HTMLGenericElementImpl(docPtr(), id);        break;// inline        // %fontstyle    case ID_TT:    case ID_U:    case ID_B:    case ID_I:    case ID_S:    case ID_STRIKE:    case ID_BIG:    case ID_SMALL:        // %phrase    case ID_EM:    case ID_STRONG:    case ID_DFN:    case ID_CODE:    case ID_SAMP:    case ID_KBD:    case ID_VAR:    case ID_CITE:    case ID_ABBR:    case ID_ACRONYM:        // %special    case ID_SUB:    case ID_SUP:    case ID_SPAN:    case ID_NOBR:    case ID_WBR:        n = new HTMLGenericElementImpl(docPtr(), id);        break;    case ID_MARQUEE:        n = new HTMLMarqueeElementImpl(docPtr());        break;    case ID_BDO:        break;// text    case ID_TEXT:        kdDebug( 6020 ) << "Use document->createTextNode()" << endl;        break;    default:        break;    }    return n;}QString DocumentImpl::nextState(){   QString state;   if (!m_state.isEmpty())   {      state = m_state.first();      m_state.remove(m_state.begin());   }   return state;}QStringList DocumentImpl::docState(){    QStringList s;    for (QPtrListIterator<NodeImpl> it(m_maintainsState); it.current(); ++it)        s.append(it.current()->state());    return s;}bool DocumentImpl::unsubmittedFormChanges(){    for (QPtrListIterator<NodeImpl> it(m_maintainsState); it.current(); ++it)        if (it.current()->state().right(1)=="M")            return true;    return false;}RangeImpl *DocumentImpl::createRange(){    return new RangeImpl( docPtr() );}NodeIteratorImpl *DocumentImpl::createNodeIterator(NodeImpl *root, unsigned long whatToShow,                                                   NodeFilter &filter, bool entityReferenceExpansion,                                                   int &exceptioncode){    if (!root) {        exceptioncode = DOMException::NOT_SUPPORTED_ERR;        return 0;    }    return new NodeIteratorImpl(root,whatToShow,filter,entityReferenceExpansion);}TreeWalkerImpl *DocumentImpl::createTreeWalker(NodeImpl *root, unsigned long whatToShow, NodeFilterImpl *filter,                                bool entityReferenceExpansion, int &exceptioncode){    if (!root) {        exceptioncode = DOMException::NOT_SUPPORTED_ERR;        return 0;    }    return new TreeWalkerImpl( root, whatToShow, filter, entityReferenceExpansion );}void DocumentImpl::setDocumentChanged(bool b){    if (!changedDocuments)        changedDocuments = s_changedDocumentsDeleter.setObject( changedDocuments, new QPtrList<DocumentImpl>() );    if (b && !m_docChanged)        changedDocuments->append(this);    else if (!b && m_docChanged)        changedDocuments->remove(this);    m_docChanged = b;}void DocumentImpl::recalcStyle( StyleChange change ){//     qDebug("recalcStyle(%p)", this);//     QTime qt;//     qt.start();    if (m_inStyleRecalc)        return; // Guard against re-entrancy. -dwh    m_inStyleRecalc = true;    if( !m_render ) goto bail_out;    if ( change == Force ) {        RenderStyle* oldStyle = m_render->style();        if ( oldStyle ) oldStyle->ref();        RenderStyle* _style = new RenderStyle();        _style->setDisplay(BLOCK);        _style->setVisuallyOrdered( visuallyOrdered );        // ### make the font stuff _really_ work!!!!	khtml::FontDef fontDef;	QFont f = KGlobalSettings::generalFont();	fontDef.family = f.family();	fontDef.italic = f.italic();	fontDef.weight = f.weight();        if (m_view) {            const KHTMLSettings *settings = m_view->part()->settings();	    QString stdfont = settings->stdFontName();	    if ( !stdfont.isEmpty() )		fontDef.family = stdfont;            fontDef.size = m_styleSelector->fontSizes()[3];        }        //kdDebug() << "DocumentImpl::attach: setting to charset " << settings->charset() << endl;        _style->setFontDef(fontDef);	_style->htmlFont().update( paintDeviceMetrics() );        if ( inCompatMode() )            _style->setHtmlHacks(true); // enable html specific rendering tricks        StyleChange ch = diff( _style, oldStyle );        if(m_render && ch != NoChange)            m_render->setStyle(_style);	else	    delete _style;        if ( change != Force )            change = ch;        if (oldStyle)            oldStyle->deref();    }    NodeImpl *n;    for (n = _first; n; n = n->nextSibling())        if ( change>= Inherit || n->hasChangedChild() || n->changed() )            n->recalcStyle( change );    //kdDebug( 6020 ) << "TIME: recalcStyle() dt=" << qt.elapsed() << endl;    if (changed() && m_view)	m_view->layout();bail_out:    setChanged( false );    setHasChangedChild( false );    setDocumentChanged( false );    m_inStyleRecalc = false;}void DocumentImpl::updateRendering(){    if (!hasChangedChild()) return;//     QTime time;//     time.start();//     kdDebug() << "UPDATERENDERING: "<<endl;    StyleChange change = NoChange;#if 0    if ( m_styleSelectorDirty ) {	recalcStyleSelector();	change = Force;    }#endif    recalcStyle( change );//    kdDebug() << "UPDATERENDERING time used="<<time.elapsed()<<endl;}void DocumentImpl::updateDocumentsRendering(){    if (!changedDocuments)        return;    while ( !changedDocuments->isEmpty() ) {        changedDocuments->first();        DocumentImpl* it = changedDocuments->take();        if (it->isDocumentChanged())            it->updateRendering();    }}void DocumentImpl::updateLayout(){    bool oldIgnore = m_ignorePendingStylesheets;    if (!haveStylesheetsLoaded()) {        m_ignorePendingStylesheets = true;        updateStyleSelector();    }    updateRendering();    // Only do a layout if changes have occurred that make it necessary.    if (m_view && renderer() && renderer()->needsLayout())	m_view->layout();    m_ignorePendingStylesheets = oldIgnore;}void DocumentImpl::attach(){    assert(!attached());    if ( m_view )        setPaintDevice( m_view );    if (!m_renderArena)	m_renderArena = new RenderArena();    // Create the rendering tree    assert(!m_styleSelector);    m_styleSelector = new CSSStyleSelector( this, m_usersheet, m_styleSheets, m_url,                                            !inCompatMode() );    m_render = new (m_renderArena) RenderCanvas(this, m_view);    m_styleSelector->computeFontSizes(paintDeviceMetrics(), m_view ? m_view->part()->zoomFactor() : 100);    recalcStyle( Force );    RenderObject* render = m_render;    m_render = 0;    NodeBaseImpl::attach();    m_render = render;}void DocumentImpl::detach(){    RenderObject* render = m_render;    // indicate destruction mode,  i.e. attached() but m_render == 0    m_render = 0;    delete m_tokenizer;    m_tokenizer = 0;    // Empty out these lists as a performance optimization    m_imageLoadEventDispatchSoonList.clear();    m_imageLoadEventDispatchingList.clear();    NodeBaseImpl::detach();    if ( render )        render->detach();    m_view = 0;    if ( m_renderArena ) {	delete m_renderArena;	m_renderArena = 0;    }}void DocumentImpl::setVisuallyOrdered(){    visuallyOrdered = true;    if (m_render)        m_render->style()->setVisuallyOrdered(true);}void DocumentImpl::setSelection(NodeImpl* s, int sp, NodeImpl* e, int ep){    if ( m_render )        static_cast<RenderCanvas*>(m_render)->setSelection(s->renderer(),sp,e->renderer(),ep);}void DocumentImpl::clearSelection(){    if ( m_render )        static_cast<RenderCanvas*>(m_render)->clearSelection();}khtml::Tokenizer *DocumentImpl::createTokenizer(){    return new khtml::XMLTokenizer(docPtr(),m_view);}void DocumentImpl::setPaintDevice( QPaintDevice *dev ){    if (m_paintDevice != dev) {        m_paintDevice = dev;        delete m_paintDeviceMetrics;        m_paintDeviceMetrics = new QPaintDeviceMetrics( dev );    }}void DocumentImpl::open( bool clearEventListeners ){    if (parsing()) return;    if (m_tokenizer)        close();    delete m_tokenizer;    m_tokenizer = 0;    KHTMLView* view = m_view;    bool was_attached = attached();    if ( was_attached )        detach();    removeChildren();    delete m_styleSelector;    m_styleSelector = 0;    m_view = view;    if ( was_attached )        attach();    if (clearEventListeners)        m_windowEventListeners.clear();    m_tokenizer = createTokenizer();    m_decoderMibEnum = 0;    connect(m_tokenizer,SIGNAL(finishedParsing()),this,SIGNAL(finishedParsing()));    m_tokenizer->begin();}HTMLElementImpl* DocumentImpl::body(){    NodeImpl *de = documentElement();    if (!de)        return 0;    // try to prefer a FRAMESET element over BODY    NodeImpl* body = 0;    for (NodeImpl* i = de->firstChild(); i; i = i->nextSibling()) {        if (i->id() == ID_FRAMESET)            return static_cast<HTMLElementImpl*>(i);        if (i->id() == ID_BODY)            body = i;    }    return static_cast<HTMLElementImpl *>(body);}void DocumentImpl::close(  ){    if (parsing() || !m_tokenizer) return;    if ( m_render )        m_render->close();    // on an explicit document.close(), the tokenizer might still be waiting on scripts,    // and in that case we don't want to destroy it because that will prevent the    // scripts from getting processed.    if (m_tokenizer && !m_tokenizer->isWaitingForScripts() && !m_tokenizer->isExecutingScript()) {        delete m_tokenizer;        m_tokenizer = 0;    }    if (m_view)        m_view->part()->checkEmitLoadEvent();}void DocumentImpl::write( const DOMString &text ){

⌨️ 快捷键说明

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