document.getItems(typeNames) should return all Microdata top level items if there are no typeNames specified in the aurgument i.e, document.getItems(). Failing test cases: fast/dom/MicroData/007.html fast/dom/MicroData/009.html fast/dom/MicroData/002.html fast/dom/MicroData/003.html fast/dom/MicroData/properties-collection-must-see-the-properties-added-in-itemref.html In case of documet.getItem() typeNames will be null string. Earlier we used to create MicroDataItemList with m_typeNames = null string. And we used to create an unique string identifier (http://webkit.org/microdata/undefinedItemType) to map such request in the cache. With r120979 this change it creates MicroDataItemList with m_typeNames = "http://webkit.org/microdata/undefinedItemType", when typeNames argument is not specified. So we need to modify the check in nodeMatches() accordingly.
Created attachment 149014 [details] Patch
Comment on attachment 149014 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=149014&action=review > Source/WebCore/dom/MicroDataItemList.cpp:62 > - if (!m_typeNames.size()) > + if (m_originalTypeNames == "http://webkit.org/microdata/undefinedItemType") Can we define this url in some static function of MicroDataItemList (using DEFINE_STATIC_LOCAL) so that we don't have to do String conversion here?
Created attachment 149062 [details] Updated patch
Comment on attachment 149062 [details] Updated patch Do we have a regression test that covers this? If not, can we add a new test that shows the bug?
Comment on attachment 149062 [details] Updated patch View in context: https://bugs.webkit.org/attachment.cgi?id=149062&action=review > Source/WebCore/ChangeLog:9 > + With r120979 change, it creates MicroDataItemList with m_typeNames = "http://webkit.org/microdata/undefinedItemType", > + when typeNames argument is not specified. Modified the check in nodeMatches() accordingly. Change log should list the regression tests that are failing to make it clear this is covered by tests. > Source/WebCore/ChangeLog:16 > + (WebCore::undefinedItemType): > + (WebCore): > + (WebCore::MicroDataItemList::MicroDataItemList): > + (WebCore::MicroDataItemList::~MicroDataItemList): > + (WebCore::MicroDataItemList::nodeMatches): Patches with per-function comments are better. Bogus lines like (WebCore): should be deleted before landing a change. > Source/WebCore/dom/MicroDataItemList.cpp:41 > +static String& undefinedItemType() Return type should be const String& because we don’t want the caller to be able to modify it. > Source/WebCore/dom/MicroDataItemList.cpp:49 > - , m_typeNames(typeNames, node()->document()->inQuirksMode()) > + , m_typeNames(typeNames, document()->inQuirksMode()) Seems like unrelated cleanup. > Source/WebCore/dom/MicroDataItemList.cpp:56 > - String localTypeNames = m_originalTypeNames.isNull() ? String("http://webkit.org/microdata/undefinedItemType") : m_originalTypeNames; > - m_node->nodeLists()->removeCacheWithName(this, DynamicNodeList::MicroDataItemListType, localTypeNames); > + ownerNode()->nodeLists()->removeCacheWithName(this, DynamicNodeList::MicroDataItemListType, m_originalTypeNames); Using ownerNode() instead of m_node seems like unrelated cleanup.
Comment on attachment 149062 [details] Updated patch View in context: https://bugs.webkit.org/attachment.cgi?id=149062&action=review > Source/WebCore/ChangeLog:3 > + Microdata: document.getItems(typeNames) is not returning Microdata items when typeNames aurgument is not specified. Typo here: aurgument
(In reply to comment #5) Thanks Darin for the review. > > Source/WebCore/ChangeLog:9 > > + With r120979 change, it creates MicroDataItemList with m_typeNames = "http://webkit.org/microdata/undefinedItemType", > > + when typeNames argument is not specified. Modified the check in nodeMatches() accordingly. > > Change log should list the regression tests that are failing to make it clear this is covered by tests. Ok. I will update the Changelog with failing test cases. > > Source/WebCore/ChangeLog:16 > > + (WebCore::undefinedItemType): > > + (WebCore): > > + (WebCore::MicroDataItemList::MicroDataItemList): > > + (WebCore::MicroDataItemList::~MicroDataItemList): > > + (WebCore::MicroDataItemList::nodeMatches): > > Patches with per-function comments are better. Bogus lines like (WebCore): should be deleted before landing a change. Ok. > > Source/WebCore/dom/MicroDataItemList.cpp:41 > > +static String& undefinedItemType() > > Return type should be const String& because we don’t want the caller to be able to modify it. Yes you are right. Will modify. > > Source/WebCore/dom/MicroDataItemList.cpp:49 > > - , m_typeNames(typeNames, node()->document()->inQuirksMode()) > > + , m_typeNames(typeNames, document()->inQuirksMode()) > > Seems like unrelated cleanup. r121003 revision added document() method which returns the document of owner node. > > Source/WebCore/dom/MicroDataItemList.cpp:56 > > - String localTypeNames = m_originalTypeNames.isNull() ? String("http://webkit.org/microdata/undefinedItemType") : m_originalTypeNames; > > - m_node->nodeLists()->removeCacheWithName(this, DynamicNodeList::MicroDataItemListType, localTypeNames); > > + ownerNode()->nodeLists()->removeCacheWithName(this, DynamicNodeList::MicroDataItemListType, m_originalTypeNames); > > Using ownerNode() instead of m_node seems like unrelated cleanup. r121003 revision renamed DynamicNodeList's m_node to m_ownerNode. So we need to use ownerNode() as m_ownerNode private to DynamicNodeList. Made changes accordingly.
Created attachment 149078 [details] Updated patch Incorporated review comments.
Comment on attachment 149078 [details] Updated patch View in context: https://bugs.webkit.org/attachment.cgi?id=149078&action=review > Source/WebCore/dom/MicroDataItemList.cpp:41 > +static const String& undefinedItemType() We should also use this function in Document::getItems.
Committed r121149: <http://trac.webkit.org/changeset/121149>