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; }
/* * Runs the test case. */ void runTest() { Document doc; NodeList acronymList; Node testNode; NamedNodeMap attributes; Attr titleAttr; String value; Node textNode; Node retval; Node lastChild; Document otherDoc; doc = (Document) baseT::load("hc_staff", true); otherDoc = (Document) baseT::load("hc_staff", true); acronymList = doc.getElementsByTagName(SA::construct_from_utf8("acronym")); testNode = acronymList.item(3); attributes = testNode.getAttributes(); titleAttr = (Attr) attributes.getNamedItem(SA::construct_from_utf8("title")); textNode = otherDoc.createTextNode(SA::construct_from_utf8("terday")); { boolean success = false; try { retval = titleAttr.appendChild(textNode); } catch (const DOMException& ex) { success = (ex.code() == DOMException::WRONG_DOCUMENT_ERR); } assertTrue(success); } }
PRBool txXPathTreeWalker::moveToNextAttribute() { // XXX an assertion should be enough here with the current code if (INNER->nodeType != Node::ATTRIBUTE_NODE) { return PR_FALSE; } Element* element = static_cast<Element*>(INNER->getXPathParent()); Attr *attribute = element->getFirstAttribute(); while (attribute != INNER) { attribute = attribute->getNextAttribute(); } NS_ASSERTION(attribute, "Attr not attribute of it's owner?"); attribute = attribute->getNextAttribute(); while (attribute) { if (attribute->getNamespaceID() != kNameSpaceID_XMLNS) { INNER = attribute; return PR_TRUE; } attribute = attribute->getNextAttribute(); } return PR_FALSE; }
bool push_explicit_style(Attr const& src, Attr & dst, markers_symbolizer const& sym) { boost::optional<stroke> const& strk = sym.get_stroke(); boost::optional<color> const& fill = sym.get_fill(); if (strk || fill) { for(unsigned i = 0; i < src.size(); ++i) { mapnik::svg::path_attributes attr = src[i]; if (strk) { attr.stroke_flag = true; attr.stroke_width = strk->get_width(); color const& s_color = strk->get_color(); attr.stroke_color = agg::rgba(s_color.red()/255.0,s_color.green()/255.0, s_color.blue()/255.0,(s_color.alpha()*strk->get_opacity())/255.0); } if (fill) { attr.fill_flag = true; color const& f_color = *fill; attr.fill_color = agg::rgba(f_color.red()/255.0,f_color.green()/255.0, f_color.blue()/255.0,(f_color.alpha()*sym.get_opacity())/255.0); } dst.push_back(attr); } return true; } return false; }
/* * Runs the test case. */ void runTest() { Document doc; NodeList acronymList; Node testNode; NamedNodeMap attributes; Attr titleAttr; String value; Text textNode; Node retval; Node lastChild; doc = (Document) baseT::load("hc_staff", true); titleAttr = doc.createAttribute(SA::construct_from_utf8("title")); textNode = doc.createTextNode(SA::construct_from_utf8("Yesterday")); retval = titleAttr.appendChild(textNode); value = titleAttr.getValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); value = titleAttr.getNodeValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); value = retval.getNodeValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); lastChild = titleAttr.getLastChild(); value = lastChild.getNodeValue(); baseT::assertEquals("Yesterday", value, __LINE__, __FILE__); }
void DeclPrinter::VisitRecordDecl(RecordDecl *D) { if (!Policy.SuppressSpecifiers && D->isModulePrivate()) Out << "__module_private__ "; Out << D->getKindName(); // HACK: clang 3.6 doesn't accept // __attribute__((transparent_union)) in // the normal location. -SJW Attr *Extra = nullptr; if (D->hasAttrs()) { AttrVec &Attrs = D->getAttrs(); for (AttrVec::const_iterator i=Attrs.begin(), e=Attrs.end(); i!=e; ++i) { Attr *A = *i; if (A->getKind() == attr::TransparentUnion) Extra = A; else A->printPretty(Out, Policy); } } if (D->getIdentifier()) Out << ' ' << *D; if (D->isCompleteDefinition()) { Out << " {\n"; VisitDeclContext(D); Indent() << "}"; } if (Extra) Extra->printPretty(Out, Policy); }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // MAIN PROGRAM START //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ int main() { Attr test; test.Load(); test.Attrs1(); AStar(); }
/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Element firstNode; Node testNode; NamedNodeMap attributes; Attr domesticAttr; Attr setAttr; Node setNode; doc = (Document) baseT::load("staff", true); elementList = doc.getElementsByTagName(SA::construct_from_utf8("address")); firstNode = (Element) elementList.item(0); domesticAttr = doc.createAttribute(SA::construct_from_utf8("domestic")); domesticAttr.setValue(SA::construct_from_utf8("Yes")); setAttr = firstNode.setAttributeNode(domesticAttr); elementList = doc.getElementsByTagName(SA::construct_from_utf8("address")); testNode = elementList.item(2); attributes = testNode.getAttributes(); { boolean success = false; try { setNode = attributes.setNamedItem(domesticAttr); } catch (const DOMException& ex) { success = (ex.code() == DOMException::INUSE_ATTRIBUTE_ERR); } assertTrue(success); } }
const XMLString& Element::getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const { Attr* pAttr = getAttributeNodeNS(namespaceURI, localName); if (pAttr) return pAttr->getValue(); else return EMPTY_STRING; }
const XMLString& Element::getAttribute(const XMLString& name) const { Attr* pAttr = getAttributeNode(name); if (pAttr) return pAttr->getValue(); else return EMPTY_STRING; }
Node * Attr::cloneNode(bool deep) const { Attr * attr = new Attr(*this); if (deep) { attr->setValue(getValue()); } return attr; }
const void Node::update_attr(Attr &attr){ for( vector<Attr>::iterator it=__attrs.begin() ; it!=__attrs.end() ; it++ ){ if(it->name()==attr.name()){ __attrs.erase(it); it--; } } if(attr.length()>0) __attrs.push_back(attr); }
void Element::dispatchNodeInsertedIntoDocument() { AbstractContainerNode::dispatchNodeInsertedIntoDocument(); Attr* pAttr = _pFirstAttr; while (pAttr) { pAttr->dispatchNodeInsertedIntoDocument(); pAttr = static_cast<Attr*>(pAttr->_pNext); } }
void FVBoxField::setupAttributesMinMax( ) { Attr * a; a = am->updateAttr( tr("Values No."), QString("%1").arg( field->size() ) , QString("text") ); a->setEditable(false); a = am->updateAttr( tr("Min. Value"), QString("%1").arg( field->min() ), QString("text") ); a->setEditable(false); a = am->updateAttr( tr("Max. Value"), QString("%1").arg( field->max() ), QString("text") ); a->setEditable(false); }
void FVBoxField::setupAttributes( ) { am->clear(); Attr * a; a = am->addAttr( tr("Type"), tr("Field"), QString("text") ); a->setEditable(false); a = am->addAttr( tr("Name"), tr(""), QString("text") ); a->setEditable(false); setupAttributesMinMax(); }
DOMString Element::getAttribute (const DOMString& name) { Attr* attr = (Attr*) _attributes.getNamedItem(name); if (attr == NULL) { return ""; } else { return attr->value(); } }
string Web::writeXML(Node *currNode, string prefix) { string xmlOut; Attr *currAttributes; vector<string> attrKeys; xmlOut += prefix + "<" + currNode->getName(); currAttributes = currNode->getAttrList(); attrKeys = currAttributes->getKeyList(); if(attrKeys.size() > 0) { for(int i = 0; i < attrKeys.size(); i++) { xmlOut += " " + attrKeys[i] + "=\"" + currAttributes->getAttr(attrKeys[i]) + "\""; } } xmlOut += ">\n"; vector<string> children = currNode->getChildren(); int reqGrpCount = currNode->getNumReqGrp(); for(int i = 0; i < children.size(); i++) { xmlOut += writeXML(currNode->getChild(children[i]), prefix + '\t'); } if(reqGrpCount > 0) { for(int i = 0; i < reqGrpCount; i++) { xmlOut += writeXML(currNode->getReqGrp(i), prefix + '\t'); } } if(currNode->getName() == "reqgrp") { vector<string> reqConcept = currNode->getReqConcept(); vector<string> reqParent = currNode->getReqParent(); for(int i = 0; i < reqConcept.size(); i++) { xmlOut += prefix + '\t' + "<req parent=\"" + reqParent[i] + "\">" + reqConcept[i] + "</req>\n"; } } xmlOut += prefix + "</" + currNode->getName() + ">\n"; return xmlOut; }
void nsDOMAttributeMap::DropAttribute(int32_t aNamespaceID, nsIAtom* aLocalName) { nsAttrKey attr(aNamespaceID, aLocalName); Attr *node = mAttributeCache.GetWeak(attr); if (node) { // Break link to map node->SetMap(nullptr); // Remove from cache mAttributeCache.Remove(attr); } }
void Element::setAttribute (const DOMString& name, const DOMString& value) throw() { Attr* attr = (Attr*) _attributes.getNamedItem(name); if (attr == NULL) { attr = new Attr(this->ownerDocument(), name); this->setAttributeNode(attr); } attr->value(value); attr->_ownerElement = this; }
PassRefPtr<Node> NamedAttrMap::setNamedItem(Node* arg, ExceptionCode& ec) { if (!element) { ec = NOT_FOUND_ERR; return 0; } // NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. if (isReadOnlyNode()) { ec = NO_MODIFICATION_ALLOWED_ERR; return 0; } // WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map. if (arg->document() != element->document()) { ec = WRONG_DOCUMENT_ERR; return 0; } // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node if (!arg->isAttributeNode()) { ec = HIERARCHY_REQUEST_ERR; return 0; } Attr *attr = static_cast<Attr*>(arg); Attribute* a = attr->attr(); Attribute* old = getAttributeItem(a->name()); if (old == a) return RefPtr<Node>(arg); // we know about it already // INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. // The DOM user must explicitly clone Attr nodes to re-use them in other elements. if (attr->ownerElement()) { ec = INUSE_ATTRIBUTE_ERR; return 0; } if (a->name() == idAttr) element->updateId(old ? old->value() : nullAtom, a->value()); // ### slightly inefficient - resizes attribute array twice. RefPtr<Node> r; if (old) { r = old->createAttrIfNeeded(element); removeAttribute(a->name()); } addAttribute(a); return r.release(); }
Element::Element(Document* pOwnerDocument, const Element& element): AbstractContainerNode(pOwnerDocument, element), _name(pOwnerDocument->namePool().insert(element._name)), _pFirstAttr(0) { Attr* pAttr = element._pFirstAttr; while (pAttr) { Attr* pClonedAttr = static_cast<Attr*>(pAttr->copyNode(false, pOwnerDocument)); setAttributeNode(pClonedAttr); pClonedAttr->release(); pAttr = static_cast<Attr*>(pAttr->_pNext); } }
void Element::setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value) { Attr* pAttr = getAttributeNodeNS(namespaceURI, qualifiedName); if (pAttr) { pAttr->setValue(value); } else { pAttr = _pOwner->createAttributeNS(namespaceURI, qualifiedName); pAttr->setValue(value); setAttributeNodeNS(pAttr); pAttr->release(); } }
void Element::setAttribute(const XMLString& name, const XMLString& value) { Attr* pAttr = getAttributeNode(name); if (pAttr) { pAttr->setValue(value); } else { pAttr = ownerDocument()->createAttribute(name); pAttr->setValue(value); setAttributeNode(pAttr); pAttr->release(); } }
/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Element testAddr; Attr addrAttr; int nodeType; doc = (Document) baseT::load("hc_staff", false); elementList = doc.getElementsByTagName(SA::construct_from_utf8("acronym")); testAddr = (Element) elementList.item(0); addrAttr = testAddr.getAttributeNode(SA::construct_from_utf8("title")); nodeType = (int) addrAttr.getNodeType(); baseT::assertEquals(2, nodeType, __LINE__, __FILE__); }
PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* arg, ExceptionCode& ec) { if (!m_element || !arg) { ec = NOT_FOUND_ERR; return 0; } // WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map. if (arg->document() != m_element->document()) { ec = WRONG_DOCUMENT_ERR; return 0; } // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node if (!arg->isAttributeNode()) { ec = HIERARCHY_REQUEST_ERR; return 0; } V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered(); int worldID = 0; if (isolatedContext!=0) worldID = isolatedContext->getWorldID(); Attr *attr = static_cast<Attr*>(arg); Attribute* a = attr->attr(); if (worldID != 0) a->setWorldID(worldID); Attribute* old = getAttributeItem(a->name()); if (old == a) return RefPtr<Node>(arg); // we know about it already // INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. // The DOM user must explicitly clone Attr nodes to re-use them in other elements. if (attr->ownerElement()) { ec = INUSE_ATTRIBUTE_ERR; return 0; } if (attr->isId()) m_element->updateId(old ? old->value() : nullAtom, a->value()); // ### slightly inefficient - resizes attribute array twice. RefPtr<Node> r; if (old) { r = old->createAttrIfNeeded(m_element); removeAttribute(a->name()); } addAttribute(a); return r.release(); }
bool push_explicit_style(Attr const& src, Attr & dst, markers_symbolizer const& sym) { boost::optional<stroke> const& strk = sym.get_stroke(); boost::optional<color> const& fill = sym.get_fill(); boost::optional<float> const& fill_opacity = sym.get_fill_opacity(); if (strk || fill || fill_opacity) { bool success = false; for(unsigned i = 0; i < src.size(); ++i) { success = true; dst.push_back(src[i]); mapnik::svg::path_attributes & attr = dst.last(); if (attr.stroke_flag) { // TODO - stroke attributes need to be boost::optional // for this to work properly if (strk) { attr.stroke_width = strk->get_width(); color const& s_color = strk->get_color(); attr.stroke_color = agg::rgba(s_color.red()/255.0, s_color.green()/255.0, s_color.blue()/255.0, s_color.alpha()/255.0); attr.stroke_opacity = strk->get_opacity(); } } if (attr.fill_flag) { if (fill) { color const& f_color = *fill; attr.fill_color = agg::rgba(f_color.red()/255.0, f_color.green()/255.0, f_color.blue()/255.0, f_color.alpha()/255.0); } if (fill_opacity) { attr.fill_opacity = *fill_opacity; } } } return success; } return false; }
/* * Runs the test case. */ void runTest() { Document doc; NodeList genderList; Node gender; NodeList genList; Node gen; NodeList gList; Node g; NamedNodeMap attrList; Attr attrNode; doc = (Document) baseT::load("staff", true); genderList = doc.getElementsByTagName(SA::construct_from_utf8("gender")); gender = genderList.item(2); baseT::assertNotNull(gender, __LINE__, __FILE__); genList = gender.getChildNodes(); gen = genList.item(0); baseT::assertNotNull(gen, __LINE__, __FILE__); gList = gen.getChildNodes(); g = gList.item(0); baseT::template skipIfNot<EntityReference>(g); baseT::assertNotNull(g, __LINE__, __FILE__); attrList = g.getAttributes(); baseT::assertNotNull(attrList, __LINE__, __FILE__); attrNode = (Attr) attrList.getNamedItem(SA::construct_from_utf8("domestic")); baseT::assertNotNull(attrNode, __LINE__, __FILE__); { boolean success = false; try { attrNode.setValue(SA::construct_from_utf8("newvalue")); } catch (const DOMException& ex) { success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR); } assertTrue(success); } { boolean success = false; try { attrNode.setNodeValue(SA::construct_from_utf8("newvalue2")); } catch (const DOMException& ex) { success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR); } assertTrue(success); } }
int main(int argc, char *argv[]) { Attr attr; size_t stacksize = 10 * 1024 * 1024; attr.setstacksize(stacksize); perror("setstacksize"); MyThread a(&attr); a.start(); size_t getsize = 0; attr.getstacksize(&getsize); printf("stacksize: %lu\n", getsize); size_t guardsize = 0; attr.getguardsize(&guardsize); printf("guardsize: %lu\n", guardsize); // DWORD id = GetCurrentProcessId(); // pid_t pid = getpid(); // pthread_t tid = pthread_self(); // printf("pid %lu tid %lu (0x%lX)\n", // static_cast<unsigned long>(pid), // static_cast<unsigned long>(tid), // static_cast<unsigned long>(tid)); // // struct msg *workq = new struct msg; // // Test test; // // test.test(); // test(); DoSomething ds; Thread thread(&ds); thread.start(); // Attr attr; // printf("detachstate:%d\n", attr.getdetachstate()); // void *stackaddr = NULL; // size_t stacksize = 0; // attr.getstacksize(&stacksize); // printf("stack size: %luM\n", stacksize / 1024 / 1024); printf("main exit\n"); // Thread::exit(); // pthread_exit(NULL); getchar(); return 0; }
void JSAttr::setValue(ExecState* exec, JSValue value) { Attr* imp = static_cast<Attr*>(impl()); String attrValue = valueToStringWithNullCheck(exec, value); Element* ownerElement = imp->ownerElement(); if (ownerElement && (ownerElement->hasTagName(iframeTag) || ownerElement->hasTagName(frameTag))) { if (equalIgnoringCase(imp->name(), "src") && protocolIsJavaScript(deprecatedParseURL(attrValue))) { if (!checkNodeSecurity(exec, static_cast<HTMLFrameElementBase*>(ownerElement)->contentDocument())) return; } } ExceptionCode ec = 0; imp->setValue(attrValue, ec); setDOMException(exec, ec); }
JSValue JSElement::setAttributeNode(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; Attr* newAttr = toAttr(args.at(0)); if (!newAttr) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } Element* imp = impl(); if (!allowSettingSrcToJavascriptURL(exec, imp, newAttr->name(), newAttr->value())) return jsUndefined(); JSValue result = toJS(exec, globalObject(), WTF::getPtr(imp->setAttributeNode(newAttr, ec))); setDOMException(exec, ec); return result; }