Bug 89544

Summary: Redraw slider tick marks when datalist changes.
Product: WebKit Reporter: Keishi Hattori <keishi>
Component: FormsAssignee: Keishi Hattori <keishi>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, gustavo, mifenton, philn, rakuco, tkent, webkit.review.bot, xan.lopez
Priority: P2 Keywords: WebExposed
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 87844    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Archive of layout-test-results from ec2-cr-linux-01
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Archive of layout-test-results from gce-cq-03
none
Patch none

Description Keishi Hattori 2012-06-19 19:11:20 PDT
We need to redraw the slider tick marks when the datalist changes.
Comment 1 Keishi Hattori 2012-06-19 20:37:01 PDT
Created attachment 148494 [details]
Patch
Comment 2 Keishi Hattori 2012-06-19 20:39:23 PDT
Here is the performance test results for setting id. The variance between runs is too high to tell a difference.
https://docs.google.com/spreadsheet/ccc?key=0AoaiM9jljUy8dDZfT3d6YzJ1UFFES2RmbHQ0Skw2bFE
Comment 3 Kent Tamura 2012-06-20 05:23:05 PDT
Please upload an EWS-cookable patch.

Can you use dom/WebKitMutationObserver.* ?
Comment 4 Keishi Hattori 2012-06-21 05:03:39 PDT
Created attachment 148769 [details]
Patch
Comment 5 Early Warning System Bot 2012-06-21 05:51:43 PDT
Comment on attachment 148769 [details]
Patch

Attachment 148769 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/13025097
Comment 6 Early Warning System Bot 2012-06-21 06:12:15 PDT
Comment on attachment 148769 [details]
Patch

Attachment 148769 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/13033084
Comment 7 Keishi Hattori 2012-06-21 06:48:34 PDT
Created attachment 148788 [details]
Patch
Comment 8 Early Warning System Bot 2012-06-21 07:19:18 PDT
Comment on attachment 148788 [details]
Patch

Attachment 148788 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/13028130
Comment 9 Early Warning System Bot 2012-06-21 07:31:32 PDT
Comment on attachment 148788 [details]
Patch

Attachment 148788 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/13029120
Comment 10 WebKit Review Bot 2012-06-21 08:11:20 PDT
Comment on attachment 148788 [details]
Patch

Attachment 148788 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13037121
Comment 11 Keishi Hattori 2012-06-22 02:48:53 PDT
Created attachment 148986 [details]
Patch
Comment 12 WebKit Review Bot 2012-06-22 05:03:27 PDT
Comment on attachment 148986 [details]
Patch

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

New failing tests:
fast/forms/datalist/update-range-with-datalist.html
Comment 13 WebKit Review Bot 2012-06-22 05:03:33 PDT
Created attachment 149000 [details]
Archive of layout-test-results from ec2-cr-linux-01

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: ec2-cr-linux-01  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Comment 14 Keishi Hattori 2012-07-17 05:58:04 PDT
Created attachment 152747 [details]
Patch
Comment 15 Gustavo Noronha (kov) 2012-07-17 06:08:10 PDT
Comment on attachment 152747 [details]
Patch

Attachment 152747 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/13279140
Comment 16 Build Bot 2012-07-17 06:19:19 PDT
Comment on attachment 152747 [details]
Patch

Attachment 152747 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/13276135
Comment 17 Gyuyoung Kim 2012-07-17 06:23:05 PDT
Comment on attachment 152747 [details]
Patch

Attachment 152747 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/13284127
Comment 18 Build Bot 2012-07-17 06:26:22 PDT
Comment on attachment 152747 [details]
Patch

Attachment 152747 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/13279141
Comment 19 Early Warning System Bot 2012-07-17 06:44:24 PDT
Comment on attachment 152747 [details]
Patch

Attachment 152747 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/13276138
Comment 20 Early Warning System Bot 2012-07-17 06:53:58 PDT
Comment on attachment 152747 [details]
Patch

Attachment 152747 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/13274146
Comment 21 Kent Tamura 2012-07-18 01:23:41 PDT
Comment on attachment 152747 [details]
Patch

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

