Bug 86602 - [Forms] Refactor HTMLFormCollection
Summary: [Forms] Refactor HTMLFormCollection
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rakesh
URL:
Keywords:
Depends on:
Blocks: 80110
  Show dependency treegraph
 
Reported: 2012-05-16 02:43 PDT by Rakesh
Modified: 2012-05-21 03:48 PDT (History)
5 users (show)

See Also:


Attachments
proposed patch (40.19 KB, patch)
2012-05-16 04:02 PDT, Rakesh
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ec2-cr-linux-02 (597.63 KB, application/zip)
2012-05-16 07:35 PDT, WebKit Review Bot
no flags Details
updated patch (40.66 KB, patch)
2012-05-17 07:45 PDT, Rakesh
no flags Details | Formatted Diff | Diff
updated patch (9.47 KB, patch)
2012-05-18 04:49 PDT, Rakesh
no flags Details | Formatted Diff | Diff
updated patch (10.02 KB, patch)
2012-05-21 02:30 PDT, Rakesh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rakesh 2012-05-16 02:43:36 PDT
Refactor HTMLFormCollection to be independent of HTMLFormElement.
This is needed for implementing HTMLFieldSetElement's  elements attribute.
Comment 1 Rakesh 2012-05-16 04:02:34 PDT
Created attachment 142214 [details]
proposed patch
Comment 2 Build Bot 2012-05-16 04:26:05 PDT
Comment on attachment 142214 [details]
proposed patch

Attachment 142214 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/12694970
Comment 3 Build Bot 2012-05-16 05:30:55 PDT
Comment on attachment 142214 [details]
proposed patch

Attachment 142214 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/12701826
Comment 4 WebKit Review Bot 2012-05-16 07:35:32 PDT
Comment on attachment 142214 [details]
proposed patch

Attachment 142214 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/12722139

New failing tests:
editing/pasteboard/paste-noscript.html
editing/pasteboard/paste-noscript-xhtml.xhtml
Comment 5 WebKit Review Bot 2012-05-16 07:35:36 PDT
Created attachment 142256 [details]
Archive of layout-test-results from ec2-cr-linux-02

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: ec2-cr-linux-02  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Comment 6 Alexey Proskuryakov 2012-05-16 09:45:46 PDT
Comment on attachment 142214 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142214&action=review

Marking r- due to build breakage.

> Source/WebCore/html/HTMLFormCollection.h:38
> -    static PassOwnPtr<HTMLFormCollection> create(HTMLFormElement*);
> +    static PassOwnPtr<HTMLFormCollection> create(Node*);

