Changeset 54640 in webkit
- Timestamp:
- Feb 10, 2010 7:47:38 PM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r54629 r54640 1 2010-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 1 19 2010-02-10 Nate Chapin <japhet@chromium.org> 2 20 -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
r54589 r54640 60 60 } 61 61 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 73 62 void AutoFillPopupMenuClient::initialize( 74 63 HTMLInputElement* textField, -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.h
r54586 r54640 51 51 virtual void removeSuggestionAtIndex(unsigned listIndex); 52 52 53 // WebCore::PopupMenuClient implementation:54 virtual void selectionChanged(unsigned listIndex, bool fireEvents);55 56 53 void initialize(WebCore::HTMLInputElement*, 57 54 const WebVector<WebString>& names, -
trunk/WebKit/chromium/src/SuggestionsPopupMenuClient.cpp
r54586 r54640 70 70 } 71 71 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 else82 m_lastFieldValues->add(m_textField->name(), m_typedFieldValue);83 }84 }85 86 72 String SuggestionsPopupMenuClient::itemText(unsigned listIndex) const 87 73 { … … 121 107 void SuggestionsPopupMenuClient::popupDidHide() 122 108 { 123 m_textField->setValue(m_typedFieldValue);124 resetLastSuggestion();125 109 WebViewImpl* webView = getWebView(); 126 110 if (webView) … … 131 115 { 132 116 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 else141 m_lastFieldValues->add(m_textField->name(), m_textField->value());142 117 } 143 118 … … 176 151 int defaultSuggestionIndex) 177 152 { 178 if (!m_lastFieldValues)179 m_lastFieldValues.set(new FieldValuesMap);180 181 153 m_textField = textField; 182 m_typedFieldValue = textField->value();183 154 m_selectedIndex = defaultSuggestionIndex; 184 185 setInitialSuggestion();186 155 187 156 FontDescription fontDescription; … … 202 171 } 203 172 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 else239 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 249 173 WebViewImpl* SuggestionsPopupMenuClient::getWebView() const 250 174 { -
trunk/WebKit/chromium/src/SuggestionsPopupMenuClient.h
r54586 r54640 62 62 // WebCore::PopupMenuClient methods: 63 63 virtual void valueChanged(unsigned listIndex, bool fireEvents = true); 64 virtual void selectionChanged(unsigned listIndex, bool fireEvents = true);65 64 virtual WebCore::String itemText(unsigned listIndex) const; 66 65 virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); } … … 91 90 void initialize(WebCore::HTMLInputElement* textField, 92 91 int defaultSuggestionIndex); 93 void setInitialSuggestion();94 92 95 93 int getSelectedIndex() const { return m_selectedIndex; } 96 94 void setSelectedIndex(int index) { m_selectedIndex = index; } 97 98 void setSuggestedValue(const WebString& suggestion);99 95 100 96 WebViewImpl* getWebView() const; … … 103 99 private: 104 100 WebCore::RenderStyle* textFieldStyle() const; 105 void resetLastSuggestion();106 101 107 102 RefPtr<WebCore::HTMLInputElement> m_textField; 108 103 int m_selectedIndex; 109 WebCore::String m_typedFieldValue;110 104 OwnPtr<WebCore::PopupMenuStyle> m_style; 111 typedef HashMap<WebCore::String, WebCore::String> FieldValuesMap;112 OwnPtr<FieldValuesMap> m_lastFieldValues;113 105 }; 114 106
Note: See TracChangeset
for help on using the changeset viewer.