Changeset 109200 in webkit
- Timestamp:
- Feb 28, 2012 11:25:52 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109199 r109200 1 2012-02-28 Arko Saha <arko@motorola.com> 2 3 Microdata: Implement HTMLPropertiesCollection collection.namedItem(). 4 https://bugs.webkit.org/show_bug.cgi?id=73156 5 6 Reviewed by Kentaro Hara. 7 8 Added test-cases for collection.namedItem(). 9 10 * fast/dom/MicroData/nameditem-must-be-case-sensitive-expected.txt: Added. 11 * fast/dom/MicroData/nameditem-must-be-case-sensitive.html: Added. 12 * fast/dom/MicroData/nameditem-must-return-correct-item-properties-expected.txt: Added. 13 * fast/dom/MicroData/nameditem-must-return-correct-item-properties.html: Added. 14 * fast/dom/MicroData/properties-collection-nameditem-test-expected.txt: Added. 15 * fast/dom/MicroData/properties-collection-nameditem-test.html: Added. 16 1 17 2012-02-28 Kenichi Ishibashi <bashi@chromium.org> 2 18 -
trunk/Source/WebCore/ChangeLog
r109198 r109200 1 2012-02-28 Arko Saha <arko@motorola.com> 2 3 Microdata: Implement HTMLPropertiesCollection collection.namedItem(). 4 https://bugs.webkit.org/show_bug.cgi?id=73156 5 6 Reviewed by Kentaro Hara. 7 8 Tests: fast/dom/MicroData/nameditem-must-be-case-sensitive.html 9 fast/dom/MicroData/nameditem-must-return-correct-item-properties.html 10 fast/dom/MicroData/properties-collection-nameditem-test.html 11 12 * bindings/scripts/CodeGeneratorJS.pm: Modified code generator to generate 13 JS bindings code for HTMLPropertiesCollection [NamedGetter] property. 14 (GenerateImplementation): 15 * html/HTMLPropertiesCollection.cpp: 16 (WebCore::HTMLPropertiesCollection::names): 17 (WebCore): 18 (WebCore::HTMLPropertiesCollection::namedItem): Returns a NodeList object 19 containing any elements that add a property named name. 20 (WebCore::HTMLPropertiesCollection::hasNamedItem): Checks if the items can 21 be retrieved or not based on the property named name. 22 * html/HTMLPropertiesCollection.h: Added namedItem(), hasProperty(), 23 hasNamedItem() methods. 24 (HTMLPropertiesCollection): 25 * html/HTMLPropertiesCollection.idl: Added namedItem() IDL method. 26 1 27 2012-02-28 Kinuko Yasuda <kinuko@chromium.org> 2 28 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r109029 r109200 2225 2225 } 2226 2226 2227 if ($interfaceName eq "HTMLPropertiesCollection") { 2228 if ($dataNode->extendedAttributes->{"NamedGetter"}) { 2229 push(@implContent, "bool ${className}::canGetItemsForName(ExecState*, $implClassName* collection, const Identifier& propertyName)\n"); 2230 push(@implContent, "{\n"); 2231 push(@implContent, " return collection->hasNamedItem(identifierToAtomicString(propertyName));\n"); 2232 push(@implContent, "}\n\n"); 2233 push(@implContent, "JSValue ${className}::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)\n"); 2234 push(@implContent, "{\n"); 2235 push(@implContent, " ${className}* thisObj = static_cast<$className*>(asObject(slotBase));\n"); 2236 push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->namedItem(identifierToAtomicString(propertyName)));\n"); 2237 push(@implContent, "}\n\n"); 2238 } 2239 } 2240 2227 2241 if ((!$hasParent && !$dataNode->extendedAttributes->{"JSCustomIsReachable"})|| $dataNode->extendedAttributes->{"JSGenerateIsReachable"} || $dataNode->extendedAttributes->{"ActiveDOMObject"}) { 2228 2242 push(@implContent, "static inline bool isObservable(JS${implClassName}* js${implClassName})\n"); -
trunk/Source/WebCore/html/HTMLPropertiesCollection.cpp
r105655 r109200 40 40 #include "HTMLNames.h" 41 41 #include "Node.h" 42 #include "StaticNodeList.h" 42 43 43 44 namespace WebCore { … … 173 174 } 174 175 176 PassRefPtr<NodeList> HTMLPropertiesCollection::namedItem(const String& name) const 177 { 178 if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr)) 179 return 0; 180 181 m_properties.clear(); 182 Vector<RefPtr<Node> > namedItems; 183 findPropetiesOfAnItem(base()); 184 185 std::sort(m_properties.begin(), m_properties.end(), compareTreeOrder); 186 187 // For each item properties, split the value of that itemprop attribute on spaces. 188 // Add element to namedItem that contains a property named name, with the order preserved. 189 for (size_t i = 0; i < m_properties.size(); ++i) { 190 DOMSettableTokenList* itemProperty = m_properties[i]->itemProp(); 191 if (itemProperty->tokens().contains(name)) 192 namedItems.append(m_properties[i]); 193 } 194 195 // FIXME: HTML5 specifies that this should return PropertyNodeList. 196 return namedItems.isEmpty() ? 0 : StaticNodeList::adopt(namedItems); 197 } 198 199 bool HTMLPropertiesCollection::hasNamedItem(const AtomicString& name) const 200 { 201 if (!base()->isHTMLElement() || !toHTMLElement(base())->fastHasAttribute(itemscopeAttr)) 202 return false; 203 204 m_properties.clear(); 205 findPropetiesOfAnItem(base()); 206 207 // For each item properties, split the value of that itemprop attribute on spaces. 208 // Return true if element contains a property named name. 209 for (size_t i = 0; i < m_properties.size(); ++i) { 210 DOMSettableTokenList* itemProperty = m_properties[i]->itemProp(); 211 if (itemProperty->tokens().contains(name)) 212 return true; 213 } 214 215 return false; 216 } 217 175 218 } // namespace WebCore 176 219 -
trunk/Source/WebCore/html/HTMLPropertiesCollection.h
r105655 r109200 51 51 PassRefPtr<DOMStringList> names() const; 52 52 53 PassRefPtr<NodeList> namedItem(const String&) const; 54 bool hasNamedItem(const AtomicString&) const; 55 53 56 private: 54 57 HTMLPropertiesCollection(Node*); 55 58 56 59 void findPropetiesOfAnItem(Node* current) const; 60 void getNamedItems(Vector<RefPtr<Node> >&, const String&) const; 57 61 58 62 mutable Vector<Node*> m_properties; -
trunk/Source/WebCore/html/HTMLPropertiesCollection.idl
r106798 r109200 33 33 interface [ 34 34 Conditional=MICRODATA, 35 IndexedGetter 35 IndexedGetter, 36 NamedGetter 36 37 ] HTMLPropertiesCollection : HTMLCollection { 37 38 readonly attribute unsigned long length; … … 40 41 readonly attribute DOMStringList names; 41 42 42 // FIXME: override inherited namedItem() 43 // FIXME: HTML5 specifies that this should return PropertyNodeList. 44 NodeList namedItem(in DOMString name); 43 45 }; 44 46 }
Note: See TracChangeset
for help on using the changeset viewer.