Changeset 141395 in webkit


Ignore:
Timestamp:
Jan 31, 2013 3:17:40 AM (11 years ago)
Author:
tkent@chromium.org
Message:

Click on a label element won't select input[type=date]
https://bugs.webkit.org/show_bug.cgi?id=108428

Reviewed by Kentaro Hara.

Source/WebCore:

date/time input types with INPUT_MULTIPLE_FIELDS_UI are not
mouse-focusable. <input> as a shadow host never gets focus and
sub-fields in its shadow tree are focusable. Howevever, the click
handling of <label> checked isMouseFocusable. We introduce new function
isFocusableByClickOnLabel to HTMLElement. It's default implementation is
same as isMouseFocusable, and we add special handling for
BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel.

Also, date/time input types without INPUT_MULTIPLE_FIELDS_UI were not
mouse-focusable by a mistake. It should be mouse-focusable.

Test: fast/forms/date/date-click-on-label.html

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::isFocusableByClickOnLabel):
Added. Just calls isMouseFocusable.

  • html/HTMLElement.h:

(HTMLElement): Declare isFocusableByClickOnLabel.

  • html/HTMLLabelElement.cpp:

(WebCore::HTMLLabelElement::defaultEventHandler):
Calls isFocusableByClickOnLabel instead of isMouseFocusable.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::isFocusableByClickOnLabel):
Delegate to InputType::isFocusableByClickOnLabel.

  • html/HTMLInputElement.h:

(HTMLInputElement): Declare isFocusableByClickOnLabel.

  • html/InputType.cpp:

(WebCore::InputType::isFocusableByClickOnLabel):
Added. Calls isMouseFocusable.

  • html/InputType.h:

(InputType): Declare isFocusableByClickOnLabel.

  • html/BaseMultipleFieldsDateAndTimeInputType.cpp:

(WebCore::BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel):
Added. Use the same logic with textfields.

  • html/BaseMultipleFieldsDateAndTimeInputType.h:

(BaseMultipleFieldsDateAndTimeInputType): Declare isFocusableByClickOnLabel.

  • html/BaseChooserOnlyDateAndTimeInputType.cpp:

(WebCore::BaseChooserOnlyDateAndTimeInputType::isMouseFocusable):
Added. Use the same logic with textfields.

  • html/BaseChooserOnlyDateAndTimeInputType.h:

(BaseChooserOnlyDateAndTimeInputType): Declare isMouseFocusable.

