2011-04-22 Yael Aharon <yael.aharon@nokia.com>
authoryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2011 22:36:46 +0000 (22:36 +0000)
committeryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2011 22:36:46 +0000 (22:36 +0000)
        Reviewed by Sam Weinig.

        HTMLFormControlElement::labels should allow custom attributes.
        https://bugs.webkit.org/show_bug.cgi?id=59128

        * fast/forms/labels-custom-property-expected.txt: Added.
        * fast/forms/labels-custom-property.html: Added.
2011-04-22  Yael Aharon  <yael.aharon@nokia.com>

        Reviewed by Sam Weinig.

        HTMLFormControlElement::labels should allow custom attributes.
        https://bugs.webkit.org/show_bug.cgi?id=59128

        Cache the labels list when it is created and keep using it for future
        labels calls.

        Test: fast/forms/labels-custom-property.html

        * html/HTMLFormControlElement.cpp:
        (WebCore::HTMLFormControlElement::labels):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@84693 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/labels-custom-property-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/labels-custom-property.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/NodeRareData.h
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/LabelsNodeList.cpp
Source/WebCore/html/LabelsNodeList.h

index dd5ee1b..f78ae9c 100644 (file)
@@ -1,3 +1,13 @@
+2011-04-22  Yael Aharon  <yael.aharon@nokia.com>
+
+        Reviewed by Sam Weinig.
+
+        HTMLFormControlElement::labels should allow custom attributes.
+        https://bugs.webkit.org/show_bug.cgi?id=59128
+
+        * fast/forms/labels-custom-property-expected.txt: Added.
+        * fast/forms/labels-custom-property.html: Added.
+
 2011-04-22  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt] REGRESSION(r84296): platform/qt/fast/history/back-to-unreachable-url-then-forward.html fails
diff --git a/LayoutTests/fast/forms/labels-custom-property-expected.txt b/LayoutTests/fast/forms/labels-custom-property-expected.txt
new file mode 100644 (file)
index 0000000..ee4ec0d
--- /dev/null
@@ -0,0 +1,11 @@
+Test that we can set and get custom properties on the labels attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS labels.customProperty is 1
+PASS document.getElementById("btn").labels.customProperty is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/labels-custom-property.html b/LayoutTests/fast/forms/labels-custom-property.html
new file mode 100644 (file)
index 0000000..41479ad
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Test that we can set and get custom properties on the labels attribute. ');
+
+var parentDiv = document.createElement('div');
+
+parentDiv.innerHTML = '<button id="btn"></button><label id="lbl1" for="btn"></label><label id="lbl2" for="btn"></label>';
+
+document.body.appendChild(parentDiv);
+
+labels = document.getElementById("btn").labels;
+labels.customProperty = 1;
+gc();
+shouldBe('labels.customProperty', '1');
+shouldBe('document.getElementById("btn").labels.customProperty', '1');
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index fc05d68..031568b 100644 (file)
@@ -1,3 +1,18 @@
+2011-04-22  Yael Aharon  <yael.aharon@nokia.com>
+
+        Reviewed by Sam Weinig.
+
+        HTMLFormControlElement::labels should allow custom attributes.
+        https://bugs.webkit.org/show_bug.cgi?id=59128
+
+        Cache the labels list when it is created and keep using it for future
+        labels calls.
+
+        Test: fast/forms/labels-custom-property.html
+
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::labels):
+
 2011-04-22  Adrienne Walker  <enne@google.com>
 
         Reviewed by James Robinson.
index ecd16e0..9c536ba 100644 (file)
@@ -34,6 +34,7 @@
 
 namespace WebCore {
 
+class LabelsNodeList;
 class TreeScope;
 
 struct NodeListsNodeData {
@@ -56,7 +57,7 @@ public:
     typedef HashMap<RefPtr<QualifiedName::QualifiedNameImpl>, TagNodeList*> TagNodeListCacheNS;
     TagNodeListCacheNS m_tagNodeListCacheNS;
  
-    RefPtr<DynamicNodeList> m_labelsNodeListCache;
+    LabelsNodeList* m_labelsNodeListCache;
  
     static PassOwnPtr<NodeListsNodeData> create()
     {
index 87f4e4d..847e454 100644 (file)
@@ -471,7 +471,12 @@ PassRefPtr<NodeList> HTMLFormControlElement::labels()
         document()->addNodeListCache();
     }
 
-    return LabelsNodeList::create(this);
+    if (data->nodeLists()->m_labelsNodeListCache)
+        return data->nodeLists()->m_labelsNodeListCache;
+
+    RefPtr<LabelsNodeList> list = LabelsNodeList::create(this);
+    data->nodeLists()->m_labelsNodeListCache = list.get();
+    return list.release();
 }
 
 HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
index f2bda17..d97ce69 100644 (file)
@@ -32,7 +32,7 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-LabelsNodeList::LabelsNodeList(PassRefPtr<Node> forNode )
+LabelsNodeList::LabelsNodeList(Node* forNode )
     : DynamicNodeList(forNode->document()) , m_forNode(forNode)
 {
 }
index c22a532..97501a4 100644 (file)
@@ -32,14 +32,14 @@ namespace WebCore {
 
 class LabelsNodeList : public DynamicNodeList {
 public:
-    static PassRefPtr<LabelsNodeList> create(PassRefPtr<Node> forNode)
+    static PassRefPtr<LabelsNodeList> create(Node* forNode)
     {
         return adoptRef(new LabelsNodeList(forNode));
     }
     ~LabelsNodeList();
 
 protected:
-    LabelsNodeList(PassRefPtr<Node> forNode);
+    LabelsNodeList(Node* forNode);
 
     virtual bool nodeMatches(Element*) const;