https://bugs.webkit.org/show_bug.cgi?id=122368
Reviewed by Andreas Kling.
Use AtomicStringImpl& instead of AtomicString* or AtomicString& to eliminate
assertions and nullity checks.
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::namedItemGetter):
(WebCore::JSDOMWindow::getOwnPropertySlot):
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::canGetItemsForName):
(WebCore::JSHTMLDocument::nameGetter):
* dom/Document.cpp:
(WebCore::Document::addImageElementByLowercasedUsemap):
(WebCore::Document::removeImageElementByLowercasedUsemap):
(WebCore::Document::imageElementByLowercasedUsemap):
* dom/Document.h:
* dom/DocumentOrderedMap.cpp:
(WebCore::keyMatchesId):
(WebCore::keyMatchesName):
(WebCore::keyMatchesMapName):
(WebCore::keyMatchesLowercasedMapName):
(WebCore::keyMatchesLowercasedUsemap):
(WebCore::keyMatchesLabelForAttribute):
(WebCore::keyMatchesWindowNamedItem):
(WebCore::keyMatchesDocumentNamedItem):
(WebCore::DocumentOrderedMap::add):
(WebCore::DocumentOrderedMap::remove):
(WebCore::DocumentOrderedMap::get):
(WebCore::DocumentOrderedMap::getElementById):
(WebCore::DocumentOrderedMap::getElementByName):
(WebCore::DocumentOrderedMap::getElementByMapName):
(WebCore::DocumentOrderedMap::getElementByLowercasedMapName):
(WebCore::DocumentOrderedMap::getElementByLowercasedUsemap):
(WebCore::DocumentOrderedMap::getElementByLabelForAttribute):
(WebCore::DocumentOrderedMap::getElementByWindowNamedItem):
(WebCore::DocumentOrderedMap::getElementByDocumentNamedItem):
(WebCore::DocumentOrderedMap::getAllElementsById):
* dom/DocumentOrderedMap.h:
(WebCore::DocumentOrderedMap::containsSingle):
(WebCore::DocumentOrderedMap::contains):
(WebCore::DocumentOrderedMap::containsMultiple):
* dom/Element.cpp:
(WebCore::Element::updateNameForTreeScope):
(WebCore::Element::updateNameForDocument):
(WebCore::Element::updateIdForTreeScope):
(WebCore::Element::updateIdForDocument):
(WebCore::Element::updateLabel):
* dom/IdTargetObserverRegistry.cpp:
(WebCore::IdTargetObserverRegistry::notifyObserversInternal):
* dom/IdTargetObserverRegistry.h:
(WebCore::IdTargetObserverRegistry::notifyObservers):
* dom/TreeScope.cpp:
(WebCore::TreeScope::getElementById):
(WebCore::TreeScope::getAllElementsById):
(WebCore::TreeScope::addElementById):
(WebCore::TreeScope::removeElementById):
(WebCore::TreeScope::getElementByName):
(WebCore::TreeScope::addElementByName):
(WebCore::TreeScope::removeElementByName):
(WebCore::TreeScope::addImageMap):
(WebCore::TreeScope::removeImageMap):
(WebCore::TreeScope::getImageMap):
(WebCore::TreeScope::addLabel):
(WebCore::TreeScope::removeLabel):
(WebCore::TreeScope::labelElementForId):
* dom/TreeScope.h:
(WebCore::TreeScope::hasElementWithId):
(WebCore::TreeScope::containsMultipleElementsWithId):
(WebCore::TreeScope::hasElementWithName):
(WebCore::TreeScope::containsMultipleElementsWithName):
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::namedItem):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::addDocumentNamedItem):
(WebCore::HTMLDocument::removeDocumentNamedItem):
(WebCore::HTMLDocument::addWindowNamedItem):
(WebCore::HTMLDocument::removeWindowNamedItem):
* html/HTMLDocument.h:
(WebCore::HTMLDocument::documentNamedItem):
(WebCore::HTMLDocument::hasDocumentNamedItem):
(WebCore::HTMLDocument::documentNamedItemContainsMultipleElements):
(WebCore::HTMLDocument::windowNamedItem):
(WebCore::HTMLDocument::hasWindowNamedItem):
(WebCore::HTMLDocument::windowNamedItemContainsMultipleElements):
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::parseAttribute):
(WebCore::HTMLImageElement::insertedInto):
(WebCore::HTMLImageElement::removedFrom):
* html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::imageElement):
(WebCore::HTMLMapElement::parseAttribute):
(WebCore::HTMLMapElement::insertedInto):
(WebCore::HTMLMapElement::removedFrom):
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::updateDocNamedItem):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156940
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-10-04 Ryosuke Niwa <rniwa@webkit.org>
+
+ Use more references instead of pointers in DocumentOrderedMap
+ https://bugs.webkit.org/show_bug.cgi?id=122368
+
+ Reviewed by Andreas Kling.
+
+ Use AtomicStringImpl& instead of AtomicString* or AtomicString& to eliminate
+ assertions and nullity checks.
+
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::namedItemGetter):
+ (WebCore::JSDOMWindow::getOwnPropertySlot):
+ (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
+ * bindings/js/JSHTMLDocumentCustom.cpp:
+ (WebCore::JSHTMLDocument::canGetItemsForName):
+ (WebCore::JSHTMLDocument::nameGetter):
+ * dom/Document.cpp:
+ (WebCore::Document::addImageElementByLowercasedUsemap):
+ (WebCore::Document::removeImageElementByLowercasedUsemap):
+ (WebCore::Document::imageElementByLowercasedUsemap):
+ * dom/Document.h:
+ * dom/DocumentOrderedMap.cpp:
+ (WebCore::keyMatchesId):
+ (WebCore::keyMatchesName):
+ (WebCore::keyMatchesMapName):
+ (WebCore::keyMatchesLowercasedMapName):
+ (WebCore::keyMatchesLowercasedUsemap):
+ (WebCore::keyMatchesLabelForAttribute):
+ (WebCore::keyMatchesWindowNamedItem):
+ (WebCore::keyMatchesDocumentNamedItem):
+ (WebCore::DocumentOrderedMap::add):
+ (WebCore::DocumentOrderedMap::remove):
+ (WebCore::DocumentOrderedMap::get):
+ (WebCore::DocumentOrderedMap::getElementById):
+ (WebCore::DocumentOrderedMap::getElementByName):
+ (WebCore::DocumentOrderedMap::getElementByMapName):
+ (WebCore::DocumentOrderedMap::getElementByLowercasedMapName):
+ (WebCore::DocumentOrderedMap::getElementByLowercasedUsemap):
+ (WebCore::DocumentOrderedMap::getElementByLabelForAttribute):
+ (WebCore::DocumentOrderedMap::getElementByWindowNamedItem):
+ (WebCore::DocumentOrderedMap::getElementByDocumentNamedItem):
+ (WebCore::DocumentOrderedMap::getAllElementsById):
+ * dom/DocumentOrderedMap.h:
+ (WebCore::DocumentOrderedMap::containsSingle):
+ (WebCore::DocumentOrderedMap::contains):
+ (WebCore::DocumentOrderedMap::containsMultiple):
+ * dom/Element.cpp:
+ (WebCore::Element::updateNameForTreeScope):
+ (WebCore::Element::updateNameForDocument):
+ (WebCore::Element::updateIdForTreeScope):
+ (WebCore::Element::updateIdForDocument):
+ (WebCore::Element::updateLabel):
+ * dom/IdTargetObserverRegistry.cpp:
+ (WebCore::IdTargetObserverRegistry::notifyObserversInternal):
+ * dom/IdTargetObserverRegistry.h:
+ (WebCore::IdTargetObserverRegistry::notifyObservers):
+ * dom/TreeScope.cpp:
+ (WebCore::TreeScope::getElementById):
+ (WebCore::TreeScope::getAllElementsById):
+ (WebCore::TreeScope::addElementById):
+ (WebCore::TreeScope::removeElementById):
+ (WebCore::TreeScope::getElementByName):
+ (WebCore::TreeScope::addElementByName):
+ (WebCore::TreeScope::removeElementByName):
+ (WebCore::TreeScope::addImageMap):
+ (WebCore::TreeScope::removeImageMap):
+ (WebCore::TreeScope::getImageMap):
+ (WebCore::TreeScope::addLabel):
+ (WebCore::TreeScope::removeLabel):
+ (WebCore::TreeScope::labelElementForId):
+ * dom/TreeScope.h:
+ (WebCore::TreeScope::hasElementWithId):
+ (WebCore::TreeScope::containsMultipleElementsWithId):
+ (WebCore::TreeScope::hasElementWithName):
+ (WebCore::TreeScope::containsMultipleElementsWithName):
+ * html/HTMLCollection.cpp:
+ (WebCore::HTMLCollection::namedItem):
+ * html/HTMLDocument.cpp:
+ (WebCore::HTMLDocument::addDocumentNamedItem):
+ (WebCore::HTMLDocument::removeDocumentNamedItem):
+ (WebCore::HTMLDocument::addWindowNamedItem):
+ (WebCore::HTMLDocument::removeWindowNamedItem):
+ * html/HTMLDocument.h:
+ (WebCore::HTMLDocument::documentNamedItem):
+ (WebCore::HTMLDocument::hasDocumentNamedItem):
+ (WebCore::HTMLDocument::documentNamedItemContainsMultipleElements):
+ (WebCore::HTMLDocument::windowNamedItem):
+ (WebCore::HTMLDocument::hasWindowNamedItem):
+ (WebCore::HTMLDocument::windowNamedItemContainsMultipleElements):
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::parseAttribute):
+ (WebCore::HTMLImageElement::insertedInto):
+ (WebCore::HTMLImageElement::removedFrom):
+ * html/HTMLMapElement.cpp:
+ (WebCore::HTMLMapElement::imageElement):
+ (WebCore::HTMLMapElement::parseAttribute):
+ (WebCore::HTMLMapElement::insertedInto):
+ (WebCore::HTMLMapElement::removedFrom):
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::updateDocNamedItem):
+
2013-10-04 Andreas Kling <akling@apple.com>
CTTE: PolicyChecker backpointer to Frame should be a reference.
ASSERT(document->isHTMLDocument());
AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
- if (!atomicPropertyName || !toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName))
+ if (!atomicPropertyName || !toHTMLDocument(document)->hasWindowNamedItem(*atomicPropertyName))
return jsUndefined();
- if (UNLIKELY(toHTMLDocument(document)->windowNamedItemContainsMultipleElements(atomicPropertyName))) {
+ if (UNLIKELY(toHTMLDocument(document)->windowNamedItemContainsMultipleElements(*atomicPropertyName))) {
RefPtr<HTMLCollection> collection = document->windowNamedItems(atomicPropertyName);
ASSERT(!collection->isEmpty());
ASSERT(!collection->hasExactlyOneItem());
return toJS(exec, thisObj->globalObject(), WTF::getPtr(collection));
}
- return toJS(exec, thisObj->globalObject(), toHTMLDocument(document)->windowNamedItem(atomicPropertyName));
+ return toJS(exec, thisObj->globalObject(), toHTMLDocument(document)->windowNamedItem(*atomicPropertyName));
}
bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
Document* document = thisObject->impl()->frame()->document();
if (document->isHTMLDocument()) {
AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
- if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) {
+ if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(*atomicPropertyName)) {
slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
return true;
}
Document* document = thisObject->impl()->frame()->document();
if (document->isHTMLDocument()) {
AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
- if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(atomicPropertyName)) {
+ if (atomicPropertyName && toHTMLDocument(document)->hasWindowNamedItem(*atomicPropertyName)) {
slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, namedItemGetter);
return true;
}
bool JSHTMLDocument::canGetItemsForName(ExecState*, HTMLDocument* document, PropertyName propertyName)
{
AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
- return atomicPropertyName && document->hasDocumentNamedItem(atomicPropertyName);
+ return atomicPropertyName && document->hasDocumentNamedItem(*atomicPropertyName);
}
JSValue JSHTMLDocument::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
HTMLDocument* document = thisObj->impl();
AtomicStringImpl* atomicPropertyName = findAtomicString(propertyName);
- if (!atomicPropertyName || !document->hasDocumentNamedItem(atomicPropertyName))
+ if (!atomicPropertyName || !document->hasDocumentNamedItem(*atomicPropertyName))
return jsUndefined();
- if (UNLIKELY(document->documentNamedItemContainsMultipleElements(atomicPropertyName))) {
+ if (UNLIKELY(document->documentNamedItemContainsMultipleElements(*atomicPropertyName))) {
RefPtr<HTMLCollection> collection = document->documentNamedItems(atomicPropertyName);
ASSERT(!collection->isEmpty());
ASSERT(!collection->hasExactlyOneItem());
return toJS(exec, thisObj->globalObject(), WTF::getPtr(collection));
}
- Node* node = document->documentNamedItem(atomicPropertyName);
- Frame* frame;
- if (node->hasTagName(iframeTag) && (frame = toHTMLIFrameElement(node)->contentFrame()))
- return toJS(exec, frame);
+ Element* element = document->documentNamedItem(*atomicPropertyName);
+ if (UNLIKELY(element->hasTagName(iframeTag))) {
+ if (Frame* frame = toHTMLIFrameElement(element)->contentFrame())
+ return toJS(exec, frame);
+ }
- return toJS(exec, thisObj->globalObject(), node);
+ return toJS(exec, thisObj->globalObject(), element);
}
// Custom attributes
m_elementsByAccessKey.clear();
}
-void Document::addImageElementByLowercasedUsemap(const AtomicString& name, HTMLImageElement& element)
+void Document::addImageElementByLowercasedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)
{
- return m_imagesByUsemap.add(name.impl(), &element);
+ return m_imagesByUsemap.add(name, element);
}
-void Document::removeImageElementByLowercasedUsemap(const AtomicString& name, HTMLImageElement& element)
+void Document::removeImageElementByLowercasedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)
{
- return m_imagesByUsemap.remove(name.impl(), &element);
+ return m_imagesByUsemap.remove(name, element);
}
-HTMLImageElement* Document::imageElementByLowercasedUsemap(const AtomicString& name) const
+HTMLImageElement* Document::imageElementByLowercasedUsemap(const AtomicStringImpl& name) const
{
- return m_imagesByUsemap.getElementByLowercasedUsemap(name.impl(), this);
+ return m_imagesByUsemap.getElementByLowercasedUsemap(name, *this);
}
SelectorQueryCache& Document::selectorQueryCache()
Element* getElementByAccessKey(const String& key);
void invalidateAccessKeyMap();
- void addImageElementByLowercasedUsemap(const AtomicString&, HTMLImageElement&);
- void removeImageElementByLowercasedUsemap(const AtomicString&, HTMLImageElement&);
- HTMLImageElement* imageElementByLowercasedUsemap(const AtomicString&) const;
+ void addImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
+ void removeImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
+ HTMLImageElement* imageElementByLowercasedUsemap(const AtomicStringImpl&) const;
SelectorQueryCache& selectorQueryCache();
using namespace HTMLNames;
-inline bool keyMatchesId(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesId(const AtomicStringImpl& key, Element* element)
{
- return element->getIdAttribute().impl() == key;
+ return element->getIdAttribute().impl() == &key;
}
-inline bool keyMatchesName(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesName(const AtomicStringImpl& key, Element* element)
{
- return element->getNameAttribute().impl() == key;
+ return element->getNameAttribute().impl() == &key;
}
-inline bool keyMatchesMapName(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesMapName(const AtomicStringImpl& key, Element* element)
{
- return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().impl() == key;
+ return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().impl() == &key;
}
-inline bool keyMatchesLowercasedMapName(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesLowercasedMapName(const AtomicStringImpl& key, Element* element)
{
- return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().lower().impl() == key;
+ return isHTMLMapElement(element) && toHTMLMapElement(element)->getName().lower().impl() == &key;
}
-inline bool keyMatchesLowercasedUsemap(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesLowercasedUsemap(const AtomicStringImpl& key, Element* element)
{
// FIXME: HTML5 specification says we should match both image and object elements.
- return isHTMLImageElement(element) && toHTMLImageElement(element)->matchesLowercasedUsemap(*key);
+ return isHTMLImageElement(element) && toHTMLImageElement(element)->matchesLowercasedUsemap(key);
}
-inline bool keyMatchesLabelForAttribute(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesLabelForAttribute(const AtomicStringImpl& key, Element* element)
{
- return isHTMLLabelElement(element) && element->getAttribute(forAttr).impl() == key;
+ return isHTMLLabelElement(element) && element->getAttribute(forAttr).impl() == &key;
}
-inline bool keyMatchesWindowNamedItem(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesWindowNamedItem(const AtomicStringImpl& key, Element* element)
{
- return WindowNameCollection::nodeMatches(element, key);
+ return WindowNameCollection::nodeMatches(element, &key);
}
-inline bool keyMatchesDocumentNamedItem(const AtomicStringImpl* key, Element* element)
+inline bool keyMatchesDocumentNamedItem(const AtomicStringImpl& key, Element* element)
{
- return DocumentNameCollection::nodeMatches(element, key);
+ return DocumentNameCollection::nodeMatches(element, &key);
}
void DocumentOrderedMap::clear()
m_map.clear();
}
-void DocumentOrderedMap::add(const AtomicStringImpl* key, Element* element)
+void DocumentOrderedMap::add(const AtomicStringImpl& key, Element& element)
{
- ASSERT(key);
- ASSERT(element);
-
- Map::AddResult addResult = m_map.add(key, MapEntry(element));
+ Map::AddResult addResult = m_map.add(&key, MapEntry(&element));
if (addResult.isNewEntry)
return;
entry.orderedList.clear();
}
-void DocumentOrderedMap::remove(const AtomicStringImpl* key, Element* element)
+void DocumentOrderedMap::remove(const AtomicStringImpl& key, Element& element)
{
- ASSERT(key);
- ASSERT(element);
-
m_map.checkConsistency();
- Map::iterator it = m_map.find(key);
+ auto it = m_map.find(&key);
ASSERT(it != m_map.end());
MapEntry& entry = it->value;
ASSERT(entry.count);
if (entry.count == 1) {
- ASSERT(!entry.element || entry.element == element);
+ ASSERT(!entry.element || entry.element == &element);
m_map.remove(it);
} else {
- if (entry.element == element)
+ if (entry.element == &element)
entry.element = 0;
entry.count--;
entry.orderedList.clear(); // FIXME: Remove the element instead if there are only few items left.
}
}
-template<bool keyMatches(const AtomicStringImpl*, Element*)>
-inline Element* DocumentOrderedMap::get(const AtomicStringImpl* key, const TreeScope* scope) const
+template<bool keyMatches(const AtomicStringImpl&, Element*)>
+inline Element* DocumentOrderedMap::get(const AtomicStringImpl& key, const TreeScope& scope) const
{
- ASSERT(key);
- ASSERT(scope);
-
m_map.checkConsistency();
- Map::iterator it = m_map.find(key);
+ auto it = m_map.find(&key);
if (it == m_map.end())
return 0;
return entry.element;
// We know there's at least one node that matches; iterate to find the first one.
- for (Element* element = ElementTraversal::firstWithin(scope->rootNode()); element; element = ElementTraversal::next(element)) {
+ for (Element* element = ElementTraversal::firstWithin(scope.rootNode()); element; element = ElementTraversal::next(element)) {
if (!keyMatches(key, element))
continue;
entry.element = element;
return 0;
}
-Element* DocumentOrderedMap::getElementById(const AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementById(const AtomicStringImpl& key, const TreeScope& scope) const
{
return get<keyMatchesId>(key, scope);
}
-Element* DocumentOrderedMap::getElementByName(const AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementByName(const AtomicStringImpl& key, const TreeScope& scope) const
{
return get<keyMatchesName>(key, scope);
}
-Element* DocumentOrderedMap::getElementByMapName(const AtomicStringImpl* key, const TreeScope* scope) const
+HTMLMapElement* DocumentOrderedMap::getElementByMapName(const AtomicStringImpl& key, const TreeScope& scope) const
{
- return get<keyMatchesMapName>(key, scope);
+ return toHTMLMapElement(get<keyMatchesMapName>(key, scope));
}
-Element* DocumentOrderedMap::getElementByLowercasedMapName(const AtomicStringImpl* key, const TreeScope* scope) const
+HTMLMapElement* DocumentOrderedMap::getElementByLowercasedMapName(const AtomicStringImpl& key, const TreeScope& scope) const
{
- return get<keyMatchesLowercasedMapName>(key, scope);
+ return toHTMLMapElement(get<keyMatchesLowercasedMapName>(key, scope));
}
-HTMLImageElement* DocumentOrderedMap::getElementByLowercasedUsemap(const AtomicStringImpl* key, const TreeScope* scope) const
+HTMLImageElement* DocumentOrderedMap::getElementByLowercasedUsemap(const AtomicStringImpl& key, const TreeScope& scope) const
{
return toHTMLImageElement(get<keyMatchesLowercasedUsemap>(key, scope));
}
-Element* DocumentOrderedMap::getElementByLabelForAttribute(const AtomicStringImpl* key, const TreeScope* scope) const
+HTMLLabelElement* DocumentOrderedMap::getElementByLabelForAttribute(const AtomicStringImpl& key, const TreeScope& scope) const
{
- return get<keyMatchesLabelForAttribute>(key, scope);
+ return toHTMLLabelElement(get<keyMatchesLabelForAttribute>(key, scope));
}
-Element* DocumentOrderedMap::getElementByWindowNamedItem(const AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementByWindowNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const
{
return get<keyMatchesWindowNamedItem>(key, scope);
}
-Element* DocumentOrderedMap::getElementByDocumentNamedItem(const AtomicStringImpl* key, const TreeScope* scope) const
+Element* DocumentOrderedMap::getElementByDocumentNamedItem(const AtomicStringImpl& key, const TreeScope& scope) const
{
return get<keyMatchesDocumentNamedItem>(key, scope);
}
-const Vector<Element*>* DocumentOrderedMap::getAllElementsById(const AtomicStringImpl* key, const TreeScope* scope) const
+const Vector<Element*>* DocumentOrderedMap::getAllElementsById(const AtomicStringImpl& key, const TreeScope& scope) const
{
- ASSERT(key);
- ASSERT(scope);
-
m_map.checkConsistency();
- Map::iterator it = m_map.find(key);
+ auto it = m_map.find(&key);
if (it == m_map.end())
return 0;
if (entry.orderedList.isEmpty()) {
entry.orderedList.reserveCapacity(entry.count);
- for (Element* element = entry.element ? entry.element : ElementTraversal::firstWithin(scope->rootNode()); element; element = ElementTraversal::next(element)) {
+ for (Element* element = entry.element ? entry.element : ElementTraversal::firstWithin(scope.rootNode()); element; element = ElementTraversal::next(element)) {
if (!keyMatchesId(key, element))
continue;
entry.orderedList.append(element);
class Element;
class HTMLImageElement;
+class HTMLLabelElement;
+class HTMLMapElement;
class TreeScope;
class DocumentOrderedMap {
public:
- void add(const AtomicStringImpl*, Element*);
- void remove(const AtomicStringImpl*, Element*);
+ void add(const AtomicStringImpl&, Element&);
+ void remove(const AtomicStringImpl&, Element&);
void clear();
- bool contains(const AtomicStringImpl*) const;
- bool containsSingle(const AtomicStringImpl*) const;
- bool containsMultiple(const AtomicStringImpl*) const;
+ bool contains(const AtomicStringImpl&) const;
+ bool containsSingle(const AtomicStringImpl&) const;
+ bool containsMultiple(const AtomicStringImpl&) const;
// concrete instantiations of the get<>() method template
- Element* getElementById(const AtomicStringImpl*, const TreeScope*) const;
- Element* getElementByName(const AtomicStringImpl*, const TreeScope*) const;
- Element* getElementByMapName(const AtomicStringImpl*, const TreeScope*) const;
- Element* getElementByLowercasedMapName(const AtomicStringImpl*, const TreeScope*) const;
- HTMLImageElement* getElementByLowercasedUsemap(const AtomicStringImpl*, const TreeScope*) const;
- Element* getElementByLabelForAttribute(const AtomicStringImpl*, const TreeScope*) const;
- Element* getElementByWindowNamedItem(const AtomicStringImpl*, const TreeScope*) const;
- Element* getElementByDocumentNamedItem(const AtomicStringImpl*, const TreeScope*) const;
+ Element* getElementById(const AtomicStringImpl&, const TreeScope&) const;
+ Element* getElementByName(const AtomicStringImpl&, const TreeScope&) const;
+ HTMLMapElement* getElementByMapName(const AtomicStringImpl&, const TreeScope&) const;
+ HTMLMapElement* getElementByLowercasedMapName(const AtomicStringImpl&, const TreeScope&) const;
+ HTMLImageElement* getElementByLowercasedUsemap(const AtomicStringImpl&, const TreeScope&) const;
+ HTMLLabelElement* getElementByLabelForAttribute(const AtomicStringImpl&, const TreeScope&) const;
+ Element* getElementByWindowNamedItem(const AtomicStringImpl&, const TreeScope&) const;
+ Element* getElementByDocumentNamedItem(const AtomicStringImpl&, const TreeScope&) const;
- const Vector<Element*>* getAllElementsById(const AtomicStringImpl*, const TreeScope*) const;
+ const Vector<Element*>* getAllElementsById(const AtomicStringImpl&, const TreeScope&) const;
void checkConsistency() const;
private:
- template<bool keyMatches(const AtomicStringImpl*, Element*)> Element* get(const AtomicStringImpl*, const TreeScope*) const;
+ template<bool keyMatches(const AtomicStringImpl&, Element*)> Element* get(const AtomicStringImpl&, const TreeScope&) const;
struct MapEntry {
MapEntry()
mutable Map m_map;
};
-inline bool DocumentOrderedMap::containsSingle(const AtomicStringImpl* id) const
+inline bool DocumentOrderedMap::containsSingle(const AtomicStringImpl& id) const
{
- Map::const_iterator it = m_map.find(id);
+ auto it = m_map.find(&id);
return it != m_map.end() && it->value.count == 1;
}
-inline bool DocumentOrderedMap::contains(const AtomicStringImpl* id) const
+inline bool DocumentOrderedMap::contains(const AtomicStringImpl& id) const
{
- return m_map.contains(id);
+ return m_map.contains(&id);
}
-inline bool DocumentOrderedMap::containsMultiple(const AtomicStringImpl* id) const
+inline bool DocumentOrderedMap::containsMultiple(const AtomicStringImpl& id) const
{
- Map::const_iterator it = m_map.find(id);
+ auto it = m_map.find(&id);
return it != m_map.end() && it->value.count > 1;
}
ASSERT(oldName != newName);
if (!oldName.isEmpty())
- scope->removeElementByName(oldName, this);
+ scope->removeElementByName(*oldName.impl(), *this);
if (!newName.isEmpty())
- scope->addElementByName(newName, this);
+ scope->addElementByName(*newName.impl(), *this);
}
void Element::updateNameForDocument(HTMLDocument& document, const AtomicString& oldName, const AtomicString& newName)
if (WindowNameCollection::nodeMatchesIfNameAttributeMatch(this)) {
const AtomicString& id = WindowNameCollection::nodeMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
if (!oldName.isEmpty() && oldName != id)
- document.removeWindowNamedItem(oldName, this);
+ document.removeWindowNamedItem(*oldName.impl(), *this);
if (!newName.isEmpty() && newName != id)
- document.addWindowNamedItem(newName, this);
+ document.addWindowNamedItem(*newName.impl(), *this);
}
if (DocumentNameCollection::nodeMatchesIfNameAttributeMatch(this)) {
const AtomicString& id = DocumentNameCollection::nodeMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
if (!oldName.isEmpty() && oldName != id)
- document.removeDocumentNamedItem(oldName, this);
+ document.removeDocumentNamedItem(*oldName.impl(), *this);
if (!newName.isEmpty() && newName != id)
- document.addDocumentNamedItem(newName, this);
+ document.addDocumentNamedItem(*newName.impl(), *this);
}
}
ASSERT(oldId != newId);
if (!oldId.isEmpty())
- scope->removeElementById(oldId, this);
+ scope->removeElementById(*oldId.impl(), *this);
if (!newId.isEmpty())
- scope->addElementById(newId, this);
+ scope->addElementById(*newId.impl(), *this);
}
void Element::updateIdForDocument(HTMLDocument& document, const AtomicString& oldId, const AtomicString& newId, HTMLDocumentNamedItemMapsUpdatingCondition condition)
if (WindowNameCollection::nodeMatchesIfIdAttributeMatch(this)) {
const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && WindowNameCollection::nodeMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
if (!oldId.isEmpty() && oldId != name)
- document.removeWindowNamedItem(oldId, this);
+ document.removeWindowNamedItem(*oldId.impl(), *this);
if (!newId.isEmpty() && newId != name)
- document.addWindowNamedItem(newId, this);
+ document.addWindowNamedItem(*newId.impl(), *this);
}
if (DocumentNameCollection::nodeMatchesIfIdAttributeMatch(this)) {
const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && DocumentNameCollection::nodeMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
if (!oldId.isEmpty() && oldId != name)
- document.removeDocumentNamedItem(oldId, this);
+ document.removeDocumentNamedItem(*oldId.impl(), *this);
if (!newId.isEmpty() && newId != name)
- document.addDocumentNamedItem(newId, this);
+ document.addDocumentNamedItem(*newId.impl(), *this);
}
}
return;
if (!oldForAttributeValue.isEmpty())
- scope->removeLabel(oldForAttributeValue, toHTMLLabelElement(this));
+ scope->removeLabel(*oldForAttributeValue.impl(), *toHTMLLabelElement(this));
if (!newForAttributeValue.isEmpty())
- scope->addLabel(newForAttributeValue, toHTMLLabelElement(this));
+ scope->addLabel(*newForAttributeValue.impl(), *toHTMLLabelElement(this));
}
void Element::willModifyAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
m_registry.remove(iter);
}
-void IdTargetObserverRegistry::notifyObserversInternal(const AtomicString& id)
+void IdTargetObserverRegistry::notifyObserversInternal(const AtomicStringImpl& id)
{
- ASSERT(!id.isEmpty());
ASSERT(!m_registry.isEmpty());
- m_notifyingObserversInSet = m_registry.get(id.impl());
+ m_notifyingObserversInSet = m_registry.get(&id);
if (!m_notifyingObserversInSet)
return;
}
if (m_notifyingObserversInSet->isEmpty())
- m_registry.remove(id.impl());
+ m_registry.remove(&id);
m_notifyingObserversInSet = 0;
}
public:
static PassOwnPtr<IdTargetObserverRegistry> create();
void notifyObservers(const AtomicString& id);
+ void notifyObservers(const AtomicStringImpl& id);
private:
IdTargetObserverRegistry() : m_notifyingObserversInSet(0) { }
void addObserver(const AtomicString& id, IdTargetObserver*);
void removeObserver(const AtomicString& id, IdTargetObserver*);
- void notifyObserversInternal(const AtomicString& id);
+ void notifyObserversInternal(const AtomicStringImpl& id);
typedef HashSet<IdTargetObserver*> ObserverSet;
- typedef HashMap<AtomicStringImpl*, OwnPtr<ObserverSet> > IdToObserverSetMap;
+ typedef HashMap<const AtomicStringImpl*, OwnPtr<ObserverSet> > IdToObserverSetMap;
IdToObserverSetMap m_registry;
ObserverSet* m_notifyingObserversInSet;
};
inline void IdTargetObserverRegistry::notifyObservers(const AtomicString& id)
+{
+ if (!id.isEmpty())
+ return notifyObservers(*id.impl());
+}
+
+inline void IdTargetObserverRegistry::notifyObservers(const AtomicStringImpl& id)
{
ASSERT(!m_notifyingObserversInSet);
- if (id.isEmpty() || m_registry.isEmpty())
+ ASSERT(id.length());
+ if (m_registry.isEmpty())
return;
IdTargetObserverRegistry::notifyObserversInternal(id);
}
return 0;
if (!m_elementsById)
return 0;
- return m_elementsById->getElementById(elementId.impl(), this);
+ return m_elementsById->getElementById(*elementId.impl(), *this);
}
const Vector<Element*>* TreeScope::getAllElementsById(const AtomicString& elementId) const
return 0;
if (!m_elementsById)
return 0;
- return m_elementsById->getAllElementsById(elementId.impl(), this);
+ return m_elementsById->getAllElementsById(*elementId.impl(), *this);
}
-void TreeScope::addElementById(const AtomicString& elementId, Element* element)
+void TreeScope::addElementById(const AtomicStringImpl& elementId, Element& element)
{
if (!m_elementsById)
m_elementsById = adoptPtr(new DocumentOrderedMap);
- m_elementsById->add(elementId.impl(), element);
+ m_elementsById->add(elementId, element);
m_idTargetObserverRegistry->notifyObservers(elementId);
}
-void TreeScope::removeElementById(const AtomicString& elementId, Element* element)
+void TreeScope::removeElementById(const AtomicStringImpl& elementId, Element& element)
{
if (!m_elementsById)
return;
- m_elementsById->remove(elementId.impl(), element);
+ m_elementsById->remove(elementId, element);
m_idTargetObserverRegistry->notifyObservers(elementId);
}
return 0;
if (!m_elementsByName)
return 0;
- return m_elementsByName->getElementByName(name.impl(), this);
+ return m_elementsByName->getElementByName(*name.impl(), *this);
}
-void TreeScope::addElementByName(const AtomicString& name, Element* element)
+void TreeScope::addElementByName(const AtomicStringImpl& name, Element& element)
{
if (!m_elementsByName)
m_elementsByName = adoptPtr(new DocumentOrderedMap);
- m_elementsByName->add(name.impl(), element);
+ m_elementsByName->add(name, element);
}
-void TreeScope::removeElementByName(const AtomicString& name, Element* element)
+void TreeScope::removeElementByName(const AtomicStringImpl& name, Element& element)
{
if (!m_elementsByName)
return;
- m_elementsByName->remove(name.impl(), element);
+ m_elementsByName->remove(name, element);
}
Node* TreeScope::ancestorInThisScope(Node* node) const
return 0;
}
-void TreeScope::addImageMap(HTMLMapElement* imageMap)
+void TreeScope::addImageMap(HTMLMapElement& imageMap)
{
- AtomicStringImpl* name = imageMap->getName().impl();
+ AtomicStringImpl* name = imageMap.getName().impl();
if (!name)
return;
if (!m_imageMapsByName)
m_imageMapsByName = adoptPtr(new DocumentOrderedMap);
- m_imageMapsByName->add(name, imageMap);
+ m_imageMapsByName->add(*name, imageMap);
}
-void TreeScope::removeImageMap(HTMLMapElement* imageMap)
+void TreeScope::removeImageMap(HTMLMapElement& imageMap)
{
if (!m_imageMapsByName)
return;
- AtomicStringImpl* name = imageMap->getName().impl();
+ AtomicStringImpl* name = imageMap.getName().impl();
if (!name)
return;
- m_imageMapsByName->remove(name, imageMap);
+ m_imageMapsByName->remove(*name, imageMap);
}
HTMLMapElement* TreeScope::getImageMap(const String& url) const
return 0;
size_t hashPos = url.find('#');
String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl();
- if (rootNode()->document().isHTMLDocument())
- return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
- return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(name).impl(), this));
+ if (name.isEmpty())
+ return 0;
+ if (rootNode()->document().isHTMLDocument()) {
+ AtomicString lowercasedName = name.lower();
+ return m_imageMapsByName->getElementByLowercasedMapName(*lowercasedName.impl(), *this);
+ }
+ return m_imageMapsByName->getElementByMapName(*AtomicString(name).impl(), *this);
}
Node* nodeFromPoint(Document* document, int x, int y, LayoutPoint* localPoint)
return toElement(node);
}
-void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement* element)
+void TreeScope::addLabel(const AtomicStringImpl& forAttributeValue, HTMLLabelElement& element)
{
ASSERT(m_labelsByForAttribute);
- m_labelsByForAttribute->add(forAttributeValue.impl(), element);
+ m_labelsByForAttribute->add(forAttributeValue, element);
}
-void TreeScope::removeLabel(const AtomicString& forAttributeValue, HTMLLabelElement* element)
+void TreeScope::removeLabel(const AtomicStringImpl& forAttributeValue, HTMLLabelElement& element)
{
ASSERT(m_labelsByForAttribute);
- m_labelsByForAttribute->remove(forAttributeValue.impl(), element);
+ m_labelsByForAttribute->remove(forAttributeValue, element);
}
HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeValue)
for (auto label = labelDescendants.begin(), end = labelDescendants.end(); label != end; ++label) {
const AtomicString& forValue = label->fastGetAttribute(forAttr);
if (!forValue.isEmpty())
- addLabel(forValue, &*label);
+ addLabel(*forValue.impl(), *label);
}
}
- return toHTMLLabelElement(m_labelsByForAttribute->getElementByLabelForAttribute(forAttributeValue.impl(), this));
+ return m_labelsByForAttribute->getElementByLabelForAttribute(*forAttributeValue.impl(), *this);
}
DOMSelection* TreeScope::getSelection() const
Element* focusedElement();
Element* getElementById(const AtomicString&) const;
const Vector<Element*>* getAllElementsById(const AtomicString&) const;
- bool hasElementWithId(AtomicStringImpl* id) const;
+ bool hasElementWithId(const AtomicStringImpl&) const;
bool containsMultipleElementsWithId(const AtomicString& id) const;
- void addElementById(const AtomicString& elementId, Element*);
- void removeElementById(const AtomicString& elementId, Element*);
+ void addElementById(const AtomicStringImpl& elementId, Element&);
+ void removeElementById(const AtomicStringImpl& elementId, Element&);
Element* getElementByName(const AtomicString&) const;
- bool hasElementWithName(AtomicStringImpl*) const;
+ bool hasElementWithName(const AtomicStringImpl&) const;
bool containsMultipleElementsWithName(const AtomicString&) const;
- void addElementByName(const AtomicString&, Element*);
- void removeElementByName(const AtomicString&, Element*);
+ void addElementByName(const AtomicStringImpl&, Element&);
+ void removeElementByName(const AtomicStringImpl&, Element&);
Document* documentScope() const { return m_documentScope; }
Node* ancestorInThisScope(Node*) const;
- void addImageMap(HTMLMapElement*);
- void removeImageMap(HTMLMapElement*);
+ void addImageMap(HTMLMapElement&);
+ void removeImageMap(HTMLMapElement&);
HTMLMapElement* getImageMap(const String& url) const;
Element* elementFromPoint(int x, int y) const;
// For accessibility.
bool shouldCacheLabelsByForAttribute() const { return m_labelsByForAttribute; }
- void addLabel(const AtomicString& forAttributeValue, HTMLLabelElement*);
- void removeLabel(const AtomicString& forAttributeValue, HTMLLabelElement*);
+ void addLabel(const AtomicStringImpl& forAttributeValue, HTMLLabelElement&);
+ void removeLabel(const AtomicStringImpl& forAttributeValue, HTMLLabelElement&);
HTMLLabelElement* labelElementForId(const AtomicString& forAttributeValue);
DOMSelection* getSelection() const;
mutable RefPtr<DOMSelection> m_selection;
};
-inline bool TreeScope::hasElementWithId(AtomicStringImpl* id) const
+inline bool TreeScope::hasElementWithId(const AtomicStringImpl& id) const
{
- ASSERT(id);
return m_elementsById && m_elementsById->contains(id);
}
inline bool TreeScope::containsMultipleElementsWithId(const AtomicString& id) const
{
- return m_elementsById && m_elementsById->containsMultiple(id.impl());
+ return m_elementsById && id.impl() && m_elementsById->containsMultiple(*id.impl());
}
-inline bool TreeScope::hasElementWithName(AtomicStringImpl* id) const
+inline bool TreeScope::hasElementWithName(const AtomicStringImpl& id) const
{
- ASSERT(id);
return m_elementsByName && m_elementsByName->contains(id);
}
inline bool TreeScope::containsMultipleElementsWithName(const AtomicString& name) const
{
- return m_elementsByName && m_elementsByName->containsMultiple(name.impl());
+ return m_elementsByName && name.impl() && m_elementsByName->containsMultiple(*name.impl());
}
Node* nodeFromPoint(Document*, int x, int y, LayoutPoint* localPoint = 0);
if (!overridesItemAfter() && root->isInTreeScope()) {
TreeScope* treeScope = root->treeScope();
Element* candidate = 0;
- if (treeScope->hasElementWithId(name.impl())) {
+ if (treeScope->hasElementWithId(*name.impl())) {
if (!treeScope->containsMultipleElementsWithId(name))
candidate = treeScope->getElementById(name);
- } else if (treeScope->hasElementWithName(name.impl())) {
+ } else if (treeScope->hasElementWithName(*name.impl())) {
if (!treeScope->containsMultipleElementsWithName(name)) {
candidate = treeScope->getElementByName(name);
if (candidate && type() == DocAll && (!candidate->isHTMLElement() || !nameShouldBeVisibleInDocumentAll(toHTMLElement(candidate))))
return attrSet;
}
-void HTMLDocument::addDocumentNamedItem(const AtomicString& name, Element* item)
+void HTMLDocument::addDocumentNamedItem(const AtomicStringImpl& name, Element& item)
{
- m_documentNamedItem.add(name.impl(), item);
+ m_documentNamedItem.add(name, item);
}
-void HTMLDocument::removeDocumentNamedItem(const AtomicString& name, Element* item)
+void HTMLDocument::removeDocumentNamedItem(const AtomicStringImpl& name, Element& item)
{
- m_documentNamedItem.remove(name.impl(), item);
+ m_documentNamedItem.remove(name, item);
}
-void HTMLDocument::addWindowNamedItem(const AtomicString& name, Element* item)
+void HTMLDocument::addWindowNamedItem(const AtomicStringImpl& name, Element& item)
{
- m_windowNamedItem.add(name.impl(), item);
+ m_windowNamedItem.add(name, item);
}
-void HTMLDocument::removeWindowNamedItem(const AtomicString& name, Element* item)
+void HTMLDocument::removeWindowNamedItem(const AtomicStringImpl& name, Element& item)
{
- m_windowNamedItem.remove(name.impl(), item);
+ m_windowNamedItem.remove(name, item);
}
bool HTMLDocument::isCaseSensitiveAttribute(const QualifiedName& attributeName)
void captureEvents();
void releaseEvents();
- Element* documentNamedItem(const AtomicStringImpl* name) const { return m_documentNamedItem.getElementByDocumentNamedItem(name, this); }
- bool hasDocumentNamedItem(const AtomicStringImpl* name) const { return m_documentNamedItem.contains(name); }
- bool documentNamedItemContainsMultipleElements(const AtomicStringImpl* name) const { return m_documentNamedItem.containsMultiple(name); }
- void addDocumentNamedItem(const AtomicString&, Element*);
- void removeDocumentNamedItem(const AtomicString&, Element*);
-
- Element* windowNamedItem(const AtomicStringImpl* name) const { return m_windowNamedItem.getElementByWindowNamedItem(name, this); }
- bool hasWindowNamedItem(const AtomicStringImpl* name) const { return m_windowNamedItem.contains(name); }
- bool windowNamedItemContainsMultipleElements(const AtomicStringImpl* name) const { return m_windowNamedItem.containsMultiple(name); }
- void addWindowNamedItem(const AtomicString&, Element*);
- void removeWindowNamedItem(const AtomicString&, Element*);
+ Element* documentNamedItem(const AtomicStringImpl& name) const { return m_documentNamedItem.getElementByDocumentNamedItem(name, *this); }
+ bool hasDocumentNamedItem(const AtomicStringImpl& name) const { return m_documentNamedItem.contains(name); }
+ bool documentNamedItemContainsMultipleElements(const AtomicStringImpl& name) const { return m_documentNamedItem.containsMultiple(name); }
+ void addDocumentNamedItem(const AtomicStringImpl&, Element&);
+ void removeDocumentNamedItem(const AtomicStringImpl&, Element&);
+
+ Element* windowNamedItem(const AtomicStringImpl& name) const { return m_windowNamedItem.getElementByWindowNamedItem(name, *this); }
+ bool hasWindowNamedItem(const AtomicStringImpl& name) const { return m_windowNamedItem.contains(name); }
+ bool windowNamedItemContainsMultipleElements(const AtomicStringImpl& name) const { return m_windowNamedItem.containsMultiple(name); }
+ void addWindowNamedItem(const AtomicStringImpl&, Element&);
+ void removeWindowNamedItem(const AtomicStringImpl&, Element&);
static bool isCaseSensitiveAttribute(const QualifiedName&);
return;
if (!m_lowercasedUsemap.isNull())
- document().removeImageElementByLowercasedUsemap(m_lowercasedUsemap, *this);
+ document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
// The HTMLImageElement's useMap() value includes the '#' symbol at the beginning, which has to be stripped off.
// FIXME: We should check that the first character is '#'.
m_lowercasedUsemap = nullAtom;
if (!m_lowercasedUsemap.isNull())
- document().addImageElementByLowercasedUsemap(m_lowercasedUsemap, *this);
+ document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
} else if (name == onbeforeloadAttr)
setAttributeEventListener(eventNames().beforeloadEvent, name, value);
else if (name == compositeAttr) {
const AtomicString& id = getIdAttribute();
if (!id.isEmpty() && id != getNameAttribute()) {
if (willHaveName)
- document->addDocumentNamedItem(id, this);
+ document->addDocumentNamedItem(*id.impl(), *this);
else
- document->removeDocumentNamedItem(id, this);
+ document->removeDocumentNamedItem(*id.impl(), *this);
}
}
}
}
if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull())
- document().addImageElementByLowercasedUsemap(m_lowercasedUsemap, *this);
+ document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
// If we have been inserted from a renderer-less document,
// our loader may have not fetched the image, so do it now.
m_form->removeImgElement(this);
if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull())
- document().removeImageElementByLowercasedUsemap(m_lowercasedUsemap, *this);
+ document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
m_form = 0;
HTMLElement::removedFrom(insertionPoint);
HTMLImageElement* HTMLMapElement::imageElement()
{
- return document().imageElementByLowercasedUsemap(m_name.lower());
+ if (m_name.isEmpty())
+ return 0;
+ AtomicString lowercasedName = m_name.lower();
+ ASSERT(lowercasedName.impl());
+ return document().imageElementByLowercasedUsemap(*lowercasedName.impl());
}
void HTMLMapElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
return;
}
if (inDocument())
- treeScope()->removeImageMap(this);
+ treeScope()->removeImageMap(*this);
String mapName = value;
if (mapName[0] == '#')
mapName = mapName.substring(1);
m_name = document().isHTMLDocument() ? mapName.lower() : mapName;
if (inDocument())
- treeScope()->addImageMap(this);
+ treeScope()->addImageMap(*this);
return;
}
Node::InsertionNotificationRequest HTMLMapElement::insertedInto(ContainerNode& insertionPoint)
{
if (insertionPoint.inDocument())
- treeScope()->addImageMap(this);
+ treeScope()->addImageMap(*this);
return HTMLElement::insertedInto(insertionPoint);
}
void HTMLMapElement::removedFrom(ContainerNode& insertionPoint)
{
if (insertionPoint.inDocument())
- treeScope()->removeImageMap(this);
+ treeScope()->removeImageMap(*this);
HTMLElement::removedFrom(insertionPoint);
}
const AtomicString& id = getIdAttribute();
if (!id.isEmpty()) {
if (isNamedItem)
- document->addDocumentNamedItem(id, this);
+ document->addDocumentNamedItem(*id.impl(), *this);
else
- document->removeDocumentNamedItem(id, this);
+ document->removeDocumentNamedItem(*id.impl(), *this);
}
const AtomicString& name = getNameAttribute();
if (!name.isEmpty() && id != name) {
if (isNamedItem)
- document->addDocumentNamedItem(name, this);
+ document->addDocumentNamedItem(*name.impl(), *this);
else
- document->removeDocumentNamedItem(name, this);
+ document->removeDocumentNamedItem(*name.impl(), *this);
}
}
m_docNamedItem = isNamedItem;