Microdata: Implement cache mechanism for HTMLPropertiesCollection.
authorarko@motorola.com <arko@motorola.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 15:20:04 +0000 (15:20 +0000)
committerarko@motorola.com <arko@motorola.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 15:20:04 +0000 (15:20 +0000)
commit716accace770f77660ffe143da408048ba9df6be
tree563e2adf63d0b3b3147e6409cfe03053490409eb
parent54635d0ef980e8cb15e2bf5f6276f8b7bc010057
Microdata: Implement cache mechanism for HTMLPropertiesCollection.
https://bugs.webkit.org/show_bug.cgi?id=80490

Reviewed by Ryosuke Niwa.

Implemented caching mechanism for HTMLPropertiesCollection.
propertyCache - contains microdata item properties.
itemRefElements - contains sorted microdata item and itemref elements.
propertyNames - contains microdata property names of the elements in the collection.
itemRefElementPosition - store the current position of itemRefElements.
hasItemRefElements - set to ture once we have sorted microdata item and itemref elements list i.e, itemRefElements.
Cache is invalidated only when dom tree modified. Whenever any query is made on HTMLPropertiesCollection,
result is returned from the cache. Earliar we used to calculate properties node list every time a query is made.

* html/HTMLPropertiesCollection.cpp:
(WebCore):
(WebCore::HTMLPropertiesCollection::HTMLPropertiesCollection):
(WebCore::HTMLPropertiesCollection::invalidateCacheIfNeeded):
(WebCore::HTMLPropertiesCollection::updateRefElements): Appends microdata item element and elements which
are added through itemref attribute in itemRefElements (in tree order).
(WebCore::nextNodeWithProperty):
(WebCore::HTMLPropertiesCollection::itemAfter): Takes parent base and previous item property as argument.
Finds the next item property in base.
(WebCore::HTMLPropertiesCollection::calcLength): Calculates the length of properties collection if length
is not available in the cache.
(WebCore::HTMLPropertiesCollection::length):
(WebCore::HTMLPropertiesCollection::firstProperty): Returns the first property in the collection.
(WebCore::HTMLPropertiesCollection::item):
(WebCore::HTMLPropertiesCollection::findProperties): Finds microdata item properties in the base element.
Appends the properties in propertyCache and property names in propertyNames.
(WebCore::HTMLPropertiesCollection::updateNameCache):  It updates the propertyCache and propertyNames if hasNameCache is false.
(WebCore::HTMLPropertiesCollection::names):
(WebCore::HTMLPropertiesCollection::namedItem):
(WebCore::HTMLPropertiesCollection::hasNamedItem):
* html/HTMLPropertiesCollection.h:
(HTMLPropertiesCollection):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113862 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLPropertiesCollection.cpp
Source/WebCore/html/HTMLPropertiesCollection.h