Why does this take a Node, not an Element?
Comment 7 Kent Tamura 2012-05-17 01:36:18 PDT
(In reply to comment #0)
> Refactor HTMLFormCollection to be independent of HTMLFormElement.
> This is needed for implementing HTMLFieldSetElement's  elements attribute.

Are you planing to update HTMLFieldSetElement so that it has a collection of element pointers?
Comment 8 Rakesh 2012-05-17 01:59:44 PDT
(In reply to comment #7)
> (In reply to comment #0)
> > Refactor HTMLFormCollection to be independent of HTMLFormElement.
> > This is needed for implementing HTMLFieldSetElement's  elements attribute.
> 
> Are you planing to update HTMLFieldSetElement so that it has a collection of element pointers?

Yes and maybe the collection can be refreshed if document version changes.
Comment 9 Kent Tamura 2012-05-17 04:57:10 PDT
(In reply to comment #8)
> (In reply to comment #7)
> > (In reply to comment #0)
> > > Refactor HTMLFormCollection to be independent of HTMLFormElement.
> > > This is needed for implementing HTMLFieldSetElement's  elements attribute.
> > 
> > Are you planing to update HTMLFieldSetElement so that it has a collection of element pointers?
> 
> Yes and maybe the collection can be refreshed if document version changes.

I see.

I wondered which one was better; 
 A) HTMLFieldSetElement has a collection of form controls, and use HTMLFormCollection.
 B) HTMLFieldSetElement has no collection of form controls, and use HTMLCollection.

Probably A is simpler because of RadioNodeList.
Comment 10 Rakesh 2012-05-17 06:03:41 PDT
(In reply to comment #9)
> 
> I wondered which one was better; 
>  A) HTMLFieldSetElement has a collection of form controls, and use HTMLFormCollection.
>  B) HTMLFieldSetElement has no collection of form controls, and use HTMLCollection.
> 
> Probably A is simpler because of RadioNodeList.

Yes because of RadioNodeList, option A is better.
Please do let me know if you have further suggestions.
Comment 11 Rakesh 2012-05-17 07:45:59 PDT
Created attachment 142472 [details]
updated patch

Fixed build and the failing tests have to addressed. Hopefully it will pass all builds.
Comment 12 Rakesh 2012-05-17 07:48:05 PDT
(In reply to comment #6)
Thanks for review.
> Marking r- due to build breakage.
Fixed.
> Why does this take a Node, not an Element?
Updated in latest patch.

(In reply to comment #11)
> Created an attachment (id=142472) [details]
> updated patch
> 
> Fixed build and the failing tests have to addressed. Hopefully it will pass all builds.

Typo, please read as "Fixed build and the failing tests have *been* addressed."
Comment 13 Build Bot 2012-05-17 08:15:57 PDT
Comment on attachment 142472 [details]
updated patch

Attachment 142472 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/12723342
Comment 14 Kent Tamura 2012-05-17 22:47:32 PDT
Comment on attachment 142472 [details]
updated patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142472&action=review

> Source/WebCore/dom/Node.h:588
> +    const Vector<FormAssociatedElement*>* formControlElements();
> +    const Vector<HTMLImageElement*>* formImageElements();
> +    unsigned numberOfFormControlElements();
> +

I don't think Node should have them. If you'd like to have common ways to get them in HTMLCollection, you should define these function like:
  static unsigned numberOfFormControlElements(HTMLElement* base);

> Source/WebCore/html/HTMLFormElement.h:162
> -    Vector<FormAssociatedElement*> m_associatedElements;
> -    Vector<HTMLImageElement*> m_imageElements;
> +    mutable OwnPtr<Vector<FormAssociatedElement*> > m_associatedElements;
> +    mutable OwnPtr<Vector<HTMLImageElement*> > m_imageElements;

Why do you need to change them to OwnPtr<>?

In general, ChangeLog entry should explain reasons of the change.
Comment 15 Rakesh 2012-05-18 00:44:33 PDT
(In reply to comment #14)
> (From update of attachment 142472 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=142472&action=review
> 
Thanks for reviewing this patch.

> I don't think Node should have them. If you'd like to have common ways to get them in HTMLCollection, you should define these function like:
>   static unsigned numberOfFormControlElements(HTMLElement* base);

Yes, having these functions like suggested in HTMLFormCollection would be better.

> 
> > Source/WebCore/html/HTMLFormElement.h:162
> > -    Vector<FormAssociatedElement*> m_associatedElements;
> > -    Vector<HTMLImageElement*> m_imageElements;
> > +    mutable OwnPtr<Vector<FormAssociatedElement*> > m_associatedElements;
> > +    mutable OwnPtr<Vector<HTMLImageElement*> > m_imageElements;
> 
> Why do you need to change them to OwnPtr<>?

Only reason being, able to 'return 0' in case of failed case of toFormElement()conversion. I think this would not be needed if we make the above change. We can assert if not an form element in conversion.

> In general, ChangeLog entry should explain reasons of the change.
Will surely add explanation.
Comment 16 Rakesh 2012-05-18 04:49:11 PDT
Created attachment 142687 [details]
updated patch

Updated as per reviews comments.
Comment 17 Kent Tamura 2012-05-18 05:34:57 PDT
Comment on attachment 142687 [details]
updated patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142687&action=review

> Source/WebCore/html/HTMLFormCollection.cpp:53
> +static const Vector<FormAssociatedElement*>& formControlElements(HTMLElement* base)

You moved these function to HTMLFormCollection.  So we can make them member functions of HTMLFormCollection and the 'base' argument is not needed.

> Source/WebCore/html/HTMLFormCollection.cpp:55
> +    ASSERT(base && base->hasTagName(formTag));

nit: You should separate this ASSERT into two.

  ASSERT(base);
  ASSERT(base->hasTagName(formTag));

in order to know which condition fails.

> Source/WebCore/html/HTMLFormElement.h:149
>  
> -    friend class HTMLFormCollection;
> -
>      typedef HashMap<RefPtr<AtomicStringImpl>, RefPtr<HTMLFormControlElement> > AliasMap;

great!
Comment 18 Rakesh 2012-05-21 02:30:42 PDT
Created attachment 142974 [details]
updated patch

Updated as per reviews comments.
Comment 19 Kent Tamura 2012-05-21 02:36:12 PDT
Comment on attachment 142974 [details]
updated patch

Looks nice.
Comment 20 WebKit Review Bot 2012-05-21 03:28:51 PDT
Comment on attachment 142974 [details]
updated patch

Clearing flags on attachment: 142974

Committed r117754: <http://trac.webkit.org/changeset/117754>
Comment 21 WebKit Review Bot 2012-05-21 03:28:57 PDT
All reviewed patches have been landed.  Closing bug.
Comment 22 Rakesh 2012-05-21 03:48:29 PDT
(In reply to comment #19)
> (From update of attachment 142974 [details])
> Looks nice.
Thanks!!