diff options
author | Russell Brenner <russellbrenner@google.com> | 2010-11-18 17:33:13 -0800 |
---|---|---|
committer | Russell Brenner <russellbrenner@google.com> | 2010-12-02 13:47:21 -0800 |
commit | 6b70adc33054f8aee8c54d0f460458a9df11b8a5 (patch) | |
tree | 103a13998c33944d6ab3b8318c509a037e639460 /WebKit/chromium/src/AutoFillPopupMenuClient.cpp | |
parent | bdf4ebc8e70b2d221b6ee7a65660918ecb1d33aa (diff) | |
download | external_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.zip external_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.tar.gz external_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.tar.bz2 |
Merge WebKit at r72274: Initial merge by git.
Change-Id: Ie51f0b4a16da82942bd516dce59cfb79ebbe25fb
Diffstat (limited to 'WebKit/chromium/src/AutoFillPopupMenuClient.cpp')
-rw-r--r-- | WebKit/chromium/src/AutoFillPopupMenuClient.cpp | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/WebKit/chromium/src/AutoFillPopupMenuClient.cpp b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp index b14840c..32abd6f 100644 --- a/WebKit/chromium/src/AutoFillPopupMenuClient.cpp +++ b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp @@ -115,10 +115,10 @@ void AutoFillPopupMenuClient::removeSuggestionAtIndex(unsigned listIndex) bool AutoFillPopupMenuClient::canRemoveSuggestionAtIndex(unsigned listIndex) { - // Only allow deletion of items before the separator and those that don't - // have a label (autocomplete). + // Only allow deletion of items before the separator that have unique id 0 + // (i.e. are autocomplete rather than autofill items). int index = convertListIndexToInternalIndex(listIndex); - return m_labels[index].isEmpty() && (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex)); + return !m_uniqueIDs[index] && (m_separatorIndex == -1 || listIndex < static_cast<unsigned>(m_separatorIndex)); } void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents) @@ -194,14 +194,19 @@ String AutoFillPopupMenuClient::itemIcon(unsigned listIndex) const return getIcon(listIndex); } +bool AutoFillPopupMenuClient::itemIsEnabled(unsigned listIndex) const +{ + return !itemIsWarning(listIndex); +} + PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const { - return *m_style; + return itemIsWarning(listIndex) ? *m_warningStyle : *m_regularStyle; } PopupMenuStyle AutoFillPopupMenuClient::menuStyle() const { - return *m_style; + return *m_regularStyle; } int AutoFillPopupMenuClient::clientPaddingLeft() const @@ -239,6 +244,16 @@ bool AutoFillPopupMenuClient::itemIsSeparator(unsigned listIndex) const return (m_separatorIndex != -1 && static_cast<unsigned>(m_separatorIndex) == listIndex); } +bool AutoFillPopupMenuClient::itemIsWarning(unsigned listIndex) const +{ + int index = convertListIndexToInternalIndex(listIndex); + if (index == -1) + return false; + + ASSERT(index >= 0 && static_cast<size_t>(index) < m_uniqueIDs.size()); + return m_uniqueIDs[index] < 0; +} + void AutoFillPopupMenuClient::setTextFromItem(unsigned listIndex) { m_textField->setValue(getSuggestion(listIndex)); @@ -282,19 +297,31 @@ void AutoFillPopupMenuClient::initialize( // AutoFillPopupMenuClient. setSuggestions(names, labels, icons, uniqueIDs, separatorIndex); - FontDescription fontDescription; + FontDescription regularFontDescription; RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl, - fontDescription); + regularFontDescription); RenderStyle* style = m_textField->computedStyle(); - fontDescription.setComputedSize(style->fontDescription().computedSize()); + regularFontDescription.setComputedSize(style->fontDescription().computedSize()); - Font font(fontDescription, 0, 0); - font.update(textField->document()->styleSelector()->fontSelector()); + Font regularFont(regularFontDescription, 0, 0); + regularFont.update(textField->document()->styleSelector()->fontSelector()); // The direction of text in popup menu is set the same as the direction of // the input element: textField. - m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true, - Length(WebCore::Fixed), - textField->renderer()->style()->direction())); + m_regularStyle.set(new PopupMenuStyle(Color::black, Color::white, regularFont, + true, false, Length(WebCore::Fixed), + textField->renderer()->style()->direction())); + + FontDescription warningFontDescription = regularFont.fontDescription(); + warningFontDescription.setItalic(true); + Font warningFont(warningFontDescription, regularFont.letterSpacing(), regularFont.wordSpacing()); + warningFont.update(regularFont.fontSelector()); + m_warningStyle.set(new PopupMenuStyle(Color::darkGray, + m_regularStyle->backgroundColor(), + warningFont, + m_regularStyle->isVisible(), + m_regularStyle->isDisplayNone(), + m_regularStyle->textIndent(), + m_regularStyle->textDirection())); } void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names, |