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

📄 dom_docimpl.cpp.orig

📁 将konqueror浏览器移植到ARM9 2410中
💻 ORIG
📖 第 1 页 / 共 3 页
字号:
            }            if (start->isElementNode() && start->isSelectable())                return static_cast<ElementImpl*>(start);        }    else        while (1)        {            if (!start->isSelectable() && start->lastChild())                start = start->lastChild();            else if (start->previousSibling())                start = start->previousSibling();            else            {                NodeImpl *pa = start;                while (pa)                {                  // find the previous sibling of the first parent that has a prevSibling                    pa = pa->parentNode();                    if (!pa)                        return 0;                    if (pa->previousSibling())                    {                        start = pa->previousSibling();                        pa = 0;                        break;                    }                }            }            if (start->isElementNode() && start->isSelectable())                return static_cast<ElementImpl*>(start);        }    kdFatal(6000) << "some error in findElement\n";}int DocumentImpl::findHighestTabIndex(){    NodeImpl *n=this;    NodeImpl *next=0;    ElementImpl *a;    int retval=-1;    int tmpval;    while(n)    {        //find out tabindex of current element, if availiable        if (n->isElementNode())        {            a=static_cast<ElementImpl *>(n);            tmpval=a->tabIndex();            if (tmpval>retval)                retval=tmpval;        }        //iterate to next element.        if (!n->isSelectable() && n->firstChild())            n=n->firstChild();        else if (n->nextSibling())            n=n->nextSibling();        else        {            next=0;            while(!next)            {                n=n->parentNode();                if (!n)                    return retval;                next=n->nextSibling();            }            n=next;        }    }    return retval;}ElementImpl *DocumentImpl::findNextLink(ElementImpl *cur, bool forward){    int curTabIndex = (cur?cur->tabIndex():(forward?1:-1));    switch(curTabIndex)    {    case -1:        return notabindex(cur, forward);    case 0:        return tabindexzero(cur, forward);    default:        return intabindex(cur, forward);    }}ElementImpl *DocumentImpl::findLink(ElementImpl *n, bool forward, int tabIndexHint){    // tabIndexHint is the tabIndex that should be found.    // if tabIndex is -1, items containing tabIndex are skipped.    //  kdDebug(6000)<<"DocumentImpl:findLink: Node: "<<n<<" forward: "<<(forward?"true":"false")<<" tabIndexHint: "<<tabIndexHint<<"\n";    int maxTabIndex;    if (forward) maxTabIndex = findHighestTabIndex();    else maxTabIndex = -1;    do    {        n = findSelectableElement(n, forward);        // this is alright even for non-tabindex-searches,        // because DOM::NodeImpl::tabIndex() defaults to -1.    } while (n && (n->tabIndex()!=tabIndexHint));    return n;}ElementImpl *DocumentImpl::notabindex(ElementImpl *cur, bool forward){    // REQ: n must be after the current node and its tabindex must be -1    if ((cur = findLink(cur, forward, -1)))        return cur;    if (forward)        return 0;    else        return tabindexzero(cur, forward);}ElementImpl *DocumentImpl::intabindex(ElementImpl *cur, bool forward){    short tmptabindex;    short maxtabindex = findHighestTabIndex();    short increment=(forward?1:-1);    if (cur)    {        tmptabindex = cur->tabIndex();    }    else tmptabindex=(forward?1:maxtabindex);    while(tmptabindex>0 && tmptabindex<=maxtabindex)    {        if ((cur = findLink(cur, forward, tmptabindex)))            return cur;        tmptabindex+=increment;    }    if (forward)        return tabindexzero(cur, forward);    else        return 0;}ElementImpl *DocumentImpl::tabindexzero(ElementImpl *cur, bool forward){    //REQ: tabindex of result must be 0 and it must be after the current node ;    if ((cur = findLink(cur, forward, 0)))        return cur;    if (forward)        return notabindex(cur, forward);    else        return intabindex(cur, forward);}bool DocumentImpl::prepareMouseEvent( int _x, int _y,                                      int, int,                                      MouseEvent *ev ){    NodeImpl *n = documentElement();    if ( n )        return n->prepareMouseEvent( _x, _y, 0, 0, ev );    else        return false;}// DOM Section 1.1.1bool DocumentImpl::childAllowed( NodeImpl *newChild ){// ### maximum of one Element// ### maximum of one DocumentType    return childTypeAllowed(newChild->nodeType());}bool DocumentImpl::childTypeAllowed( unsigned short type ){    switch (type) {        case Node::ELEMENT_NODE:        case Node::PROCESSING_INSTRUCTION_NODE:        case Node::COMMENT_NODE:        case Node::DOCUMENT_TYPE_NODE:            return true;            break;        default:            return false;    }}NodeImpl *DocumentImpl::cloneNode ( bool /*deep*/, int &exceptioncode ){    exceptioncode = DOMException::NOT_SUPPORTED_ERR;    return 0;}unsigned short DocumentImpl::elementId(DOMStringImpl *_name){    unsigned short id = 0;    // note: this does not take namespaces into account, as it is only really used for css at the moment    if (_name->isLower()) // use the html id instead (if one exists)        id = khtml::getTagID(DOMString(_name).string().ascii(), _name->l);    if (id)        return id;    // first try and find the element    for (id = 0; id < m_elementNameCount; id++)        if (!strcmp(m_elementNames[id],_name))            return id+1000;    // we don't have it yet, assign it an id    if (m_elementNameCount+1 > m_elementNameAlloc) {        m_elementNameAlloc += 100;        DOMStringImpl **newNames = new DOMStringImpl* [m_elementNameAlloc];        if (m_elementNames) {            unsigned short i;            for (i = 0; i < m_elementNameCount; i++)                newNames[i] = m_elementNames[i];            delete [] m_elementNames;        }        m_elementNames = newNames;    }    id = m_elementNameCount++;    m_elementNames[id] = _name;    _name->ref();    // we add 1000 to the XML element id to avoid clashes with HTML element ids    return id+1000;}DOMStringImpl *DocumentImpl::elementName(unsigned short _id) const{    if (_id >= 1000)        return m_elementNames[_id-1000];    else        return getTagName(_id).implementation()->lower();}StyleSheetListImpl* DocumentImpl::styleSheets(){    return m_styleSheets;}void DocumentImpl::createSelector(){    if ( !m_render || !attached() ) return;    QList<StyleSheetImpl> oldStyleSheets = m_styleSheets->styleSheets;    m_styleSheets->styleSheets.clear();    NodeImpl *n;    for (n = this; n; n = n->traverseNextNode()) {    	StyleSheetImpl *sheet = 0;    	if (n->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)	    sheet = static_cast<ProcessingInstructionImpl*>(n)->sheet();    	else if (n->id() == ID_LINK)	    sheet = static_cast<HTMLLinkElementImpl*>(n)->sheet();    	else if (n->id() == ID_STYLE)	    sheet = static_cast<HTMLStyleElementImpl*>(n)->sheet();    	else if (n->id() == ID_BODY)	    sheet = static_cast<HTMLBodyElementImpl*>(n)->sheet();	if (sheet) {	    sheet->ref();	    m_styleSheets->styleSheets.append(sheet);	}	if (isHTMLDocument() && n->id() == ID_BODY)	    break;    }    QListIterator<StyleSheetImpl> it(oldStyleSheets);    for (; it.current(); ++it)	it.current()->deref();    applyChanges(true,true);}void DocumentImpl::setFocusNode(ElementImpl *n){    // ### add check for same Document    if (m_focusNode != n)    {        if (m_focusNode)        {            if (m_focusNode->active()) m_focusNode->setActive(false);            m_focusNode->setFocus(false);	    int exceptioncode;	    UIEventImpl *ue = new UIEventImpl(EventImpl::DOMFOCUSOUT_EVENT,	                                      true,false,defaultView(),					      0);	    ue->ref();	    m_focusNode->dispatchEvent(ue,exceptioncode);	    ue->deref();        }        m_focusNode = n;        //kdDebug(6020)<<"DOM::DocumentImpl::setFocusNode("<<n<<")"<<endl;        if (n)	{	    int exceptioncode;	    UIEventImpl *ue = new UIEventImpl(EventImpl::DOMFOCUSIN_EVENT,	                                      true,false,defaultView(),					      0);	    ue->ref();	    m_focusNode->dispatchEvent(ue,exceptioncode);	    ue->deref();            n->setFocus();	}    }}ElementImpl *DocumentImpl::focusNode(){    return m_focusNode;}void DocumentImpl::attachNodeIterator(NodeIteratorImpl *ni){    m_nodeIterators.append(ni);}void DocumentImpl::detachNodeIterator(NodeIteratorImpl *ni){    m_nodeIterators.remove(ni);}void DocumentImpl::notifyBeforeNodeRemoval(NodeImpl *n){    QListIterator<NodeIteratorImpl> it(m_nodeIterators);    for (; it.current(); ++it)        it.current()->notifyBeforeNodeRemoval(n);}AbstractViewImpl *DocumentImpl::defaultView() const{    return m_defaultView;}EventImpl *DocumentImpl::createEvent(const DOMString &eventType, int &exceptioncode){    if (eventType == "UIEvents")        return new UIEventImpl();    else if (eventType == "MouseEvents")        return new MouseEventImpl();    else if (eventType == "MutationEvents")        return new MutationEventImpl();    else if (eventType == "HTMLEvents")        return new EventImpl();    else {        exceptioncode = DOMException::NOT_SUPPORTED_ERR;        return 0;    }}CSSStyleDeclarationImpl *DocumentImpl::getOverrideStyle(ElementImpl */*elt*/, DOMStringImpl */*pseudoElt*/){    return 0; // ###}void DocumentImpl::defaultEventHandler(EventImpl *evt){    // if any html event listeners are registered on the window, then dispatch them here    QListIterator<RegisteredEventListener> it(m_windowEventListeners);    Event ev = evt;    for (; it.current(); ++it) {        if (it.current()->id == evt->id()) {            it.current()->listener->handleEvent(ev);	    return;	}    }}void DocumentImpl::setWindowEventListener(int id, EventListener *listener){    removeWindowEventListener(id);    if (listener) {	RegisteredEventListener *rl = new RegisteredEventListener(static_cast<EventImpl::EventId>(id),listener,false);	m_windowEventListeners.append(rl);    }}EventListener *DocumentImpl::getWindowEventListener(int id){    QListIterator<RegisteredEventListener> it(m_windowEventListeners);    for (; it.current(); ++it) {	if (it.current()->id == id) {	    return it.current()->listener;	}    }    return 0;}void DocumentImpl::removeWindowEventListener(int id){    QListIterator<RegisteredEventListener> it(m_windowEventListeners);    for (; it.current(); ++it) {	if (it.current()->id == id) {	    m_windowEventListeners.removeRef(it.current());	    return;	}    }}EventListener *DocumentImpl::createHTMLEventListener(QString code){    return view()->part()->createHTMLEventListener(code);}// ----------------------------------------------------------------------------DocumentFragmentImpl::DocumentFragmentImpl(DocumentPtr *doc) : NodeBaseImpl(doc){}DocumentFragmentImpl::DocumentFragmentImpl(const DocumentFragmentImpl &other)    : NodeBaseImpl(other){}const DOMString DocumentFragmentImpl::nodeName() const{  return "#document-fragment";}unsigned short DocumentFragmentImpl::nodeType() const{    return Node::DOCUMENT_FRAGMENT_NODE;}// DOM Section 1.1.1bool DocumentFragmentImpl::childTypeAllowed( unsigned short type ){    switch (type) {        case Node::ELEMENT_NODE:        case Node::PROCESSING_INSTRUCTION_NODE:        case Node::COMMENT_NODE:        case Node::TEXT_NODE:        case Node::CDATA_SECTION_NODE:        case Node::ENTITY_REFERENCE_NODE:            return true;            break;        default:            return false;    }}NodeImpl *DocumentFragmentImpl::cloneNode ( bool deep, int &exceptioncode ){    DocumentFragmentImpl *clone = new DocumentFragmentImpl( docPtr() );    if (deep)        cloneChildNodes(clone,exceptioncode);    return clone;}// ----------------------------------------------------------------------------DocumentTypeImpl::DocumentTypeImpl(DocumentPtr *doc) : NodeImpl(doc){    m_entities = new GenericRONamedNodeMapImpl();    m_entities->ref();    m_notations = new GenericRONamedNodeMapImpl();    m_notations->ref();}DocumentTypeImpl::~DocumentTypeImpl(){    m_entities->deref();    m_notations->deref();}const DOMString DocumentTypeImpl::name() const{    // ###    return 0;}NamedNodeMapImpl *DocumentTypeImpl::entities() const{    return m_entities;}NamedNodeMapImpl *DocumentTypeImpl::notations() const{    return m_notations;}const DOMString DocumentTypeImpl::nodeName() const{    return name();}unsigned short DocumentTypeImpl::nodeType() const{    return Node::DOCUMENT_TYPE_NODE;}// DOM Section 1.1.1bool DocumentTypeImpl::childTypeAllowed( unsigned short /*type*/ ){    return false;}NodeImpl *DocumentTypeImpl::cloneNode ( bool /*deep*/, int &exceptioncode ){    exceptioncode = DOMException::NOT_SUPPORTED_ERR;    return 0;}#include "dom_docimpl.moc"

⌨️ 快捷键说明

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