535
536
if (localName == idAttributeName().localName())
536
537
updateId(old ? old->value() : nullAtom, value);
538
539
if (old && value.isNull())
539
540
namedAttrMap->removeAttribute(old->name());
540
541
else if (!old && !value.isNull())
543
544
old->setValue(value);
544
545
attributeChanged(old);
548
#if ENABLE(INSPECTOR)
549
if (Page* page = document()->page()) {
550
if (InspectorController* inspectorController = page->inspectorController())
551
inspectorController->didModifyDOMAttr(this);
548
556
void Element::setAttribute(const QualifiedName& name, const AtomicString& value, ExceptionCode&)
555
563
if (name == idAttributeName())
556
564
updateId(old ? old->value() : nullAtom, value);
558
566
if (old && value.isNull())
559
567
namedAttrMap->removeAttribute(name);
560
568
else if (!old && !value.isNull())
563
571
old->setValue(value);
564
572
attributeChanged(old);
575
#if ENABLE(INSPECTOR)
576
if (Page* page = document()->page()) {
577
if (InspectorController* inspectorController = page->inspectorController())
578
inspectorController->didModifyDOMAttr(this);
568
583
PassRefPtr<Attribute> Element::createAttribute(const QualifiedName& name, const AtomicString& value)
579
594
void Element::updateAfterAttributeChanged(Attribute* attr)
581
AXObjectCache* axObjectCache = document()->axObjectCache();
582
if (!axObjectCache->accessibilityEnabled())
596
if (!AXObjectCache::accessibilityEnabled())
585
599
const QualifiedName& attrName = attr->name();
586
600
if (attrName == aria_activedescendantAttr) {
587
601
// any change to aria-activedescendant attribute triggers accessibility focus change, but document focus remains intact
588
axObjectCache->handleActiveDescendantChanged(renderer());
602
document()->axObjectCache()->handleActiveDescendantChanged(renderer());
589
603
} else if (attrName == roleAttr) {
590
604
// the role attribute can change at any time, and the AccessibilityObject must pick up these changes
591
axObjectCache->handleAriaRoleChanged(renderer());
605
document()->axObjectCache()->handleAriaRoleChanged(renderer());
592
606
} else if (attrName == aria_valuenowAttr) {
593
607
// If the valuenow attribute changes, AX clients need to be notified.
594
axObjectCache->postNotification(renderer(), AXObjectCache::AXValueChanged, true);
608
document()->axObjectCache()->postNotification(renderer(), AXObjectCache::AXValueChanged, true);
595
609
} else if (attrName == aria_labelAttr || attrName == aria_labeledbyAttr || attrName == altAttr || attrName == titleAttr) {
596
610
// If the content of an element changes due to an attribute change, notify accessibility.
597
axObjectCache->contentChanged(renderer());
611
document()->axObjectCache()->contentChanged(renderer());
603
617
if (document()->attached() && document()->styleSelector()->hasSelectorForAttribute(attr->name().localName()))
604
618
setNeedsStyleRecalc();
607
void Element::setAttributeMap(PassRefPtr<NamedNodeMap> list)
621
// Returns true is the given attribute is an event handler.
622
// We consider an event handler any attribute that begins with "on".
623
// It is a simple solution that has the advantage of not requiring any
624
// code or configuration change if a new event handler is defined.
626
static bool isEventHandlerAttribute(const QualifiedName& name)
628
return name.namespaceURI().isNull() && name.localName().startsWith("on");
631
void Element::setAttributeMap(PassRefPtr<NamedNodeMap> list, FragmentScriptingPermission scriptingPermission)
609
633
document()->incDOMTreeVersion();
625
649
if (namedAttrMap) {
626
650
namedAttrMap->m_element = this;
651
// If the element is created as result of a paste or drag-n-drop operation
652
// we want to remove all the script and event handlers.
653
if (scriptingPermission == FragmentScriptingNotAllowed) {
655
while (i < namedAttrMap->length()) {
656
const QualifiedName& attributeName = namedAttrMap->m_attributes[i]->name();
657
if (isEventHandlerAttribute(attributeName)) {
658
namedAttrMap->m_attributes.remove(i);
661
if ((attributeName == hrefAttr || attributeName == srcAttr || attributeName == actionAttr) && protocolIsJavaScript(deprecatedParseURL(namedAttrMap->m_attributes[i]->value())))
662
namedAttrMap->m_attributes[i]->setValue(nullAtom);
627
666
unsigned len = namedAttrMap->length();
628
667
for (unsigned i = 0; i < len; i++)
629
668
attributeChanged(namedAttrMap->m_attributes[i].get());
654
693
return m_tagName.toString();
657
void Element::setPrefix(const AtomicString &_prefix, ExceptionCode& ec)
696
void Element::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
660
checkSetPrefix(_prefix, ec);
699
checkSetPrefix(prefix, ec);
664
m_tagName.setPrefix(_prefix);
703
m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
667
706
KURL Element::baseURI() const
1156
1197
if (ec == NOT_FOUND_ERR)
1201
#if ENABLE(INSPECTOR)
1202
if (Page* page = document()->page()) {
1203
if (InspectorController* inspectorController = page->inspectorController())
1204
inspectorController->didModifyDOMAttr(this);
1161
1210
void Element::removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode& ec)