Bug 129084 - m_ancestorDisabledState should never be unknown
Summary: m_ancestorDisabledState should never be unknown
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords:
Depends on:
Blocks: 129035
  Show dependency treegraph
 
Reported: 2014-02-19 23:06 PST by Ryosuke Niwa
Modified: 2014-02-20 22:34 PST (History)
4 users (show)

See Also:


Attachments
Patch (25.64 KB, patch)
2014-02-19 23:51 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Reverted erroneous xcworkspace chagnes (21.22 KB, patch)
2014-02-19 23:53 PST, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Updated per review comments (23.87 KB, patch)
2014-02-20 18:49 PST, Ryosuke Niwa
benjamin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2014-02-19 23:06:32 PST
In order to resolve the bug 129035, we need to be notified whenever form control element's disabled-ness changes.
Comment 1 Ryosuke Niwa 2014-02-19 23:51:56 PST
Created attachment 224723 [details]
Patch
Comment 2 Ryosuke Niwa 2014-02-19 23:53:32 PST
Created attachment 224724 [details]
Reverted erroneous xcworkspace chagnes
Comment 3 Benjamin Poulain 2014-02-20 15:28:53 PST
Comment on attachment 224724 [details]
Reverted erroneous xcworkspace chagnes

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

Ok with the idea but I have some questions when you have time.

> Source/WebCore/html/HTMLFieldSetElement.cpp:77
> +        document().removeDisabledFieldsetElement();

Don't you also need this on document destruction?

> Source/WebCore/html/HTMLFieldSetElement.cpp:89
> +        updateFromControlElementsAncestorDisabledStateUnder(control, thisFieldsetIsDisabled);

I am not following this. This loop will go over all the HTMLElements under the FieldSet. updateFromControlElementsAncestorDisabledStateUnder will again traverse the tree looking for any HTMLFormControlElement.
Aren't we traversing twice?

> Source/WebCore/html/HTMLFieldSetElement.cpp:104
> +    while ((legend = Traversal<HTMLLegendElement>::nextSibling(legend)))

I am not following here, why do check only the siblings instead of the whole tree after legend?

> Source/WebCore/html/HTMLFormControlElement.cpp:118
> +void HTMLFormControlElement::setAncestorDisabled(bool isDisabled)
>  {
> -    m_ancestorDisabledState = AncestorDisabledStateUnknown;
> -    disabledAttributeChanged();
> +    ASSERT(computeIsDisabledByFieldsetAncestor() == isDisabled);

Shouldn't this be updateIsAncestorDisabled() called without arguments disabledAttributeChanged().
Comment 4 Ryosuke Niwa 2014-02-20 16:26:22 PST
(In reply to comment #3)
> (From update of attachment 224724 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=224724&action=review
> 
> Ok with the idea but I have some questions when you have time.
> 
> > Source/WebCore/html/HTMLFieldSetElement.cpp:77
> > +        document().removeDisabledFieldsetElement();
> 
> Don't you also need this on document destruction?

We don't because all fieldset elements would have been removed at that point.

> > Source/WebCore/html/HTMLFieldSetElement.cpp:89
> > +        updateFromControlElementsAncestorDisabledStateUnder(control, thisFieldsetIsDisabled);
> 
> I am not following this. This loop will go over all the HTMLElements under the FieldSet. updateFromControlElementsAncestorDisabledStateUnder will again traverse the tree looking for any HTMLFormControlElement.
> Aren't we traversing twice?

Here, I'm traversing over all child elements, and then for each child node and its descendants we update its internals states. We can't call updateFromControlElementsAncestorDisabledStateUnder on this here because we need to call it with isDisabled set to false when the child is the first legend element we saw.

> > Source/WebCore/html/HTMLFieldSetElement.cpp:104
> > +    while ((legend = Traversal<HTMLLegendElement>::nextSibling(legend)))
> 
> I am not following here, why do check only the siblings instead of the whole tree after legend?

See my change log description:
Update disabled-ness of form controls under child legend elements because controls aren't disabled in the first legend element, and adding or removing child elements may have changed the first legend element.

Removing or adding child nodes DO NOT change disabled-ness of elements outside of the new and the old first legend element.

> > Source/WebCore/html/HTMLFormControlElement.cpp:118
> > +void HTMLFormControlElement::setAncestorDisabled(bool isDisabled)
> >  {
> > -    m_ancestorDisabledState = AncestorDisabledStateUnknown;
> > -    disabledAttributeChanged();
> > +    ASSERT(computeIsDisabledByFieldsetAncestor() == isDisabled);
> 
> Shouldn't this be updateIsAncestorDisabled() called without arguments disabledAttributeChanged().

I don't understand what you're saying here.
Comment 5 Ryosuke Niwa 2014-02-20 18:49:10 PST
Created attachment 224818 [details]
Updated per review comments
Comment 6 Ryosuke Niwa 2014-02-20 22:34:53 PST
Committed r164475: <http://trac.webkit.org/changeset/164475>