Changeset 54640 in webkit


Ignore:
Timestamp:
Feb 10, 2010 7:47:38 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-10 James Hawkins <jhawkins@chromium.org>

Reviewed by Eric Seidel.

[Chromium] Remove code from SuggestionsPopup that was removed in a
previous revision of AutocompletePopup and accidentally added back in
the refactoring.

https://bugs.webkit.org/show_bug.cgi?id=34818

  • src/AutoFillPopupMenuClient.cpp:
  • src/AutoFillPopupMenuClient.h: Added property svn:eol-style.
  • src/SuggestionsPopupMenuClient.cpp: (WebKit::SuggestionsPopupMenuClient::popupDidHide): (WebKit::SuggestionsPopupMenuClient::setTextFromItem): (WebKit::SuggestionsPopupMenuClient::initialize):
  • src/SuggestionsPopupMenuClient.h:
Location:
trunk/WebKit/chromium
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r54629 r54640  
     12010-02-10  James Hawkins  <jhawkins@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        [Chromium] Remove code from SuggestionsPopup that was removed in a
     6        previous revision of AutocompletePopup and accidentally added back in
     7        the refactoring.
     8
     9        https://bugs.webkit.org/show_bug.cgi?id=34818
     10
     11        * src/AutoFillPopupMenuClient.cpp:
     12        * src/AutoFillPopupMenuClient.h: Added property svn:eol-style.
     13        * src/SuggestionsPopupMenuClient.cpp:
     14        (WebKit::SuggestionsPopupMenuClient::popupDidHide):
     15        (WebKit::SuggestionsPopupMenuClient::setTextFromItem):
     16        (WebKit::SuggestionsPopupMenuClient::initialize):
     17        * src/SuggestionsPopupMenuClient.h:
     18
    1192010-02-10  Nate Chapin  <japhet@chromium.org>
    220
  • trunk/WebKit/chromium/src/AutoFillPopupMenuClient.cpp

    r54589 r54640  
    6060}
    6161
    62 void AutoFillPopupMenuClient:: selectionChanged(unsigned listIndex,
    63                                                 bool fireEvents) {
    64     if (listIndex == static_cast<unsigned>(-1)) {
    65         SuggestionsPopupMenuClient::selectionChanged(listIndex, fireEvents);
    66         return;
    67     }
    68 
    69     ASSERT(listIndex >= 0 && listIndex < m_names.size());
    70     setSuggestedValue(m_names[listIndex]);
    71 }
    72 
    7362void AutoFillPopupMenuClient::initialize(
    7463    HTMLInputElement* textField,
  • trunk/WebKit/chromium/src/AutoFillPopupMenuClient.h

    r54586 r54640  
    5151    virtual void removeSuggestionAtIndex(unsigned listIndex);
    5252
    53     // WebCore::PopupMenuClient implementation:
    54     virtual void selectionChanged(unsigned listIndex, bool fireEvents);
    55 
    5653    void initialize(WebCore::HTMLInputElement*,
    5754                    const WebVector<WebString>& names,
  • trunk/WebKit/chromium/src/SuggestionsPopupMenuClient.cpp

    r54586 r54640  
    7070}
    7171
    72 void SuggestionsPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents)
    73 {
    74     if (listIndex != static_cast<unsigned>(-1)) {
    75         const WebString& suggestion = getSuggestion(listIndex);
    76         setSuggestedValue(suggestion);
    77     } else {
    78         m_textField->setValue(m_typedFieldValue);
    79         if (m_lastFieldValues->contains(m_textField->name()))
    80             m_lastFieldValues->set(m_textField->name(), m_typedFieldValue);
    81         else
    82             m_lastFieldValues->add(m_textField->name(), m_typedFieldValue);
    83     }
    84 }
    85 
    8672String SuggestionsPopupMenuClient::itemText(unsigned listIndex) const
    8773{
     
    121107void SuggestionsPopupMenuClient::popupDidHide()
    122108{
    123     m_textField->setValue(m_typedFieldValue);
    124     resetLastSuggestion();
    125109    WebViewImpl* webView = getWebView();
    126110    if (webView)
     
    131115{
    132116    m_textField->setValue(getSuggestion(listIndex));
    133     resetLastSuggestion();
    134 }
    135 
    136 void SuggestionsPopupMenuClient::resetLastSuggestion()
    137 {
    138     if (m_lastFieldValues->contains(m_textField->name()))
    139         m_lastFieldValues->set(m_textField->name(), m_textField->value());
    140     else
    141         m_lastFieldValues->add(m_textField->name(), m_textField->value());
    142117}
    143118
     
    176151                                            int defaultSuggestionIndex)
    177152{
    178     if (!m_lastFieldValues)
    179         m_lastFieldValues.set(new FieldValuesMap);
    180 
    181153    m_textField = textField;
    182     m_typedFieldValue = textField->value();
    183154    m_selectedIndex = defaultSuggestionIndex;
    184 
    185     setInitialSuggestion();
    186155
    187156    FontDescription fontDescription;
     
    202171}
    203172
    204 void SuggestionsPopupMenuClient::setInitialSuggestion()
    205 {
    206     if (!getSuggestionsCount() || !m_textField->name().length() || !m_typedFieldValue.length())
    207         return;
    208 
    209     int newIndex = m_selectedIndex >= 0 ? m_selectedIndex : 0;
    210     const String& suggestion = getSuggestion(newIndex);
    211     bool hasPreviousValue = m_lastFieldValues->contains(m_textField->name());
    212 
    213     String prevValue;
    214     if (hasPreviousValue)
    215         prevValue = m_lastFieldValues->get(m_textField->name());
    216 
    217     if (!hasPreviousValue || m_typedFieldValue.length() > m_lastFieldValues->get(m_textField->name()).length()) {
    218         if (suggestion.startsWith(m_typedFieldValue))
    219             m_selectedIndex = newIndex;
    220 
    221         int start = 0;
    222         String newSuggestion = suggestion;
    223         if (suggestion.startsWith(m_typedFieldValue, false)) {
    224             newSuggestion = m_typedFieldValue;
    225             if (suggestion.length() > m_typedFieldValue.length()) {
    226                 newSuggestion.append(suggestion.substring(m_typedFieldValue.length(),
    227                     suggestion.length() - m_typedFieldValue.length()));
    228             }
    229             start = m_typedFieldValue.length();
    230         }
    231 
    232         m_textField->setSuggestedValue(newSuggestion);
    233         m_textField->setSelectionRange(start, newSuggestion.length());
    234     }
    235 
    236     if (hasPreviousValue)
    237         m_lastFieldValues->set(m_textField->name(), m_typedFieldValue);
    238     else
    239         m_lastFieldValues->add(m_textField->name(), m_typedFieldValue);
    240 }
    241 
    242 void SuggestionsPopupMenuClient::setSuggestedValue(const WebString& suggestion)
    243 {
    244     m_textField->setSuggestedValue(suggestion);
    245     m_textField->setSelectionRange(m_typedFieldValue.length(),
    246                                    suggestion.length());
    247 }
    248 
    249173WebViewImpl* SuggestionsPopupMenuClient::getWebView() const
    250174{
  • trunk/WebKit/chromium/src/SuggestionsPopupMenuClient.h

    r54586 r54640  
    6262    // WebCore::PopupMenuClient methods:
    6363    virtual void valueChanged(unsigned listIndex, bool fireEvents = true);
    64     virtual void selectionChanged(unsigned listIndex, bool fireEvents = true);
    6564    virtual WebCore::String itemText(unsigned listIndex) const;
    6665    virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); }
     
    9190    void initialize(WebCore::HTMLInputElement* textField,
    9291                    int defaultSuggestionIndex);
    93     void setInitialSuggestion();
    9492
    9593    int getSelectedIndex() const { return m_selectedIndex; }
    9694    void setSelectedIndex(int index) { m_selectedIndex = index; }
    97 
    98     void setSuggestedValue(const WebString& suggestion);
    9995
    10096    WebViewImpl* getWebView() const;
     
    10399private:
    104100    WebCore::RenderStyle* textFieldStyle() const;
    105     void resetLastSuggestion();
    106101
    107102    RefPtr<WebCore::HTMLInputElement> m_textField;
    108103    int m_selectedIndex;
    109     WebCore::String m_typedFieldValue;
    110104    OwnPtr<WebCore::PopupMenuStyle> m_style;
    111     typedef HashMap<WebCore::String, WebCore::String> FieldValuesMap;
    112     OwnPtr<FieldValuesMap> m_lastFieldValues;
    113105};
    114106
Note: See TracChangeset for help on using the changeset viewer.