LayoutTests:

  • fast/forms/date/date-click-on-label-expected.txt: Added.
  • fast/forms/date/date-click-on-label.html: Added.
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141393 r141395  
     12013-01-31  Kent Tamura  <tkent@chromium.org>
     2
     3        Click on a label element won't select input[type=date]
     4        https://bugs.webkit.org/show_bug.cgi?id=108428
     5
     6        Reviewed by Kentaro Hara.
     7
     8        * fast/forms/date/date-click-on-label-expected.txt: Added.
     9        * fast/forms/date/date-click-on-label.html: Added.
     10
    1112013-01-30  Yury Semikhatsky  <yurys@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r141394 r141395  
     12013-01-31  Kent Tamura  <tkent@chromium.org>
     2
     3        Click on a label element won't select input[type=date]
     4        https://bugs.webkit.org/show_bug.cgi?id=108428
     5
     6        Reviewed by Kentaro Hara.
     7
     8        date/time input types with INPUT_MULTIPLE_FIELDS_UI are not
     9        mouse-focusable. <input> as a shadow host never gets focus and
     10        sub-fields in its shadow tree are focusable. Howevever, the click
     11        handling of <label> checked isMouseFocusable. We introduce new function
     12        isFocusableByClickOnLabel to HTMLElement. It's default implementation is
     13        same as isMouseFocusable, and we add special handling for
     14        BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel.
     15
     16        Also, date/time input types without INPUT_MULTIPLE_FIELDS_UI were not
     17        mouse-focusable by a mistake. It should be mouse-focusable.
     18
     19        Test: fast/forms/date/date-click-on-label.html
     20
     21        * html/HTMLElement.cpp:
     22        (WebCore::HTMLElement::isFocusableByClickOnLabel):
     23        Added. Just calls isMouseFocusable.
     24        * html/HTMLElement.h:
     25        (HTMLElement): Declare isFocusableByClickOnLabel.
     26        * html/HTMLLabelElement.cpp:
     27        (WebCore::HTMLLabelElement::defaultEventHandler):
     28        Calls isFocusableByClickOnLabel instead of isMouseFocusable.
     29
     30        * html/HTMLInputElement.cpp:
     31        (WebCore::HTMLInputElement::isFocusableByClickOnLabel):
     32        Delegate to InputType::isFocusableByClickOnLabel.
     33        * html/HTMLInputElement.h:
     34        (HTMLInputElement): Declare isFocusableByClickOnLabel.
     35        * html/InputType.cpp:
     36        (WebCore::InputType::isFocusableByClickOnLabel):
     37        Added. Calls isMouseFocusable.
     38        * html/InputType.h:
     39        (InputType): Declare isFocusableByClickOnLabel.
     40
     41        * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
     42        (WebCore::BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel):
     43        Added. Use the same logic with textfields.
     44        * html/BaseMultipleFieldsDateAndTimeInputType.h:
     45        (BaseMultipleFieldsDateAndTimeInputType): Declare isFocusableByClickOnLabel.
     46        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
     47        (WebCore::BaseChooserOnlyDateAndTimeInputType::isMouseFocusable):
     48        Added. Use the same logic with textfields.
     49        * html/BaseChooserOnlyDateAndTimeInputType.h:
     50        (BaseChooserOnlyDateAndTimeInputType): Declare isMouseFocusable.
     51
    1522013-01-31  Kentaro Hara  <haraken@chromium.org>
    253
  • trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp

    r140385 r141395  
    132132}
    133133
     134bool BaseChooserOnlyDateAndTimeInputType::isMouseFocusable() const
     135{
     136    return element()->isTextFormControlFocusable();
     137}
     138
    134139}
    135140#endif
  • trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h

    r139424 r141395  
    5353    virtual void handleKeyupEvent(KeyboardEvent*) OVERRIDE;
    5454    virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE;
     55    virtual bool isMouseFocusable() const OVERRIDE;
    5556
    5657    // DateTimeChooserClient functions:
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp

    r141195 r141395  
    284284}
    285285
     286bool BaseMultipleFieldsDateAndTimeInputType::isFocusableByClickOnLabel() const
     287{
     288    return element()->isTextFormControlFocusable();
     289}
     290
    286291bool BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable(KeyboardEvent*) const
    287292{
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h

    r141195 r141395  
    8787    virtual bool hasBadInput() const OVERRIDE;
    8888    virtual bool hasCustomFocusLogic() const OVERRIDE FINAL;
     89    virtual bool isFocusableByClickOnLabel() const OVERRIDE;
    8990    virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE FINAL;
    9091    virtual bool isMouseFocusable() const OVERRIDE FINAL;
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r140436 r141395  
    11641164}
    11651165
     1166bool HTMLElement::isFocusableByClickOnLabel() const
     1167{
     1168    return isMouseFocusable();
     1169}
     1170
    11661171} // namespace WebCore
    11671172
  • trunk/Source/WebCore/html/HTMLElement.h

    r140436 r141395  
    108108
    109109    virtual bool isLabelable() const { return false; }
     110    virtual bool isFocusableByClickOnLabel() const;
    110111
    111112protected:
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r141228 r141395  
    12331233}
    12341234
     1235bool HTMLInputElement::isFocusableByClickOnLabel() const
     1236{
     1237    return m_inputType->isFocusableByClickOnLabel();
     1238}
     1239
    12351240String HTMLInputElement::defaultValue() const
    12361241{
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r141277 r141395  
    361361
    362362    virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
    363 
     363    virtual bool isFocusableByClickOnLabel() const OVERRIDE;
    364364    virtual bool isInRange() const;
    365365    virtual bool isOutOfRange() const;
  • trunk/Source/WebCore/html/HTMLLabelElement.cpp

    r137406 r141395  
    137137        element->dispatchSimulatedClick(evt);
    138138
    139         // If the control can be focused via the mouse, then do that too.
    140         if (element->isMouseFocusable())
     139        if (element->isFocusableByClickOnLabel())
    141140            element->focus();
    142141
  • trunk/Source/WebCore/html/InputType.cpp

    r141195 r141395  
    548548}
    549549
     550bool InputType::isFocusableByClickOnLabel() const
     551{
     552    return isMouseFocusable();
     553}
     554
    550555bool InputType::isKeyboardFocusable(KeyboardEvent* event) const
    551556{
  • trunk/Source/WebCore/html/InputType.h

    r141195 r141395  
    202202    virtual PassRefPtr<HTMLFormElement> formForSubmission() const;
    203203    virtual bool hasCustomFocusLogic() const;
     204    virtual bool isFocusableByClickOnLabel() const;
    204205    virtual bool isKeyboardFocusable(KeyboardEvent*) const;
    205206    virtual bool isMouseFocusable() const;
Note: See TracChangeset for help on using the changeset viewer.