Changeset 72001 in webkit
- Timestamp:
- Nov 15, 2010 3:37:21 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71997 r72001 1 2010-11-15 Ilya Sherman <isherman@chromium.org> 2 3 Reviewed by Kent Tamura. 4 5 Add capability for displaying warnings to autofill popup 6 Warnings are displayed in dark gray italic. 7 https://bugs.webkit.org/show_bug.cgi?id=49291 8 http://code.google.com/p/chromium/issues/detail?id=58509 9 10 * platform/chromium/PopupMenuChromium.cpp: 11 (WebCore::PopupListBox::getRowFont): 12 Use item-specific font, not just the generic menu font. 13 (WebCore::PopupListBox::selectIndex): 14 Updated to clear the selection when hovering over a non-selectable item. 15 * platform/chromium/PopupMenuChromium.h: Minor cleanup 16 1 17 2010-11-14 David Hyatt <hyatt@apple.com> 2 18 -
trunk/WebCore/platform/chromium/PopupMenuChromium.cpp
r71963 r72001 50 50 #include "PlatformScreen.h" 51 51 #include "PlatformWheelEvent.h" 52 #include "PopupMenuClient.h" 52 53 #include "RenderTheme.h" 53 54 #include "ScrollbarTheme.h" … … 992 993 Font PopupListBox::getRowFont(int rowIndex) 993 994 { 994 Font itemFont = m_popupClient-> menuStyle().font();995 Font itemFont = m_popupClient->itemStyle(rowIndex).font(); 995 996 if (m_popupClient->itemIsLabel(rowIndex)) { 996 997 // Bold-ify labels (ie, an <optgroup> heading). … … 1070 1071 return; 1071 1072 1072 if (index != m_selectedIndex && isSelectableItem(index)) { 1073 bool isSelectable = isSelectableItem(index); 1074 if (index != m_selectedIndex && isSelectable) { 1073 1075 invalidateRow(m_selectedIndex); 1074 1076 m_selectedIndex = index; … … 1077 1079 scrollToRevealSelection(); 1078 1080 m_popupClient->selectionChanged(m_selectedIndex); 1081 } else if (!isSelectable) { 1082 clearSelection(); 1079 1083 } 1080 1084 } -
trunk/WebCore/platform/chromium/PopupMenuChromium.h
r71900 r72001 33 33 34 34 #include "config.h" 35 #include "PopupMenuClient.h"36 35 37 36 #include "FramelessScrollView.h" 38 37 #include "IntRect.h" 38 #include "PlatformString.h" 39 39 #include "PopupMenu.h" 40 40 #include "PopupMenuPrivate.h" 41 #include "PopupMenuStyle.h" 41 42 42 43 namespace WebCore { … … 45 46 class FrameView; 46 47 class PopupListBox; 48 class PopupMenuClient; 47 49 48 50 // A container for the data for each menu item (e.g. represented by <option> -
trunk/WebKit/chromium/ChangeLog
r71996 r72001 1 2010-11-15 Ilya Sherman <isherman@chromium.org> 2 3 Reviewed by Kent Tamura. 4 5 Add capability for displaying warnings to autofill popup 6 Warnings are displayed in dark gray italic. 7 https://bugs.webkit.org/show_bug.cgi?id=49291 8 http://code.google.com/p/chromium/issues/detail?id=58509 9 10 * src/AutoFillPopupMenuClient.cpp: 11 (WebKit::AutoFillPopupMenuClient::canRemoveSuggestionAtIndex): 12 Updated logic -- can only remove Autocomplete suggestions, which have unique ID 0. 13 (WebKit::AutoFillPopupMenuClient::itemIsEnabled): False for warnings. 14 (WebKit::AutoFillPopupMenuClient::itemStyle): Dark gray italic for warnings. 15 (WebKit::AutoFillPopupMenuClient::menuStyle): Variable name changed. 16 (WebKit::AutoFillPopupMenuClient::itemIsWarning): True for unique ID < 0. 17 (WebKit::AutoFillPopupMenuClient::initialize): Updated cached styles (see above). 18 * src/AutoFillPopupMenuClient.h: Added itemIsEnabled(), variable to cache warning style. 19 * src/WebViewImpl.cpp: Minor cleanup. 20 (WebKit::WebViewImpl::applyAutoFillSuggestions): 21 1 22 2010-11-14 Kent Tamura <tkent@chromium.org> 2 23 -
trunk/WebKit/chromium/public/WebView.h
r70222 r72001 290 290 // Notifies the WebView that AutoFill suggestions are available for a node. 291 291 // |uniqueIDs| is a vector of IDs that represent the unique ID of each 292 // AutoFill profile in the suggestions popup. 292 // AutoFill profile in the suggestions popup. If a unique ID is 0, then the 293 // corresponding suggestion comes from Autocomplete rather than AutoFill. 294 // If a unique ID is negative, then the corresponding "suggestion" is 295 // actually a user-facing warning, e.g. explaining why AutoFill is 296 // unavailable for the current form. 293 297 virtual void applyAutoFillSuggestions( 294 298 const WebNode&, -
trunk/WebKit/chromium/public/WebViewClient.h
r71610 r72001 310 310 311 311 // Informs the browser that the user has accepted an AutoFill suggestion for 312 // a WebNode. |name| and |label| form a key into the set of AutoFill 313 // profiles. |index| is an index of the selected suggestion in the list of 314 // suggestions provided by the client 312 // a WebNode. |uniqueID| is used as a key into the set of AutoFill profiles, 313 // and should never be negative. If it is 0, then the suggestion is an 314 // Autocomplete suggestion; and |value| stores the suggested text. |index| 315 // is an index of the selected suggestion in the list of suggestions provided 316 // by the client. 315 317 virtual void didAcceptAutoFillSuggestion(const WebNode&, 316 const WebString& name,318 const WebString& value, 317 319 const WebString& label, 318 320 int uniqueID, -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
r71618 r72001 116 116 bool AutoFillPopupMenuClient::canRemoveSuggestionAtIndex(unsigned listIndex) 117 117 { 118 // Only allow deletion of items before the separator and those that don't119 // have a label (autocomplete).120 int index = convertListIndexToInternalIndex(listIndex); 121 return m_labels[index].isEmpty()&& (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex));118 // Only allow deletion of items before the separator that have unique id 0 119 // (i.e. are autocomplete rather than autofill items). 120 int index = convertListIndexToInternalIndex(listIndex); 121 return !m_uniqueIDs[index] && (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex)); 122 122 } 123 123 … … 195 195 } 196 196 197 bool AutoFillPopupMenuClient::itemIsEnabled(unsigned listIndex) const 198 { 199 return !itemIsWarning(listIndex); 200 } 201 197 202 PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const 198 203 { 199 return *m_style;204 return itemIsWarning(listIndex) ? *m_warningStyle : *m_regularStyle; 200 205 } 201 206 202 207 PopupMenuStyle AutoFillPopupMenuClient::menuStyle() const 203 208 { 204 return *m_ style;209 return *m_regularStyle; 205 210 } 206 211 … … 238 243 { 239 244 return (m_separatorIndex != -1 && static_cast<unsigned>(m_separatorIndex) == listIndex); 245 } 246 247 bool AutoFillPopupMenuClient::itemIsWarning(unsigned listIndex) const 248 { 249 int index = convertListIndexToInternalIndex(listIndex); 250 if (index == -1) 251 return false; 252 253 ASSERT(index >= 0 && static_cast<size_t>(index) < m_uniqueIDs.size()); 254 return m_uniqueIDs[index] < 0; 240 255 } 241 256 … … 283 298 setSuggestions(names, labels, icons, uniqueIDs, separatorIndex); 284 299 285 FontDescription fontDescription;300 FontDescription regularFontDescription; 286 301 RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl, 287 fontDescription);302 regularFontDescription); 288 303 RenderStyle* style = m_textField->computedStyle(); 289 fontDescription.setComputedSize(style->fontDescription().computedSize());290 291 Font font(fontDescription, 0, 0);292 font.update(textField->document()->styleSelector()->fontSelector());304 regularFontDescription.setComputedSize(style->fontDescription().computedSize()); 305 306 Font regularFont(regularFontDescription, 0, 0); 307 regularFont.update(textField->document()->styleSelector()->fontSelector()); 293 308 // The direction of text in popup menu is set the same as the direction of 294 309 // the input element: textField. 295 m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true, 296 false, Length(WebCore::Fixed), 297 textField->renderer()->style()->direction())); 310 m_regularStyle.set(new PopupMenuStyle(Color::black, Color::white, regularFont, 311 true, false, Length(WebCore::Fixed), 312 textField->renderer()->style()->direction())); 313 314 FontDescription warningFontDescription = regularFont.fontDescription(); 315 warningFontDescription.setItalic(true); 316 Font warningFont(warningFontDescription, regularFont.letterSpacing(), regularFont.wordSpacing()); 317 warningFont.update(regularFont.fontSelector()); 318 m_warningStyle.set(new PopupMenuStyle(Color::darkGray, 319 m_regularStyle->backgroundColor(), 320 warningFont, 321 m_regularStyle->isVisible(), 322 m_regularStyle->isDisplayNone(), 323 m_regularStyle->textIndent(), 324 m_regularStyle->textDirection())); 298 325 } 299 326 -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.h
r65021 r72001 79 79 virtual WTF::String itemToolTip(unsigned lastIndex) const { return WTF::String(); } 80 80 virtual WTF::String itemAccessibilityText(unsigned lastIndex) const { return WTF::String(); } 81 virtual bool itemIsEnabled(unsigned listIndex) const { return true; }81 virtual bool itemIsEnabled(unsigned listIndex) const; 82 82 virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const; 83 83 virtual WebCore::PopupMenuStyle menuStyle() const; … … 131 131 void setSelectedIndex(int index) { m_selectedIndex = index; } 132 132 133 bool itemIsWarning(unsigned listIndex) const; 134 133 135 // The names, labels and icons that make up the contents of the menu items. 134 136 Vector<WTF::String> m_names; … … 144 146 145 147 RefPtr<WebCore::HTMLInputElement> m_textField; 146 OwnPtr<WebCore::PopupMenuStyle> m_style; 148 OwnPtr<WebCore::PopupMenuStyle> m_regularStyle; 149 OwnPtr<WebCore::PopupMenuStyle> m_warningStyle; 147 150 148 151 // DEPRECATED: Will be removed once Autocomplete and AutoFill merge is -
trunk/WebKit/chromium/src/WebViewImpl.cpp
r71900 r72001 179 179 true, // loopSelectionNavigation 180 180 false, // restrictWidthOfListBox (For security reasons show the entire entry 181 // so the user doesn't enter information itdid not intend to.)181 // so the user doesn't enter information he did not intend to.) 182 182 // For suggestions, we use the direction of the input field as the direction 183 183 // of the popup items. The main reason is to keep the display of items in … … 1944 1944 1945 1945 if (m_autoFillPopupShowing) { 1946 m_autoFillPopupClient->setSuggestions(1947 names, labels, icons, uniqueIDs, separatorIndex);1948 1946 refreshAutoFillPopup(); 1949 1947 } else { 1950 m_autoFillPopup->show(focusedNode->getRect(), 1951 focusedNode->ownerDocument()->view(), 0); 1948 m_autoFillPopup->show(focusedNode->getRect(), focusedNode->ownerDocument()->view(), 0); 1952 1949 m_autoFillPopupShowing = true; 1953 1950 }
Note: See TracChangeset
for help on using the changeset viewer.