Diff
Modified: trunk/Source/WebCore/ChangeLog (166376 => 166377)
--- trunk/Source/WebCore/ChangeLog 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/ChangeLog 2014-03-27 22:47:15 UTC (rev 166377)
@@ -1,3 +1,58 @@
+2014-03-27 Antti Koivisto <[email protected]>
+
+ Remove LiveNodeList::Type
+ https://bugs.webkit.org/show_bug.cgi?id=130866
+
+ Reviewed by Andreas Kling.
+
+ We don't need dynamic type information anymore.
+
+ * dom/ClassNodeList.cpp:
+ (WebCore::ClassNodeList::ClassNodeList):
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::getElementsByTagName):
+ (WebCore::ContainerNode::getElementsByName):
+ (WebCore::ContainerNode::getElementsByClassName):
+ (WebCore::ContainerNode::radioNodeList):
+ * dom/LiveNodeList.cpp:
+ (WebCore::LiveNodeList::LiveNodeList):
+ * dom/LiveNodeList.h:
+ (WebCore::LiveNodeList::invalidationType):
+ (WebCore::CachedLiveNodeList<NodeListType>::CachedLiveNodeList):
+ (WebCore::LiveNodeList::type): Deleted.
+ * dom/NameNodeList.cpp:
+ (WebCore::NameNodeList::NameNodeList):
+ (WebCore::NameNodeList::nodeMatches): Deleted.
+ * dom/NameNodeList.h:
+ (WebCore::NameNodeList::nodeMatches):
+ * dom/NodeRareData.h:
+ (WebCore::NodeListTypeIdentifier<ClassNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<NameNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<TagNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<HTMLTagNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<RadioNodeList>::value):
+ (WebCore::NodeListTypeIdentifier<LabelsNodeList>::value):
+
+ Get unique id from type for key generation purposes only.
+
+ (WebCore::NodeListsNodeData::addCacheWithAtomicName):
+ (WebCore::NodeListsNodeData::addCacheWithName):
+ (WebCore::NodeListsNodeData::removeCacheWithAtomicName):
+ (WebCore::NodeListsNodeData::removeCacheWithName):
+ (WebCore::NodeListsNodeData::namedNodeListKey):
+ * dom/TagNodeList.cpp:
+ (WebCore::TagNodeList::TagNodeList):
+ (WebCore::HTMLTagNodeList::HTMLTagNodeList):
+ * dom/TagNodeList.h:
+ * html/LabelableElement.cpp:
+ (WebCore::LabelableElement::labels):
+ * html/LabelsNodeList.cpp:
+ (WebCore::LabelsNodeList::LabelsNodeList):
+ * html/LabelsNodeList.h:
+ * html/RadioNodeList.cpp:
+ (WebCore::RadioNodeList::RadioNodeList):
+ * html/RadioNodeList.h:
+
2014-03-27 Simon Fraser <[email protected]>
Fix crash when RenderView is cleared inside of frame flattening layout
Modified: trunk/Source/WebCore/dom/ClassNodeList.cpp (166376 => 166377)
--- trunk/Source/WebCore/dom/ClassNodeList.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/ClassNodeList.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -36,7 +36,7 @@
namespace WebCore {
ClassNodeList::ClassNodeList(ContainerNode& rootNode, const String& classNames)
- : CachedLiveNodeList(rootNode, Type::ClassNodeListType, InvalidateOnClassAttrChange)
+ : CachedLiveNodeList(rootNode, InvalidateOnClassAttrChange)
, m_classNames(classNames, document().inQuirksMode())
, m_originalClassNames(classNames)
{
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (166376 => 166377)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -1018,8 +1018,8 @@
return 0;
if (document().isHTMLDocument())
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, LiveNodeList::Type::HTMLTagNodeListType, localName);
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, LiveNodeList::Type::TagNodeListType, localName);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, localName);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, localName);
}
PassRefPtr<NodeList> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
@@ -1035,18 +1035,18 @@
PassRefPtr<NodeList> ContainerNode::getElementsByName(const String& elementName)
{
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, LiveNodeList::Type::NameNodeListType, elementName);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, elementName);
}
PassRefPtr<NodeList> ContainerNode::getElementsByClassName(const String& classNames)
{
- return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(*this, LiveNodeList::Type::ClassNodeListType, classNames);
+ return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(*this, classNames);
}
PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name)
{
ASSERT(hasTagName(HTMLNames::formTag) || hasTagName(HTMLNames::fieldsetTag));
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, LiveNodeList::Type::RadioNodeListType, name);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, name);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/LiveNodeList.cpp (166376 => 166377)
--- trunk/Source/WebCore/dom/LiveNodeList.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/LiveNodeList.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -31,15 +31,13 @@
namespace WebCore {
-LiveNodeList::LiveNodeList(ContainerNode& ownerNode, Type type, NodeListInvalidationType invalidationType, NodeListRootType rootType)
+LiveNodeList::LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType, NodeListRootType rootType)
: m_ownerNode(ownerNode)
, m_rootType(rootType)
, m_invalidationType(invalidationType)
- , m_type(static_cast<unsigned>(type))
{
ASSERT(m_rootType == static_cast<unsigned>(rootType));
ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType));
- ASSERT(m_type == static_cast<unsigned>(type));
}
LiveNodeList::~LiveNodeList()
Modified: trunk/Source/WebCore/dom/LiveNodeList.h (166376 => 166377)
--- trunk/Source/WebCore/dom/LiveNodeList.h 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/LiveNodeList.h 2014-03-27 22:47:15 UTC (rev 166377)
@@ -46,16 +46,7 @@
class LiveNodeList : public NodeList {
public:
- enum class Type {
- ClassNodeListType,
- NameNodeListType,
- TagNodeListType,
- HTMLTagNodeListType,
- RadioNodeListType,
- LabelsNodeListType,
- };
-
- LiveNodeList(ContainerNode& ownerNode, Type, NodeListInvalidationType, NodeListRootType);
+ LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType, NodeListRootType);
virtual Node* namedItem(const AtomicString&) const override final;
virtual bool nodeMatches(Element*) const = 0;
@@ -63,7 +54,6 @@
ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; }
ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); }
- ALWAYS_INLINE Type type() const { return static_cast<Type>(m_type); }
ContainerNode& ownerNode() const { return const_cast<ContainerNode&>(m_ownerNode.get()); }
ALWAYS_INLINE void invalidateCacheForAttribute(const QualifiedName* attrName) const
{
@@ -87,7 +77,6 @@
const unsigned m_rootType : 1;
const unsigned m_invalidationType : 4;
- const unsigned m_type : 3;
};
template <class NodeListType>
@@ -110,7 +99,7 @@
virtual size_t memoryCost() const override;
protected:
- CachedLiveNodeList(ContainerNode& rootNode, Type, NodeListInvalidationType, NodeListRootType = NodeListIsRootedAtNode);
+ CachedLiveNodeList(ContainerNode& rootNode, NodeListInvalidationType, NodeListRootType = NodeListIsRootedAtNode);
private:
mutable CollectionIndexCache<NodeListType, Element> m_indexCache;
@@ -149,8 +138,8 @@
}
template <class NodeListType>
-CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, Type type, NodeListInvalidationType invalidationType, NodeListRootType rootType)
- : LiveNodeList(ownerNode, type, invalidationType, rootType)
+CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType, NodeListRootType rootType)
+ : LiveNodeList(ownerNode, invalidationType, rootType)
{
}
Modified: trunk/Source/WebCore/dom/NameNodeList.cpp (166376 => 166377)
--- trunk/Source/WebCore/dom/NameNodeList.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/NameNodeList.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -30,7 +30,7 @@
using namespace HTMLNames;
NameNodeList::NameNodeList(ContainerNode& rootNode, const AtomicString& name)
- : CachedLiveNodeList(rootNode, Type::NameNodeListType, InvalidateOnNameAttrChange)
+ : CachedLiveNodeList(rootNode, InvalidateOnNameAttrChange)
, m_name(name)
{
}
@@ -40,9 +40,4 @@
ownerNode().nodeLists()->removeCacheWithAtomicName(this, m_name);
}
-bool NameNodeList::nodeMatches(Element* testNode) const
-{
- return testNode->getNameAttribute() == m_name;
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/NameNodeList.h (166376 => 166377)
--- trunk/Source/WebCore/dom/NameNodeList.h 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/NameNodeList.h 2014-03-27 22:47:15 UTC (rev 166377)
@@ -33,9 +33,8 @@
// NodeList which lists all Nodes in a Element with a given "name" attribute
class NameNodeList final : public CachedLiveNodeList<NameNodeList> {
public:
- static PassRefPtr<NameNodeList> create(ContainerNode& rootNode, Type type, const AtomicString& name)
+ static PassRefPtr<NameNodeList> create(ContainerNode& rootNode, const AtomicString& name)
{
- ASSERT_UNUSED(type, type == Type::NameNodeListType);
return adoptRef(new NameNodeList(rootNode, name));
}
@@ -49,6 +48,11 @@
AtomicString m_name;
};
+inline bool NameNodeList::nodeMatches(Element* element) const
+{
+ return element->getNameAttribute() == m_name;
+}
+
} // namespace WebCore
#endif // NameNodeList_h
Modified: trunk/Source/WebCore/dom/NodeRareData.h (166376 => 166377)
--- trunk/Source/WebCore/dom/NodeRareData.h 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/NodeRareData.h 2014-03-27 22:47:15 UTC (rev 166377)
@@ -49,6 +49,14 @@
class RadioNodeList;
class TreeScope;
+template <class ListType> struct NodeListTypeIdentifier;
+template <> struct NodeListTypeIdentifier<ClassNodeList> { static int value() { return 0; } };
+template <> struct NodeListTypeIdentifier<NameNodeList> { static int value() { return 1; } };
+template <> struct NodeListTypeIdentifier<TagNodeList> { static int value() { return 2; } };
+template <> struct NodeListTypeIdentifier<HTMLTagNodeList> { static int value() { return 3; } };
+template <> struct NodeListTypeIdentifier<RadioNodeList> { static int value() { return 4; } };
+template <> struct NodeListTypeIdentifier<LabelsNodeList> { static int value() { return 5; } };
+
class NodeListsNodeData {
WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED;
public:
@@ -110,21 +118,21 @@
typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCacheNS;
template<typename T, typename ContainerType>
- PassRefPtr<T> addCacheWithAtomicName(ContainerType& container, LiveNodeList::Type type, const AtomicString& name)
+ PassRefPtr<T> addCacheWithAtomicName(ContainerType& container, const AtomicString& name)
{
- NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey(type, name), nullptr);
+ NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey<T>(name), nullptr);
if (!result.isNewEntry)
return static_cast<T*>(result.iterator->value);
- RefPtr<T> list = T::create(container, type, name);
+ RefPtr<T> list = T::create(container, name);
result.iterator->value = list.get();
return list.release();
}
template<typename T>
- PassRefPtr<T> addCacheWithName(ContainerNode& node, LiveNodeList::Type type, const String& name)
+ PassRefPtr<T> addCacheWithName(ContainerNode& node, const String& name)
{
- NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListKey(type, name), nullptr);
+ NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListKey<T>(name), nullptr);
if (!result.isNewEntry)
return static_cast<T*>(result.iterator->value);
@@ -175,20 +183,22 @@
return static_cast<T*>(m_cachedCollections.get(namedCollectionKey(collectionType, starAtom)));
}
- void removeCacheWithAtomicName(LiveNodeList* list, const AtomicString& name = starAtom)
+ template <class NodeListType>
+ void removeCacheWithAtomicName(NodeListType* list, const AtomicString& name = starAtom)
{
- ASSERT(list == m_atomicNameCaches.get(namedNodeListKey(list->type(), name)));
+ ASSERT(list == m_atomicNameCaches.get(namedNodeListKey<NodeListType>(name)));
if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode()))
return;
- m_atomicNameCaches.remove(namedNodeListKey(list->type(), name));
+ m_atomicNameCaches.remove(namedNodeListKey<NodeListType>(name));
}
- void removeCacheWithName(LiveNodeList* list, const String& name)
+ template <class NodeListType>
+ void removeCacheWithName(NodeListType* list, const String& name)
{
- ASSERT(list == m_nameCaches.get(namedNodeListKey(list->type(), name)));
+ ASSERT(list == m_nameCaches.get(namedNodeListKey<NodeListType>(name)));
if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode()))
return;
- m_nameCaches.remove(namedNodeListKey(list->type(), name));
+ m_nameCaches.remove(namedNodeListKey<NodeListType>(name));
}
void removeCacheWithQualifiedName(LiveNodeList* list, const AtomicString& namespaceURI, const AtomicString& localName)
@@ -259,9 +269,10 @@
return std::pair<unsigned char, AtomicString>(type, name);
}
- std::pair<unsigned char, String> namedNodeListKey(LiveNodeList::Type type, const String& name)
+ template <class NodeListType>
+ std::pair<unsigned char, String> namedNodeListKey(const String& name)
{
- return std::pair<unsigned char, String>(static_cast<unsigned char>(type), name);
+ return std::pair<unsigned char, String>(NodeListTypeIdentifier<NodeListType>::value(), name);
}
bool deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(Node&);
Modified: trunk/Source/WebCore/dom/TagNodeList.cpp (166376 => 166377)
--- trunk/Source/WebCore/dom/TagNodeList.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/TagNodeList.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -29,7 +29,7 @@
namespace WebCore {
TagNodeList::TagNodeList(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
- : CachedLiveNodeList(rootNode, Type::TagNodeListType, DoNotInvalidateOnAttributeChanges)
+ : CachedLiveNodeList(rootNode, DoNotInvalidateOnAttributeChanges)
, m_namespaceURI(namespaceURI)
, m_localName(localName)
{
@@ -45,7 +45,7 @@
}
HTMLTagNodeList::HTMLTagNodeList(ContainerNode& rootNode, const AtomicString& localName)
- : CachedLiveNodeList(rootNode, Type::HTMLTagNodeListType, DoNotInvalidateOnAttributeChanges)
+ : CachedLiveNodeList(rootNode, DoNotInvalidateOnAttributeChanges)
, m_localName(localName)
, m_loweredLocalName(localName.lower())
{
Modified: trunk/Source/WebCore/dom/TagNodeList.h (166376 => 166377)
--- trunk/Source/WebCore/dom/TagNodeList.h 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/dom/TagNodeList.h 2014-03-27 22:47:15 UTC (rev 166377)
@@ -39,9 +39,8 @@
return adoptRef(new TagNodeList(rootNode, namespaceURI, localName));
}
- static PassRefPtr<TagNodeList> create(ContainerNode& rootNode, Type type, const AtomicString& localName)
+ static PassRefPtr<TagNodeList> create(ContainerNode& rootNode, const AtomicString& localName)
{
- ASSERT_UNUSED(type, type == Type::TagNodeListType);
return adoptRef(new TagNodeList(rootNode, starAtom, localName));
}
@@ -67,9 +66,8 @@
class HTMLTagNodeList final : public CachedLiveNodeList<HTMLTagNodeList> {
public:
- static PassRefPtr<HTMLTagNodeList> create(ContainerNode& rootNode, Type type, const AtomicString& localName)
+ static PassRefPtr<HTMLTagNodeList> create(ContainerNode& rootNode, const AtomicString& localName)
{
- ASSERT_UNUSED(type, type == Type::HTMLTagNodeListType);
return adoptRef(new HTMLTagNodeList(rootNode, localName));
}
Modified: trunk/Source/WebCore/html/LabelableElement.cpp (166376 => 166377)
--- trunk/Source/WebCore/html/LabelableElement.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/html/LabelableElement.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -45,7 +45,7 @@
if (!supportLabels())
return 0;
- return ensureRareData().ensureNodeLists().addCacheWithAtomicName<LabelsNodeList>(*this, LiveNodeList::Type::LabelsNodeListType, starAtom);
+ return ensureRareData().ensureNodeLists().addCacheWithAtomicName<LabelsNodeList>(*this, starAtom);
}
} // namespace Webcore
Modified: trunk/Source/WebCore/html/LabelsNodeList.cpp (166376 => 166377)
--- trunk/Source/WebCore/html/LabelsNodeList.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/html/LabelsNodeList.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -34,7 +34,7 @@
using namespace HTMLNames;
LabelsNodeList::LabelsNodeList(LabelableElement& forNode)
- : CachedLiveNodeList(forNode, Type::LabelsNodeListType, InvalidateOnForAttrChange, NodeListIsRootedAtDocument)
+ : CachedLiveNodeList(forNode, InvalidateOnForAttrChange, NodeListIsRootedAtDocument)
{
}
Modified: trunk/Source/WebCore/html/LabelsNodeList.h (166376 => 166377)
--- trunk/Source/WebCore/html/LabelsNodeList.h 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/html/LabelsNodeList.h 2014-03-27 22:47:15 UTC (rev 166377)
@@ -32,9 +32,8 @@
class LabelsNodeList final : public CachedLiveNodeList<LabelsNodeList> {
public:
- static PassRef<LabelsNodeList> create(LabelableElement& forNode, Type type, const AtomicString&)
+ static PassRef<LabelsNodeList> create(LabelableElement& forNode, const AtomicString&)
{
- ASSERT_UNUSED(type, type == Type::LabelsNodeListType);
return adoptRef(*new LabelsNodeList(forNode));
}
~LabelsNodeList();
Modified: trunk/Source/WebCore/html/RadioNodeList.cpp (166376 => 166377)
--- trunk/Source/WebCore/html/RadioNodeList.cpp 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/html/RadioNodeList.cpp 2014-03-27 22:47:15 UTC (rev 166377)
@@ -38,7 +38,7 @@
using namespace HTMLNames;
RadioNodeList::RadioNodeList(ContainerNode& rootNode, const AtomicString& name)
- : CachedLiveNodeList(rootNode, Type::RadioNodeListType, InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
+ : CachedLiveNodeList(rootNode, InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
, m_name(name)
{
}
Modified: trunk/Source/WebCore/html/RadioNodeList.h (166376 => 166377)
--- trunk/Source/WebCore/html/RadioNodeList.h 2014-03-27 22:39:00 UTC (rev 166376)
+++ trunk/Source/WebCore/html/RadioNodeList.h 2014-03-27 22:47:15 UTC (rev 166377)
@@ -34,9 +34,8 @@
class RadioNodeList final : public CachedLiveNodeList<RadioNodeList> {
public:
- static PassRefPtr<RadioNodeList> create(ContainerNode& rootNode, Type type, const AtomicString& name)
+ static PassRefPtr<RadioNodeList> create(ContainerNode& rootNode, const AtomicString& name)
{
- ASSERT_UNUSED(type, type == Type::RadioNodeListType);
return adoptRef(new RadioNodeList(rootNode, name));
}