Diff
Modified: trunk/Source/WebCore/ChangeLog (135666 => 135667)
--- trunk/Source/WebCore/ChangeLog 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/ChangeLog 2012-11-25 08:01:28 UTC (rev 135667)
@@ -1,3 +1,66 @@
+2012-11-22 Ryosuke Niwa <[email protected]>
+
+ REGRESSION(r135493): HTMLCollection and DynamicNodeList have two vtable pointers
+ https://bugs.webkit.org/show_bug.cgi?id=103096
+
+ Reviewed by Sam Weinig.
+
+ Co-authored by Ilya Tikhonovsky.
+
+ Made DynamicNodeListCacheBase inherit from NodeList. While HTMLCollection doesn't inherit
+ from NodeList in IDL, it makes a lot of sense for the C++ implementation to do so via
+ DynamicNodeListCacheBase since HTMLCollection and live NodeList share a lot of code in
+ DynamicNodeListCacheBase.
+
+ This lets remove proxies for item() and length() in DynamicNodeList and HTMLCollection
+ and directly implement them in DynamicNodeListCacheBase which used to provide itemCommon()
+ and lengthCommon().
+
+ Also renamed NodeList::itemWithName() to NodeList::namedItem() to match HTMLCollection's
+ naming convention.
+
+ Finally, removed reportMemoryUsage in DynamicNodeList::reportMemoryUsage since DynamicNodeList
+ now uses single inheritance.
+
+ * bindings/js/JSNodeListCustom.cpp:
+ (WebCore::JSNodeList::canGetItemsForName): Calls namedItem, which has been renamed from
+ itemWithName.
+ (WebCore::JSNodeList::nameGetter): Ditto.
+ * bindings/v8/custom/V8NodeListCustom.cpp:
+ (WebCore::V8NodeList::namedPropertyGetter): Ditto.
+ * bindings/v8/custom/V8NamedNodesCollection.cpp:
+ (WebCore::V8NamedNodesCollection::namedItem): Renamed from itemWithName.
+ * bindings/v8/custom/V8NamedNodesCollection.h:
+ * dom/ChildNodeList.cpp:
+ (WebCore::ChildNodeList::nodeMatches): Updated comment.
+ * dom/DynamicNodeList.cpp:
+ (WebCore::DynamicNodeList::namedItem): Renamed from itemWithName.
+ * dom/DynamicNodeList.h:
+ (DynamicNodeListCacheBase): Inhertis from NodeList and renamed lengthCommon and itemCommon
+ to virtual length and item respectively.
+ (DynamicNodeList): Now inherits from just DynamicNodeListCacheBase instead of NodeList
+ and DynamicNodeListCacheBase since the former now inhertis from NodeList. Also removed
+ length() and item() since they're implemented in DynamicNodeListCacheBase now and renamed
+ itemWithName() to namedItem() to match HTMLCollection's naming convention.
+ * dom/NodeList.h:
+ (NodeList::namedItem): Renamed from itemWithName. Note that this member function is not
+ exposed via IDL. It's merely used in the binding code.
+ * dom/StaticHashSetNodeList.cpp:
+ (WebCore::StaticHashSetNodeList::namedItem): Ditto.
+ * dom/StaticHashSetNodeList.h:
+ (StaticHashSetNodeList::namedItem): Ditto.
+ * dom/StaticNodeList.cpp:
+ (WebCore::StaticNodeList::namedItem): Ditto.
+ * dom/StaticNodeList.h:
+ (StaticNodeList::namedItem): Ditto.
+ * html/HTMLCollection.cpp:
+ (WebCore::DynamicNodeListCacheBase::length): Renamed from lengthCommon.
+ (WebCore::DynamicNodeListCacheBase::item): Renamed from itemCommon.
+ * html/HTMLCollection.h:
+ (HTMLCollection): Inherits from DynamicNodeListCacheBase since DynamicNodeListCacheBase
+ is already RefCount'ed and NodeList, from which DynamicNodeListCacheBase inherits,
+ inherits from ScriptWrappable.
+
2012-11-24 Christophe Dumez <[email protected]>
[EFL] Refactor RenderThemeEfl::paintThemePart()
Modified: trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp (135666 => 135667)
--- trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -48,13 +48,13 @@
bool JSNodeList::canGetItemsForName(ExecState*, NodeList* impl, PropertyName propertyName)
{
- return impl->itemWithName(propertyNameToAtomicString(propertyName));
+ return impl->namedItem(propertyNameToAtomicString(propertyName));
}
JSValue JSNodeList::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
{
JSNodeList* thisObj = jsCast<JSNodeList*>(asObject(slotBase));
- return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(propertyNameToAtomicString(propertyName)));
+ return toJS(exec, thisObj->globalObject(), thisObj->impl()->namedItem(propertyNameToAtomicString(propertyName)));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/custom/V8NamedNodesCollection.cpp (135666 => 135667)
--- trunk/Source/WebCore/bindings/v8/custom/V8NamedNodesCollection.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NamedNodesCollection.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -42,7 +42,7 @@
return 0;
}
-Node* V8NamedNodesCollection::itemWithName(const AtomicString& id) const
+Node* V8NamedNodesCollection::namedItem(const AtomicString& id) const
{
for (unsigned i = 0; i < m_nodes.size(); ++i) {
Node* node = m_nodes[i].get();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8NamedNodesCollection.h (135666 => 135667)
--- trunk/Source/WebCore/bindings/v8/custom/V8NamedNodesCollection.h 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NamedNodesCollection.h 2012-11-25 08:01:28 UTC (rev 135667)
@@ -46,9 +46,9 @@
return adoptRef(new V8NamedNodesCollection(nodes));
}
- virtual unsigned length() const { return m_nodes.size(); }
- virtual Node* item(unsigned) const;
- virtual Node* itemWithName(const AtomicString&) const;
+ virtual unsigned length() const OVERRIDE { return m_nodes.size(); }
+ virtual Node* item(unsigned) const OVERRIDE;
+ virtual Node* namedItem(const AtomicString&) const OVERRIDE;
private:
explicit V8NamedNodesCollection(const Vector<RefPtr<Node> >& nodes)
Modified: trunk/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp (135666 => 135667)
--- trunk/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -53,7 +53,7 @@
if (key == length)
return v8Integer(list->length(), info.GetIsolate());
- RefPtr<Node> result = list->itemWithName(key);
+ RefPtr<Node> result = list->namedItem(key);
if (!result)
return v8Undefined();
Modified: trunk/Source/WebCore/dom/ChildNodeList.cpp (135666 => 135667)
--- trunk/Source/WebCore/dom/ChildNodeList.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/ChildNodeList.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -39,7 +39,7 @@
bool ChildNodeList::nodeMatches(Element* testNode) const
{
- // This function will be called only by DynamicNodeList::itemWithName,
+ // This function will be called only by DynamicNodeList::namedItem,
// for an element that was located with getElementById.
return testNode->parentNode() == rootNode();
}
Modified: trunk/Source/WebCore/dom/DynamicNodeList.cpp (135666 => 135667)
--- trunk/Source/WebCore/dom/DynamicNodeList.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/DynamicNodeList.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -85,35 +85,13 @@
void DynamicNodeListCacheBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+ NodeList::reportMemoryUsage(memoryObjectInfo);
info.addMember(m_ownerNode);
info.addWeakPointer(m_cachedItem);
}
-void DynamicNodeList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+Node* DynamicNodeList::namedItem(const AtomicString& elementId) const
{
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- NodeList::reportMemoryUsage(memoryObjectInfo);
- DynamicNodeListCacheBase::reportMemoryUsage(memoryObjectInfo);
-}
-
-void DynamicSubtreeNodeList::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- DynamicNodeList::reportMemoryUsage(memoryObjectInfo);
-}
-
-unsigned DynamicNodeList::length() const
-{
- return lengthCommon();
-}
-
-Node* DynamicNodeList::item(unsigned offset) const
-{
- return itemCommon(offset);
-}
-
-Node* DynamicNodeList::itemWithName(const AtomicString& elementId) const
-{
Node* rootNode = this->rootNode();
if (rootNode->inDocument()) {
Modified: trunk/Source/WebCore/dom/DynamicNodeList.h (135666 => 135667)
--- trunk/Source/WebCore/dom/DynamicNodeList.h 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/DynamicNodeList.h 2012-11-25 08:01:28 UTC (rev 135667)
@@ -41,7 +41,8 @@
NodeListIsRootedAtDocumentIfOwnerHasItemrefAttr,
};
-class DynamicNodeListCacheBase {
+// FIXME: CacheBase is a bad postfix for this class that now inherits from NodeList. Rename it to DynamicNodeListBase.
+class DynamicNodeListCacheBase : public NodeList {
public:
enum ItemAfterOverrideType {
OverridesItemAfter,
@@ -68,11 +69,12 @@
ASSERT(!m_overridesItemAfter || !isNodeList(collectionType));
}
- virtual ~DynamicNodeListCacheBase() { }
-
virtual void reportMemoryUsage(MemoryObjectInfo*) const;
-public:
+ // DOM API
+ virtual unsigned length() const OVERRIDE;
+ virtual Node* item(unsigned offset) const OVERRIDE;
+
ALWAYS_INLINE bool hasIdNameCache() const { return !isNodeList(type()); }
ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument || m_rootType == NodeListIsRootedAtDocumentIfOwnerHasItemrefAttr; }
ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); }
@@ -123,8 +125,6 @@
bool hasNameCache() const { return m_isNameCacheValid; }
void setHasNameCache() const { m_isNameCacheValid = true; }
- unsigned lengthCommon() const;
- Node* itemCommon(unsigned offset) const;
Node* itemBeforeOrAfterCachedItem(unsigned offset) const;
Node* itemAfter(unsigned&, Node* previousItem) const;
@@ -182,7 +182,7 @@
return false;
}
-class DynamicNodeList : public NodeList, public DynamicNodeListCacheBase {
+class DynamicNodeList : public DynamicNodeListCacheBase {
public:
DynamicNodeList(PassRefPtr<Node> ownerNode, CollectionType collectionType, NodeListRootType rootType, NodeListInvalidationType invalidationType)
: DynamicNodeListCacheBase(ownerNode.get(), rootType, invalidationType, collectionType == ChildNodeListType,
@@ -190,16 +190,10 @@
{ }
virtual ~DynamicNodeList() { }
- // DOM methods & attributes for NodeList
- virtual unsigned length() const OVERRIDE;
- virtual Node* item(unsigned offset) const OVERRIDE;
- virtual Node* itemWithName(const AtomicString&) const;
-
// Other methods (not part of DOM)
+ virtual Node* namedItem(const AtomicString&) const OVERRIDE;
virtual bool nodeMatches(Element*) const = 0;
- virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
-
private:
virtual bool isDynamicNodeList() const OVERRIDE { return true; }
};
@@ -211,8 +205,6 @@
document()->unregisterNodeListCache(this);
}
- virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
-
protected:
DynamicSubtreeNodeList(PassRefPtr<Node> node, CollectionType type, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
: DynamicNodeList(node, type, rootType, invalidationType)
Modified: trunk/Source/WebCore/dom/NodeList.h (135666 => 135667)
--- trunk/Source/WebCore/dom/NodeList.h 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/NodeList.h 2012-11-25 08:01:28 UTC (rev 135667)
@@ -39,8 +39,8 @@
// DOM methods & attributes for NodeList
virtual unsigned length() const = 0;
virtual Node* item(unsigned index) const = 0;
- virtual Node* itemWithName(const AtomicString&) const = 0;
-
+ virtual Node* namedItem(const AtomicString&) const = 0;
+
// Other methods (not part of DOM)
virtual bool isDynamicNodeList() const { return false; }
};
Modified: trunk/Source/WebCore/dom/StaticHashSetNodeList.cpp (135666 => 135667)
--- trunk/Source/WebCore/dom/StaticHashSetNodeList.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/StaticHashSetNodeList.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -63,7 +63,7 @@
return 0;
}
-Node* StaticHashSetNodeList::itemWithName(const AtomicString& elementId) const
+Node* StaticHashSetNodeList::namedItem(const AtomicString& elementId) const
{
ListHashSet<RefPtr<Node> >::const_iterator it = m_nodes.begin();
ListHashSet<RefPtr<Node> >::const_iterator end = m_nodes.end();
Modified: trunk/Source/WebCore/dom/StaticHashSetNodeList.h (135666 => 135667)
--- trunk/Source/WebCore/dom/StaticHashSetNodeList.h 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/StaticHashSetNodeList.h 2012-11-25 08:01:28 UTC (rev 135667)
@@ -55,9 +55,9 @@
return adoptRef(new StaticHashSetNodeList(nodes));
}
- virtual unsigned length() const;
- virtual Node* item(unsigned index) const;
- virtual Node* itemWithName(const AtomicString&) const;
+ virtual unsigned length() const OVERRIDE;
+ virtual Node* item(unsigned index) const OVERRIDE;
+ virtual Node* namedItem(const AtomicString&) const OVERRIDE;
private:
explicit StaticHashSetNodeList(ListHashSet<RefPtr<Node> >& nodes);
Modified: trunk/Source/WebCore/dom/StaticNodeList.cpp (135666 => 135667)
--- trunk/Source/WebCore/dom/StaticNodeList.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/StaticNodeList.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -45,7 +45,7 @@
return 0;
}
-Node* StaticNodeList::itemWithName(const AtomicString& elementId) const
+Node* StaticNodeList::namedItem(const AtomicString& elementId) const
{
size_t length = m_nodes.size();
for (size_t i = 0; i < length; ++i) {
Modified: trunk/Source/WebCore/dom/StaticNodeList.h (135666 => 135667)
--- trunk/Source/WebCore/dom/StaticNodeList.h 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/dom/StaticNodeList.h 2012-11-25 08:01:28 UTC (rev 135667)
@@ -46,9 +46,9 @@
return adoptRef(new StaticNodeList(nodes));
}
- virtual unsigned length() const;
- virtual Node* item(unsigned index) const;
- virtual Node* itemWithName(const AtomicString&) const;
+ virtual unsigned length() const OVERRIDE;
+ virtual Node* item(unsigned index) const OVERRIDE;
+ virtual Node* namedItem(const AtomicString&) const OVERRIDE;
private:
explicit StaticNodeList(Vector<RefPtr<Node> >& nodes)
Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (135666 => 135667)
--- trunk/Source/WebCore/html/HTMLCollection.cpp 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp 2012-11-25 08:01:28 UTC (rev 135667)
@@ -369,18 +369,18 @@
ASSERT(!elementsArrayOffset);
}
-unsigned DynamicNodeListCacheBase::lengthCommon() const
+unsigned DynamicNodeListCacheBase::length() const
{
if (isLengthCacheValid())
return cachedLength();
- itemCommon(UINT_MAX);
+ item(UINT_MAX);
ASSERT(isLengthCacheValid());
return cachedLength();
}
-Node* DynamicNodeListCacheBase::itemCommon(unsigned offset) const
+Node* DynamicNodeListCacheBase::item(unsigned offset) const
{
if (isItemCacheValid() && cachedItemOffset() == offset)
return cachedItem();
Modified: trunk/Source/WebCore/html/HTMLCollection.h (135666 => 135667)
--- trunk/Source/WebCore/html/HTMLCollection.h 2012-11-25 07:25:16 UTC (rev 135666)
+++ trunk/Source/WebCore/html/HTMLCollection.h 2012-11-25 08:01:28 UTC (rev 135667)
@@ -33,14 +33,12 @@
namespace WebCore {
-class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection>, public DynamicNodeListCacheBase {
+class HTMLCollection : public DynamicNodeListCacheBase {
public:
static PassRefPtr<HTMLCollection> create(Node* base, CollectionType);
virtual ~HTMLCollection();
// DOM API
- unsigned length() const { return lengthCommon(); }
- Node* item(unsigned offset) const { return itemCommon(offset); }
virtual Node* namedItem(const AtomicString& name) const;
PassRefPtr<NodeList> tags(const String&);
@@ -81,6 +79,8 @@
private:
bool checkForNameMatch(Element*, bool checkName, const AtomicString& name) const;
+ virtual bool isDynamicNodeList() const OVERRIDE { ASSERT_NOT_REACHED(); return true; }
+
static void append(NodeCacheMap&, const AtomicString&, Element*);
mutable NodeCacheMap m_idCache;