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

📄 dom_docimpl.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    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: // FIXME: make an element here. "bdo" with dir adds the CSS direction and unicode-bidi with override.        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;}KHTMLPart *DocumentImpl::part() const {    return m_view ? m_view->part() : 0; }RangeImpl *DocumentImpl::createRange(){    return new RangeImpl( docPtr() );}NodeIteratorImpl *DocumentImpl::createNodeIterator(NodeImpl *root, unsigned long whatToShow,     NodeFilterImpl *filter, bool expandEntityReferences, int &exceptioncode){    if (!root) {        exceptioncode = DOMException::NOT_SUPPORTED_ERR;        return 0;    }    return new NodeIteratorImpl(root, whatToShow, filter, expandEntityReferences);}TreeWalkerImpl *DocumentImpl::createTreeWalker(NodeImpl *root, unsigned long whatToShow,     NodeFilterImpl *filter, bool expandEntityReferences, int &exceptioncode){    if (!root) {        exceptioncode = DOMException::NOT_SUPPORTED_ERR;        return 0;    }    return new TreeWalkerImpl(root, whatToShow, filter, expandEntityReferences);}void DocumentImpl::setDocumentChanged(bool b){    if (!changedDocuments)        changedDocuments = s_changedDocumentsDeleter.setObject( new QPtrList<DocumentImpl>() );    if (b && !m_docChanged)        changedDocuments->append(this);    else if (!b && m_docChanged)        changedDocuments->remove(this);    m_docChanged = b;        if (m_docChanged)        m_accessKeyDictValid = false;}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 (m_renderArena) RenderStyle();        _style->setDisplay(BLOCK);        _style->setVisuallyOrdered( visuallyOrdered );        // ### make the font stuff _really_ work!!!!	khtml::FontDef fontDef;	QFont f = KGlobalSettings::generalFont();	fontDef.family = *(f.firstFamily());	fontDef.italic = f.italic();	fontDef.weight = f.weight();#if APPLE_CHANGES        bool printing = m_paintDevice && (m_paintDevice->devType() == QInternal::Printer);        fontDef.usePrinterFont = printing;#endif        if (m_view) {            const KHTMLSettings *settings = m_view->part()->settings();#if APPLE_CHANGES            if (printing && !settings->shouldPrintBackgrounds()) {                _style->setShouldCorrectTextColor(true);            }#endif            QString stdfont = settings->stdFontName();            if ( !stdfont.isEmpty() ) {                fontDef.family.setFamily(stdfont);                fontDef.family.appendFamily(0);            }            m_styleSelector->setFontSize(fontDef, m_styleSelector->fontSizeForKeyword(CSS_VAL_MEDIUM, inCompatMode()));        }        //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(m_renderArena);    }    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 (DocumentImpl* doc = changedDocuments->take()) {        doc->m_docChanged = false;        doc->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 APPLE_CHANGES    assert(!m_inPageCache);#endif    if ( m_view )        setPaintDevice( m_view );    if (!m_renderArena)        m_renderArena = new RenderArena();        // Create the rendering tree    m_render = new (m_renderArena) RenderCanvas(this, m_view);    recalcStyle( Force );    RenderObject* render = m_render;    m_render = 0;    NodeBaseImpl::attach();    m_render = render;}void DocumentImpl::restoreRenderer(RenderObject* render){    m_render = render;}void DocumentImpl::detach(){    RenderObject* render = m_render;    // indicate destruction mode,  i.e. attached() but m_render == 0    m_render = 0;    #if APPLE_CHANGES    if (m_inPageCache) {        return;    }#endif    // Empty out these lists as a performance optimization, since detaching    // all the individual render objects will cause all the RenderImage    // objects to remove themselves from the lists.    m_imageLoadEventDispatchSoonList.clear();    m_imageLoadEventDispatchingList.clear();    NodeBaseImpl::detach();    if ( render )        render->detach();    if (m_paintDevice == m_view)        setPaintDevice(0);    m_view = 0;        if (m_renderArena){        delete m_renderArena;        m_renderArena = 0;    }}#if APPLE_CHANGESKWQAccObjectCache* DocumentImpl::getOrCreateAccObjectCache(){    if (!m_accCache)        m_accCache = new KWQAccObjectCache;    return m_accCache;}#endifvoid DocumentImpl::setVisuallyOrdered(){    visuallyOrdered = true;    if (m_render)        m_render->style()->setVisuallyOrdered(true);}void DocumentImpl::updateSelection(){    if (!m_render)        return;        RenderCanvas *canvas = static_cast<RenderCanvas*>(m_render);    Selection s = part()->selection();    if (s.isEmpty() || s.state() == Selection::CARET) {        canvas->clearSelection();    }    else {        RenderObject *startRenderer = s.start().node() ? s.start().node()->renderer() : 0;        RenderObject *endRenderer = s.end().node() ? s.end().node()->renderer() : 0;        static_cast<RenderCanvas*>(m_render)->setSelection(startRenderer, s.start().offset(), endRenderer, s.end().offset());    }}Tokenizer *DocumentImpl::createTokenizer(){    return new XMLTokenizer(docPtr(),m_view);}XMLHandler* DocumentImpl::createTokenHandler(){    return new XMLHandler(docPtr(), m_view);}void DocumentImpl::setPaintDevice( QPaintDevice *dev ){    if (m_paintDevice == dev) {        return;    }    m_paintDevice = dev;    delete m_paintDeviceMetrics;    m_paintDeviceMetrics = dev ? new QPaintDeviceMetrics( dev ) : 0;}void DocumentImpl::open(  ){    if (parsing()) return;    if (m_tokenizer)        close();    clear();    m_tokenizer = createTokenizer();    connect(m_tokenizer,SIGNAL(finishedParsing()),this,SIGNAL(finishedParsing()));    m_tokenizer->begin();    if (m_view && m_view->part()->jScript()) {        m_view->part()->jScript()->setSourceFile(m_url,""); //fixme    }}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(){    // First fire the onload.    bool doload = !parsing() && m_tokenizer && !m_processingLoadEvent;        bool wasNotRedirecting = !part() || part()->d->m_scheduledRedirection == noRedirectionScheduled || part()->d->m_scheduledRedirection == historyNavigationScheduled;        m_processingLoadEvent = true;    if (body() && doload) {        // We have to clear the tokenizer, in case someone document.write()s from the        // onLoad event handler, as in Radar 3206524        delete m_tokenizer;        m_tokenizer = 0;        dispatchImageLoadEventsNow();        body()->dispatchWindowEvent(EventImpl::LOAD_EVENT, false, false);#ifdef INSTRUMENT_LAYOUT_SCHEDULING        if (!ownerElement())            printf("onload fired at %d\n", elapsedTime());#endif    }    m_processingLoadEvent = false;        // Make sure both the initial layout and reflow happen after the onload    // fires. This will improve onload scores, and other browsers do it.    // If they wanna cheat, we can too. -dwh        bool isRedirectingSoon = view() && view()->part()->d->m_scheduledRedirection != noRedirectionScheduled && view()->part()->d->m_scheduledRedirection != historyNavigationScheduled && view()->part()->d->m_delayRedirect == 0;        if (doload && wasNotRedirecting && isRedirectingSoon && m_startTime.elapsed() < cLayoutTimerDelay) {	// Just bail out. During the onload we were shifted to another page.	// i-Bench does this. When this happens don't bother painting or laying out.

⌨️ 快捷键说明

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