summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLMapElement.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/html/HTMLMapElement.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/html/HTMLMapElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLMapElement.cpp84
1 files changed, 34 insertions, 50 deletions
diff --git a/Source/WebCore/html/HTMLMapElement.cpp b/Source/WebCore/html/HTMLMapElement.cpp
index 66fd73e80..ecc875296 100644
--- a/Source/WebCore/html/HTMLMapElement.cpp
+++ b/Source/WebCore/html/HTMLMapElement.cpp
@@ -24,35 +24,32 @@
#include "Attribute.h"
#include "Document.h"
+#include "ElementIterator.h"
+#include "GenericCachedHTMLCollection.h"
#include "HTMLAreaElement.h"
-#include "HTMLCollection.h"
#include "HTMLImageElement.h"
-#include "HTMLNames.h"
#include "HitTestResult.h"
#include "IntSize.h"
-#include "NodeTraversal.h"
-#include "RenderObject.h"
-
-using namespace std;
+#include "NodeRareData.h"
namespace WebCore {
using namespace HTMLNames;
-HTMLMapElement::HTMLMapElement(const QualifiedName& tagName, Document* document)
+HTMLMapElement::HTMLMapElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
{
ASSERT(hasTagName(mapTag));
}
-PassRefPtr<HTMLMapElement> HTMLMapElement::create(Document* document)
+Ref<HTMLMapElement> HTMLMapElement::create(Document& document)
{
- return adoptRef(new HTMLMapElement(mapTag, document));
+ return adoptRef(*new HTMLMapElement(mapTag, document));
}
-PassRefPtr<HTMLMapElement> HTMLMapElement::create(const QualifiedName& tagName, Document* document)
+Ref<HTMLMapElement> HTMLMapElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(new HTMLMapElement(tagName, document));
+ return adoptRef(*new HTMLMapElement(tagName, document));
}
HTMLMapElement::~HTMLMapElement()
@@ -62,16 +59,13 @@ 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 (auto& area : descendantsOfType<HTMLAreaElement>(*this)) {
+ if (area.isDefault()) {
+ if (!defaultArea)
+ defaultArea = &area;
+ } else if (area.mapMouseEvent(location, size, result))
+ return true;
}
if (defaultArea) {
@@ -83,20 +77,9 @@ bool HTMLMapElement::mapMouseEvent(LayoutPoint location, const LayoutSize& size,
HTMLImageElement* HTMLMapElement::imageElement()
{
- RefPtr<HTMLCollection> images = document()->images();
- for (unsigned i = 0; Node* curr = images->item(i); i++) {
- if (!isHTMLImageElement(curr))
- continue;
-
- // 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);
- if (equalIgnoringCase(useMapName, m_name))
- return imageElement;
- }
-
- return 0;
+ if (m_name.isEmpty())
+ return nullptr;
+ return document().imageElementByCaseFoldedUsemap(*AtomicString(m_name.string().foldCase()).impl());
}
void HTMLMapElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
@@ -104,21 +87,21 @@ void HTMLMapElement::parseAttribute(const QualifiedName& name, const AtomicStrin
// FIXME: This logic seems wrong for XML documents.
// Either the id or name will be used depending on the order the attributes are parsed.
- if (isIdAttributeName(name) || name == nameAttr) {
- if (isIdAttributeName(name)) {
+ if (name == HTMLNames::idAttr || name == HTMLNames::nameAttr) {
+ if (name == HTMLNames::idAttr) {
// Call base class so that hasID bit gets set.
HTMLElement::parseAttribute(name, value);
- if (document()->isHTMLDocument())
+ if (document().isHTMLDocument())
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;
+ m_name = document().isHTMLDocument() ? mapName.foldCase() : mapName;
if (inDocument())
- treeScope()->addImageMap(this);
+ treeScope().addImageMap(*this);
return;
}
@@ -126,22 +109,23 @@ void HTMLMapElement::parseAttribute(const QualifiedName& name, const AtomicStrin
HTMLElement::parseAttribute(name, value);
}
-PassRefPtr<HTMLCollection> HTMLMapElement::areas()
+Ref<HTMLCollection> HTMLMapElement::areas()
{
- return ensureCachedHTMLCollection(MapAreas);
+ return ensureRareData().ensureNodeLists().addCachedCollection<GenericCachedHTMLCollection<CollectionTypeTraits<MapAreas>::traversalType>>(*this, MapAreas);
}
-Node::InsertionNotificationRequest HTMLMapElement::insertedInto(ContainerNode* insertionPoint)
+Node::InsertionNotificationRequest HTMLMapElement::insertedInto(ContainerNode& insertionPoint)
{
- if (insertionPoint->inDocument())
- treeScope()->addImageMap(this);
- return HTMLElement::insertedInto(insertionPoint);
+ Node::InsertionNotificationRequest request = HTMLElement::insertedInto(insertionPoint);
+ if (insertionPoint.inDocument())
+ treeScope().addImageMap(*this);
+ return request;
}
-void HTMLMapElement::removedFrom(ContainerNode* insertionPoint)
+void HTMLMapElement::removedFrom(ContainerNode& insertionPoint)
{
- if (insertionPoint->inDocument())
- treeScope()->removeImageMap(this);
+ if (insertionPoint.inDocument())
+ treeScope().removeImageMap(*this);
HTMLElement::removedFrom(insertionPoint);
}