> Source/WebCore/html/HTMLInputElement.cpp:693
> -    }
>  #if ENABLE(DATALIST)
> -    else if (attribute.name() == listAttr)
> +    } else if (attribute.name() == listAttr) {

I recommend not to change '}' position.

> Source/WebCore/html/HTMLInputElement.cpp:701
>  #endif
>  #if ENABLE(INPUT_SPEECH)
> -    else if (attribute.name() == webkitspeechAttr) {
> +    } else if (attribute.name() == webkitspeechAttr) {

I recommend move '}' before #endif.

> Source/WebCore/html/HTMLInputElement.cpp:1517
> +    m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fastGetAttribute(listAttr), this);

Do we need to create LIstAttributeTargetObserver when the input element is !inDocument()?

> Source/WebCore/html/HTMLInputElement.cpp:1523
> +    if (isRangeControl())
> +        setNeedsStyleRecalc();

Should introduce new virtual member function in InputType, or call setNeedsStyleRecalc() unconditionally.

> Source/WebCore/html/HTMLOptionElement.cpp:282
> +    ContainerNode* dataList = parentNode();
> +    while (dataList && !dataList->hasTagName(datalistTag))
> +        dataList = dataList->parentNode();
> +
> +    if (!dataList)
> +        return 0;
> +
> +    return static_cast<HTMLDataListElement*>(dataList);

Readability of this code isn't good.
 - Not following an idiom of parent traversal
 - static_cast<> is far from its requirement (hasTagName(datalistTag))

How about the following?

for (ContainerNode parent = parentNode(); parent ; parent = parent->parentNode()) {
    if (parent->hasTagName(datalistTag))
        return static_cast<HTMLDataListElement*>(dataList);
}
return 0;

> LayoutTests/ChangeLog:12
> +        * fast/forms/datalist/update-range-with-datalist-expected.txt: Added.
> +        * fast/forms/datalist/update-range-with-datalist.html: Added.
> +        * platform/chromium-mac/fast/forms/datalist/update-range-with-datalist-expected.png: Added.

This can be a ref-test.
Comment 22 Keishi Hattori 2012-07-18 04:14:15 PDT
Created attachment 152984 [details]
Patch
Comment 23 Keishi Hattori 2012-07-18 04:14:27 PDT
Comment on attachment 152747 [details]
Patch

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

>> Source/WebCore/html/HTMLInputElement.cpp:693
>> +    } else if (attribute.name() == listAttr) {
> 
> I recommend not to change '}' position.

Done.

>> Source/WebCore/html/HTMLInputElement.cpp:701
>> +    } else if (attribute.name() == webkitspeechAttr) {
> 
> I recommend move '}' before #endif.

Done.

>> Source/WebCore/html/HTMLInputElement.cpp:1517
>> +    m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fastGetAttribute(listAttr), this);
> 
> Do we need to create LIstAttributeTargetObserver when the input element is !inDocument()?

No. Added check.

>> Source/WebCore/html/HTMLInputElement.cpp:1523
>> +        setNeedsStyleRecalc();
> 
> Should introduce new virtual member function in InputType, or call setNeedsStyleRecalc() unconditionally.

We will be doing different things for input type text and color so I added a new virtual member function to InputType.

>> Source/WebCore/html/HTMLOptionElement.cpp:282
>> +    return static_cast<HTMLDataListElement*>(dataList);
> 
> Readability of this code isn't good.
>  - Not following an idiom of parent traversal
>  - static_cast<> is far from its requirement (hasTagName(datalistTag))
> 
> How about the following?
> 
> for (ContainerNode parent = parentNode(); parent ; parent = parent->parentNode()) {
>     if (parent->hasTagName(datalistTag))
>         return static_cast<HTMLDataListElement*>(dataList);
> }
> return 0;

Done.

>> LayoutTests/ChangeLog:12
>> +        * platform/chromium-mac/fast/forms/datalist/update-range-with-datalist-expected.png: Added.
> 
> This can be a ref-test.

Done.
Comment 24 Build Bot 2012-07-18 04:37:52 PDT
Comment on attachment 152984 [details]
Patch

Attachment 152984 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/13278488
Comment 25 Build Bot 2012-07-18 05:20:35 PDT
Comment on attachment 152984 [details]
Patch

Attachment 152984 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/13277512
Comment 26 Kent Tamura 2012-07-18 06:45:00 PDT
Comment on attachment 152984 [details]
Patch

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

