本文整理汇总了C++中Text::appendData方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::appendData方法的具体用法?C++ Text::appendData怎么用?C++ Text::appendData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::appendData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOuterText
void HTMLElement::setOuterText(const String &text, ExceptionCode& ec)
{
// follow the IE specs about when this is allowed
if (endTagRequirement() == TagStatusForbidden) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return;
}
if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(framesetTag) ||
hasLocalName(headTag) || hasLocalName(htmlTag) || hasLocalName(tableTag) ||
hasLocalName(tbodyTag) || hasLocalName(tfootTag) || hasLocalName(theadTag) ||
hasLocalName(trTag)) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return;
}
Node* parent = parentNode();
if (!parent) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return;
}
// FIXME: This creates a new text node even when the text is empty.
// FIXME: This creates a single text node even when the text has CR and LF
// characters in it. Instead it should create <br> elements.
RefPtr<Text> t = new Text(document(), text);
ec = 0;
parent->replaceChild(t, this, ec);
if (ec)
return;
// is previous node a text node? if so, merge into it
Node* prev = t->previousSibling();
if (prev && prev->isTextNode()) {
Text* textPrev = static_cast<Text*>(prev);
textPrev->appendData(t->data(), ec);
if (ec)
return;
t->remove(ec);
if (ec)
return;
t = textPrev;
}
// is next node a text node? if so, merge it in
Node* next = t->nextSibling();
if (next && next->isTextNode()) {
Text* textNext = static_cast<Text*>(next);
t->appendData(textNext->data(), ec);
if (ec)
return;
textNext->remove(ec);
if (ec)
return;
}
}
示例2: tryMergeAdjacentTextCells
bool WMLTableElement::tryMergeAdjacentTextCells(Node* item, Node* nextItem) const
{
if (!item || !nextItem)
return false;
if (!item->isTextNode() || !nextItem->isTextNode())
return false;
Text* itemText = static_cast<Text*>(item);
Text* nextItemText = static_cast<Text*>(nextItem);
String newContent = " ";
newContent += nextItemText->data();
ExceptionCode ec = 0;
itemText->appendData(newContent, ec);
ASSERT(ec == 0);
return true;
}