Changeset 60985 in webkit
- Timestamp:
- Jun 10, 2010 5:51:36 PM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r60977 r60985 1 2010-06-09 James Hawkins <jhawkins@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 [Chromium] Add the ability to specify a separator in 6 AutoFillPopupMenuClient. 7 8 https://bugs.webkit.org/show_bug.cgi?id=40397 9 10 * public/WebViewClient.h: 11 (WebKit::WebViewClient::didAcceptAutoFillSuggestion): 12 * src/AutoFillPopupMenuClient.cpp: 13 (WebKit::AutoFillPopupMenuClient::getSuggestionsCount): 14 (WebKit::AutoFillPopupMenuClient::getSuggestion): 15 (WebKit::AutoFillPopupMenuClient::valueChanged): 16 (WebKit::AutoFillPopupMenuClient::selectionChanged): 17 (WebKit::AutoFillPopupMenuClient::itemIsSeparator): 18 (WebKit::AutoFillPopupMenuClient::initialize): 19 (WebKit::AutoFillPopupMenuClient::setSuggestions): 20 * src/AutoFillPopupMenuClient.h: 21 * src/WebViewImpl.cpp: 22 (WebKit::WebViewImpl::applyAutoFillSuggestions): 23 * src/WebViewImpl.h: 24 1 25 2010-06-10 Dmitry Titov <dimich@chromium.org> 2 26 -
trunk/WebKit/chromium/public/WebViewClient.h
r60934 r60985 277 277 278 278 279 // Auto fill ------------------------------------------------------------279 // AutoFill ------------------------------------------------------------ 280 280 281 281 // Queries the browser for suggestions to be shown for the form text … … 286 286 const WebString& value) { } 287 287 288 // Instructs the browser to remove the autofillentry specified from288 // Instructs the browser to remove the Autocomplete entry specified from 289 289 // its DB. 290 // FIXME: This method should be named removeAutocompleteSugestion. 290 291 virtual void removeAutofillSuggestions(const WebString& name, 291 292 const WebString& value) { } … … 293 294 // Informs the browser that the user has accepted an AutoFill suggestion for 294 295 // a WebNode. |name| and |label| form a key into the set of AutoFill 295 // profiles. 296 // profiles. |index| is an index of the selected suggestion in the list of 297 // suggestions provided by the client 296 298 virtual void didAcceptAutoFillSuggestion(const WebNode&, 297 299 const WebString& name, 298 const WebString& label) { } 300 const WebString& label, 301 unsigned index) { } 299 302 300 303 // Informs the browser that the user has selected an AutoFill suggestion for -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
r60514 r60985 45 45 unsigned AutoFillPopupMenuClient::getSuggestionsCount() const 46 46 { 47 return m_names.size() ;47 return m_names.size() + ((m_separatorIndex == -1) ? 0 : 1); 48 48 } 49 49 50 50 WebString AutoFillPopupMenuClient::getSuggestion(unsigned listIndex) const 51 51 { 52 if (listIndex == m_separatorIndex) 53 return WebString(); 54 55 if (m_separatorIndex != -1 && listIndex > m_separatorIndex) 56 --listIndex; 57 52 58 // FIXME: Modify the PopupMenu to add the label in gray right-justified. 53 59 ASSERT(listIndex >= 0 && listIndex < m_names.size()); 54 return m_names[listIndex] + String(" (") + m_labels[listIndex] + String(")"); 60 61 WebString suggestion = m_names[listIndex]; 62 if (m_labels[listIndex].isEmpty()) 63 return suggestion; 64 65 return suggestion + String(" (") + m_labels[listIndex] + String(")"); 55 66 } 56 67 … … 65 76 void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents) 66 77 { 67 ASSERT(listIndex >= 0 && listIndex < m_names.size());68 69 78 WebViewImpl* webView = getWebView(); 70 79 if (!webView) 71 80 return; 72 81 82 if (m_separatorIndex != -1 && listIndex > m_separatorIndex) 83 --listIndex; 84 85 ASSERT(listIndex >= 0 && listIndex < m_names.size()); 86 73 87 webView->client()->didAcceptAutoFillSuggestion(WebNode(getTextField()), 74 88 m_names[listIndex], 75 m_labels[listIndex]); 89 m_labels[listIndex], 90 listIndex); 76 91 } 77 92 78 93 void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents) 79 94 { 80 ASSERT(listIndex >= 0 && listIndex < m_names.size());81 82 95 WebViewImpl* webView = getWebView(); 83 96 if (!webView) 84 97 return; 98 99 if (m_separatorIndex != -1 && listIndex > m_separatorIndex) 100 --listIndex; 101 102 ASSERT(listIndex >= 0 && listIndex < m_names.size()); 85 103 86 104 webView->client()->didSelectAutoFillSuggestion(WebNode(getTextField()), … … 93 111 WebViewImpl* webView = getWebView(); 94 112 if (!webView) 95 return;113 return; 96 114 97 115 webView->client()->didClearAutoFillSelection(WebNode(getTextField())); … … 104 122 WebViewImpl* webView = getWebView(); 105 123 if (!webView) 106 return;124 return; 107 125 108 126 webView->client()->didClearAutoFillSelection(WebNode(getTextField())); 127 } 128 129 bool AutoFillPopupMenuClient::itemIsSeparator(unsigned listIndex) const 130 { 131 return (m_separatorIndex != -1 && m_separatorIndex == listIndex); 109 132 } 110 133 … … 113 136 const WebVector<WebString>& names, 114 137 const WebVector<WebString>& labels, 115 int defaultSuggestionIndex)138 int separatorIndex) 116 139 { 117 140 ASSERT(names.size() == labels.size()); 118 ASSERT( defaultSuggestionIndex < static_cast<int>(names.size()));141 ASSERT(separatorIndex < static_cast<int>(names.size())); 119 142 120 143 // The suggestions must be set before initializing the 121 144 // SuggestionsPopupMenuClient. 122 setSuggestions(names, labels );145 setSuggestions(names, labels, separatorIndex); 123 146 124 SuggestionsPopupMenuClient::initialize(textField, defaultSuggestionIndex);147 SuggestionsPopupMenuClient::initialize(textField, -1); 125 148 } 126 149 127 150 void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names, 128 const WebVector<WebString>& labels) 151 const WebVector<WebString>& labels, 152 int separatorIndex) 129 153 { 130 154 ASSERT(names.size() == labels.size()); 155 ASSERT(separatorIndex < static_cast<int>(names.size())); 131 156 132 157 m_names.clear(); … … 137 162 } 138 163 164 m_separatorIndex = separatorIndex; 165 139 166 // Try to preserve selection if possible. 140 167 if (getSelectedIndex() >= static_cast<int>(names.size())) -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.h
r60514 r60985 56 56 virtual void selectionCleared(); 57 57 virtual void popupDidHide(); 58 virtual bool itemIsSeparator(unsigned listIndex) const; 58 59 59 60 void initialize(WebCore::HTMLInputElement*, 60 61 const WebVector<WebString>& names, 61 62 const WebVector<WebString>& labels, 62 int defaultSuggestionIndex);63 int separatorIndex); 63 64 64 65 void setSuggestions(const WebVector<WebString>& names, 65 const WebVector<WebString>& labels); 66 const WebVector<WebString>& labels, 67 int separatorIndex); 66 68 67 69 private: 68 70 Vector<WebCore::String> m_names; 69 71 Vector<WebCore::String> m_labels; 72 73 // The index of the separator. -1 if there is no separator. 74 int m_separatorIndex; 70 75 }; 71 76 -
trunk/WebKit/chromium/src/WebViewImpl.cpp
r60651 r60985 1787 1787 const WebVector<WebString>& names, 1788 1788 const WebVector<WebString>& labels, 1789 int defaultSuggestionIndex)1789 int separatorIndex) 1790 1790 { 1791 1791 ASSERT(names.size() == labels.size()); 1792 ASSERT( defaultSuggestionIndex < static_cast<int>(names.size()));1792 ASSERT(separatorIndex < static_cast<int>(names.size())); 1793 1793 1794 1794 if (names.isEmpty()) { … … 1815 1815 1816 1816 m_autoFillPopupClient->initialize(inputElem, names, labels, 1817 defaultSuggestionIndex);1817 separatorIndex); 1818 1818 1819 1819 if (m_suggestionsPopupClient != m_autoFillPopupClient.get()) { … … 1832 1832 1833 1833 if (m_suggestionsPopupShowing) { 1834 m_autoFillPopupClient->setSuggestions(names, labels );1834 m_autoFillPopupClient->setSuggestions(names, labels, separatorIndex); 1835 1835 refreshSuggestionsPopup(); 1836 1836 } else { -
trunk/WebKit/chromium/src/WebViewImpl.h
r60651 r60985 167 167 const WebVector<WebString>& names, 168 168 const WebVector<WebString>& labels, 169 int defaultSuggestionIndex);169 int separatorIndex); 170 170 virtual void applyAutocompleteSuggestions( 171 171 const WebNode&,
Note: See TracChangeset
for help on using the changeset viewer.