Changeset 139424 in webkit


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

BaseDateAndTimeInputType should not inherit from TextFieldInputType
https://bugs.webkit.org/show_bug.cgi?id=106306

Reviewed by Hajime Morita.

Date/time input types don't need text-field features at all.

No new tests. This should not make any behavior changes except reduction
of memory usage.

  • html/BaseDateAndTimeInputType.h:

Inherit InputType instead of TextFieldInputType.
(WebCore::BaseDateAndTimeInputType::BaseDateAndTimeInputType):
(BaseDateAndTimeInputType): Update function declarations.

  • html/BaseDateAndTimeInputType.cpp:

Remove handleKeydownEvent and convertFromVisibleValue, which are for
TextFieldInputType.
(WebCore::BaseDateAndTimeInputType::shouldRespectListAttribute):
Added. This is necessary for <datalist> support. TextFieldInputType has
the same code.
(WebCore::BaseDateAndTimeInputType::valueMissing):
Added. This is necessary for validity.valueMissing. TextFieldInputType
has the same code.

  • html/BaseChooserOnlyDateAndTimeInputType.cpp:

Remove unnecessary functions which cancel TextFieldInputType behavior.

  • html/BaseChooserOnlyDateAndTimeInputType.h:

(BaseChooserOnlyDateAndTimeInputType): Remove declarations for them.

  • html/BaseMultipleFieldsDateAndTimeInputType.cpp:

Remove unnecessary functions which cancel TextFieldInputType behavior.

  • html/BaseMultipleFieldsDateAndTimeInputType.h:

