default:
kdDebug( 6030 ) << "Error in HTMLCollection, wrong tagId!" << endl;
}
- if(deep && current->firstChild())
- len += calcLength(current->firstChild());
+ if(deep) {
+ current = current->traverseNextNode(base);
+ continue;
+ }
}
- current = current->nextSibling();
+ current = current->traverseNextSibling(base);
}
return len;
}
kdDebug( 6030 ) << "Error in HTMLCollection, wrong tagId!" << endl;
}
if(len == (index + 1)) return current;
- NodeImpl *retval=0;
- if(deep && current->firstChild())
- retval = getItem(current->firstChild(), index, len);
- if(retval) return retval;
+ if (deep) {
+ current = current->traverseNextNode(base);
+ continue;
+ }
}
- current = current->nextSibling();
+ current = current->traverseNextSibling(base);
}
return 0;
}
}
int pos = (int) info->position;
NodeImpl *node = getItem(info->current, index, pos);
- while (!node && info->current->parentNode() && info->current->parentNode() != base) {
- info->current = info->current->parentNode();
- if (info->current->nextSibling())
- node = getItem(info->current->nextSibling(), index, pos);
-
- }
info->current = node;
info->position = index;
return info->current;
resetCollectionInfo();
int pos = 0;
- info->position = ~0; // no position
// Look for the 'second' item. The first one is currentItem, already given back.
NodeImpl *retval = getItem(info->current, 1, pos);
- if (retval)
- {
- info->current = retval;
- return retval;
- }
- // retval was 0, means we have to go up
- while( !retval && info->current->parentNode()
- && info->current->parentNode() != base )
- {
- info->current = info->current->parentNode();
- if (info->current->nextSibling())
- {
- // ... and to take the first one from there
- pos = 0;
- retval = getItem(info->current->nextSibling(), 0, pos);
- }
- }
+
info->current = retval;
- return info->current;
+ return retval;
}
NodeImpl *HTMLCollectionImpl::getNamedItem( NodeImpl *current, int attr_id,
return current;
}
}
- NodeImpl *retval = 0;
- if(deep && current->firstChild())
- retval = getNamedItem(current->firstChild(), attr_id, name, caseSensitive);
- if(retval)
- {
- //kdDebug( 6030 ) << "got a return value " << retval << endl;
- return retval;
- }
+ if (deep) {
+ current = current->traverseNextNode(base);
+ continue;
+ }
}
- current = current->nextSibling();
+ current = current->traverseNextSibling(base);
}
return 0;
}
// attribute. If a match is not found, the method then searches for an
// object with a matching name attribute, but only on those elements
// that are allowed a name attribute.
- resetCollectionInfo();
- info->position = ~0; // no position
+ resetCollectionInfo();
idsDone = false;
info->current = getNamedItem(base->firstChild(), ATTR_ID, name);
if(info->current)
info->current = retval;
return retval;
}
-
- // retval was 0, means we have to go up
- while( !retval && info->current->parentNode()
- && info->current->parentNode() != base )
- {
- info->current = info->current->parentNode();
- if (info->current->nextSibling())
- {
- // ... and to take the first one from there
- retval = getNamedItem(info->current->nextSibling(), idsDone ? ATTR_NAME : ATTR_ID, name);
- }
- }
- if ( retval )
- {
- //kdDebug() << "*HTMLCollectionImpl::nextNamedItem found after going up " << retval << endl;
- info->current = retval;
- return info->current;
- }
}
if ( idsDone )
NodeImpl * HTMLFormCollectionImpl::nextNamedItemInternal( const DOMString &name ) const
{
- NodeImpl *retval = getNamedFormItem( idsDone ? ATTR_NAME : ATTR_ID, name, ++currentPos, true );
+ NodeImpl *retval = getNamedFormItem( idsDone ? ATTR_NAME : ATTR_ID, name, ++info->position, true );
if ( retval )
return retval;
if ( idsDone ) // we're done