本文整理汇总了C++中NamedNodeMap::length方法的典型用法代码示例。如果您正苦于以下问题:C++ NamedNodeMap::length方法的具体用法?C++ NamedNodeMap::length怎么用?C++ NamedNodeMap::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamedNodeMap
的用法示例。
在下文中一共展示了NamedNodeMap::length方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: areIdenticalElements
bool areIdenticalElements(const Node* first, const Node* second)
{
// check that tag name and all attribute names and values are identical
if (!first->isElementNode() || !second->isElementNode())
return false;
if (!toElement(first)->tagQName().matches(toElement(second)->tagQName()))
return false;
NamedNodeMap* firstMap = toElement(first)->attributes();
NamedNodeMap* secondMap = toElement(second)->attributes();
unsigned firstLength = firstMap->length();
if (firstLength != secondMap->length())
return false;
for (unsigned i = 0; i < firstLength; i++) {
Attribute* attribute = firstMap->attributeItem(i);
Attribute* secondAttribute = secondMap->getAttributeItem(attribute->name());
if (!secondAttribute || attribute->value() != secondAttribute->value())
return false;
}
return true;
}
示例2: imageToMarkup
static String imageToMarkup(const String& url, Element* element)
{
StringBuilder markup;
markup.append("<img src=\"");
markup.append(url);
markup.append("\"");
// Copy over attributes. If we are dragging an image, we expect things like
// the id to be copied as well.
NamedNodeMap* attrs = element->attributes();
unsigned length = attrs->length();
for (unsigned i = 0; i < length; ++i) {
Attribute* attr = attrs->attributeItem(i);
if (attr->localName() == "src")
continue;
markup.append(" ");
markup.append(attr->localName());
markup.append("=\"");
String escapedAttr = attr->value();
escapedAttr.replace("\"", """);
markup.append(escapedAttr);
markup.append("\"");
}
markup.append("/>");
return markup.toString();
}
示例3: setAttributes
void NamedNodeMap::setAttributes(const NamedNodeMap& other)
{
// clone all attributes in the other map, but attach to our element
if (!m_element)
return;
// If assigning the map changes the id attribute, we need to call
// updateId.
Attribute* oldId = getAttributeItem(m_element->idAttributeName());
Attribute* newId = other.getAttributeItem(m_element->idAttributeName());
if (oldId || newId)
m_element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom);
clearAttributes();
unsigned newLength = other.length();
m_attributes.resize(newLength);
for (unsigned i = 0; i < newLength; i++)
m_attributes[i] = other.m_attributes[i]->clone();
// FIXME: This is wasteful. The class list could be preserved on a copy, and we
// wouldn't have to waste time reparsing the attribute.
// The derived class, HTMLNamedNodeMap, which manages a parsed class list for the CLASS attribute,
// will update its member variable when parse attribute is called.
for (unsigned i = 0; i < newLength; i++)
m_element->attributeChanged(m_attributes[i].get(), true);
}
示例4:
Node*
Element::_getElementById (const DOMString& id)
{
for (size_t i = 0; i < _children.length(); i++) {
NamedNodeMap attrs = _children.item(i)->attributes();
for (size_t h = 0; h < attrs.length(); h++) {
Attr* attr = (Attr*) attrs.item(h);
if (attr->_isId) {
if (attr->value() == id) {
return _children.item(i);
}
}
}
}
for (size_t i = 0; i < _children.length(); i++) {
Node* element = _children.item(i)->_getElementById(id);
if (element) {
return element;
}
}
return NULL;
}
示例5: jsNamedNodeMapLength
JSValue jsNamedNodeMapLength(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSNamedNodeMap* castedThis = static_cast<JSNamedNodeMap*>(asObject(slotBase));
UNUSED_PARAM(exec);
NamedNodeMap* imp = static_cast<NamedNodeMap*>(castedThis->impl());
JSValue result = jsNumber(imp->length());
return result;
}
示例6: appendElement
void MarkupAccumulator::appendElement(StringBuilder& out, Element* element, Namespaces* namespaces)
{
appendOpenTag(out, element, namespaces);
NamedNodeMap* attributes = element->attributes();
unsigned length = attributes->length();
for (unsigned int i = 0; i < length; i++)
appendAttribute(out, element, *attributes->attributeItem(i), namespaces);
appendCloseTag(out, element);
}
示例7: getNames
void DatasetDOMStringMap::getNames(Vector<String>& names)
{
NamedNodeMap* attributeMap = m_element->attributes(true);
if (attributeMap) {
unsigned length = attributeMap->length();
for (unsigned i = 0; i < length; i++) {
Attribute* attribute = attributeMap->attributeItem(i);
if (isValidAttributeName(attribute->localName()))
names.append(convertAttributeNameToPropertyName(attribute->localName()));
}
}
}
示例8: parametersForPlugin
void HTMLEmbedElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues)
{
NamedNodeMap* attributes = this->attributes(true);
if (!attributes)
return;
for (unsigned i = 0; i < attributes->length(); ++i) {
Attribute* it = attributes->attributeItem(i);
paramNames.append(it->localName().string());
paramValues.append(it->value().string());
}
}
示例9: contains
bool DatasetDOMStringMap::contains(const String& name)
{
NamedNodeMap* attributeMap = m_element->attributes(true);
if (attributeMap) {
unsigned length = attributeMap->length();
for (unsigned i = 0; i < length; i++) {
Attribute* attribute = attributeMap->attributeItem(i);
if (propertyNameMatchesAttributeName(name, attribute->localName()))
return true;
}
}
return false;
}
示例10:
PassRefPtr<InspectorObject> InspectorCSSAgent::buildObjectForAttributeStyles(Element* element)
{
RefPtr<InspectorObject> styleAttributes = InspectorObject::create();
NamedNodeMap* attributes = element->attributes();
for (unsigned i = 0; attributes && i < attributes->length(); ++i) {
Attribute* attribute = attributes->attributeItem(i);
if (attribute->style()) {
String attributeName = attribute->localName();
RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), attribute->style(), 0);
styleAttributes->setObject(attributeName.utf8().data(), inspectorStyle->buildObjectForStyle());
}
}
return styleAttributes;
}
示例11: parametersForPlugin
// FIXME: This function should not deal with url or serviceType!
void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
{
HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
String urlParameter;
// Scan the PARAM children and store their name/value pairs.
// Get the URL and type from the params if we don't already have them.
for (Node* child = firstChild(); child; child = child->nextSibling()) {
if (!child->hasTagName(paramTag))
continue;
HTMLParamElement* p = static_cast<HTMLParamElement*>(child);
String name = p->name();
if (name.isEmpty())
continue;
uniqueParamNames.add(name.impl());
paramNames.append(p->name());
paramValues.append(p->value());
// FIXME: url adjustment does not belong in this function.
if (url.isEmpty() && urlParameter.isEmpty() && (equalIgnoringCase(name, "src") || equalIgnoringCase(name, "movie") || equalIgnoringCase(name, "code") || equalIgnoringCase(name, "url")))
urlParameter = stripLeadingAndTrailingHTMLSpaces(p->value());
// FIXME: serviceType calculation does not belong in this function.
if (serviceType.isEmpty() && equalIgnoringCase(name, "type")) {
serviceType = p->value();
size_t pos = serviceType.find(";");
if (pos != notFound)
serviceType = serviceType.left(pos);
}
}
// When OBJECT is used for an applet via Sun's Java plugin, the CODEBASE attribute in the tag
// points to the Java plugin itself (an ActiveX component) while the actual applet CODEBASE is
// in a PARAM tag. See <http://java.sun.com/products/plugin/1.2/docs/tags.html>. This means
// we have to explicitly suppress the tag's CODEBASE attribute if there is none in a PARAM,
// else our Java plugin will misinterpret it. [4004531]
String codebase;
if (MIMETypeRegistry::isJavaAppletMIMEType(serviceType)) {
codebase = "codebase";
uniqueParamNames.add(codebase.impl()); // pretend we found it in a PARAM already
}
// Turn the attributes of the <object> element into arrays, but don't override <param> values.
NamedNodeMap* attributes = this->attributes(true);
if (attributes) {
for (unsigned i = 0; i < attributes->length(); ++i) {
Attribute* it = attributes->attributeItem(i);
const AtomicString& name = it->name().localName();
if (!uniqueParamNames.contains(name.impl())) {
paramNames.append(name.string());
paramValues.append(it->value().string());
}
}
}
mapDataParamToSrc(¶mNames, ¶mValues);
// HTML5 says that an object resource's URL is specified by the object's data
// attribute, not by a param element. However, for compatibility, allow the
// resource's URL to be given by a param named "src", "movie", "code" or "url"
// if we know that resource points to a plug-in.
if (url.isEmpty() && !urlParameter.isEmpty()) {
SubframeLoader* loader = document()->frame()->loader()->subframeLoader();
if (loader->resourceWillUsePlugin(urlParameter, serviceType, shouldPreferPlugInsForImages()))
url = urlParameter;
}
}
示例12: parseXML
/**
* Parse incomming message (from server).
* @param str Incomming server message
* @return Message in Command structure
*/
Command XMLTool::parseXML(string str) {
Command cmd;
try {
DOMParser parser = DOMParser(0);
AutoPtr<Document> pDoc = parser.parseString(str);
NodeIterator it(pDoc, NodeFilter::SHOW_ELEMENT);
Node* pNode = it.nextNode();
NamedNodeMap* attributes = NULL;
Node* attribute = NULL;
while (pNode) {
if (pNode->nodeName().compare("server_adapter") == 0) {
if (pNode->hasAttributes()) {
attributes = pNode->attributes();
for(unsigned int i = 0; i < attributes->length(); i++) {
attribute = attributes->item(i);
if (attribute->nodeName().compare("protocol_version") == 0) {
cmd.protocol_version = attribute->nodeValue();
}
else if (attribute->nodeName().compare("state") == 0) {
cmd.state = attribute->nodeValue();
}
// FIXME - id attribute is here only for backward compatibility, it should be removed in Q1/2016
else if (attribute->nodeName().compare("euid") == 0 || attribute->nodeName().compare("id") == 0) {
cmd.euid = stoull(attribute->nodeValue(), nullptr, 0);
}
else if (attribute->nodeName().compare("device_id") == 0) {
cmd.device_id = atoll(attribute->nodeValue().c_str());
}
else if (attribute->nodeName().compare("time") == 0) {
cmd.time = atoll(attribute->nodeValue().c_str());
}
else {
log.error("Unknow attribute for SERVER_ADAPTER : " + fromXMLString(attribute->nodeName()));
}
}
attributes->release();
}
}
else if (pNode->nodeName().compare("value") == 0) {
if(cmd.state == "getparameters" || cmd.state == "parameters"){
string inner = pNode->innerText();
string device_id = "";
if (pNode->hasAttributes()) {
attributes = pNode->attributes();
string device_id = "";
for(unsigned int i = 0; i < attributes->length(); i++) {
attribute = attributes->item(i);
if (attribute->nodeName().compare("device_id") == 0) {
device_id = toNumFromString(attribute->nodeValue());
}
}
attributes->release();
}
cmd.params.value.push_back({inner, device_id});
}
else {
float val = atof(pNode->innerText().c_str());
if (pNode->hasAttributes()) {
int module_id = 0;
attributes = pNode->attributes();
for(unsigned int i = 0; i < attributes->length(); i++) {
attribute = attributes->item(i);
if (attribute->nodeName().compare("module_id") == 0) {
module_id = toNumFromString(attribute->nodeValue());
}
}
cmd.values.push_back({module_id, val}); //TODO Hex number is processed wrongly
attributes->release();
}
}
}
else if (pNode->nodeName().compare("parameter") == 0) {
if (pNode->hasAttributes()) {
attributes = pNode->attributes();
for(unsigned int i = 0; i < attributes->length(); i++) {
attribute = attributes->item(i);
if (attribute->nodeName().compare("param_id") == 0 || attribute->nodeName().compare("id") == 0) {
cmd.params.param_id = toNumFromString(attribute->nodeValue());
}
else if (attribute->nodeName().compare("euid") == 0) {
cmd.params.euid = toNumFromString(attribute->nodeValue());
}
}
attributes->release();
}
}
//.........这里部分代码省略.........