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

📄 dom_docimpl.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	delete m_tokenizer;	m_tokenizer = 0; 	view()->unscheduleRelayout();	return;    }        // The initial layout happens here.    DocumentImpl::closeInternal(!doload);        // Now do our painting/layout, but only if we aren't in a subframe or if we're in a subframe    // that has been sized already.  Otherwise, our view size would be incorrect, so doing any     // layout/painting now would be pointless.    if (doload) {        if (!ownerElement() || (ownerElement()->renderer() && !ownerElement()->renderer()->needsLayout())) {            updateRendering();                        // Always do a layout after loading if needed.            if (view() && renderer() && (!renderer()->firstChild() || renderer()->needsLayout()))                view()->layout();        }#if APPLE_CHANGES        if (renderer() && KWQAccObjectCache::accessibilityEnabled())            getOrCreateAccObjectCache()->postNotification(renderer(), "AXLoadComplete");#endif    }}void DocumentImpl::closeInternal( bool checkTokenizer ){    if (parsing() || (checkTokenizer && !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()) {	delete m_tokenizer;	m_tokenizer = 0;    }    if (m_view)        m_view->part()->checkEmitLoadEvent();}void DocumentImpl::setParsing(bool b){    m_bParsing = b;#ifdef INSTRUMENT_LAYOUT_SCHEDULING    if (!ownerElement() && !m_bParsing)        printf("Parsing turned off at %d\n", elapsedTime());#endif}bool DocumentImpl::shouldScheduleLayout(){    return renderer() && haveStylesheetsLoaded();}int DocumentImpl::minimumLayoutDelay(){    if (allDataReceived() && m_overMinimumLayoutThreshold)        return 0;        int elapsed = m_startTime.elapsed();    m_overMinimumLayoutThreshold = elapsed > cLayoutScheduleThreshold;        if (!allDataReceived()) // Always want the nearest multiple of the timer delay.        return cLayoutTimerDelay - elapsed % cLayoutTimerDelay;    // We'll want to schedule the timer to fire at the minimum layout threshold.    return kMax(0, cLayoutScheduleThreshold - elapsed);}int DocumentImpl::elapsedTime(){    return m_startTime.elapsed();}void DocumentImpl::write( const DOMString &text ){    write(text.string());}void DocumentImpl::write( const QString &text ){    if (!m_tokenizer) {        open();        write(QString::fromLatin1("<html>"));    }    m_tokenizer->write(text, false);    if (m_view && m_view->part()->jScript())        m_view->part()->jScript()->appendSourceFile(m_url,text);}void DocumentImpl::writeln( const DOMString &text ){    write(text);    write(DOMString("\n"));}void DocumentImpl::finishParsing(){    // Let the tokenizer go through as much data as it can.  There will be three possible outcomes after    // finish() is called:    // (1) All remaining data is parsed, document isn't loaded yet    // (2) All remaining data is parsed, document is loaded, tokenizer gets deleted    // (3) Data is still remaining to be parsed.    if (m_tokenizer)        m_tokenizer->finish();    // Don't say we've really received all the data until we've given the tokenizer    // a chance to try to eat as much of the data as it can.    m_bAllDataReceived = true;    if (m_tokenizer) {        // Update layout *now* if possible.  If we don't have a tokenizer any more, we already updated        // layout because of the onload firing.        #ifdef INSTRUMENT_LAYOUT_SCHEDULING        if (!ownerElement())            printf("Received all data and parsed as much as possible at time: %d with delay until next layout of %d\n", elapsedTime(), minimumLayoutDelay());#endif        // We can update layout if:        // (a) we're an XML document or we're an HTML document and our body has been parsed (ensuring we'll have        // the background ready to paint)        // (b) our stylesheets are all loaded        // (c) we're over the minimum layout threshold        // (d) we are an iframe in a document that has flowed us already or we aren't an iframe at all        // (e) we actually need a layout        if ((!isHTMLDocument() || body()) && haveStylesheetsLoaded() && !minimumLayoutDelay() &&            (!ownerElement() || (ownerElement()->renderer() && !ownerElement()->renderer()->needsLayout())) &&            renderer() && renderer()->needsLayout())            updateLayout();    }}void DocumentImpl::clear(){    delete m_tokenizer;    m_tokenizer = 0;    removeChildren();    QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);    for (; it.current();)        m_windowEventListeners.removeRef(it.current());}void DocumentImpl::setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet){//    kdDebug( 6030 ) << "HTMLDocument::setStyleSheet()" << endl;    m_sheet = new CSSStyleSheetImpl(this, url);    m_sheet->ref();    m_sheet->parseString(sheet);    m_loadingSheet = false;    updateStyleSelector();}void DocumentImpl::setUserStyleSheet( const QString& sheet ){    if ( m_usersheet != sheet ) {        m_usersheet = sheet;	updateStyleSelector();    }}CSSStyleSheetImpl* DocumentImpl::elementSheet(){    if (!m_elemSheet) {        m_elemSheet = new CSSStyleSheetImpl(this, baseURL() );        m_elemSheet->ref();    }    return m_elemSheet;}void DocumentImpl::determineParseMode( const QString &/*str*/ ){    // For XML documents use strict parse mode.  HTML docs will override this method to    // determine their parse mode.    pMode = Strict;    hMode = XHtml;    kdDebug(6020) << " using strict parseMode" << endl;}// Please see if there`s a possibility to merge that code// with the next function and getElementByID().NodeImpl *DocumentImpl::findElement( Id id ){    QPtrStack<NodeImpl> nodeStack;    NodeImpl *current = _first;    while(1)    {        if(!current)        {            if(nodeStack.isEmpty()) break;            current = nodeStack.pop();            current = current->nextSibling();        }        else        {            if(current->id() == id)                return current;            NodeImpl *child = current->firstChild();            if(child)            {                nodeStack.push(current);                current = child;            }            else            {                current = current->nextSibling();            }        }    }    return 0;}NodeImpl *DocumentImpl::nextFocusNode(NodeImpl *fromNode){    unsigned short fromTabIndex;    if (!fromNode) {	// No starting node supplied; begin with the top of the document	NodeImpl *n;	int lowestTabIndex = 65535;	for (n = this; n != 0; n = n->traverseNextNode()) {	    if (n->isKeyboardFocusable()) {		if ((n->tabIndex() > 0) && (n->tabIndex() < lowestTabIndex))		    lowestTabIndex = n->tabIndex();	    }	}	if (lowestTabIndex == 65535)	    lowestTabIndex = 0;	// Go to the first node in the document that has the desired tab index	for (n = this; n != 0; n = n->traverseNextNode()) {	    if (n->isKeyboardFocusable() && (n->tabIndex() == lowestTabIndex))		return n;	}	return 0;    }    else {	fromTabIndex = fromNode->tabIndex();    }    if (fromTabIndex == 0) {	// Just need to find the next selectable node after fromNode (in document order) that doesn't have a tab index	NodeImpl *n = fromNode->traverseNextNode();	while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))	    n = n->traverseNextNode();	return n;    }    else {	// Find the lowest tab index out of all the nodes except fromNode, that is greater than or equal to fromNode's	// tab index. For nodes with the same tab index as fromNode, we are only interested in those that come after	// fromNode in document order.	// If we don't find a suitable tab index, the next focus node will be one with a tab index of 0.	unsigned short lowestSuitableTabIndex = 65535;	NodeImpl *n;	bool reachedFromNode = false;	for (n = this; n != 0; n = n->traverseNextNode()) {	    if (n->isKeyboardFocusable() &&		((reachedFromNode && (n->tabIndex() >= fromTabIndex)) ||		 (!reachedFromNode && (n->tabIndex() > fromTabIndex))) &&		(n->tabIndex() < lowestSuitableTabIndex) &&		(n != fromNode)) {		// We found a selectable node with a tab index at least as high as fromNode's. Keep searching though,		// as there may be another node which has a lower tab index but is still suitable for use.		lowestSuitableTabIndex = n->tabIndex();	    }	    if (n == fromNode)		reachedFromNode = true;	}	if (lowestSuitableTabIndex == 65535) {	    // No next node with a tab index -> just take first node with tab index of 0	    NodeImpl *n = this;	    while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))		n = n->traverseNextNode();	    return n;	}	// Search forwards from fromNode	for (n = fromNode->traverseNextNode(); n != 0; n = n->traverseNextNode()) {	    if (n->isKeyboardFocusable() && (n->tabIndex() == lowestSuitableTabIndex))		return n;	}	// The next node isn't after fromNode, start from the beginning of the document	for (n = this; n != fromNode; n = n->traverseNextNode()) {	    if (n->isKeyboardFocusable() && (n->tabIndex() == lowestSuitableTabIndex))		return n;	}	assert(false); // should never get here	return 0;    }}NodeImpl *DocumentImpl::previousFocusNode(NodeImpl *fromNode){    NodeImpl *lastNode = this;    while (lastNode->lastChild())	lastNode = lastNode->lastChild();    if (!fromNode) {	// No starting node supplied; begin with the very last node in the document	NodeImpl *n;	int highestTabIndex = 0;	for (n = lastNode; n != 0; n = n->traversePreviousNode()) {	    if (n->isKeyboardFocusable()) {		if (n->tabIndex() == 0)		    return n;		else if (n->tabIndex() > highestTabIndex)		    highestTabIndex = n->tabIndex();	    }	}	// No node with a tab index of 0; just go to the last node with the highest tab index	for (n = lastNode; n != 0; n = n->traversePreviousNode()) {	    if (n->isKeyboardFocusable() && (n->tabIndex() == highestTabIndex))		return n;	}	return 0;    }    else {	unsigned short fromTabIndex = fromNode->tabIndex();	if (fromTabIndex == 0) {	    // Find the previous selectable node before fromNode (in document order) that doesn't have a tab index	    NodeImpl *n = fromNode->traversePreviousNode();	    while (n && !(n->isKeyboardFocusable() && n->tabIndex() == 0))		n = n->traversePreviousNode();	    if (n)		return n;	    // No previous nodes with a 0 tab index, go to the last node in the document that has the highest tab index	    int highestTabIndex = 0;	    for (n = this; n != 0; n = n->traverseNextNode()) {		if (n->isKeyboardFocusable() && (n->tabIndex() > highestTabIndex))		    highestTabIndex = n->tabIndex();	    }	    if (highestTabIndex == 0)		return 0;	    for (n = lastNode; n != 0; n = n->traversePreviousNode()) {		if (n->isKeyboardFocusable() && (n->tabIndex() == highestTabIndex))		    return n;	    }	    assert(false); // should never get here	    return 0;	}	else {	    // Find the lowest tab index out of all the nodes except fromNode, that is less than or equal to fromNode's	    // tab index. For nodes with the same tab index as fromNode, we are only interested in those before	    // fromNode.	    // If we don't find a suitable tab index, then there will be no previous focus node.	    unsigned short highestSuitableTabIndex = 0;	    NodeImpl *n;	    bool reachedFromNode = false;	    for (n = this; n != 0; n = n->traverseNextNode()) {		if (n->isKeyboardFocusable() &&		    ((!reachedFromNode && (n->tabIndex() <= fromTabIndex)) ||		     (reachedFromNode && (n->tabIndex() < fromTabIndex)))  &&		    (n->tabIndex() > highestSuitableTabIndex) &&		    (n != fromNode)) {		    // We found a selectable node with a tab index no higher than fromNode's. Keep searching though, as		    // there may be another node which has a higher tab index but is still suitable for use.		    highestSuitableTabIndex = n->tabIndex();		}		if (n == fromNode)		    reachedFromNode = true;	    }	    if (highestSuitableTabIndex == 0) {		// No previous node with a tab index. Since the order specified by HTML is nodes with tab index > 0		// first, this means that there is no previous node.		return 0;	    }	    // Search backwards from fromNode	    for (n = fromNode->traversePreviousNode(); n != 0; n = n->traversePreviousNode()) {		if (n->isKeyboardFocusable() && (n->tabIndex() == highestSuitableTabIndex))		    return n;	    }	    // The previous node isn't before fromNode, start from the end of the document	    for (n = lastNode; n != fromNode; n = n->traversePreviousNode()) {		if (n->isKeyboardFocusable() && (n->tabIndex() == highestSuitableTabIndex))		    return n;	    }	    assert(false); // should never get here	    return 0;	}    }}int DocumentImpl::nodeAbsIndex(NodeImpl *node){    assert(node->getDocument() == this);    int absIndex = 0;    for (NodeImpl *n = node; n && n != this; n = n->traversePreviousNode())	absIndex++;    return absIndex;}NodeImpl *DocumentImpl::nodeWithAbsIndex(int absIndex){    NodeImpl *n = this;    for (int i = 0; n && (i < absIndex); i++) {	n = n->traverseNextNode();    }    return n;}void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &content){    assert(!equiv.isNull() && !content.isNull());    KHTMLPart *part = getDocument()->part();    if (strcasecmp(equiv, "default-style") == 0) {        // The preferred style set has been overridden as per section         // 14.3.2 of the HTML4.0 specification.  We need to update the        // sheet used variable and then update our style selector. 

⌨️ 快捷键说明

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