本文整理汇总了C++中Attr::ownerElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Attr::ownerElement方法的具体用法?C++ Attr::ownerElement怎么用?C++ Attr::ownerElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attr
的用法示例。
在下文中一共展示了Attr::ownerElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAttributeItem
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();
}
示例2: getAttributeItem
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();
}
示例3: setValue
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);
}
示例4: getAttributeItem
PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* arg, ExceptionCode& ec)
{
if (!m_element || !arg) {
ec = NOT_FOUND_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 (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();
}
示例5: getAttributeItemIndex
PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* node, ExceptionCode& ec)
{
if (!m_element || !node) {
ec = NOT_FOUND_ERR;
return 0;
}
// Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node
if (!node->isAttributeNode()) {
ec = HIERARCHY_REQUEST_ERR;
return 0;
}
Attr* attr = static_cast<Attr*>(node);
Attribute* attribute = attr->attr();
size_t index = getAttributeItemIndex(attribute->name());
Attribute* oldAttribute = index != notFound ? attributeItem(index) : 0;
if (oldAttribute == attribute)
return node; // we know about it already
// INUSE_ATTRIBUTE_ERR: Raised if node 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;
}
RefPtr<Attr> oldAttr;
if (oldAttribute) {
oldAttr = oldAttribute->createAttrIfNeeded(m_element);
replaceAttribute(index, attribute);
} else
addAttribute(attribute);
return oldAttr.release();
}