Changeset 52204 in webkit


Ignore:
Timestamp:
Dec 16, 2009 10:43:27 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-16 Zelidrag Hornung <zelidrag@chromium.org>

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=32261
Added ability to separate the autocomplete suggestion previewing from
the actual accepting of the suggested value in HTMLInputElement.
This element (it's single line text incarnation) can now
be put in suggestion mode where renderer might display the suggested
value without making it automatically exposed to JavaScript.

No new tests. This new methods are not exposed yet. It's use will be
platform specific. PopupMenu and Chromium specific changes will be
separated based on Darin Adler's comments.

  • dom/InputElement.h: (WebCore::InputElementData::suggestedValue): (WebCore::InputElementData::setSuggestedValue):
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::suggestedValue): (WebCore::HTMLInputElement::setSuggestedValue): (WebCore::HTMLInputElement::setValue): (WebCore::HTMLInputElement::setValueFromRenderer):
  • html/HTMLInputElement.h:
  • rendering/RenderTextControlSingleLine.cpp: (WebCore::RenderTextControlSingleLine::updateFromElement):
  • wml/WMLInputElement.cpp: (WebCore::WMLInputElement::suggestedValue):
  • wml/WMLInputElement.h:
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52203 r52204  
     12009-12-16  Zelidrag Hornung  <zelidrag@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=32261
     6        Added ability to separate the autocomplete suggestion previewing from
     7        the actual accepting of the suggested value in HTMLInputElement.
     8        This element (it's single line text incarnation) can now
     9        be put in suggestion mode where renderer might display the suggested
     10        value without making it automatically exposed to JavaScript.
     11
     12        No new tests. This new methods are not exposed yet. It's use will be
     13        platform specific. PopupMenu and Chromium specific changes will be
     14        separated based on Darin Adler's comments.
     15
     16        * dom/InputElement.h:
     17        (WebCore::InputElementData::suggestedValue):
     18        (WebCore::InputElementData::setSuggestedValue):
     19        * html/HTMLInputElement.cpp:
     20        (WebCore::HTMLInputElement::suggestedValue):
     21        (WebCore::HTMLInputElement::setSuggestedValue):
     22        (WebCore::HTMLInputElement::setValue):
     23        (WebCore::HTMLInputElement::setValueFromRenderer):
     24        * html/HTMLInputElement.h:
     25        * rendering/RenderTextControlSingleLine.cpp:
     26        (WebCore::RenderTextControlSingleLine::updateFromElement):
     27        * wml/WMLInputElement.cpp:
     28        (WebCore::WMLInputElement::suggestedValue):
     29        * wml/WMLInputElement.h:
     30
    1312009-12-16  Pavel Feldman  <pfeldman@chromium.org>
    232
  • trunk/WebCore/dom/InputElement.h

    r51602 r52204  
    4848
    4949    virtual int size() const = 0;
     50    virtual const String& suggestedValue() const = 0;
    5051    virtual String value() const = 0;
    5152    virtual void setValue(const String&, bool sendChangeEvent = false) = 0;
     
    9394    void setValue(const String& value) { m_value = value; }
    9495
     96    const String& suggestedValue() const { return m_suggestedValue; }
     97    void setSuggestedValue(const String& value) { m_suggestedValue = value; }
     98
    9599    int size() const { return m_size; }
    96100    void setSize(int value) { m_size = value; }
     
    108112    AtomicString m_name;
    109113    String m_value;
     114    String m_suggestedValue;
    110115    int m_size;
    111116    int m_maxLength;
  • trunk/WebCore/html/HTMLInputElement.cpp

    r51877 r52204  
    13141314}
    13151315
     1316const String& HTMLInputElement::suggestedValue() const
     1317{
     1318    return m_data.suggestedValue();
     1319}
     1320
     1321void HTMLInputElement::setSuggestedValue(const String& value)
     1322{
     1323    if (inputType() != TEXT)
     1324        return;
     1325    setFormControlValueMatchesRenderer(false);
     1326    m_data.setSuggestedValue(sanitizeValue(value));
     1327    updatePlaceholderVisibility(false);
     1328    if (renderer())
     1329        renderer()->updateFromElement();
     1330    setNeedsStyleRecalc();
     1331}
     1332
    13161333void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
    13171334{
     
    13461363        else
    13471364            cacheSelection(max, max);
     1365        m_data.setSuggestedValue(String());
    13481366    }
    13491367
     
    13761394    // File upload controls will always use setFileListFromRenderer.
    13771395    ASSERT(inputType() != FILE);
     1396    m_data.setSuggestedValue(String());
    13781397    updatePlaceholderVisibility(false);
    13791398    InputElement::setValueFromRenderer(m_data, this, this, value);
  • trunk/WebCore/html/HTMLInputElement.h

    r51822 r52204  
    138138    void setType(const String&);
    139139
     140    virtual const String& suggestedValue() const;
     141    void setSuggestedValue(const String&);
     142
    140143    virtual String value() const;
    141144    virtual void setValue(const String&, bool sendChangeEvent = false);
  • trunk/WebCore/rendering/RenderTextControlSingleLine.cpp

    r51148 r52204  
    462462        innerTextElement()->setInnerText(static_cast<Element*>(node())->getAttribute(placeholderAttr), ec);
    463463        ASSERT(!ec);
    464     } else
    465         setInnerTextValue(inputElement()->value());
     464    } else {
     465        if (!inputElement()->suggestedValue().isNull())
     466            setInnerTextValue(inputElement()->suggestedValue());
     467        else
     468            setInnerTextValue(inputElement()->value());
     469    }
    466470
    467471    if (m_searchPopupIsVisible)
  • trunk/WebCore/wml/WMLInputElement.cpp

    r52107 r52204  
    122122{
    123123    return m_data.name();
     124}
     125
     126const String& WMLInputElement::suggestedValue() const
     127{
     128    return m_data.suggestedValue();
    124129}
    125130
  • trunk/WebCore/wml/WMLInputElement.h

    r52107 r52204  
    5757    virtual const AtomicString& formControlType() const;
    5858    virtual const AtomicString& formControlName() const;
     59    virtual const String& suggestedValue() const;
    5960    virtual String value() const;
    6061    virtual void setValue(const String&, bool sendChangeEvent = false);
Note: See TracChangeset for help on using the changeset viewer.