本文整理汇总了C++中ContainerNode类的典型用法代码示例。如果您正苦于以下问题:C++ ContainerNode类的具体用法?C++ ContainerNode怎么用?C++ ContainerNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContainerNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: determineScopingNodeForStyleScoped
static Node* determineScopingNodeForStyleScoped(HTMLStyleElement* ownerElement, StyleSheetContents* styleSheetContents)
{
ASSERT(ownerElement && ownerElement->isRegisteredAsScoped());
if (ownerElement->isInShadowTree()) {
if (hasDistributedRule(styleSheetContents)) {
ContainerNode* scope = ownerElement;
do {
scope = scope->containingShadowRoot()->shadowHost();
} while (scope->isInShadowTree());
return scope;
}
if (ownerElement->isRegisteredAsScoped())
return ownerElement->containingShadowRoot()->shadowHost();
}
return ownerElement->isRegisteredInShadowRoot() ? ownerElement->containingShadowRoot()->shadowHost() : ownerElement->parentNode();
}
示例2: writeQosParams
void writeQosParams( ContainerNode &node,
const pj_qos_params &qos) throw(Error)
{
ContainerNode this_node = node.writeNewContainer("qosParams");
NODE_WRITE_NUM_T( this_node, pj_uint8_t, qos.flags);
NODE_WRITE_NUM_T( this_node, pj_uint8_t, qos.dscp_val);
NODE_WRITE_NUM_T( this_node, pj_uint8_t, qos.so_prio);
NODE_WRITE_NUM_T( this_node, pj_qos_wmm_prio, qos.wmm_prio);
}
示例3: readIntVector
void readIntVector( ContainerNode &node,
const string &array_name,
IntVector &v) throw(Error)
{
ContainerNode array_node = node.readArray(array_name);
v.resize(0);
while (array_node.hasUnread()) {
v.push_back((int)array_node.readNumber());
}
}
示例4: readQosParams
void readQosParams( ContainerNode &node,
pj_qos_params &qos) throw(Error)
{
ContainerNode this_node = node.readContainer("qosParams");
NODE_READ_NUM_T( this_node, pj_uint8_t, qos.flags);
NODE_READ_NUM_T( this_node, pj_uint8_t, qos.dscp_val);
NODE_READ_NUM_T( this_node, pj_uint8_t, qos.so_prio);
NODE_READ_NUM_T( this_node, pj_qos_wmm_prio, qos.wmm_prio);
}
示例5: notifyDescendantInsertedIntoDocument
static void notifyDescendantInsertedIntoDocument(ContainerNode& insertionPoint, ContainerNode& node, NodeVector& postInsertionNotificationTargets)
{
ChildNodesLazySnapshot snapshot(node);
while (RefPtr<Node> child = snapshot.nextNode()) {
// If we have been removed from the document during this loop, then
// we don't want to tell the rest of our children that they've been
// inserted into the document because they haven't.
if (node.inDocument() && child->parentNode() == &node)
notifyNodeInsertedIntoDocument(insertionPoint, *child, postInsertionNotificationTargets);
}
if (!is<Element>(node))
return;
if (RefPtr<ShadowRoot> root = downcast<Element>(node).shadowRoot()) {
if (node.inDocument() && root->host() == &node)
notifyNodeInsertedIntoDocument(insertionPoint, *root, postInsertionNotificationTargets);
}
}
示例6: findFosterSite
void HTMLConstructionSite::findFosterSite(HTMLConstructionSiteTask& task)
{
HTMLElementStack::ElementRecord* lastTableElementRecord = m_openElements.topmost(tableTag.localName());
if (lastTableElementRecord) {
Element* lastTableElement = lastTableElementRecord->element();
ContainerNode* parent = lastTableElement->parentNode();
// When parsing HTML fragments, we skip step 4.2 ("Let root be a new html element with no attributes") for efficiency,
// and instead use the DocumentFragment as a root node. So we must treat the root node (DocumentFragment) as if it is a html element here.
if (parent && (parent->isElementNode() || (m_isParsingFragment && parent == m_openElements.rootNode()))) {
task.parent = parent;
task.nextChild = lastTableElement;
return;
}
task.parent = lastTableElementRecord->next()->element();
return;
}
// Fragment case
task.parent = m_openElements.rootNode(); // DocumentFragment
}
示例7: m_document
XMLTreeBuilder::XMLTreeBuilder(NewXMLDocumentParser* parser, DocumentFragment* fragment, Element* parent)
: m_document(fragment->document())
, m_parser(parser)
, m_isXHTML(false)
, m_sawFirstElement(true)
{
NodeStackItem stackItem(fragment);
// Figure out namespaces
Vector<Element*> nodeStack;
while (parent) {
nodeStack.append(parent);
ContainerNode* node = parent->parentNode();
if (!node || !node->isElementNode())
break;
parent = static_cast<Element*>(node);
}
if (nodeStack.isEmpty()) {
m_currentNodeStack.append(stackItem);
return;
}
for (Element* element; !nodeStack.isEmpty(); nodeStack.removeLast()) {
element = nodeStack.last();
if (element->hasAttributes()) {
for (size_t i = 0; i < element->attributeCount(); ++i) {
const Attribute* attribute = element->attributeItem(i);
if (attribute->localName() == xmlnsAtom)
stackItem.setNamespaceURI(attribute->value());
else if (attribute->prefix() == xmlnsAtom)
stackItem.setNamespaceURI(attribute->localName(), attribute->value());
}
}
}
// If the parent element is not in document tree, there may be no xmlns attribute; just default to the parent's namespace.
if (stackItem.namespaceURI().isNull() && !parent->inDocument())
stackItem.setNamespaceURI(parent->namespaceURI());
m_currentNodeStack.append(stackItem);
}
示例8: hasLocalName
void HTMLElement::setOuterText(const String &text, ExceptionState& es)
{
if (ieForbidsInsertHTML()) {
es.throwDOMException(NoModificationAllowedError);
return;
}
if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(framesetTag) ||
hasLocalName(headTag) || hasLocalName(htmlTag) || hasLocalName(tableTag) ||
hasLocalName(tbodyTag) || hasLocalName(tfootTag) || hasLocalName(theadTag) ||
hasLocalName(trTag)) {
es.throwDOMException(NoModificationAllowedError);
return;
}
ContainerNode* parent = parentNode();
if (!parent) {
es.throwDOMException(NoModificationAllowedError);
return;
}
RefPtr<Node> prev = previousSibling();
RefPtr<Node> next = nextSibling();
RefPtr<Node> newChild;
// Convert text to fragment with <br> tags instead of linebreaks if needed.
if (text.contains('\r') || text.contains('\n'))
newChild = textToFragment(text, es);
else
newChild = Text::create(document(), text);
if (!this || !parentNode())
es.throwDOMException(HierarchyRequestError);
if (es.hadException())
return;
parent->replaceChild(newChild.release(), this, es);
RefPtr<Node> node = next ? next->previousSibling() : 0;
if (!es.hadException() && node && node->isTextNode())
mergeWithNextTextNode(node.release(), es);
if (!es.hadException() && prev && prev->isTextNode())
mergeWithNextTextNode(prev.release(), es);
}
示例9: localName
void HTMLElement::setOuterText(const String& text, ExceptionState& exceptionState)
{
if (ieForbidsInsertHTML()) {
exceptionState.throwDOMException(NoModificationAllowedError, "The '" + localName() + "' element does not support text insertion.");
return;
}
if (shouldProhibitSetInnerOuterText(*this)) {
exceptionState.throwDOMException(NoModificationAllowedError, "The '" + localName() + "' element does not support text insertion.");
return;
}
ContainerNode* parent = parentNode();
if (!parent) {
exceptionState.throwDOMException(NoModificationAllowedError, "The element has no parent.");
return;
}
RefPtrWillBeRawPtr<Node> prev = previousSibling();
RefPtrWillBeRawPtr<Node> next = nextSibling();
RefPtrWillBeRawPtr<Node> newChild = nullptr;
// Convert text to fragment with <br> tags instead of linebreaks if needed.
if (text.contains('\r') || text.contains('\n'))
newChild = textToFragment(text, exceptionState);
else
newChild = Text::create(document(), text);
// textToFragment might cause mutation events.
if (!parentNode())
exceptionState.throwDOMException(HierarchyRequestError, "The element has no parent.");
if (exceptionState.hadException())
return;
parent->replaceChild(newChild.release(), this, exceptionState);
RefPtrWillBeRawPtr<Node> node = next ? next->previousSibling() : nullptr;
if (!exceptionState.hadException() && node && node->isTextNode())
mergeWithNextTextNode(toText(node.get()), exceptionState);
if (!exceptionState.hadException() && prev && prev->isTextNode())
mergeWithNextTextNode(toText(prev.get()), exceptionState);
}
示例10: insertedInto
Node::InsertionNotificationRequest HTMLFrameSetElement::insertedInto(ContainerNode& insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
if (insertionPoint.inDocument()) {
if (Frame* frame = document().frame())
frame->loader().client().dispatchDidBecomeFrameset(document().isFrameSet());
}
return InsertionDone;
}
示例11: insertedInto
Node::InsertionNotificationRequest SVGImageElement::insertedInto(ContainerNode& rootParent)
{
SVGGraphicsElement::insertedInto(rootParent);
if (!rootParent.inDocument())
return InsertionDone;
// Update image loader, as soon as we're living in the tree.
// We can only resolve base URIs properly, after that!
m_imageLoader.updateFromElement();
return InsertionDone;
}
示例12: cachedItem
// FIXME: It is silly that these functions are in HTMLCollection.cpp.
Node* LiveNodeListBase::item(unsigned offset) const
{
if (isItemCacheValid() && cachedItemOffset() == offset)
return cachedItem();
if (isLengthCacheValid() && cachedLength() <= offset)
return 0;
ContainerNode* root = rootContainerNode();
if (!root) {
// FIMXE: In someTextNode.childNodes case the root is Text. We shouldn't even make a LiveNodeList for that.
setLengthCache(0);
return 0;
}
if (isLengthCacheValid() && !overridesItemAfter() && isLastItemCloserThanLastOrCachedItem(offset)) {
Node* lastItem = itemBefore(0);
ASSERT(lastItem);
setItemCache(lastItem, cachedLength() - 1, 0);
} else if (!isItemCacheValid() || isFirstItemCloserThanCachedItem(offset) || (overridesItemAfter() && offset < cachedItemOffset())) {
unsigned offsetInArray = 0;
Node* firstItem;
if (type() == ChildNodeListType)
firstItem = root->firstChild();
else if (isNodeList(type()))
firstItem = traverseLiveNodeListFirstElement(root);
else
firstItem = static_cast<const HTMLCollection*>(this)->traverseFirstElement(offsetInArray, root);
if (!firstItem) {
setLengthCache(0);
return 0;
}
setItemCache(firstItem, 0, offsetInArray);
ASSERT(!cachedItemOffset());
}
if (cachedItemOffset() == offset)
return cachedItem();
return itemBeforeOrAfterCachedItem(offset, root);
}
示例13: patchDocument
Node* DOMPatchSupport::patchNode(Node* node, const String& markup, ExceptionCode& ec)
{
// Don't parse <html> as a fragment.
if (node->isDocumentNode() || (node->parentNode() && node->parentNode()->isDocumentNode())) {
patchDocument(markup);
return 0;
}
Node* previousSibling = node->previousSibling();
RefPtr<DocumentFragment> fragment = DocumentFragment::create(m_document);
fragment->parseHTML(markup, node->parentElement() ? node->parentElement() : m_document->documentElement());
// Compose the old list.
ContainerNode* parentNode = node->parentNode();
Vector<OwnPtr<Digest> > oldList;
for (Node* child = parentNode->firstChild(); child; child = child->nextSibling())
oldList.append(createDigest(child, 0));
// Compose the new list.
String markupCopy = markup;
markupCopy.makeLower();
Vector<OwnPtr<Digest> > newList;
for (Node* child = parentNode->firstChild(); child != node; child = child->nextSibling())
newList.append(createDigest(child, 0));
for (Node* child = fragment->firstChild(); child; child = child->nextSibling()) {
if (child->hasTagName(headTag) && !child->firstChild() && markupCopy.find("</head>") == notFound)
continue; // HTML5 parser inserts empty <head> tag whenever it parses <body>
if (child->hasTagName(bodyTag) && !child->firstChild() && markupCopy.find("</body>") == notFound)
continue; // HTML5 parser inserts empty <body> tag whenever it parses </head>
newList.append(createDigest(child, &m_unusedNodesMap));
}
for (Node* child = node->nextSibling(); child; child = child->nextSibling())
newList.append(createDigest(child, 0));
if (!innerPatchChildren(parentNode, oldList, newList, ec)) {
// Fall back to total replace.
ec = 0;
if (!m_domEditor->replaceChild(parentNode, fragment.release(), node, ec))
return 0;
}
return previousSibling ? previousSibling->nextSibling() : parentNode->firstChild();
}
示例14: willAttachRenderers
void HTMLFrameSetElement::willAttachRenderers()
{
// Inherit default settings from parent frameset
// FIXME: This is not dynamic.
for (ContainerNode* node = parentNode(); node; node = node->parentNode()) {
if (!node->hasTagName(framesetTag))
continue;
HTMLFrameSetElement* frameset = static_cast<HTMLFrameSetElement*>(node);
if (!m_frameborderSet)
m_frameborder = frameset->hasFrameBorder();
if (m_frameborder) {
if (!m_borderSet)
m_border = frameset->border();
if (!m_borderColorSet)
m_borderColorSet = frameset->hasBorderColor();
}
if (!m_noresize)
m_noresize = frameset->noResize();
}
}
示例15: swapInNodePreservingAttributesAndChildren
static void swapInNodePreservingAttributesAndChildren(HTMLElement* newNode, HTMLElement* nodeToReplace)
{
ASSERT(nodeToReplace->inDocument());
ExceptionCode ec = 0;
ContainerNode* parentNode = nodeToReplace->parentNode();
parentNode->insertBefore(newNode, nodeToReplace, ec);
ASSERT(!ec);
RefPtr<Node> nextChild;
for (Node* child = nodeToReplace->firstChild(); child; child = nextChild.get()) {
nextChild = child->nextSibling();
newNode->appendChild(child, ec);
ASSERT(!ec);
}
newNode->attributes()->setAttributes(*nodeToReplace->attributes());
parentNode->removeChild(nodeToReplace, ec);
ASSERT(!ec);
}