using namespace HTMLNames;
-HTMLMapElement::HTMLMapElement(const QualifiedName& tagName, Document& document)
- : HTMLElement(tagName, document)
+HTMLMapElement::HTMLMapElement(Document& document)
+ : HTMLElement(mapTag, document)
{
- ASSERT(hasTagName(mapTag));
ScriptWrappable::init(this);
}
-PassRefPtr<HTMLMapElement> HTMLMapElement::create(Document& document)
+PassRefPtrWillBeRawPtr<HTMLMapElement> HTMLMapElement::create(Document& document)
{
- return adoptRef(new HTMLMapElement(mapTag, document));
-}
-
-PassRefPtr<HTMLMapElement> HTMLMapElement::create(const QualifiedName& tagName, Document& document)
-{
- return adoptRef(new HTMLMapElement(tagName, document));
+ return adoptRefWillBeRefCountedGarbageCollected(new HTMLMapElement(document));
}
HTMLMapElement::~HTMLMapElement()
bool HTMLMapElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size, HitTestResult& result)
{
HTMLAreaElement* defaultArea = 0;
- Element* element = this;
- while ((element = ElementTraversal::next(element, this))) {
- if (isHTMLAreaElement(element)) {
- HTMLAreaElement* areaElt = toHTMLAreaElement(element);
- if (areaElt->isDefault()) {
- if (!defaultArea)
- defaultArea = areaElt;
- } else if (areaElt->mapMouseEvent(location, size, result))
- return true;
+ for (HTMLAreaElement* area = Traversal<HTMLAreaElement>::firstWithin(*this); area; area = Traversal<HTMLAreaElement>::next(*area, this)) {
+ if (area->isDefault()) {
+ if (!defaultArea)
+ defaultArea = area;
+ } else if (area->mapMouseEvent(location, size, result)) {
+ return true;
}
}
HTMLImageElement* HTMLMapElement::imageElement()
{
RefPtr<HTMLCollection> images = document().images();
- for (unsigned i = 0; Node* curr = images->item(i); i++) {
- if (!curr->hasTagName(imgTag))
- continue;
+ for (unsigned i = 0; Element* curr = images->item(i); i++) {
+ ASSERT(isHTMLImageElement(curr));
// The HTMLImageElement's useMap() value includes the '#' symbol at the beginning,
// which has to be stripped off.
- HTMLImageElement* imageElement = toHTMLImageElement(curr);
- String useMapName = imageElement->getAttribute(usemapAttr).string().substring(1);
+ HTMLImageElement& imageElement = toHTMLImageElement(*curr);
+ String useMapName = imageElement.getAttribute(usemapAttr).string().substring(1);
if (equalIgnoringCase(useMapName, m_name))
- return imageElement;
+ return &imageElement;
}
return 0;
String mapName = value;
if (mapName[0] == '#')
mapName = mapName.substring(1);
- m_name = document().isHTMLDocument() ? mapName.lower() : mapName;
+ m_name = AtomicString(document().isHTMLDocument() ? mapName.lower() : mapName);
if (inDocument())
treeScope().addImageMap(this);