(BaseMultipleFieldsDateAndTimeInputType):
Add SpinButtonOwner interface. We didn't need it because
TextFieldInputType implements it.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139423 r139424  
     12013-01-11  Kent Tamura  <tkent@chromium.org>
     2
     3        BaseDateAndTimeInputType should not inherit from TextFieldInputType
     4        https://bugs.webkit.org/show_bug.cgi?id=106306
     5
     6        Reviewed by Hajime Morita.
     7
     8        Date/time input types don't need text-field features at all.
     9
     10        No new tests. This should not make any behavior changes except reduction
     11        of memory usage.
     12
     13        * html/BaseDateAndTimeInputType.h:
     14        Inherit InputType instead of TextFieldInputType.
     15        (WebCore::BaseDateAndTimeInputType::BaseDateAndTimeInputType):
     16        (BaseDateAndTimeInputType): Update function declarations.
     17        * html/BaseDateAndTimeInputType.cpp:
     18        Remove handleKeydownEvent and convertFromVisibleValue, which are for
     19        TextFieldInputType.
     20        (WebCore::BaseDateAndTimeInputType::shouldRespectListAttribute):
     21        Added. This is necessary for <datalist> support. TextFieldInputType has
     22        the same code.
     23        (WebCore::BaseDateAndTimeInputType::valueMissing):
     24        Added. This is necessary for validity.valueMissing. TextFieldInputType
     25        has the same code.
     26
     27        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
     28        Remove unnecessary functions which cancel TextFieldInputType behavior.
     29        * html/BaseChooserOnlyDateAndTimeInputType.h:
     30        (BaseChooserOnlyDateAndTimeInputType): Remove declarations for them.
     31
     32        * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
     33        Remove unnecessary functions which cancel TextFieldInputType behavior.
     34        * html/BaseMultipleFieldsDateAndTimeInputType.h:
     35        (BaseMultipleFieldsDateAndTimeInputType):
     36        Add SpinButtonOwner interface. We didn't need it because
     37        TextFieldInputType implements it.
     38
    1392013-01-11  Mary Wu  <mary.wu@torchmobile.com.cn>
    240
  • trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp

    r137124 r139424  
    5858        return;
    5959    m_dateTimeChooser = chrome->openDateTimeChooser(this, parameters);
    60 }
    61 
    62 RenderObject* BaseChooserOnlyDateAndTimeInputType::createRenderer(RenderArena* arena, RenderStyle* style) const
    63 {
    64     // Cancel the override by TextFieldInputType.
    65     // FIXME: Remove this function when we stop inheriting TextFieldInputType.
    66     return InputType::createRenderer(arena, style);
    67 }
    68 
    69 void BaseChooserOnlyDateAndTimeInputType::updateInnerTextValue()
    70 {
    71     // Cancel the override by TextFieldInputType.
    72     // FIXME: Remove this function when we stop inheriting TextFieldInputType.
    73 }
    74 
    75 void BaseChooserOnlyDateAndTimeInputType::forwardEvent(Event*)
    76 {
    77     // Cancel the override by TextFieldInputType.
    78     // FIXME: Remove this function when we stop inheriting TextFieldInputType.
    7960}
    8061
  • trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.h

    r134036 r139424  
    4545
    4646    // InputType functions:
    47     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
    48     virtual void updateInnerTextValue() OVERRIDE;
    49     void forwardEvent(Event*) OVERRIDE;
    5047    virtual void createShadowSubtree() OVERRIDE;
    5148    virtual void detach() OVERRIDE;
  • trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp

    r135829 r139424  
    9797}
    9898
    99 void BaseDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* event)
    100 {
    101     if (shouldHaveSpinButton())
    102         handleKeydownEventForSpinButton(event);
    103     if (!event->defaultHandled())
    104         TextFieldInputType::handleKeydownEvent(event);
    105 }
    106 
    10799Decimal BaseDateAndTimeInputType::parseToNumber(const String& source, const Decimal& defaultValue) const
    108100{
     
    167159}
    168160
    169 String BaseDateAndTimeInputType::convertFromVisibleValue(const String& visibleValue) const
    170 {
    171     // convertFromVisibleValue is used in the textfield UI. Though this class
    172     // inherits TextFieldInputType, users are unable to edit visible values, and
    173     // this function is never called.
    174     ASSERT_NOT_REACHED();
    175     return visibleValue;
    176 }
    177 
    178161String BaseDateAndTimeInputType::sanitizeValue(const String& proposedValue) const
    179162{
     
    186169}
    187170
     171bool BaseDateAndTimeInputType::shouldRespectListAttribute()
     172{
     173    return InputType::themeSupportsDataListUI(this);
     174}
     175
     176bool BaseDateAndTimeInputType::valueMissing(const String& value) const
     177{
     178    return element()->isRequired() && value.isEmpty();
     179}
     180
    188181} // namespace WebCore
    189182#endif
  • trunk/Source/WebCore/html/BaseDateAndTimeInputType.h

    r135829 r139424  
    3434#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
    3535#include "DateComponents.h"
    36 #include "TextFieldInputType.h"
     36#include "InputType.h"
    3737#include <wtf/unicode/Unicode.h>
    3838
     
    4040
    4141// A super class of date, datetime, datetime-local, month, time, and week types.
    42 // FIXME: Don't inherit TextFieldInputType. webkit.org/b/100935
    43 class BaseDateAndTimeInputType : public TextFieldInputType {
     42class BaseDateAndTimeInputType : public InputType {
    4443protected:
    45     BaseDateAndTimeInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
    46     virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
     44    BaseDateAndTimeInputType(HTMLInputElement* element) : InputType(element) { }
    4745    virtual Decimal parseToNumber(const String&, const Decimal&) const OVERRIDE;
    4846    virtual bool parseToDateComponents(const String&, DateComponents*) const OVERRIDE;
     
    6260    virtual bool typeMismatchFor(const String&) const OVERRIDE;
    6361    virtual bool typeMismatch() const OVERRIDE;
     62    virtual bool valueMissing(const String&) const OVERRIDE;
    6463    virtual Decimal defaultValueForStepUp() const OVERRIDE;
    6564    virtual bool isSteppable() const OVERRIDE;
    6665    virtual String serializeWithMilliseconds(double) const;
    6766    virtual String localizeValue(const String&) const OVERRIDE;
    68     virtual String convertFromVisibleValue(const String&) const OVERRIDE;
    6967    virtual bool supportsReadOnly() const OVERRIDE;
     68    virtual bool shouldRespectListAttribute() OVERRIDE;
    7069};
    7170
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp

    r138254 r139424  
    182182}
    183183
    184 RenderObject* BaseMultipleFieldsDateAndTimeInputType::createRenderer(RenderArena* arena, RenderStyle* style) const
    185 {
    186     return InputType::createRenderer(arena, style);
    187 }
    188 
    189184void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree()
    190185{
     
    313308}
    314309
    315 bool BaseMultipleFieldsDateAndTimeInputType::isTextField() const
    316 {
    317     return false;
    318 }
    319 
    320310void BaseMultipleFieldsDateAndTimeInputType::restoreFormControlState(const FormControlState& state)
    321311{
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h

    r138254 r139424  
    4343struct DateTimeChooserParameters;
    4444
    45 class BaseMultipleFieldsDateAndTimeInputType : public BaseDateAndTimeInputType, protected DateTimeEditElement::EditControlOwner, protected PickerIndicatorElement::PickerIndicatorOwner {
     45class BaseMultipleFieldsDateAndTimeInputType
     46    : public BaseDateAndTimeInputType
     47    , protected DateTimeEditElement::EditControlOwner
     48    , protected PickerIndicatorElement::PickerIndicatorOwner
     49    , protected SpinButtonElement::SpinButtonOwner {
    4650protected:
    4751    BaseMultipleFieldsDateAndTimeInputType(HTMLInputElement*);
     
    7579    virtual String badInputText() const OVERRIDE;
    7680    virtual void blur() OVERRIDE FINAL;
    77     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE FINAL;
    7881    virtual void createShadowSubtree() OVERRIDE FINAL;
    7982    virtual void destroyShadowSubtree() OVERRIDE FINAL;
     
    8689    virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE FINAL;
    8790    virtual bool isMouseFocusable() const OVERRIDE FINAL;
    88     virtual bool isTextField() const OVERRIDE FINAL;
    8991    virtual void minOrMaxAttributeChanged() OVERRIDE FINAL;
    9092    virtual void readonlyAttributeChanged() OVERRIDE FINAL;
Note: See TracChangeset for help on using the changeset viewer.