本文整理汇总了C++中NodeImpl::firstChild方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeImpl::firstChild方法的具体用法?C++ NodeImpl::firstChild怎么用?C++ NodeImpl::firstChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeImpl
的用法示例。
在下文中一共展示了NodeImpl::firstChild方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deepEquivalent
Position VisiblePosition::deepEquivalent(const Position &pos)
{
NodeImpl *node = pos.node();
long offset = pos.offset();
if (!node)
return Position();
if (isAtomicNode(node))
return pos;
if (offset >= (long)node->childNodeCount()) {
do {
NodeImpl *child = node->lastChild();
if (!child)
break;
node = child;
} while (!isAtomicNode(node));
return Position(node, node->caretMaxOffset());
}
node = node->childNode(offset);
ASSERT(node);
while (!isAtomicNode(node)) {
NodeImpl *child = node->firstChild();
if (!child)
break;
node = child;
}
return Position(node, 0);
}
示例2: title
DOMString HTMLDocument::title() const
{
if(!impl) return 0;
NodeImpl *e = static_cast<HTMLDocumentImpl *>(impl)->findElement(ID_TITLE);
if(!e) return 0;
NodeImpl *t = e->firstChild();
if(!t) return 0;
// ### join all text nodes within <TITLE>
return static_cast<TextImpl *>(t)->data();
}
示例3: rowIndex
long HTMLTableRowElementImpl::rowIndex() const
{
int rIndex = 0;
NodeImpl *table = parentNode();
if ( !table )
return -1;
table = table->parentNode();
if ( !table || table->id() != ID_TABLE )
return -1;
HTMLTableSectionElementImpl *head = static_cast<HTMLTableElementImpl *>(table)->tHead();
HTMLTableSectionElementImpl *foot = static_cast<HTMLTableElementImpl *>(table)->tFoot();
if ( head ) {
const NodeImpl *row = head->firstChild();
while ( row ) {
if ( row == this )
return rIndex;
rIndex++;
row = row->nextSibling();
}
}
NodeImpl *node = table->firstChild();
while ( node ) {
if ( node != foot && node != head && (node->id() == ID_THEAD || node->id() == ID_TFOOT || node->id() == ID_TBODY) ) {
HTMLTableSectionElementImpl* section = static_cast<HTMLTableSectionElementImpl *>(node);
const NodeImpl *row = section->firstChild();
while ( row ) {
if ( row == this )
return rIndex;
rIndex++;
row = row->nextSibling();
}
}
node = node->nextSibling();
}
const NodeImpl *row = foot->firstChild();
while ( row ) {
if ( row == this )
return rIndex;
rIndex++;
row = row->nextSibling();
}
// should never happen
return -1;
}
示例4: documentElement
HTMLElementImpl *HTMLDocumentImpl::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);
}
示例5: nodePositionRelativeToRoot
static QString nodePositionRelativeToRoot(NodeImpl *node, NodeImpl *root)
{
QString result;
NodeImpl *n = node;
while (1) {
NodeImpl *p = n->parentNode();
if (!p || n == root) {
result += " of root {" + getTagName(n) + "}";
break;
}
if (n != node)
result += " of ";
int count = 1;
for (NodeImpl *search = p->firstChild(); search != n; search = search->nextSibling())
count++;
result += "child " + QString::number(count) + " {" + getTagName(n) + "}";
n = p;
}
return result;
}
示例6: downstream
Position Position::downstream(EStayInBlock stayInBlock) const
{
Position start = equivalentDeepPosition();
NodeImpl *startNode = start.node();
if (!startNode)
return Position();
NodeImpl *block = startNode->enclosingBlockFlowOrTableElement();
Position lastVisible;
PositionIterator it(start);
for (; !it.atEnd(); it.next()) {
NodeImpl *currentNode = it.current().node();
if (stayInBlock) {
NodeImpl *currentBlock = currentNode->enclosingBlockFlowOrTableElement();
if (block != currentBlock)
return it.previous();
}
RenderObject *renderer = currentNode->renderer();
if (!renderer)
continue;
if (renderer->style()->visibility() != VISIBLE)
continue;
lastVisible = it.current();
if (currentNode != startNode && renderer->isBlockFlow()) {
if (it.current().offset() == 0) {
// If no first child, or first visible child is a not a block, return; otherwise continue.
if (!currentNode->firstChild())
return Position(currentNode, 0);
for (NodeImpl *child = currentNode->firstChild(); child; child = child->nextSibling()) {
RenderObject *r = child->renderer();
if (r && r->style()->visibility() == VISIBLE) {
if (r->isBlockFlow())
break; // break causes continue code below to run.
else
return Position(child, 0);
}
}
continue;
}
}
if (renderer->isReplaced() || renderer->isBR()) {
if (it.current().offset() <= renderer->caretMinOffset())
return Position(currentNode, renderer->caretMinOffset());
else
continue;
}
if (renderer->isText() && static_cast<RenderText *>(renderer)->firstTextBox()) {
if (currentNode != start.node())
return Position(currentNode, renderer->caretMinOffset());
if (it.current().offset() < 0)
continue;
uint textOffset = it.current().offset();
RenderText *textRenderer = static_cast<RenderText *>(renderer);
for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
if (textOffset >= box->start() && textOffset <= box->end())
return it.current();
else if (box != textRenderer->lastTextBox() &&
!box->nextOnLine() &&
textOffset == box->start() + box->len())
return it.current();
}
}
}
return lastVisible.isNotNull() ? lastVisible : *this;
}
示例7: handleResidualStyleCloseTagAcrossBlocks
//.........这里部分代码省略.........
while (currElem->node != residualElem) {
if (isResidualStyleTag(currElem->node->id())) {
// Create a clone of this element.
currNode = currElem->node->cloneNode(false);
// Change the stack element's node to point to the clone.
currElem->node = currNode;
// Attach the previous node as a child of this new node.
if (prevNode)
currNode->appendChild(prevNode, exceptionCode);
else // The new parent for the block element is going to be the innermost clone.
parentElem = currNode;
prevNode = currNode;
}
currElem = currElem->next;
}
// Now append the chain of new residual style elements if one exists.
if (prevNode)
elem->node->appendChild(prevNode, exceptionCode);
}
// We need to make a clone of |residualElem| and place it just inside |blockElem|.
// All content of |blockElem| is reparented to be under this clone. We then
// reparent |blockElem| using real DOM calls so that attachment/detachment will
// be performed to fix up the rendering tree.
// So for this example: <b>...<p>Foo</b>Goo</p>
// The end result will be: <b>...</b><p><b>Foo</b>Goo</p>
//
// Step 1: Remove |blockElem| from its parent, doing a batch detach of all the kids.
blockElem->parentNode()->removeChild(blockElem, exceptionCode);
// Step 2: Clone |residualElem|.
NodeImpl* newNode = residualElem->cloneNode(false); // Shallow clone. We don't pick up the same kids.
// Step 3: Place |blockElem|'s children under |newNode|. Remove all of the children of |blockElem|
// before we've put |newElem| into the document. That way we'll only do one attachment of all
// the new content (instead of a bunch of individual attachments).
NodeImpl* currNode = blockElem->firstChild();
while (currNode) {
NodeImpl* nextNode = currNode->nextSibling();
blockElem->removeChild(currNode, exceptionCode);
newNode->appendChild(currNode, exceptionCode);
currNode = nextNode;
}
// Step 4: Place |newNode| under |blockElem|. |blockElem| is still out of the document, so no
// attachment can occur yet.
blockElem->appendChild(newNode, exceptionCode);
// Step 5: Reparent |blockElem|. Now the full attachment of the fixed up tree takes place.
parentElem->appendChild(blockElem, exceptionCode);
// Step 6: Elide |elem|, since it is effectively no longer open. Also update
// the node associated with the previous stack element so that when it gets popped,
// it doesn't make the residual element the next current node.
HTMLStackElem* currElem = maxElem;
HTMLStackElem* prevElem = 0;
while (currElem != elem) {
prevElem = currElem;
currElem = currElem->next;
}
prevElem->next = elem->next;
prevElem->node = elem->node;
delete elem;
// Step 7: Reopen intermediate inlines, e.g., <b><p><i>Foo</b>Goo</p>.
// In the above example, Goo should stay italic.
curr = blockStack;
HTMLStackElem* residualStyleStack = 0;
while (curr && curr != maxElem) {
// We will actually schedule this tag for reopening
// after we complete the close of this entire block.
NodeImpl* currNode = current;
if (isResidualStyleTag(curr->id)) {
// We've overloaded the use of stack elements and are just reusing the
// struct with a slightly different meaning to the variables. Instead of chaining
// from innermost to outermost, we build up a list of all the tags we need to reopen
// from the outermost to the innermost, i.e., residualStyleStack will end up pointing
// to the outermost tag we need to reopen.
// We also set curr->node to be the actual element that corresponds to the ID stored in
// curr->id rather than the node that you should pop to when the element gets pulled off
// the stack.
popOneBlock(false);
curr->node = currNode;
curr->next = residualStyleStack;
residualStyleStack = curr;
}
else
popOneBlock();
curr = blockStack;
}
reopenResidualStyleTags(residualStyleStack, 0); // FIXME: Deal with stray table content some day
// if it becomes necessary to do so.
}