> Source/WebCore/html/HTMLInputElement.cpp:90
> +class ListAttributeTargetObserver : IdTargetObserver {
> +public:
> +    static PassOwnPtr<ListAttributeTargetObserver> create(const AtomicString& id, HTMLInputElement*);
> +    virtual void idTargetChanged() OVERRIDE;
> +
> +private:
> +    ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement*);
> +
> +    HTMLInputElement* m_element;
> +};

should be enclosed with #if ENABLE(DATALIST)

> Source/WebCore/html/HTMLInputElement.cpp:1522
> +{
> +    if (!inDocument())
> +        return;
> +    m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fastGetAttribute(listAttr), this);
> +}

I know this works well.  However this code might make a reader nervous because of possibility of leak of a wrong ListAttributeTargetObserver object.
I recommend clearing m_listAttributeTargetObserver if !inDocument(), and use resetListAttributeTargetObserver() in removedFrom() too.

> Source/WebCore/html/HTMLInputElement.cpp:1811
> +PassOwnPtr<ListAttributeTargetObserver> ListAttributeTargetObserver::create(const AtomicString& id, HTMLInputElement* element)
> +{
> +    return adoptPtr(new ListAttributeTargetObserver(id, element));
> +}
> +
> +ListAttributeTargetObserver::ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement* element)
> +    : IdTargetObserver(element->treeScope()->idTargetObserverRegistry(), id)
> +    , m_element(element)
> +{
> +}
> +
> +void ListAttributeTargetObserver::idTargetChanged()
> +{
> +    m_element->listAttributeTargetChanged();
> +}

should be enclosed with #if ENABLE(DATALIST)

> Source/WebCore/html/HTMLInputElement.h:398
> +    OwnPtr<ListAttributeTargetObserver> m_listAttributeTargetObserver;

should be enclosed with #if ENABLE(DATALIST)
Comment 27 Keishi Hattori 2012-07-18 19:19:24 PDT
Created attachment 153160 [details]
Patch
Comment 28 Kent Tamura 2012-07-18 19:23:15 PDT
Comment on attachment 153160 [details]
Patch

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

> Source/WebCore/html/HTMLInputElement.cpp:1446
> +#if ENABLE(DATALIST)
> +    resetListAttributeTargetObserver();
> +#endif
>      HTMLTextFormControlElement::removedFrom(insertionPoint);

Node::removedFrom() clears inDocument flag.  So this should be

    HTMLTextFormControlElement::removedFrom(insertionPoint);
    ASSERT(!inDocument());
#if ENABLE(DATALIST)
    resetListAttributeTargetObserver();
#endif
Comment 29 Keishi Hattori 2012-07-18 20:19:12 PDT
Created attachment 153168 [details]
Patch
Comment 30 Kent Tamura 2012-07-18 21:10:57 PDT
Comment on attachment 153168 [details]
Patch

ok
Comment 31 Keishi Hattori 2012-07-18 22:53:49 PDT
Created attachment 153181 [details]
Patch
Comment 32 WebKit Review Bot 2012-07-19 00:10:20 PDT
Comment on attachment 153181 [details]
Patch

Rejecting attachment 153181 [details] from commit-queue.

New failing tests:
fast/forms/datalist/update-range-with-datalist.html
Full output: http://queues.webkit.org/results/13273776
Comment 33 WebKit Review Bot 2012-07-19 00:10:26 PDT
Created attachment 153192 [details]
Archive of layout-test-results from gce-cq-03

The attached test failures were seen while running run-webkit-tests on the commit-queue.
Bot: gce-cq-03  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.39-gcg-201203291735-x86_64-with-Ubuntu-10.04-lucid
Comment 34 Keishi Hattori 2012-07-19 00:56:39 PDT
Created attachment 153200 [details]
Patch
Comment 35 WebKit Review Bot 2012-07-19 01:55:21 PDT
Comment on attachment 153200 [details]
Patch

Clearing flags on attachment: 153200

Committed r123081: <http://trac.webkit.org/changeset/123081>
Comment 36 WebKit Review Bot 2012-07-19 01:55:29 PDT
All reviewed patches have been landed.  Closing bug.