Skip to content
  • arko@motorola.com's avatar
    Microdata: Implement PropertyNodeList interface. · decc3e86
    arko@motorola.com authored
    https://bugs.webkit.org/show_bug.cgi?id=80269
    
    Reviewed by Ryosuke Niwa.
    
    Source/WebCore: 
    
    Added support for PropertyNodeList interface. Currently HTMLPropertiesCollection.namedItem(name)
    returns NodeList object. Made changes so that it will return PropertyNodeList object.
    
    Implemented propertyNodeList.getValues() method. It returns an array of various values. Its
    values are obtained from the "itemValue" DOM property of each of the elements represented by
    the object, in tree order.
    
    Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#propertynodelist
    
    Tests: fast/dom/MicroData/nameditem-returns-propertynodelist.html
           fast/dom/MicroData/propertynodelist-getvalues-array-values-obtained-from-itemvalue-of-each-element.html
           fast/dom/MicroData/propertynodelist-getvalues-test.html
           fast/dom/MicroData/propertynodelist-test-add-remove-element.html
    
    * CMakeLists.txt:
    * DerivedSources.cpp:
    * DerivedSources.make:
    * DerivedSources.pri:
    * GNUmakefile.list.am:
    * Target.pri:
    * UseJSC.cmake:
    * UseV8.cmake:
    * WebCore.gypi:
    * WebCore.vcproj/WebCore.vcproj:
    * WebCore.xcodeproj/project.pbxproj:
    * bindings/gobject/GNUmakefile.am:
    * bindings/js/JSBindingsAllInOne.cpp:
    * bindings/js/JSMicroDataItemValueCustom.cpp: Added.
    (WebCore):
    (WebCore::toJS): Added toJS() custom method. Returns Node if itemValue is node else returns String.
    * bindings/v8/custom/V8MicroDataItemValueCustom.cpp: Added.
    (WebCore):
    (WebCore::toV8): Added toV8 custom code.
    * dom/DynamicNodeList.cpp:
    (WebCore::DynamicNodeListCacheBase::rootNode): Return document if owner node has itemref attribute specified.
    (WebCore):
    (WebCore::DynamicNodeListCacheBase::ownerNodeHasItemRefAttribute): Returns true if owner node has itemref attribute
    specified with root type NodeListRootedAtDocumentIfOwnerHasItemrefAttr.
    (WebCore::DynamicNodeListCacheBase::invalidateCache):
    (WebCore::DynamicNodeList::itemWithName): Update itemrefElements cache if root type is
    NodeListIsRootedAtDocumentIfOwnerHasItemrefAttr.
    * dom/DynamicNodeList.h: Added m_hasItemRefElements in DynamicNodeListCacheBase to check if itemRefElmenets cache
    is valid.
    (WebCore::DynamicNodeListCacheBase::DynamicNodeListCacheBase):
    (WebCore::DynamicNodeListCacheBase::isRootedAtDocument):
    (DynamicNodeListCacheBase):
    (WebCore::DynamicNodeListCacheBase::isItemRefElementsCacheValid):
    (WebCore::DynamicNodeListCacheBase::setItemRefElementsCacheValid):
    (WebCore::DynamicNodeListCacheBase::rootType): Returns cached root type.
    (WebCore::DynamicNodeListCacheBase::shouldInvalidateTypeOnAttributeChange): Invalidate NodeListCache on itemref
    attribute change.
    * dom/Node.cpp:
    (WebCore::Node::propertyNodeList):
    * dom/Node.h:
    (WebCore):
    (Node):
    * dom/PropertyNodeList.cpp: Added.
    (WebCore):
    (WebCore::PropertyNodeList::PropertyNodeList):
    (WebCore::PropertyNodeList::~PropertyNodeList):
    (WebCore::PropertyNodeList::elementIsPropertyOfRefElement): Checks if the testElement is a property of Microdata
    item.
    (WebCore::PropertyNodeList::updateRefElements):
    (WebCore::PropertyNodeList::nodeMatches):
    (WebCore::PropertyNodeList::getValues): Returns PropertyValueArray whose values are obtained from the
    itemValue DOM property of each of the elements represented by the object, in tree order.
    * dom/PropertyNodeList.h: Added.
    (WebCore):
    (PropertyNodeList):
    (WebCore::PropertyNodeList::create):
    * dom/PropertyNodeList.idl: Added.
    * html/HTMLCollection.cpp:
    (WebCore::DynamicNodeListCacheBase::itemCommon): Update itemrefElements cache if its a NodeListCollectionType with
    root type NodeListIsRootedAtDocumentIfOwnerHasItemrefAttr.
    * html/HTMLElement.cpp:
    (WebCore::HTMLElement::properties):
    (WebCore):
    (WebCore::HTMLElement::getItemRefElements): Returns the ItemRefElements list of given element. Added this
    method to share the code between HTMLPropertiesCollection and PropertyNodeList to update itemRefElements.
    * html/HTMLElement.h:
    (HTMLElement):
    * html/HTMLPropertiesCollection.cpp:
    (WebCore::HTMLPropertiesCollection::HTMLPropertiesCollection):
    (WebCore::HTMLPropertiesCollection::updateRefElements):
    (WebCore::HTMLPropertiesCollection::updateNameCache):
    (WebCore::HTMLPropertiesCollection::namedItem): Return PropertyNodeList object instead of NodeList.
    (WebCore::HTMLPropertiesCollection::hasNamedItem): Return true if it finds an item with given
    name in the properties collection.
    * html/HTMLPropertiesCollection.h: Removed m_hasItemRefElements member variable, now DynamicNodeListCacheBase
    has isItemRefElementsCacheValid. Also removed m_hasPropertyNameCache, as DynamicNodeListCacheBase already has
    hasNameCache() and setHasNameCache().
    (WebCore):
    (HTMLPropertiesCollection):
    (WebCore::HTMLPropertiesCollection::invalidateCache):
    (WebCore::HTMLPropertiesCollection::updatePropertyCache):
    * html/HTMLPropertiesCollection.idl:
    * html/MicroDataItemValue.idl: Added.
    * page/DOMWindow.idl:
    
    LayoutTests: 
    
    Added test cases for PropertyNodeList interface and PropertyNodeList.getValues() method.
    Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#propertynodelist
    
    * fast/dom/MicroData/nameditem-returns-propertynodelist-expected.txt: Added.
    * fast/dom/MicroData/nameditem-returns-propertynodelist.html: Added.
    * fast/dom/MicroData/propertynodelist-getvalues-array-values-obtained-from-itemvalue-of-each-element-expected.txt: Added.
    * fast/dom/MicroData/propertynodelist-getvalues-array-values-obtained-from-itemvalue-of-each-element.html: Added.
    * fast/dom/MicroData/propertynodelist-getvalues-test-expected.txt: Added.
    * fast/dom/MicroData/propertynodelist-getvalues-test.html: Added.
    * fast/dom/MicroData/propertynodelist-test-add-remove-element-expected.txt: Added.
    * fast/dom/MicroData/propertynodelist-test-add-remove-element.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@123434 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    decc3e86